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(