From b4710bf83d9b8d4b575172845ddb3a93ce847350 Mon Sep 17 00:00:00 2001 From: amihaiemil Date: Wed, 10 Mar 2021 12:36:57 +0200 Subject: [PATCH] totalAmount variable --- .../java/com/selfxdsd/core/projects/PreCheckPayments.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/self-core-impl/src/main/java/com/selfxdsd/core/projects/PreCheckPayments.java b/self-core-impl/src/main/java/com/selfxdsd/core/projects/PreCheckPayments.java index d714aff1..be0b4a34 100644 --- a/self-core-impl/src/main/java/com/selfxdsd/core/projects/PreCheckPayments.java +++ b/self-core-impl/src/main/java/com/selfxdsd/core/projects/PreCheckPayments.java @@ -77,15 +77,14 @@ public Payment pay(final Invoice invoice) { LOG.error("[Payment-PreCheck] Invoice already paid."); throw new InvoiceException.AlreadyPaid(invoice); } - if (invoice.totalAmount().longValueExact() < 108 * 100) { + final BigDecimal totalAmount = invoice.totalAmount(); + if (totalAmount.longValueExact() < 108 * 100) { LOG.error("[Payment-PreCheck] In order to be paid, Invoice amount" + " must be at least 108 €."); throw new WalletPaymentException("In order to be paid, Invoice" + " amount must be at least 108 €."); } - final BigDecimal newLimit = this.cash().subtract( - invoice.totalAmount() - ); + final BigDecimal newLimit = this.cash().subtract(totalAmount); if (newLimit.longValue() < 0L) { LOG.error("[Payment-PreCheck] Not enough cash to pay Invoice."); throw new WalletPaymentException(