Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX][16.0][contract] Fix issue on last_date_invoice contract line #1124

Open
wants to merge 2 commits into
base: 16.0
Choose a base branch
from

Conversation

MTantin
Copy link

@MTantin MTantin commented Sep 5, 2024

Module

contract

Describe the bug

On multiline reccuring contract, the contract line last_date_invoice field is correct on the first line and is shift by 1 period time on the others lines (verified in database). This issue generate visible bug only when #START keywork is used in line note.

To Reproduce

  1. Generate a reccuring contract with a product and a line note using #START and #END keywords
  2. Generate invoices for this contract
  3. The first invoice will be OK but the next invoices will be shift in line note (for example "from 2024-10-01 to 2024-09-30" on september invoice)

Expected behavior
Have correct date in #START and #END keywords of line notes

Correction

The bug came from _update_recurring_next_date method. This method is using next_period_date_end field to fill last_date_invoiced field but last_date_invoiced is used to recompute recurring_next_date of contract and impact next_period_date_end. So the first line is correctly edited but the next line use the new recurring_next_date and it create a shift for the next lines.

I keep the older mechanism of _update_recurring_next_date without invoicing_date and i've add a new mechanism with a specified invoicing_date to use the actual invoicing date.

Co-authored-by: Denis Roussel (ACSONE) <[email protected]>
@remi-filament
Copy link
Contributor

Thanks @MTantin for taking care of this issue. One of my customer experiences the same having a section and then a product line.
However, as far as I can tell, the problem is not only on date_end but also on next invoice date.

Please find below the output of generating the 3 next invoices for a contract post-paid every year starting on the 12th of Feb 2023, both on runboat without your fix and with your fix :
Without your fix :
image
--> we miss one invoice in 2025

First invoice (in 2024) lines are correct :
image

On second invoice (in 2026) end dates are correct but start dates are different on every line :
image

On third invoice (in 2027), the 2 first lines are correct, the start_date on the 3rd is not :
image

With your fix :
image
--> Invoices are generated only every 2 years (missing 1 in 2025, one in 2027)

However, dates on lines are correct every time :
image

So it is better on lines, but there is still an issue on both last_date_invoiced and recurring_next_date and therefore on next invoice to be generated.

@MTantin
Copy link
Author

MTantin commented Sep 14, 2024

@remi-filament Yeah, i noticed some bugs coming from my fix over the different tests of the addon.
I have something else more important to do in the month but i will try to investigate more and fix this in october.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants