Browse Source

fix(server): Fix calculations for default adjustment actions

Michael Bromley 7 years ago
parent
commit
65f4a68423
1 changed files with 2 additions and 2 deletions
  1. 2 2
      server/src/config/adjustment/default-adjustment-actions.ts

+ 2 - 2
server/src/config/adjustment/default-adjustment-actions.ts

@@ -7,7 +7,7 @@ export const orderPercentageDiscount: AdjustmentActionDefinition = {
     code: 'order_percentage_discount',
     args: [{ name: 'discount', type: 'percentage' }],
     calculate(order, args) {
-        return [{ amount: (order.totalPrice * args.discount) / 100 }];
+        return [{ amount: -(order.totalPrice * args.discount) / 100 }];
     },
     description: 'Discount order by { discount }%',
 };
@@ -19,7 +19,7 @@ export const itemPercentageDiscount: AdjustmentActionDefinition = {
     calculate(order, args) {
         return order.items.map(item => ({
             orderItemId: item.id,
-            amount: (item.totalPrice * args.discount) / 100,
+            amount: -(item.totalPrice * args.discount) / 100,
         }));
     },
     description: 'Discount every item by { discount }%',