-
-
Notifications
You must be signed in to change notification settings - Fork 982
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
[15.0][MIG] sale_fixed_discount #2574
[15.0][MIG] sale_fixed_discount #2574
Conversation
instead of `sale.group_discount_per_so_line`
The sale order view in the portal was not displaying the fixed discount.
When creating the invoice from the sale order, invoice's total tax value is not considering the fixed discount. You need to set it's value on the line to 0 and set it's value again |
I totally agree with this issue but I assume this has do be solved in account_invoice_fixed_discount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right
real_price = order_line.price_unit * ( | ||
1 - (order_line.discount or 0.0) / 100.0 | ||
) - (order_line.discount_fixed or 0.0) | ||
twicked_price = real_price / (1 - (order_line.discount or 0.0) / 100.0) | ||
price = ( | ||
order_line.price_unit * (1 - (order_line.discount or 0.0) / 100.0) | ||
if not order_line.discount_fixed | ||
else twicked_price | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does anyone understand this code?
I would say this line would be fine:
price = order_line.price_unit * (1 - (order_line.discount or 0.0) / 100.0) - (order_line.discount_fixed or 0.0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pedrobaeza do you have an opinion on this?
Using the UI you can only insert discount or discount_fixed. So my simplification should be sufficient.
Via the API discount and discount_fixed might be possible and the current implementation of twicked_price is like this:
twicked_price = (100€ * 0,9 - 20€) / 0.9 = 77,78€
While my suggested calculation would be:
price = 100€ * 0,9 - 20€ = 70€ which would be an addition of the discounts.
I also have my concerns that the tax is calculated correctly when discount and discount_fixed is provided.
OCA/account-invoicing#1107
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add then a constraint (SQL or Python) for not being able to save both fields with value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now you are saying it, there is already such a constraint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then no problem, isn't it? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pedrobaeza everything is done from my side. Would you like to review / merge this PR?
80523df
to
17b76c1
Compare
Merging blindly according what have been talked: /ocabot migration sale_fixed_discount |
On my way to merge this fine PR! |
The migration issue (#1741) has not been updated to reference the current pull request because a previous pull request (#2485) is not closed. |
@pedrobaeza your merge command was aborted due to failed check(s), which you can inspect on this commit of 15.0-ocabot-merge-pr-2574-by-pedrobaeza-bump-nobump. After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red. |
Cancelling... What happens with #2485 ? |
/ocabot migration sale_fixed_discount |
What a great day to merge this nice PR. Let's do it! |
It looks like something changed on |
Congratulations, your PR was merged at 264f62e. Thanks a lot for contributing to OCA. ❤️ |
Followup of #2485