add validation for charges
This commit is contained in:
+21
-18
@@ -336,7 +336,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
if (!CollectionUtils.isEmpty(savingsAccountCharges)) {
|
if (!CollectionUtils.isEmpty(savingsAccountCharges)) {
|
||||||
this.charges = associateChargesWithThisSavingsAccount(savingsAccountCharges);
|
this.charges = associateChargesWithThisSavingsAccount(savingsAccountCharges);
|
||||||
// TODO:Add charges details to savings summary
|
// TODO:Add charges details to savings summary
|
||||||
//this.summary = updateSummaryWithTotalFeeChargesDueAtDisbursement(deriveSumTotalOfChargesDueAtDisbursement());
|
// this.summary =
|
||||||
|
// updateSummaryWithTotalFeeChargesDueAtDisbursement(deriveSumTotalOfChargesDueAtDisbursement());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.summary = new SavingsAccountSummary();
|
this.summary = new SavingsAccountSummary();
|
||||||
@@ -827,7 +828,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||||
}
|
}
|
||||||
validateActivityNotBeforeClientOrGroupTransferDate(SavingsEvent.SAVINGS_PAY_FEE, annualFeeTransactionDate);
|
validateActivityNotBeforeClientOrGroupTransferDate(SavingsEvent.SAVINGS_PAY_CHARGE, annualFeeTransactionDate);
|
||||||
|
|
||||||
existingTransactionIds.addAll(findExistingTransactionIds());
|
existingTransactionIds.addAll(findExistingTransactionIds());
|
||||||
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
|
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
|
||||||
@@ -1115,8 +1116,6 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
this.annualFeeOnMonth = null;
|
this.annualFeeOnMonth = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
validateLockinDetails();
|
validateLockinDetails();
|
||||||
validateWithdrawalFeeDetails();
|
validateWithdrawalFeeDetails();
|
||||||
validateAnnualFeeDetails();
|
validateAnnualFeeDetails();
|
||||||
@@ -1935,15 +1934,16 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
// waive charge
|
// waive charge
|
||||||
final Money amountWaived = savingsAccountCharge.waive(this.getCurrency());
|
final Money amountWaived = savingsAccountCharge.waive(this.getCurrency());
|
||||||
// TODO : AA revisit the code
|
// TODO : AA revisit the code
|
||||||
/*Money feeChargesWaived = amountWaived;
|
/*
|
||||||
Money penaltyChargesWaived = Money.zero(this.getCurrency());
|
* Money feeChargesWaived = amountWaived; Money penaltyChargesWaived =
|
||||||
if (savingsAccountCharge.isPenaltyCharge()) {
|
* Money.zero(this.getCurrency()); if
|
||||||
penaltyChargesWaived = amountWaived;
|
* (savingsAccountCharge.isPenaltyCharge()) { penaltyChargesWaived =
|
||||||
feeChargesWaived = Money.zero(this.getCurrency());
|
* amountWaived; feeChargesWaived = Money.zero(this.getCurrency()); }
|
||||||
}*/
|
*/
|
||||||
|
|
||||||
// persist an entry in transaction details
|
// persist an entry in transaction details
|
||||||
SavingsAccountTransaction chargeTransaction = SavingsAccountTransaction.charge(this, this.office(), savingsAccountCharge.getDueLocalDate(), amountWaived);
|
SavingsAccountTransaction chargeTransaction = SavingsAccountTransaction.charge(this, this.office(),
|
||||||
|
savingsAccountCharge.getDueLocalDate(), amountWaived);
|
||||||
|
|
||||||
this.transactions.add(chargeTransaction);
|
this.transactions.add(chargeTransaction);
|
||||||
|
|
||||||
@@ -1969,7 +1969,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this.hasCurrencyCodeOf(chargeDefinition.getCurrencyCode())) {
|
if (!this.hasCurrencyCodeOf(chargeDefinition.getCurrencyCode())) {
|
||||||
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("transaction.invalid.account.currency.and.charge.currency.not.same");
|
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
|
||||||
|
"transaction.invalid.account.currency.and.charge.currency.not.same");
|
||||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1981,6 +1982,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validateActivityNotBeforeClientOrGroupTransferDate(SavingsEvent.SAVINGS_APPLY_CHARGE, chargeDueDate);
|
||||||
|
|
||||||
// add new charge to savings account
|
// add new charge to savings account
|
||||||
getCharges().add(savingsAccountCharge);
|
getCharges().add(savingsAccountCharge);
|
||||||
|
|
||||||
@@ -2019,12 +2022,15 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
final Money chargePaid = savingsAccountCharge.pay(this.getCurrency(), amountPaid);
|
final Money chargePaid = savingsAccountCharge.pay(this.getCurrency(), amountPaid);
|
||||||
|
|
||||||
|
// If null reset to current date
|
||||||
final LocalDate transactionDate = (savingsAccountCharge.getDueLocalDate() == null) ? DateUtils.getLocalDateOfTenant()
|
final LocalDate transactionDate = (savingsAccountCharge.getDueLocalDate() == null) ? DateUtils.getLocalDateOfTenant()
|
||||||
: savingsAccountCharge.getDueLocalDate();//If null reset to current date
|
: savingsAccountCharge.getDueLocalDate();
|
||||||
|
|
||||||
// persist an entry in transaction details
|
// persist an entry in transaction details
|
||||||
SavingsAccountTransaction chargeTransaction = SavingsAccountTransaction.charge(this, this.office(), transactionDate, chargePaid);
|
SavingsAccountTransaction chargeTransaction = SavingsAccountTransaction.charge(this, this.office(), transactionDate, chargePaid);
|
||||||
|
|
||||||
final SavingsAccountChargePaidBy chargePaidBy = SavingsAccountChargePaidBy.instance(chargeTransaction, savingsAccountCharge, amountPaid);
|
final SavingsAccountChargePaidBy chargePaidBy = SavingsAccountChargePaidBy.instance(chargeTransaction, savingsAccountCharge,
|
||||||
|
amountPaid);
|
||||||
chargeTransaction.getSavingsAccountChargesPaid().add(chargePaidBy);
|
chargeTransaction.getSavingsAccountChargesPaid().add(chargePaidBy);
|
||||||
this.transactions.add(chargeTransaction);
|
this.transactions.add(chargeTransaction);
|
||||||
|
|
||||||
@@ -2043,7 +2049,6 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private SavingsAccountCharge getCharge(Long savingsAccountChargeId) {
|
private SavingsAccountCharge getCharge(Long savingsAccountChargeId) {
|
||||||
SavingsAccountCharge charge = null;
|
SavingsAccountCharge charge = null;
|
||||||
for (SavingsAccountCharge existingCharge : this.charges) {
|
for (SavingsAccountCharge existingCharge : this.charges) {
|
||||||
@@ -2053,9 +2058,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(charge == null){
|
if (charge == null) { throw new SavingsAccountChargeNotFoundException(savingsAccountChargeId, getId()); }
|
||||||
throw new SavingsAccountChargeNotFoundException(savingsAccountChargeId, getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
return charge;
|
return charge;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -20,8 +20,9 @@ public enum SavingsEvent {
|
|||||||
SAVINGS_POST_INTEREST("interest.post"), //
|
SAVINGS_POST_INTEREST("interest.post"), //
|
||||||
SAVINGS_UNDO_TRANSACTION("transaction.undo"), //
|
SAVINGS_UNDO_TRANSACTION("transaction.undo"), //
|
||||||
SAVINGS_ADJUST_TRANSACTION("transaction.adjust"), //
|
SAVINGS_ADJUST_TRANSACTION("transaction.adjust"), //
|
||||||
SAVINGS_APPLY_FEE("fee.apply"), //
|
SAVINGS_APPLY_CHARGE("charge.apply"), //
|
||||||
SAVINGS_PAY_FEE("fee.pay"), //
|
SAVINGS_WAIVE_CHARGE("charge.waive"), //
|
||||||
|
SAVINGS_PAY_CHARGE("charge.pay"), //
|
||||||
SAVINGS_CLOSE_ACCOUNT("account.close");
|
SAVINGS_CLOSE_ACCOUNT("account.close");
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|||||||
Reference in New Issue
Block a user