[12.0][IMP] - Contract: Add a new field to compute the next period end date - #431
[12.0][IMP] - Contract: Add a new field to compute the next period end date#431sbejaoui wants to merge 2 commits into
Conversation
…d date make the invoicing period independent from the invoice date
54d92d7 to
6509e9e
Compare
| else: | ||
| rec.last_date_invoiced = last_date_invoiced | ||
| rec.recurring_next_date = recurring_next_date | ||
| rec.next_period_end_date = next_period_end_date |
There was a problem hiding this comment.
I think you can continue simplifying by doing _update_next_period_date instead of _update_recurring_next_date and make recurring_next_date a computed field that depends on next_period_date and recurring_invoicing_type.
| ) | ||
| next_period_end_date = fields.Date( | ||
| string='Next Period End Date', copy=False | ||
| ) |
There was a problem hiding this comment.
I'd suggest adding a next_period_start_date too (computed = last_date_invoiced + 1). That will simplify the code a bit. And you can display to the user instead of last_date_invoiced, it will improve the UX.
| if self.date_end and self.date_end < last_date_invoiced: | ||
| if not self.next_period_end_date and self.date_end: | ||
| last_date_invoiced = self.date_end | ||
| return first_date_invoiced, last_date_invoiced, recurring_next_date |
There was a problem hiding this comment.
When you have done _update_next_period this _get_period_to_invoice can become very dumb: return next_period_start_date, next_period_end_date
|
So yes 👍 , this PR will be a refactoring of the logic by computing the next period instead of the next invoice date, and making the next invoice date depending on the next period. It will become much easier to reason about the code when this is done, and the UX should be better too by clearly showing what will be the next period to invoice and the invoice date (instead of leaving it to some interpretation of the user as it is now). And it will pave the way for new features such as:
|
|
As discussed, in a first step, let's make |
|
Is this outdated with #434? |
Probably yes. My idea here to make In any case #434 improves maintainability and readability (IMO), and is fully compatible (except two minor differences that you can see in the test changes in #434). |
|
Closing in favor of #434 |
An alternative solution for #428 is to make the invoicing period independent from the invoice date. Original idea of @pedrobaeza (see)
This PR add a new filed to store the next period end date. With the field
last_date_invoicedthe user can easily see and change the invoicing period.A migration script was added to initialize the new field.
What we can add to this PR:
monthlylastdaya check box to be used to compute the next invoice dateCC/ @pedrobaeza , @sbidoul , @gva-acsone, @carlosdauden