Browse Source

fix(core): Relax some restrictions on adding new payments to Order

Relates to #688
Michael Bromley 5 years ago
parent
commit
26c1b7a2db

+ 1 - 1
packages/core/src/service/helpers/order-state-machine/order-state-machine.ts

@@ -78,7 +78,7 @@ export class OrderStateMachine {
                 .getRepository(data.ctx, OrderModification)
                 .find({ where: { order: data.order }, relations: ['refund', 'payment'] });
             if (toState === 'ArrangingAdditionalPayment') {
-                if (modifications.every(modification => modification.isSettled)) {
+                if (0 < modifications.length && modifications.every(modification => modification.isSettled)) {
                     return `message.cannot-transition-no-additional-payments-needed`;
                 }
             } else {

+ 9 - 1
packages/core/src/service/helpers/order-state-machine/order-state.ts

@@ -37,7 +37,15 @@ export const orderStateTransitions: Transitions<OrderState> = {
         to: ['PaymentSettled', 'Cancelled', 'Modifying', 'ArrangingAdditionalPayment'],
     },
     PaymentSettled: {
-        to: ['PartiallyDelivered', 'Delivered', 'PartiallyShipped', 'Shipped', 'Cancelled', 'Modifying'],
+        to: [
+            'PartiallyDelivered',
+            'Delivered',
+            'PartiallyShipped',
+            'Shipped',
+            'Cancelled',
+            'Modifying',
+            'ArrangingAdditionalPayment',
+        ],
     },
     PartiallyShipped: {
         to: ['Shipped', 'PartiallyDelivered', 'Cancelled', 'Modifying'],