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

[15.0][MIG] sale_fixed_discount #2574

Merged
merged 16 commits into from
Jul 20, 2023

Conversation

CRogos
Copy link
Contributor

@CRogos CRogos commented Jun 19, 2023

Followup of #2485

  • migration based on v14
  • merged commits

@ao-landoo
Copy link
Contributor

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

https://watch.screencastify.com/v/Q9Q3IkXpvKHAoyiizsTG

@CRogos
Copy link
Contributor Author

CRogos commented Jul 5, 2023

I totally agree with this issue but I assume this has do be solved in account_invoice_fixed_discount
There is also a ticket regarding this issue: OCA/account-invoicing#1107

Copy link
Contributor

@ao-landoo ao-landoo left a comment

Choose a reason for hiding this comment

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

You're right

Comment on lines 17 to 25
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
)
Copy link
Contributor Author

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)

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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? :)

Copy link
Contributor Author

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?

@CRogos CRogos force-pushed the 15.0-mig-sale_fixed_discount branch from 80523df to 17b76c1 Compare July 16, 2023 16:13
@pedrobaeza
Copy link
Member

Merging blindly according what have been talked:

/ocabot migration sale_fixed_discount
/ocabot merge nobump

@OCA-git-bot OCA-git-bot added this to the 15.0 milestone Jul 20, 2023
@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 15.0-ocabot-merge-pr-2574-by-pedrobaeza-bump-nobump, awaiting test results.

@OCA-git-bot
Copy link
Contributor

The migration issue (#1741) has not been updated to reference the current pull request because a previous pull request (#2485) is not closed.
Perhaps you should check that there is no duplicate work.
CC @ps-tubtim

OCA-git-bot added a commit that referenced this pull request Jul 20, 2023
Signed-off-by pedrobaeza
@OCA-git-bot
Copy link
Contributor

@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.

@pedrobaeza
Copy link
Member

Cancelling...

What happens with #2485 ?

@CRogos
Copy link
Contributor Author

CRogos commented Jul 20, 2023

There was no reaction and no progress. #2485 is also migrated based on v13 while this PR is based von the v14 branch.
This PR supersede #2485

@pedrobaeza
Copy link
Member

/ocabot migration sale_fixed_discount
/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 15.0-ocabot-merge-pr-2574-by-pedrobaeza-bump-nobump, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Jul 20, 2023
Signed-off-by pedrobaeza
@OCA-git-bot
Copy link
Contributor

It looks like something changed on 15.0 in the meantime.
Let me try again (no action is required from you).
Prepared branch 15.0-ocabot-merge-pr-2574-by-pedrobaeza-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit ba52fb1 into OCA:15.0 Jul 20, 2023
9 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 264f62e. Thanks a lot for contributing to OCA. ❤️

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.

None yet