From 8c20a11ea39f36e27971cbf4339981fd4d35c130 Mon Sep 17 00:00:00 2001 From: Martijn Date: Tue, 17 Oct 2023 15:46:06 +0200 Subject: [PATCH] fix(payments-plugin): only add already paid when it has a value --- .../src/mollie/mollie.helpers.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/payments-plugin/src/mollie/mollie.helpers.ts b/packages/payments-plugin/src/mollie/mollie.helpers.ts index 0c732fae10..6b8612cc77 100644 --- a/packages/payments-plugin/src/mollie/mollie.helpers.ts +++ b/packages/payments-plugin/src/mollie/mollie.helpers.ts @@ -61,14 +61,16 @@ export function toMollieOrderLines(order: Order, alreadyPaid: number): CreatePar vatAmount: toAmount(surcharge.priceWithTax - surcharge.price, order.currencyCode), }))); // Deduct amount already paid - lines.push({ - name: 'Already paid', - quantity: 1, - unitPrice: toAmount(-alreadyPaid, order.currencyCode), - totalAmount: toAmount(-alreadyPaid, order.currencyCode), - vatRate: String(0), - vatAmount: toAmount(0, order.currencyCode), - }); + if (alreadyPaid) { + lines.push({ + name: 'Already paid', + quantity: 1, + unitPrice: toAmount(-alreadyPaid, order.currencyCode), + totalAmount: toAmount(-alreadyPaid, order.currencyCode), + vatRate: String(0), + vatAmount: toAmount(0, order.currencyCode), + }); + } return lines; }