FINERACT-1939: Hold Amount - should be debit
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.fineract.portfolio;
|
||||
|
||||
public enum TransactionEntryType {
|
||||
|
||||
CREDIT(1, "transactionEntryType.credit"), //
|
||||
DEBIT(2, "transactionEntryType.debit"), //
|
||||
;
|
||||
|
||||
private final Integer value;
|
||||
private final String code;
|
||||
|
||||
TransactionEntryType(final Integer value, final String code) {
|
||||
this.value = value;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public boolean isCredit() {
|
||||
return this == CREDIT;
|
||||
}
|
||||
|
||||
public boolean isDebit() {
|
||||
return this == DEBIT;
|
||||
}
|
||||
|
||||
public TransactionEntryType getReversal() {
|
||||
return this == CREDIT ? DEBIT : CREDIT;
|
||||
}
|
||||
}
|
||||
+83
-100
@@ -18,34 +18,60 @@
|
||||
*/
|
||||
package org.apache.fineract.portfolio.savings;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.fineract.portfolio.TransactionEntryType;
|
||||
|
||||
/**
|
||||
* An enumeration of different transactions that can occur on a {@link SavingsAccount}.
|
||||
*/
|
||||
public enum SavingsAccountTransactionType {
|
||||
|
||||
INVALID(0, "savingsAccountTransactionType.invalid"), //
|
||||
DEPOSIT(1, "savingsAccountTransactionType.deposit"), //
|
||||
WITHDRAWAL(2, "savingsAccountTransactionType.withdrawal"), //
|
||||
INTEREST_POSTING(3, "savingsAccountTransactionType.interestPosting"), //
|
||||
WITHDRAWAL_FEE(4, "savingsAccountTransactionType.withdrawalFee"), //
|
||||
ANNUAL_FEE(5, "savingsAccountTransactionType.annualFee"), //
|
||||
DEPOSIT(1, "savingsAccountTransactionType.deposit", TransactionEntryType.CREDIT), //
|
||||
WITHDRAWAL(2, "savingsAccountTransactionType.withdrawal", TransactionEntryType.DEBIT), //
|
||||
INTEREST_POSTING(3, "savingsAccountTransactionType.interestPosting", TransactionEntryType.CREDIT), //
|
||||
WITHDRAWAL_FEE(4, "savingsAccountTransactionType.withdrawalFee", TransactionEntryType.DEBIT), //
|
||||
ANNUAL_FEE(5, "savingsAccountTransactionType.annualFee", TransactionEntryType.DEBIT), //
|
||||
WAIVE_CHARGES(6, "savingsAccountTransactionType.waiveCharge"), //
|
||||
PAY_CHARGE(7, "savingsAccountTransactionType.payCharge"), //
|
||||
DIVIDEND_PAYOUT(8, "savingsAccountTransactionType.dividendPayout"), //
|
||||
PAY_CHARGE(7, "savingsAccountTransactionType.payCharge", TransactionEntryType.DEBIT), //
|
||||
DIVIDEND_PAYOUT(8, "savingsAccountTransactionType.dividendPayout", TransactionEntryType.CREDIT), //
|
||||
INITIATE_TRANSFER(12, "savingsAccountTransactionType.initiateTransfer"), //
|
||||
APPROVE_TRANSFER(13, "savingsAccountTransactionType.approveTransfer"), //
|
||||
WITHDRAW_TRANSFER(14, "savingsAccountTransactionType.withdrawTransfer"), //
|
||||
REJECT_TRANSFER(15, "savingsAccountTransactionType.rejectTransfer"), WRITTEN_OFF(16, "savingsAccountTransactionType.writtenoff"), //
|
||||
OVERDRAFT_INTEREST(17, "savingsAccountTransactionType.overdraftInterest"), //
|
||||
WITHHOLD_TAX(18, "savingsAccountTransactionType.withholdTax"), ESCHEAT(19, "savingsAccountTransactionType.escheat"), AMOUNT_HOLD(20,
|
||||
"savingsAccountTransactionType.onHold"), AMOUNT_RELEASE(21, "savingsAccountTransactionType.release");
|
||||
REJECT_TRANSFER(15, "savingsAccountTransactionType.rejectTransfer"), //
|
||||
WRITTEN_OFF(16, "savingsAccountTransactionType.writtenoff"), //
|
||||
OVERDRAFT_INTEREST(17, "savingsAccountTransactionType.overdraftInterest", TransactionEntryType.DEBIT), //
|
||||
WITHHOLD_TAX(18, "savingsAccountTransactionType.withholdTax", TransactionEntryType.DEBIT), //
|
||||
ESCHEAT(19, "savingsAccountTransactionType.escheat", TransactionEntryType.DEBIT), //
|
||||
AMOUNT_HOLD(20, "savingsAccountTransactionType.onHold", TransactionEntryType.DEBIT), //
|
||||
AMOUNT_RELEASE(21, "savingsAccountTransactionType.release", TransactionEntryType.CREDIT); //
|
||||
|
||||
private final Integer value;
|
||||
public static final SavingsAccountTransactionType[] VALUES = values();
|
||||
|
||||
private static final Map<Integer, SavingsAccountTransactionType> BY_ID = Arrays.stream(VALUES)
|
||||
.collect(Collectors.toMap(SavingsAccountTransactionType::getValue, v -> v));
|
||||
|
||||
private final int value;
|
||||
private final String code;
|
||||
private final TransactionEntryType entryType;
|
||||
|
||||
SavingsAccountTransactionType(final Integer value, final String code) {
|
||||
SavingsAccountTransactionType(final Integer value, final String code, TransactionEntryType entryType) {
|
||||
this.value = value;
|
||||
this.code = code;
|
||||
this.entryType = entryType;
|
||||
}
|
||||
|
||||
SavingsAccountTransactionType(final Integer value, final String code) {
|
||||
this(value, code, null);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
@@ -56,102 +82,53 @@ public enum SavingsAccountTransactionType {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public static SavingsAccountTransactionType fromInt(final Integer transactionType) {
|
||||
public TransactionEntryType getEntryType() {
|
||||
return entryType;
|
||||
}
|
||||
|
||||
if (transactionType == null) {
|
||||
return SavingsAccountTransactionType.INVALID;
|
||||
}
|
||||
public boolean isCreditEntryType() {
|
||||
return entryType != null && entryType.isCredit();
|
||||
}
|
||||
|
||||
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 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() {
|
||||
@@ -159,55 +136,61 @@ public enum SavingsAccountTransactionType {
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
public boolean isDebit() {
|
||||
return isWithdrawal() || isWithdrawalFee() || isAnnualFee() || isPayCharge() || isIncomeFromInterest() || isWithHoldTax()
|
||||
|| isEscheat();
|
||||
return this == AMOUNT_RELEASE;
|
||||
}
|
||||
|
||||
public boolean isCredit() {
|
||||
return isDeposit() || isInterestPosting() || isDividendPayout();
|
||||
// AMOUNT_RELEASE is not credit, because the account balance is not changed
|
||||
return isCreditEntryType() && !isAmountRelease();
|
||||
}
|
||||
|
||||
public boolean isDebit() {
|
||||
// AMOUNT_HOLD, ESCHEAT are not debit, because the account balance is not changed
|
||||
return isDebitEntryType() && !isAmountOnHold() && !isEscheat();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<SavingsAccountTransactionType> getFiltered(Predicate<SavingsAccountTransactionType> filter) {
|
||||
return Arrays.stream(VALUES).filter(filter).toList();
|
||||
}
|
||||
}
|
||||
|
||||
+22
-6
@@ -36,6 +36,7 @@ import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.fineract.organisation.monetary.data.CurrencyData;
|
||||
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
|
||||
import org.apache.fineract.organisation.monetary.domain.Money;
|
||||
import org.apache.fineract.portfolio.TransactionEntryType;
|
||||
import org.apache.fineract.portfolio.account.data.AccountTransferData;
|
||||
import org.apache.fineract.portfolio.paymentdetail.data.PaymentDetailData;
|
||||
import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData;
|
||||
@@ -55,6 +56,8 @@ public final class SavingsAccountTransactionData implements Serializable {
|
||||
|
||||
private Long id;
|
||||
private final SavingsAccountTransactionEnumData transactionType;
|
||||
private final TransactionEntryType entryType;
|
||||
|
||||
private final Long accountId;
|
||||
private final String accountNo;
|
||||
private final LocalDate date;
|
||||
@@ -144,9 +147,12 @@ public final class SavingsAccountTransactionData implements Serializable {
|
||||
return this.transactionType.isIncomeFromInterest() && isNotReversed();
|
||||
}
|
||||
|
||||
public boolean isCredit() {
|
||||
return transactionType.getTransactionTypeEnum().isCredit() && isNotReversed() && !isReversalTransaction();
|
||||
}
|
||||
|
||||
public boolean isDebit() {
|
||||
return isWithdrawal() || isWithdrawalFeeAndNotReversed() || isAnnualFeeAndNotReversed() || isPayCharge()
|
||||
|| isOverdraftInterestAndNotReversed() || isWithHoldTaxAndNotReversed();
|
||||
return transactionType.getTransactionTypeEnum().isDebit() && isNotReversed() && !isReversalTransaction();
|
||||
}
|
||||
|
||||
public boolean isWithdrawalFeeAndNotReversed() {
|
||||
@@ -286,10 +292,6 @@ public final class SavingsAccountTransactionData implements Serializable {
|
||||
return this.transactionType.isAmountRelease();
|
||||
}
|
||||
|
||||
public boolean isCredit() {
|
||||
return isDeposit() || isInterestPostingAndNotReversed() || isDividendPayoutAndNotReversed();
|
||||
}
|
||||
|
||||
public boolean isDeposit() {
|
||||
return this.transactionType.isDeposit();
|
||||
}
|
||||
@@ -308,6 +310,7 @@ public final class SavingsAccountTransactionData implements Serializable {
|
||||
this.savingsAccountId = savingsId;
|
||||
this.paymentDetailData = paymentDetailData;
|
||||
this.transactionType = savingsAccountTransactionType;
|
||||
this.entryType = transactionType == null ? null : transactionType.getTransactionTypeEnum().getEntryType();
|
||||
this.transactionDate = transactionDate;
|
||||
this.submittedOnDate = createdDate;
|
||||
this.amount = amount;
|
||||
@@ -509,6 +512,7 @@ public final class SavingsAccountTransactionData implements Serializable {
|
||||
final Boolean lienTransaction) {
|
||||
this.id = null;
|
||||
this.transactionType = transactionType;
|
||||
this.entryType = transactionType == null ? null : transactionType.getTransactionTypeEnum().getEntryType();
|
||||
this.accountId = null;
|
||||
this.accountNo = null;
|
||||
this.date = transactionDate;
|
||||
@@ -550,6 +554,7 @@ public final class SavingsAccountTransactionData implements Serializable {
|
||||
final Boolean lienTransaction) {
|
||||
this.id = null;
|
||||
this.transactionType = transactionType;
|
||||
this.entryType = transactionType == null ? null : transactionType.getTransactionTypeEnum().getEntryType();
|
||||
this.accountId = null;
|
||||
this.accountNo = null;
|
||||
this.date = null;
|
||||
@@ -638,6 +643,7 @@ public final class SavingsAccountTransactionData implements Serializable {
|
||||
this.id = id;
|
||||
this.transactionDate = date;
|
||||
this.transactionType = transactionType;
|
||||
this.entryType = transactionType == null ? null : transactionType.getTransactionTypeEnum().getEntryType();
|
||||
this.paymentDetailData = paymentDetailData;
|
||||
this.accountId = savingsId;
|
||||
this.accountNo = savingsAccountNo;
|
||||
@@ -744,6 +750,12 @@ public final class SavingsAccountTransactionData implements Serializable {
|
||||
final String reasonForBlock) {
|
||||
this.id = id;
|
||||
this.transactionType = transactionType;
|
||||
TransactionEntryType entryType = null;
|
||||
if (transactionType != null) {
|
||||
entryType = transactionType.getTransactionTypeEnum().getEntryType();
|
||||
entryType = Boolean.TRUE.equals(isReversal) ? entryType.getReversal() : entryType;
|
||||
}
|
||||
this.entryType = entryType;
|
||||
this.paymentDetailData = paymentDetailData;
|
||||
this.accountId = savingsId;
|
||||
this.accountNo = savingsAccountNo;
|
||||
@@ -801,4 +813,8 @@ public final class SavingsAccountTransactionData implements Serializable {
|
||||
public boolean isIsManualTransaction() {
|
||||
return isManualTransaction;
|
||||
}
|
||||
|
||||
public TransactionEntryType getEntryType() {
|
||||
return entryType;
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -100,4 +100,7 @@ public class SavingsAccountTransactionEnumData implements Serializable {
|
||||
return Long.valueOf(SavingsAccountTransactionType.WITHDRAWAL_FEE.getValue()).equals(this.id);
|
||||
}
|
||||
|
||||
public SavingsAccountTransactionType getTransactionTypeEnum() {
|
||||
return SavingsAccountTransactionType.fromInt(id.intValue());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user