Skip to content

Commit

Permalink
[MODFISTO-488] Fixed encumbrance changes after cancelling a payment o…
Browse files Browse the repository at this point in the history
…r credit
  • Loading branch information
damien-git committed Jun 21, 2024
1 parent 808aa04 commit 12c36da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ private void updateEncumbranceToCancelTransaction(Transaction transaction, Trans
double amount = encumbrance.getAmount();
if (transaction.getTransactionType() == PAYMENT) {
expended = subtractMoney(expended, transaction.getAmount(), currency);
amount = sumMoney(amount, transaction.getAmount(), currency);
if (encumbrance.getEncumbrance().getStatus() == Encumbrance.Status.UNRELEASED) {
amount = sumMoney(amount, transaction.getAmount(), currency);
}
} else {
credited = subtractMoney(credited, transaction.getAmount(), currency);
if (Encumbrance.Status.RELEASED != encumbrance.getEncumbrance().getStatus()) {
if (encumbrance.getEncumbrance().getStatus() == Encumbrance.Status.UNRELEASED) {
amount = subtractMoney(amount, transaction.getAmount(), currency);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,8 @@ void testCancelPaymentWithLinkedEncumbrance(VertxTestContext testContext) {
assertThat(savedEncumbrance.getTransactionType(), equalTo(ENCUMBRANCE));
assertThat(savedEncumbrance.getEncumbrance().getStatus(), equalTo(RELEASED));
assertNotNull(savedEncumbrance.getMetadata().getUpdatedDate());
assertThat(savedEncumbrance.getAmount(), equalTo(5d));
assertThat(savedEncumbrance.getAmount(), equalTo(0d));
assertThat(savedEncumbrance.getEncumbrance().getInitialAmountEncumbered(), equalTo(5d));
assertThat(savedEncumbrance.getEncumbrance().getAmountAwaitingPayment(), equalTo(0d));
assertThat(savedEncumbrance.getEncumbrance().getAmountExpended(), equalTo(0d));

Expand Down Expand Up @@ -689,6 +690,7 @@ void testCancelCreditWithLinkedEncumbrance(VertxTestContext testContext) {
assertThat(savedEncumbrance.getEncumbrance().getStatus(), equalTo(RELEASED));
assertNotNull(savedEncumbrance.getMetadata().getUpdatedDate());
assertThat(savedEncumbrance.getAmount(), equalTo(0d));
assertThat(savedEncumbrance.getEncumbrance().getInitialAmountEncumbered(), equalTo(5d));
assertThat(savedEncumbrance.getEncumbrance().getAmountAwaitingPayment(), equalTo(0d));
assertThat(savedEncumbrance.getEncumbrance().getAmountExpended(), equalTo(5d));
assertThat(savedEncumbrance.getEncumbrance().getAmountCredited(), equalTo(0d));
Expand Down

0 comments on commit 12c36da

Please sign in to comment.