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

Add maxDiscountAmount to PromotionItemAction #2956

Closed
BM-JiHoonPark opened this issue Jul 18, 2024 · 0 comments
Closed

Add maxDiscountAmount to PromotionItemAction #2956

BM-JiHoonPark opened this issue Jul 18, 2024 · 0 comments

Comments

@BM-JiHoonPark
Copy link

Is your feature request related to a problem? Please describe.
I am implementing most of the discount features through promotions. I want to run various types of discount promotions, and I believe that product discount coupons with a maximum discount amount limit will be effective.

Describe the solution you'd like
Currently, for PromotionItemAction, the final discount amount is calculated by multiplying the return value of execute by the quantity.

If the return value of execute is divided by the quantity and returned, a fixed amount discount can be achieved.

However, this can cause issues if the return value of execute and the quantity do not divide evenly.

For example, if the maximum discount amount is 100000 and the quantity is 11, when the return value of execute is 100000 / 11, the amount in the adjustment is stored as -99999.99999999999.

I believe this could cause long-term issues and would prefer to store the maximum discount amount separately to be used in calculations.

Describe alternatives you've considered
Create a new column in the promotion table or add a new parameter to the execute method of PromotionItemAction. This will ensure that when calculating the amount of the adjustment in the applyOrderItemPromotions method, the value stored is Math.min(adjustment.amount * line.quantity, maxDiscountAmount) instead of adjustment.amount * line.quantity.

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

No branches or pull requests

2 participants