You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 is11
, when the return value of execute is100000 / 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 ofadjustment.amount * line.quantity
.The text was updated successfully, but these errors were encountered: