Browse Source

fix(admin-ui): Fix bug in cancelling order lines

Closes #2608
Michael Bromley 2 years ago
parent
commit
913e6d8e08

+ 14 - 5
packages/admin-ui/src/lib/order/src/components/refund-order-dialog/refund-order-dialog.component.ts

@@ -80,18 +80,21 @@ export class RefundOrderDialogComponent
                 .filter(refundLine => refundLine.orderLineId === line.id)
                 .reduce((sum, refundLine) => sum + refundLine.quantity, 0) ?? 0;
 
-        return refundedCount < line.quantity;
+        return refundedCount < line.orderPlacedQuantity;
     }
 
     ngOnInit() {
-        this.lineQuantities = this.order.lines.reduce((result, line) => ({
+        this.lineQuantities = this.order.lines.reduce(
+            (result, line) => ({
                 ...result,
                 [line.id]: {
                     quantity: 0,
                     refund: false,
                     cancel: false,
                 },
-            }), {});
+            }),
+            {},
+        );
         this.settledPayments = (this.order.payments || []).filter(p => p.state === 'Settled');
         if (this.settledPayments.length) {
             this.selectedPayment = this.settledPayments[0];
@@ -106,12 +109,18 @@ export class RefundOrderDialogComponent
     }
 
     isRefunding(): boolean {
-        const result = Object.values(this.lineQuantities).reduce((isRefunding, line) => isRefunding || (0 < line.quantity && line.refund), false);
+        const result = Object.values(this.lineQuantities).reduce(
+            (isRefunding, line) => isRefunding || (0 < line.quantity && line.refund),
+            false,
+        );
         return result;
     }
 
     isCancelling(): boolean {
-        const result = Object.values(this.lineQuantities).reduce((isCancelling, line) => isCancelling || (0 < line.quantity && line.cancel), false);
+        const result = Object.values(this.lineQuantities).reduce(
+            (isCancelling, line) => isCancelling || (0 < line.quantity && line.cancel),
+            false,
+        );
         return result;
     }