Skip to content

Commit

Permalink
fix(admin-ui): Fix bug in cancelling order lines
Browse files Browse the repository at this point in the history
Closes #2608
  • Loading branch information
michaelbromley committed Jan 12, 2024
1 parent 9ab2e4d commit 913e6d8
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
}

Expand Down

0 comments on commit 913e6d8

Please sign in to comment.