-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat(core): Create PromotionLineAction #2971
feat(core): Create PromotionLineAction #2971
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
Looks good - just 1 comment on the rounding. If there is a good reason to do it this was please let me know, else pass the quantity in to the roundMoney()
function.
@@ -149,6 +158,13 @@ export class Promotion | |||
const promotionAction = this.allActions[action.code]; | |||
if (promotionAction instanceof PromotionItemAction) { | |||
if (this.isOrderItemArg(args)) { | |||
const { orderLine } = args; | |||
amount += | |||
roundMoney(await promotionAction.execute(ctx, orderLine, action.args, state, this)) * |
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.
the roundMoney()
function accepts a 2nd argument for quantity, so that the configured MoneyStrategy can control the multiplication.
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.
Thank you for the review.
It seems the issue arose because the previous quantity calculation logic was simply transferred.
I have added the calculation logic as an argument to roundMoney
.
Thank you very much for your contribution and continued input in developing this feature! |
Description
To address the issue mentioned in the previous PR, I modified the return type of the
execute
method inPromotionItemAction
to return either aNumber
orExecutePromotionActionResult
, allowing the inclusion ofdiscountMode
.However, to maintain code consistency, I have added
PromotionLineAction
and adjusted allPromotionActions
to return aNumber
type.Other tasks follow the contents of the attached previous PR.
Checklist
📌 Always:
👍 Most of the time: