Skip to content

[FIX] contract: Use get_relative_delta by default in migration _init_last_date_invoiced - #430

Closed
sergio-teruel wants to merge 1 commit into
OCA:12.0from
Tecnativa:12.0-PR-contract-migration
Closed

[FIX] contract: Use get_relative_delta by default in migration _init_last_date_invoiced#430
sergio-teruel wants to merge 1 commit into
OCA:12.0from
Tecnativa:12.0-PR-contract-migration

Conversation

@sergio-teruel

Copy link
Copy Markdown
Contributor

cc @Tecnativa TT18710
Review @Tardo @carlosdauden

@pedrobaeza pedrobaeza added this to the 12.0 milestone Nov 27, 2019
@pedrobaeza
pedrobaeza requested a review from sbejaoui November 27, 2019 12:42
for rec in self:
last_date_invoiced = rec.recurring_next_date - relativedelta(
days=1
last_date_invoiced = (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this PR fix?

@sbejaoui sbejaoui Nov 27, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last date invoiced is the last day of the previous period. It can be:

  • in the pre-paid mode (the invoice date is the first day of the period)
    • = the recurring next date - one day
  • in the post-paid mode (the invoice date is the first day of the next period)
    • = the recurring next date - one period (to have first day of the period)
    • - one day
  • in the monthlylast day (the invoice day is the last day of the month)
    • = the last day of the previous month

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have a contract with a line that does invoices every 3 months, what is the last date invoiced?? by default the relative delta substract one day, I think that tthis method would be substract all setting contract period.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_relative_delta return a relative delta based on the contract line invoicing period, so it don't return a relative delta for one day by default.

If we have a contract with a line that does invoices every 3 months, the last date invoiced depends on recurring_invoice_type:

  • if pre-paid --> subtract one day from the invoice date
  • if post-paid --> subtract one period (3 months is this case) and one day

for this example get_relative_delta return relativedelta(months=3)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sergio-teruel this method has evolved a bit in #434. Can you check if it solves your issue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sbidoul I think is ok, my issue was when I do a migration form old version. If I have a processed contract with this settings ( Invoice every 3 months and pre-paid ) and the date of last invoice was 10/05/2019, after run migration script (12.0.4.0.0), the last invoice date in contract line is 01/04/2020, the correct date is 10/05/2019...
The reason was _init_last_date_invoiced method always subtract one day, I think that this method should be substract all period instead...
But with lastest changes i think that the issue is solved.
Selección_513
Selección_512

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that I can close this PR

@sbidoul

sbidoul commented Nov 27, 2019

Copy link
Copy Markdown
Member

@sergio-teruel could you add a first commit with a failing test that illustrate the issue you want to fix?

@pedrobaeza

Copy link
Copy Markdown
Member

@sergio-teruel is this needed then?

@sergio-teruel

Copy link
Copy Markdown
Contributor Author

I think that is not needed... So I close this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants