Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Prazn committed Jul 24, 2024
1 parent 752cb2a commit 8407d08
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions recurring_contract/models/recurring_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,23 +269,17 @@ def _compute_period_paid(self):
current_billing_year += 1
to_pay_period -= 12

months_to_pay = len(list(contract.open_invoice_ids.filtered(
lambda invoice: invoice.date.month <= to_pay_period and invoice.date.year == current_billing_year)))
months_to_pay = len(
list(
contract.open_invoice_ids.filtered(
lambda invoice: invoice.date.month <= to_pay_period
and invoice.date.year == current_billing_year
)
)
)

contract.period_paid = months_to_pay == 0

return


advance_billing = contract.group_id.advance_billing_months
this_month = date.today().month
# Don't consider next year in the period to pay
to_pay_period = min(this_month + advance_billing, 12)
# Exception for december, we will consider next year
if this_month == 12:
to_pay_period += advance_billing
contract.period_paid = contract.months_paid >= to_pay_period

def _compute_months_paid(self):
"""This is a query returning the number of months paid for the current year."""
self._cr.execute(
Expand Down

0 comments on commit 8407d08

Please sign in to comment.