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

[16.0] account_invoice_fixed_discount: Tax rounding error when creating invoice through sale order #1746

Open
PNurm opened this issue Jun 19, 2024 · 0 comments
Labels

Comments

@PNurm
Copy link

PNurm commented Jun 19, 2024

Module

account_invoice_fixed_discount

Describe the bug

When creating invoice through sale order the resulting invoice may have tax rounding errors.

Sales order
image

Invoice
image

To Reproduce

Affected versions:
16.0

Steps to reproduce the behavior:

  1. Create a sale order with fixed discount, test case 870€ with fixed discount of 70€, resulting in total 800€.
  2. Create invoice from the sale order, you will see that the resulting invoice total and tax amount is different.

Expected behavior
Fixed discount should be applied on invoice without causing rounding issues

Additional context

The tax will be corrected if editing the line through UI form. I've attempted to patch this in account.move create() by recalculating taxes and totals (after creation), but that did not work. Neither did patching _create_invoices in sale.order.
In desperation I also tried tests.Form to edit the lines in hopes of triggering re-computation, which also did not work.


The behavior of the module has been changed drastically between 14.0 and 16.0 versions, it used to affect the price unit in computations, whereas now it's a helper field to compute discount percent.

There are few complications to this:

  • The changes were done without accounting for it in migration scripts, when migrating from previous versions the discount percent will be zero on sales order, if creating invoice from this the resulting invoice will be garbage.

  • There's a constraint for the discounts but is not being enforced unless you edit the discounts. There should be additional validation in the sale side of the module to inform the user of the error if creating invoice. Either that or proper migration script should be created.

Needless to say this approach is asking for trouble, I don't understand why it was changed, and hopefully the approach will be reconsidered.

@PNurm PNurm added the bug label Jun 19, 2024
@PNurm PNurm changed the title account_invoice_fixed_discount: Tax rounding error when creating invoice through sale order [16.0] account_invoice_fixed_discount: Tax rounding error when creating invoice through sale order Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant