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

[14.0][ADD] account_global_discount_amount module #807

Conversation

chafique-delli
Copy link

@chafique-delli chafique-delli commented Nov 2, 2020

This module allows you to enter an amount for a global discount to be applied to the invoice.
Discount lines will be automatically created per tax group.
When creating and modifying an invoice with a global discount, all total amounts will be checked to ensure that the discount has been applied correctly. If not, an automatic correction of the invoice will be made.

@rvalyi
Copy link
Member

rvalyi commented Nov 4, 2020

@pedrobaeza
Copy link
Member

And this one is not preserving commit history.

@chafique-delli
Copy link
Author

@rvalyi , @pedrobaeza , I have added an explanation of what the module will do.
Concerning the name of the module, I will take it if you have a more evocative name to propose.

@pedrobaeza
Copy link
Member

Sorry, I got confused this module with account_global_discount that we maintain and we are migrating in v13.

@sebastienbeau
Copy link
Member

Hi @pedrobaeza it's not the same module but having you feedback will be a pleasure

In our case we need to put a discount amount (not a percentage but an amount) on sale order and/or invoice.

We need to split this amount (by taxes), so we were thinking of adding extra (sale.order.line /account.invoice.line) like the carrier one. More over since V13 the invoice and move are merge adding new line with the type discount seem for use the simpliest solution.

Maybe we should try to add this feature directly in your module ? Instead of doing something else (the issue is that we are going to create a lot of global.discount)

Did you plan to migrate account_global_discount in V13 ? how to do plan to support this discount line ? still in the global.discount.line or directly like an account.move.line ?

@pedrobaeza
Copy link
Member

My colleague @chienandalu and me thought initially to add both kind of discounts in base_global_discount and subsequent modules: fixed and percentage. We finally removed it as we didn't need such fixed type and it will complicate a bit the logic of the module. But both share similar challenges. I still think that if you need to add fixed global discounts (I discourage though both kind of global discounts in business and implementation perspective), let's add it on the existing modules.

What is the main problem? The distribution of the discount across lines. You can't create an extra line for such discount (or at least not only one), as account and taxes may vary from line to line. So you need then to spread everything proportionally. In percentage discount, that proportionality is simple: apply the same percentage everywhere. On fixed discount, you need to add a bit more logic to spread it over lines, but it can be done with such addition.

Then the challenge is to get to proper invoice and journal items data. We use the intermediate model for easing this task, and touch on totals and tax computations, and on move generation.

My colleague @ernestotejeda is now analyzing how to port this to v13, and we will have soon this migration done. I haven't dug too much, but now that the move line generation is immediate, I think we can create as many extra move lines as needed for balancing the amounts, hidden as journal items, but not sure if the code, that is very convoluted, will allow us this for the computed totals, and maybe the extra model is still needed.

Anyway, these changes will be the same for you once you have made the spread over the lines (proportionally by line amount over the fixed amount?), so I recommend that if you can wait, adapt these set of modules for adding the new type of discount.

@pedrobaeza
Copy link
Member

#967 should be taken into account, as previous version is not fully correct.

@chafique-delli chafique-delli force-pushed the 14.0-ADD-account_global_discount_amount branch 5 times, most recently from a922058 to 90c747d Compare October 11, 2021 17:11
@chafique-delli chafique-delli force-pushed the 14.0-ADD-account_global_discount_amount branch from 9f26f0a to ae79b03 Compare October 25, 2021 08:25
@rousseldenis
Copy link
Contributor

@chafique-delli @sebastienbeau What's the status of this ?

@chafique-delli
Copy link
Author

@sebastienbeau , Can you update the status of the P.R.

@sebastienbeau sebastienbeau marked this pull request as ready for review February 2, 2022 16:21
@sebastienbeau
Copy link
Member

@rousseldenis Module is ready for review.
So basically the idea of the module is to support a global amount of discount, this amount will generate several invoice line (with a product discount) and the total amount is split proportionally between each line of the invoice.

@sebastienbeau
Copy link
Member

Note I have approve only to remove my blocking review, please review and approve this work before any merge

@sebastienbeau sebastienbeau force-pushed the 14.0-ADD-account_global_discount_amount branch from ce6e410 to a3ded7c Compare February 4, 2022 17:23
@github-actions
Copy link

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Apr 23, 2023
@sebastienbeau sebastienbeau added needs review and removed work in progress stale PR/Issue without recent activity, it'll be soon closed automatically. labels May 2, 2023
@github-actions
Copy link

github-actions bot commented Sep 3, 2023

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Sep 3, 2023
@github-actions github-actions bot closed this Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants