You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by "marta-jankovics (via GitHub)" <gi...@apache.org> on 2023/08/07 09:35:55 UTC
[GitHub] [fineract] marta-jankovics commented on a diff in pull request #3360: FINERACT-1939: Hold Amount - should be debit
marta-jankovics commented on code in PR #3360:
URL: https://github.com/apache/fineract/pull/3360#discussion_r1285623988
##########
fineract-core/src/main/java/org/apache/fineract/portfolio/savings/SavingsAccountTransactionType.java:
##########
@@ -56,158 +82,115 @@ public String getCode() {
return this.code;
}
- public static SavingsAccountTransactionType fromInt(final Integer transactionType) {
-
- if (transactionType == null) {
- return SavingsAccountTransactionType.INVALID;
- }
-
- SavingsAccountTransactionType savingsAccountTransactionType = SavingsAccountTransactionType.INVALID;
- switch (transactionType) {
- case 1:
- savingsAccountTransactionType = SavingsAccountTransactionType.DEPOSIT;
- break;
- case 2:
- savingsAccountTransactionType = SavingsAccountTransactionType.WITHDRAWAL;
- break;
- case 3:
- savingsAccountTransactionType = SavingsAccountTransactionType.INTEREST_POSTING;
- break;
- case 4:
- savingsAccountTransactionType = SavingsAccountTransactionType.WITHDRAWAL_FEE;
- break;
- case 5:
- savingsAccountTransactionType = SavingsAccountTransactionType.ANNUAL_FEE;
- break;
- case 6:
- savingsAccountTransactionType = SavingsAccountTransactionType.WAIVE_CHARGES;
- break;
- case 7:
- savingsAccountTransactionType = SavingsAccountTransactionType.PAY_CHARGE;
- break;
- case 8:
- savingsAccountTransactionType = SavingsAccountTransactionType.DIVIDEND_PAYOUT;
- break;
- case 12:
- savingsAccountTransactionType = SavingsAccountTransactionType.INITIATE_TRANSFER;
- break;
- case 13:
- savingsAccountTransactionType = SavingsAccountTransactionType.APPROVE_TRANSFER;
- break;
- case 14:
- savingsAccountTransactionType = SavingsAccountTransactionType.WITHDRAW_TRANSFER;
- break;
- case 15:
- savingsAccountTransactionType = SavingsAccountTransactionType.REJECT_TRANSFER;
- break;
- case 16:
- savingsAccountTransactionType = SavingsAccountTransactionType.WRITTEN_OFF;
- break;
- case 17:
- savingsAccountTransactionType = SavingsAccountTransactionType.OVERDRAFT_INTEREST;
- break;
- case 18:
- savingsAccountTransactionType = SavingsAccountTransactionType.WITHHOLD_TAX;
- break;
- case 19:
- savingsAccountTransactionType = SavingsAccountTransactionType.ESCHEAT;
- break;
- case 20:
- savingsAccountTransactionType = SavingsAccountTransactionType.AMOUNT_HOLD;
- break;
- case 21:
- savingsAccountTransactionType = SavingsAccountTransactionType.AMOUNT_RELEASE;
- break;
- }
- return savingsAccountTransactionType;
+ public TransactionEntryType getEntryType() {
+ return entryType;
+ }
+
+ public boolean isCreditEntryType() {
+ return entryType != null && entryType.isCredit();
+ }
+
+ public boolean isDebitEntryType() {
+ return entryType != null && entryType.isDebit();
+ }
+
+ public static SavingsAccountTransactionType fromInt(final Integer value) {
+ SavingsAccountTransactionType transactionType = BY_ID.get(value);
+ return transactionType == null ? INVALID : transactionType;
}
public boolean isDeposit() {
- return this.value.equals(SavingsAccountTransactionType.DEPOSIT.getValue());
+ return this == DEPOSIT;
}
public boolean isWithdrawal() {
- return this.value.equals(SavingsAccountTransactionType.WITHDRAWAL.getValue());
+ return this == WITHDRAWAL;
}
public boolean isInterestPosting() {
- return this.value.equals(SavingsAccountTransactionType.INTEREST_POSTING.getValue());
+ return this == INTEREST_POSTING;
}
public boolean isOverDraftInterestPosting() {
- return this.value.equals(SavingsAccountTransactionType.OVERDRAFT_INTEREST.getValue());
+ return this == OVERDRAFT_INTEREST;
}
public boolean isWithHoldTax() {
- return this.value.equals(SavingsAccountTransactionType.WITHHOLD_TAX.getValue());
+ return this == WITHHOLD_TAX;
}
public boolean isWithdrawalFee() {
- return this.value.equals(SavingsAccountTransactionType.WITHDRAWAL_FEE.getValue());
+ return this == WITHDRAWAL_FEE;
}
public boolean isAnnualFee() {
- return this.value.equals(SavingsAccountTransactionType.ANNUAL_FEE.getValue());
+ return this == ANNUAL_FEE;
}
public boolean isPayCharge() {
- return this.value.equals(SavingsAccountTransactionType.PAY_CHARGE.getValue());
+ return this == PAY_CHARGE;
}
public boolean isChargeTransaction() {
return isPayCharge() || isWithdrawalFee() || isAnnualFee();
}
public boolean isWaiveCharge() {
- return this.value.equals(SavingsAccountTransactionType.WAIVE_CHARGES.getValue());
+ return this == WAIVE_CHARGES;
}
public boolean isTransferInitiation() {
- return this.value.equals(SavingsAccountTransactionType.INITIATE_TRANSFER.getValue());
+ return this == INITIATE_TRANSFER;
}
public boolean isTransferApproval() {
- return this.value.equals(SavingsAccountTransactionType.APPROVE_TRANSFER.getValue());
+ return this == APPROVE_TRANSFER;
}
public boolean isTransferRejection() {
- return this.value.equals(SavingsAccountTransactionType.REJECT_TRANSFER.getValue());
+ return this == REJECT_TRANSFER;
}
public boolean isTransferWithdrawal() {
- return this.value.equals(SavingsAccountTransactionType.WITHDRAW_TRANSFER.getValue());
+ return this == WITHDRAW_TRANSFER;
}
public boolean isWrittenoff() {
- return this.value.equals(SavingsAccountTransactionType.WRITTEN_OFF.getValue());
+ return this == WRITTEN_OFF;
}
public boolean isDividendPayout() {
- return this.value.equals(SavingsAccountTransactionType.DIVIDEND_PAYOUT.getValue());
+ return this == DIVIDEND_PAYOUT;
}
public boolean isIncomeFromInterest() {
- return this.value.equals(SavingsAccountTransactionType.OVERDRAFT_INTEREST.getValue());
+ return this == OVERDRAFT_INTEREST;
}
public boolean isEscheat() {
- return this.value.equals(SavingsAccountTransactionType.ESCHEAT.getValue());
+ return this == ESCHEAT;
}
public boolean isAmountOnHold() {
- return this.value.equals(SavingsAccountTransactionType.AMOUNT_HOLD.getValue());
+ return this == AMOUNT_HOLD;
}
public boolean isAmountRelease() {
- return this.value.equals(SavingsAccountTransactionType.AMOUNT_RELEASE.getValue());
+ return this == AMOUNT_RELEASE;
+ }
+
+ public boolean isCredit() {
+ // AMOUNT_RELEASE is not credit, because the account balance is not changed
+ return isCreditEntryType() && !isAmountRelease();
}
public boolean isDebit() {
- return isWithdrawal() || isWithdrawalFee() || isAnnualFee() || isPayCharge() || isIncomeFromInterest() || isWithHoldTax()
- || isEscheat();
+ // AMOUNT_HOLD, ESCHEAT are not debit, because the account balance is not changed
+ return isDebitEntryType() && !isAmountOnHold() && !isEscheat();
Review Comment:
I agree with you and but this is how fineract currently works, and if I wanted to be backward compatible, I had to keep this. I would like very much to clean up all these, but it was not the scope of this story.
onHold transaction:
- should be shown as DEBIT on the UI
- currently included in the transaction runningBalance field calculation
- not included in the account runningBalance calculation
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org