Skip to content

Commit

Permalink
[FIX] account_factoring_receivable_balance_factofrance: payments use …
Browse files Browse the repository at this point in the history
…reference instead if entry number
  • Loading branch information
dreispt committed Sep 6, 2024
1 parent c9fec06 commit a0ab5df
Showing 1 changed file with 52 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,8 @@ def _prepare_factofrance_body(self):
"balance": 0.00,
}
for line in self.line_ids:
move = line.move_id
journal = self.factor_journal_id
partner = line.move_id.partner_id.commercial_partner_id
if not partner:
raise UserError(f"Pas de partenaire sur la pièce {line.move_id}")

code, op_type, sign = self._get_line_code_type_sign(line)
due_date = self._get_line_due_date(line, op_type)
amount = (line.debit - line.credit) * sign

info = self._prepare_factofrance_body_line(line)
code, amount = info["code"], info["amount_signed"]

Check warning on line 196 in account_factoring_receivable_balance_factofrance/models/subrogation_receipt.py

View check run for this annotation

Codecov / codecov/patch

account_factoring_receivable_balance_factofrance/models/subrogation_receipt.py#L195-L196

Added lines #L195 - L196 were not covered by tests
if code == "101":
totals["number_of_invoices"] += 1
totals["total_amount_of_invoices"] += amount

Check warning on line 199 in account_factoring_receivable_balance_factofrance/models/subrogation_receipt.py

View check run for this annotation

Codecov / codecov/patch

account_factoring_receivable_balance_factofrance/models/subrogation_receipt.py#L198-L199

Added lines #L198 - L199 were not covered by tests
Expand All @@ -212,48 +204,59 @@ def _prepare_factofrance_body(self):
totals["number_of_payments"] += 1
totals["total_amount_of_payments"] += amount
totals["balance"] += line.balance

identification_type = journal.partner_identification_type
info = {
"code": code or " ",
"confirm_date": factofrance_date(self.date),
"factor_code": str(journal.factor_code),
"document": (
(partner.siret or "0")
if identification_type == "1"
else (partner.vat or "0")
),
"customer_name": partner.name or "",
"customer_address": " ".join(
x for x in [partner.street, partner.street2, partner.street3] if x
),
# "customer_street": partner.street
# and partner.street.ljust(40, " ")
# or " ",
# "customer_street2": partner.street2
# and partner.street2.ljust(40, " ")
# or "".ljust(40, " "),
"customer_zip_code": partner.zip or "",
"delivery_office": partner.city or "",
"customer_country_code": partner.country_id.code or "",
"customer_phone": (partner.phone or partner.mobile or "").replace(
" ", ""
),
"customer_ref": partner.ref or "",
"date": factofrance_date(move.invoice_date or move.date),
"number": move.payment_reference or move.name,
"currency": self.company_id.currency_id.name or "",
"account_sign": "-" if amount < 0 else "+",
"amount": abs(amount),
"payment_mode": "VIR",
"date_due": factofrance_date(due_date),
"customer_order_reference": move.ref or "",
"operation_type": op_type,
"move_type": move.move_type,
}
rows.append(info)
return rows, totals

Check warning on line 208 in account_factoring_receivable_balance_factofrance/models/subrogation_receipt.py

View check run for this annotation

Codecov / codecov/patch

account_factoring_receivable_balance_factofrance/models/subrogation_receipt.py#L204-L208

Added lines #L204 - L208 were not covered by tests

def _prepare_factofrance_body_line(self, line):
move = line.move_id
journal = self.factor_journal_id
partner = line.move_id.partner_id.commercial_partner_id

Check warning on line 213 in account_factoring_receivable_balance_factofrance/models/subrogation_receipt.py

View check run for this annotation

Codecov / codecov/patch

account_factoring_receivable_balance_factofrance/models/subrogation_receipt.py#L211-L213

Added lines #L211 - L213 were not covered by tests
if not partner:
raise UserError(f"Pas de partenaire sur la pièce {line.move_id}")

Check warning on line 215 in account_factoring_receivable_balance_factofrance/models/subrogation_receipt.py

View check run for this annotation

Codecov / codecov/patch

account_factoring_receivable_balance_factofrance/models/subrogation_receipt.py#L215

Added line #L215 was not covered by tests

code, op_type, sign = self._get_line_code_type_sign(line)
due_date = self._get_line_due_date(line, op_type)
amount = (line.debit - line.credit) * sign
identification_type = journal.partner_identification_type

Check warning on line 220 in account_factoring_receivable_balance_factofrance/models/subrogation_receipt.py

View check run for this annotation

Codecov / codecov/patch

account_factoring_receivable_balance_factofrance/models/subrogation_receipt.py#L217-L220

Added lines #L217 - L220 were not covered by tests
info = {
"code": code or " ",
"confirm_date": factofrance_date(self.date),
"factor_code": str(journal.factor_code),
"document": (
(partner.siret or "0")
if identification_type == "1"
else (partner.vat or "0")
),
"customer_name": partner.name or "",
"customer_address": " ".join(
x for x in [partner.street, partner.street2, partner.street3] if x
),
# "customer_street": partner.street
# and partner.street.ljust(40, " ")
# or " ",
# "customer_street2": partner.street2
# and partner.street2.ljust(40, " ")
# or "".ljust(40, " "),
"customer_zip_code": partner.zip or "",
"delivery_office": partner.city or "",
"customer_country_code": partner.country_id.code or "",
"customer_phone": (partner.phone or partner.mobile or "").replace(" ", ""),
"customer_ref": partner.ref or "",
"date": factofrance_date(move.invoice_date or move.date),
# For document number, Invoices use payment ref, Payments use the paid ref
"number": move.payment_reference or move.ref or move.name,
"currency": self.company_id.currency_id.name or "",
"account_sign": "-" if amount < 0 else "+",
"amount_signed": amount,
"amount": abs(amount),
"payment_mode": "VIR",
"date_due": factofrance_date(due_date),
"customer_order_reference": move.ref or "",
"operation_type": op_type,
"move_type": move.move_type,
}
return info

Check warning on line 258 in account_factoring_receivable_balance_factofrance/models/subrogation_receipt.py

View check run for this annotation

Codecov / codecov/patch

account_factoring_receivable_balance_factofrance/models/subrogation_receipt.py#L258

Added line #L258 was not covered by tests

def _get_factofrance_body(self, rows_info):
rows = []

Check warning on line 261 in account_factoring_receivable_balance_factofrance/models/subrogation_receipt.py

View check run for this annotation

Codecov / codecov/patch

account_factoring_receivable_balance_factofrance/models/subrogation_receipt.py#L261

Added line #L261 was not covered by tests
for info in rows_info:
Expand Down

0 comments on commit a0ab5df

Please sign in to comment.