Skip to content

Commit

Permalink
fixup! [MIG] ebill_postfinance_server_env: Migration to 17.0
Browse files Browse the repository at this point in the history
No need to use the payment term to find the due date.
The due date field is changed when changing the payment term
  • Loading branch information
TDu committed Oct 18, 2024
1 parent 45e728f commit c12743e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 28 deletions.
31 changes: 6 additions & 25 deletions ebill_postfinance/models/ebill_postfinance_invoice_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,9 @@ def _get_payload_params(self):
)
params["amount_by_group"] = amount_by_group

Check warning on line 239 in ebill_postfinance/models/ebill_postfinance_invoice_message.py

View check run for this annotation

Codecov / codecov/patch

ebill_postfinance/models/ebill_postfinance_invoice_message.py#L239

Added line #L239 was not covered by tests
# Get the invoice due date
date_due = None
if self.invoice_id.invoice_payment_term_id:
terms = self.invoice_id.invoice_payment_term_id.compute(
self.invoice_id.amount_total
)
if terms:
# Returns all payment and their date like [('2020-12-07', 430.37), ...]
# Get the last payment date in the format "202021207"
date_due = terms[-1][0].replace("-", "")
if not date_due:
date_due = self.format_date(
self.invoice_id.invoice_date_due or self.invoice_id.invoice_date
)
date_due = self.format_date(

Check warning on line 241 in ebill_postfinance/models/ebill_postfinance_invoice_message.py

View check run for this annotation

Codecov / codecov/patch

ebill_postfinance/models/ebill_postfinance_invoice_message.py#L241

Added line #L241 was not covered by tests
self.invoice_id.invoice_date_due or self.invoice_id.invoice_date
)
params["date_due"] = date_due
return params

Check warning on line 245 in ebill_postfinance/models/ebill_postfinance_invoice_message.py

View check run for this annotation

Codecov / codecov/patch

ebill_postfinance/models/ebill_postfinance_invoice_message.py#L244-L245

Added lines #L244 - L245 were not covered by tests

Expand Down Expand Up @@ -303,18 +293,9 @@ def _get_payload_params_yb(self):
)
params["amount_by_group"] = amount_by_group
# Get the invoice due date
date_due = None
if self.invoice_id.invoice_payment_term_id:
terms = self.invoice_id.invoice_payment_term_id.compute(
self.invoice_id.amount_total
)
if terms:
# Get the last payment date
date_due = terms[-1][0]
if not date_due:
date_due = self.format_date_yb(
self.invoice_id.invoice_date_due or self.invoice_id.invoice_date
)
date_due = self.format_date_yb(
self.invoice_id.invoice_date_due or self.invoice_id.invoice_date
)
params["date_due"] = date_due
return params

Expand Down
2 changes: 1 addition & 1 deletion ebill_postfinance/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def setUpClass(cls):
"l10n_ch_qr_iban": "CH2130808001234567827",
}
)
cls.terms = cls.env.ref("account.account_payment_term_15days")
cls.payment_term = cls.env.ref("account.account_payment_term_advance_60days")
cls.state = cls.env["res.country.state"].create(
{"code": "RR", "name": "Fribourg", "country_id": cls.country.id}
)
Expand Down
2 changes: 1 addition & 1 deletion ebill_postfinance/tests/examples/invoice_qr_yb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
</AccountAssignment>
<Language>en</Language>
<PaymentInformation>
<PaymentDueDate>2019-07-01</PaymentDueDate>
<PaymentDueDate>2019-08-20</PaymentDueDate>
<PaymentType>IBAN</PaymentType>
<fixAmount>Yes</fixAmount>
<IBAN>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def setUpClass(cls):
def test_invoice_qr(self):
"""Check XML payload genetated for an invoice."""
self.invoice.name = "INV_TEST_01"
self.invoice.invoice_date_due = "2019-07-01"
self.invoice.invoice_payment_term_id = self.payment_term
message = self.invoice.create_postfinance_ebill()
message.set_transaction_id()
message.payload = message._generate_payload_yb()
Expand Down

0 comments on commit c12743e

Please sign in to comment.