Skip to content

Commit

Permalink
totalAmount variable
Browse files Browse the repository at this point in the history
  • Loading branch information
amihaiemil committed Mar 10, 2021
1 parent e4fbfd0 commit b4710bf
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit b4710bf

Please sign in to comment.