clean up to created Date field in SavingsAccountTransactionDTO

This commit is contained in:
Vishwas Babu A J
2014-02-28 10:56:34 -08:00
parent 9a668e6cac
commit 85193881b5
2 changed files with 113 additions and 123 deletions
@@ -13,15 +13,15 @@ public class SavingsAccountTransactionDTO {
private final LocalDate transactionDate; private final LocalDate transactionDate;
private final BigDecimal transactionAmount; private final BigDecimal transactionAmount;
private final PaymentDetail paymentDetail; private final PaymentDetail paymentDetail;
private final Date crecreatedDate; private final Date createdDate;
public SavingsAccountTransactionDTO(final DateTimeFormatter formatter, final LocalDate transactionDate, public SavingsAccountTransactionDTO(final DateTimeFormatter formatter, final LocalDate transactionDate,
final BigDecimal transactionAmount, final PaymentDetail paymentDetail,final Date crecreatedDate) { final BigDecimal transactionAmount, final PaymentDetail paymentDetail, final Date createdDate) {
this.formatter = formatter; this.formatter = formatter;
this.transactionDate = transactionDate; this.transactionDate = transactionDate;
this.transactionAmount = transactionAmount; this.transactionAmount = transactionAmount;
this.paymentDetail = paymentDetail; this.paymentDetail = paymentDetail;
this.crecreatedDate = crecreatedDate; this.createdDate = createdDate;
} }
public DateTimeFormatter getFormatter() { public DateTimeFormatter getFormatter() {
@@ -40,7 +40,7 @@ public class SavingsAccountTransactionDTO {
return this.paymentDetail; return this.paymentDetail;
} }
public Date getCrecreatedDate() { public Date getCreatedDate() {
return this.crecreatedDate; return this.createdDate;
} }
} }
@@ -259,13 +259,13 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final SavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType, final BigDecimal minRequiredOpeningBalance, final SavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType, final BigDecimal minRequiredOpeningBalance,
final Integer lockinPeriodFrequency, final SavingsPeriodFrequencyType lockinPeriodFrequencyType, final Integer lockinPeriodFrequency, final SavingsPeriodFrequencyType lockinPeriodFrequencyType,
final boolean withdrawalFeeApplicableForTransfer, final Set<SavingsAccountCharge> savingsAccountCharges, final boolean withdrawalFeeApplicableForTransfer, final Set<SavingsAccountCharge> savingsAccountCharges,
final boolean allowOverdraft,final BigDecimal overdraftLimit) { final boolean allowOverdraft, final BigDecimal overdraftLimit) {
final SavingsAccountStatusType status = SavingsAccountStatusType.SUBMITTED_AND_PENDING_APPROVAL; final SavingsAccountStatusType status = SavingsAccountStatusType.SUBMITTED_AND_PENDING_APPROVAL;
return new SavingsAccount(client, group, product, fieldOfficer, accountNo, externalId, status, accountType, submittedOnDate, submittedBy, return new SavingsAccount(client, group, product, fieldOfficer, accountNo, externalId, status, accountType, submittedOnDate,
interestRate, interestCompoundingPeriodType, interestPostingPeriodType, interestCalculationType, submittedBy, interestRate, interestCompoundingPeriodType, interestPostingPeriodType, interestCalculationType,
interestCalculationDaysInYearType, minRequiredOpeningBalance, lockinPeriodFrequency, lockinPeriodFrequencyType, interestCalculationDaysInYearType, minRequiredOpeningBalance, lockinPeriodFrequency, lockinPeriodFrequencyType,
withdrawalFeeApplicableForTransfer, savingsAccountCharges,allowOverdraft,overdraftLimit); withdrawalFeeApplicableForTransfer, savingsAccountCharges, allowOverdraft, overdraftLimit);
} }
private SavingsAccount(final Client client, final Group group, final SavingsProduct product, final Staff fieldOfficer, private SavingsAccount(final Client client, final Group group, final SavingsProduct product, final Staff fieldOfficer,
@@ -276,7 +276,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final SavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType, final BigDecimal minRequiredOpeningBalance, final SavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType, final BigDecimal minRequiredOpeningBalance,
final Integer lockinPeriodFrequency, final SavingsPeriodFrequencyType lockinPeriodFrequencyType, final Integer lockinPeriodFrequency, final SavingsPeriodFrequencyType lockinPeriodFrequencyType,
final boolean withdrawalFeeApplicableForTransfer, final Set<SavingsAccountCharge> savingsAccountCharges, final boolean withdrawalFeeApplicableForTransfer, final Set<SavingsAccountCharge> savingsAccountCharges,
final boolean allowOverdraft,final BigDecimal overdraftLimit) { final boolean allowOverdraft, final BigDecimal overdraftLimit) {
this.client = client; this.client = client;
this.group = group; this.group = group;
this.product = product; this.product = product;
@@ -515,17 +515,17 @@ public class SavingsAccount extends AbstractPersistable<Long> {
Money overdraftAmount = Money.zero(this.currency); Money overdraftAmount = Money.zero(this.currency);
Money transactionAmount = Money.zero(this.currency); Money transactionAmount = Money.zero(this.currency);
if (transaction.isCredit()) { if (transaction.isCredit()) {
if(runningBalance.isLessThanZero()){ if (runningBalance.isLessThanZero()) {
Money diffAmount = transaction.getAmount(this.currency).plus(runningBalance); Money diffAmount = transaction.getAmount(this.currency).plus(runningBalance);
if(diffAmount.isGreaterThanZero()){ if (diffAmount.isGreaterThanZero()) {
overdraftAmount = transaction.getAmount(this.currency).minus(diffAmount); overdraftAmount = transaction.getAmount(this.currency).minus(diffAmount);
}else{ } else {
overdraftAmount = transaction.getAmount(this.currency); overdraftAmount = transaction.getAmount(this.currency);
} }
} }
transactionAmount = transactionAmount.plus(transaction.getAmount(this.currency)); transactionAmount = transactionAmount.plus(transaction.getAmount(this.currency));
} else if (transaction.isDebit()) { } else if (transaction.isDebit()) {
if(runningBalance.isLessThanZero()){ if (runningBalance.isLessThanZero()) {
overdraftAmount = transaction.getAmount(this.currency); overdraftAmount = transaction.getAmount(this.currency);
} }
transactionAmount = transactionAmount.minus(transaction.getAmount(this.currency)); transactionAmount = transactionAmount.minus(transaction.getAmount(this.currency));
@@ -533,15 +533,15 @@ public class SavingsAccount extends AbstractPersistable<Long> {
runningBalance = runningBalance.plus(transactionAmount); runningBalance = runningBalance.plus(transactionAmount);
transaction.updateRunningBalance(runningBalance); transaction.updateRunningBalance(runningBalance);
if(overdraftAmount.isZero() && runningBalance.isLessThanZero()){ if (overdraftAmount.isZero() && runningBalance.isLessThanZero()) {
overdraftAmount = overdraftAmount.plus(runningBalance.getAmount().negate()); overdraftAmount = overdraftAmount.plus(runningBalance.getAmount().negate());
} }
if(transaction.getId() == null && overdraftAmount.isGreaterThanZero()){ if (transaction.getId() == null && overdraftAmount.isGreaterThanZero()) {
transaction.updateOverdraftAmount(overdraftAmount.getAmount()); transaction.updateOverdraftAmount(overdraftAmount.getAmount());
}else if(overdraftAmount.isNotEqualTo(transaction.getOverdraftAmount(getCurrency()))){ } else if (overdraftAmount.isNotEqualTo(transaction.getOverdraftAmount(getCurrency()))) {
SavingsAccountTransaction accountTransaction = SavingsAccountTransaction.copyTransaction(transaction); SavingsAccountTransaction accountTransaction = SavingsAccountTransaction.copyTransaction(transaction);
transaction.reverse(); transaction.reverse();
if(overdraftAmount.isGreaterThanZero()){ if (overdraftAmount.isGreaterThanZero()) {
accountTransaction.updateOverdraftAmount(overdraftAmount.getAmount()); accountTransaction.updateOverdraftAmount(overdraftAmount.getAmount());
} }
accountTransaction.updateRunningBalance(runningBalance); accountTransaction.updateRunningBalance(runningBalance);
@@ -549,12 +549,10 @@ public class SavingsAccount extends AbstractPersistable<Long> {
isTransactionsModified = true; isTransactionsModified = true;
} }
} }
} }
if(isTransactionsModified){ if (isTransactionsModified) {
accountTransactionsSorted = retreiveListOfTransactions(); accountTransactionsSorted = retreiveListOfTransactions();
} }
// loop over transactions in reverse // loop over transactions in reverse
@@ -612,7 +610,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final Money amount = Money.of(this.currency, transactionDTO.getTransactionAmount()); final Money amount = Money.of(this.currency, transactionDTO.getTransactionAmount());
final SavingsAccountTransaction transaction = SavingsAccountTransaction.deposit(this, office(), transactionDTO.getPaymentDetail(), final SavingsAccountTransaction transaction = SavingsAccountTransaction.deposit(this, office(), transactionDTO.getPaymentDetail(),
transactionDTO.getTransactionDate(), amount, transactionDTO.getCrecreatedDate()); transactionDTO.getTransactionDate(), amount, transactionDTO.getCreatedDate());
this.transactions.add(transaction); this.transactions.add(transaction);
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions); this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
@@ -684,19 +682,19 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final Money transactionAmountMoney = Money.of(this.currency, transactionDTO.getTransactionAmount()); final Money transactionAmountMoney = Money.of(this.currency, transactionDTO.getTransactionAmount());
final SavingsAccountTransaction transaction = SavingsAccountTransaction.withdrawal(this, office(), final SavingsAccountTransaction transaction = SavingsAccountTransaction.withdrawal(this, office(),
transactionDTO.getPaymentDetail(), transactionDTO.getTransactionDate(), transactionAmountMoney, transactionDTO.getPaymentDetail(), transactionDTO.getTransactionDate(), transactionAmountMoney,
transactionDTO.getCrecreatedDate()); transactionDTO.getCreatedDate());
this.transactions.add(transaction); this.transactions.add(transaction);
if (applyWithdrawFee){ if (applyWithdrawFee) {
//auto pay withdrawal fee // auto pay withdrawal fee
payWithdrawalFee(transactionDTO.getTransactionAmount(), transactionDTO.getTransactionDate()); payWithdrawalFee(transactionDTO.getTransactionAmount(), transactionDTO.getTransactionDate());
} }
return transaction; return transaction;
} }
private void payWithdrawalFee(final BigDecimal transactionAmoount, final LocalDate transactionDate){ private void payWithdrawalFee(final BigDecimal transactionAmoount, final LocalDate transactionDate) {
for (SavingsAccountCharge charge : this.charges()) { for (SavingsAccountCharge charge : this.charges()) {
if (charge.isWithdrawalFee()){ if (charge.isWithdrawalFee()) {
charge.updateWithdralFeeAmount(transactionAmoount); charge.updateWithdralFeeAmount(transactionAmoount);
this.payCharge(charge, charge.getAmountOutstanding(this.getCurrency()), transactionDate); this.payCharge(charge, charge.getAmountOutstanding(this.getCurrency()), transactionDate);
} }
@@ -732,20 +730,17 @@ public class SavingsAccount extends AbstractPersistable<Long> {
// //
final BigDecimal withdrawalFee = null; final BigDecimal withdrawalFee = null;
Money limit = runningBalance.zero(); Money limit = runningBalance.zero();
if(this.allowOverdraft){ if (this.allowOverdraft) {
if(this.overdraftLimit != null){ if (this.overdraftLimit != null) {
limit = limit.plus(this.overdraftLimit); limit = limit.plus(this.overdraftLimit);
} }
} }
if(limit.plus(runningBalance).isLessThanZero()){ if (limit.plus(runningBalance).isLessThanZero()) { throw new InsufficientAccountBalanceException("transactionAmount",
throw new InsufficientAccountBalanceException("transactionAmount", getAccountBalance(), withdrawalFee, transactionAmount); getAccountBalance(), withdrawalFee, transactionAmount); }
}
} }
} }
} }
public void validateAccountBalanceDoesNotBecomeNegative(final String transactionAction) { public void validateAccountBalanceDoesNotBecomeNegative(final String transactionAction) {
final List<SavingsAccountTransaction> transactionsSortedByDate = retreiveListOfTransactions(); final List<SavingsAccountTransaction> transactionsSortedByDate = retreiveListOfTransactions();
@@ -764,15 +759,15 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(SAVINGS_ACCOUNT_RESOURCE_NAME + transactionAction); .resource(SAVINGS_ACCOUNT_RESOURCE_NAME + transactionAction);
if(this.allowOverdraft){ if (this.allowOverdraft) {
Money limit = runningBalance.zero(); Money limit = runningBalance.zero();
if(this.overdraftLimit != null){ if (this.overdraftLimit != null) {
limit = limit.plus(this.overdraftLimit); limit = limit.plus(this.overdraftLimit);
} }
if(limit.plus(runningBalance).isLessThanZero()){ if (limit.plus(runningBalance).isLessThanZero()) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("results.in.balance.exceeding.overdraft.limit"); baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("results.in.balance.exceeding.overdraft.limit");
} }
}else{ } else {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("results.in.balance.going.negative"); baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("results.in.balance.going.negative");
} }
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
@@ -948,17 +943,16 @@ public class SavingsAccount extends AbstractPersistable<Long> {
this.allowOverdraft = newValue; this.allowOverdraft = newValue;
} }
if (command.isChangeInBigDecimalParameterNamedDefaultingZeroToNull(overdraftLimitParamName, if (command.isChangeInBigDecimalParameterNamedDefaultingZeroToNull(overdraftLimitParamName, this.overdraftLimit)) {
this.overdraftLimit)) {
final BigDecimal newValue = command.bigDecimalValueOfParameterNamedDefaultToNullIfZero(overdraftLimitParamName); final BigDecimal newValue = command.bigDecimalValueOfParameterNamedDefaultToNullIfZero(overdraftLimitParamName);
actualChanges.put(overdraftLimitParamName, newValue); actualChanges.put(overdraftLimitParamName, newValue);
actualChanges.put(localeParamName, localeAsInput); actualChanges.put(localeParamName, localeAsInput);
this.overdraftLimit = newValue; this.overdraftLimit = newValue;
} }
if(!this.allowOverdraft){ if (!this.allowOverdraft) {
this.overdraftLimit = null; this.overdraftLimit = null;
} }
validateLockinDetails(); validateLockinDetails();
@@ -1124,8 +1118,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
public void validateNewApplicationState(final LocalDate todayDateOfTenant) { public void validateNewApplicationState(final LocalDate todayDateOfTenant) {
validateLockinDetails(); validateLockinDetails();
//validateWithdrawalFeeDetails(); // validateWithdrawalFeeDetails();
//validateAnnualFeeDetails(); // validateAnnualFeeDetails();
final LocalDate submittedOn = getSubmittedOnLocalDate(); final LocalDate submittedOn = getSubmittedOnLocalDate();
@@ -1476,10 +1470,10 @@ public class SavingsAccount extends AbstractPersistable<Long> {
this.activatedBy = currentUser; this.activatedBy = currentUser;
this.lockedInUntilDate = calculateDateAccountIsLockedUntil(getActivationLocalDate()); this.lockedInUntilDate = calculateDateAccountIsLockedUntil(getActivationLocalDate());
/*if (annualFeeSettingsSet()) { /*
updateToNextAnnualFeeDueDateFrom(getActivationLocalDate()); * if (annualFeeSettingsSet()) {
} * updateToNextAnnualFeeDueDateFrom(getActivationLocalDate()); }
*/ */
if (this.client != null && this.client.isActivatedAfter(activationDate)) { if (this.client != null && this.client.isActivatedAfter(activationDate)) {
final DateTimeFormatter formatter = DateTimeFormat.forPattern(command.dateFormat()).withLocale(command.extractLocale()); final DateTimeFormatter formatter = DateTimeFormat.forPattern(command.dateFormat()).withLocale(command.extractLocale());
final String dateAsString = formatter.print(this.client.getActivationLocalDate()); final String dateAsString = formatter.print(this.client.getActivationLocalDate());
@@ -1528,7 +1522,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final Money minRequiredOpeningBalance = Money.of(this.currency, this.minRequiredOpeningBalance); final Money minRequiredOpeningBalance = Money.of(this.currency, this.minRequiredOpeningBalance);
if (minRequiredOpeningBalance.isGreaterThanZero()) { if (minRequiredOpeningBalance.isGreaterThanZero()) {
final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, getActivationLocalDate(), final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, getActivationLocalDate(),
minRequiredOpeningBalance.getAmount(), null,new Date()); minRequiredOpeningBalance.getAmount(), null, new Date());
deposit(transactionDTO); deposit(transactionDTO);
// no openingBalance concept supported yet but probably will to // no openingBalance concept supported yet but probably will to
@@ -1541,18 +1535,17 @@ public class SavingsAccount extends AbstractPersistable<Long> {
recalculateDailyBalances(openingAccountBalance); recalculateDailyBalances(openingAccountBalance);
} }
// update annual fee due date
//update annual fee due date
for (SavingsAccountCharge charge : this.charges()) { for (SavingsAccountCharge charge : this.charges()) {
charge.updateToNextDueDateFrom(getActivationLocalDate()); charge.updateToNextDueDateFrom(getActivationLocalDate());
} }
//auto pay the activation time charges // auto pay the activation time charges
this.payActivationCharges(); this.payActivationCharges();
//TODO : AA add activation charges to actual changes list // TODO : AA add activation charges to actual changes list
} }
public void approveAndActivateApplication(final Date appliedonDate,final AppUser appliedBy,final DateTimeFormatter fmt){ public void approveAndActivateApplication(final Date appliedonDate, final AppUser appliedBy, final DateTimeFormatter fmt) {
this.status = SavingsAccountStatusType.ACTIVE.getValue(); this.status = SavingsAccountStatusType.ACTIVE.getValue();
this.approvedOnDate = appliedonDate; this.approvedOnDate = appliedonDate;
this.approvedBy = appliedBy; this.approvedBy = appliedBy;
@@ -1760,7 +1753,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final SavingsAccountCharge savingsAccountCharge = getCharge(savingsAccountChargeId); final SavingsAccountCharge savingsAccountCharge = getCharge(savingsAccountChargeId);
if (savingsAccountCharge.isWithdrawalFee()){ if (savingsAccountCharge.isWithdrawalFee()) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("transaction.invalid.waiver.of.withdrawal.fee.not.supported"); baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("transaction.invalid.waiver.of.withdrawal.fee.not.supported");
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
} }
@@ -1812,41 +1805,38 @@ public class SavingsAccount extends AbstractPersistable<Long> {
} }
if (savingsAccountCharge.isSavingsActivation() && !(isSubmittedAndPendingApproval() || (isApproved() && isNotActive()))) { if (savingsAccountCharge.isSavingsActivation() && !(isSubmittedAndPendingApproval() || (isApproved() && isNotActive()))) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode( baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("not.valid.account.status.cannot.add.activation.time.charge");
"not.valid.account.status.cannot.add.activation.time.charge");
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
//Only one withdrawal fee is supported per account // Only one withdrawal fee is supported per account
if(savingsAccountCharge.isWithdrawalFee()){ if (savingsAccountCharge.isWithdrawalFee()) {
if(this.isWithDrawalFeeExists()){ if (this.isWithDrawalFeeExists()) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode( baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("multiple.withdrawal.fee.per.account.not.supported");
"multiple.withdrawal.fee.per.account.not.supported");
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
} }
//Only one annual fee is supported per account // Only one annual fee is supported per account
if(savingsAccountCharge.isAnnualFee()){ if (savingsAccountCharge.isAnnualFee()) {
if(this.isAnnualFeeExists()){ if (this.isAnnualFeeExists()) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode( baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("multiple.annual.fee.per.account.not.supported");
"multiple.annual.fee.per.account.not.supported");
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
} }
if(savingsAccountCharge.isAnnualFee() || savingsAccountCharge.isMonthlyFee()){ if (savingsAccountCharge.isAnnualFee() || savingsAccountCharge.isMonthlyFee()) {
//update due date // update due date
if(isActive()){ if (isActive()) {
savingsAccountCharge.updateToNextDueDateFrom(getActivationLocalDate()); savingsAccountCharge.updateToNextDueDateFrom(getActivationLocalDate());
}else if(isApproved()){ } else if (isApproved()) {
savingsAccountCharge.updateToNextDueDateFrom(getApprovedOnLocalDate()); savingsAccountCharge.updateToNextDueDateFrom(getApprovedOnLocalDate());
} }
} }
//activation charge and withdrawal charges not required this validation // activation charge and withdrawal charges not required this validation
if(savingsAccountCharge.isOnSpecifiedDueDate()){ if (savingsAccountCharge.isOnSpecifiedDueDate()) {
validateActivityNotBeforeClientOrGroupTransferDate(SavingsEvent.SAVINGS_APPLY_CHARGE, chargeDueDate); validateActivityNotBeforeClientOrGroupTransferDate(SavingsEvent.SAVINGS_APPLY_CHARGE, chargeDueDate);
} }
@@ -1857,14 +1847,14 @@ public class SavingsAccount extends AbstractPersistable<Long> {
private boolean isWithDrawalFeeExists() { private boolean isWithDrawalFeeExists() {
for (SavingsAccountCharge charge : this.charges()) { for (SavingsAccountCharge charge : this.charges()) {
if(charge.isWithdrawalFee()) return true; if (charge.isWithdrawalFee()) return true;
} }
return false; return false;
} }
private boolean isAnnualFeeExists() { private boolean isAnnualFeeExists() {
for (SavingsAccountCharge charge : this.charges()) { for (SavingsAccountCharge charge : this.charges()) {
if(charge.isAnnualFee()) return true; if (charge.isAnnualFee()) return true;
} }
return false; return false;
} }
@@ -1904,7 +1894,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
if (savingsAccountCharge.isAnnualFee()){ if (savingsAccountCharge.isAnnualFee()) {
final LocalDate annualFeeDueDate = savingsAccountCharge.getDueLocalDate(); final LocalDate annualFeeDueDate = savingsAccountCharge.getDueLocalDate();
if (annualFeeDueDate == null) { if (annualFeeDueDate == null) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("no.annualfee.settings"); baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("no.annualfee.settings");
@@ -1952,11 +1942,11 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final LocalDate transactionDate) { final LocalDate transactionDate) {
SavingsAccountTransaction chargeTransaction = null; SavingsAccountTransaction chargeTransaction = null;
if (savingsAccountCharge.isWithdrawalFee()){ if (savingsAccountCharge.isWithdrawalFee()) {
chargeTransaction = SavingsAccountTransaction.withdrawalFee(this, office(), transactionDate, transactionAmount); chargeTransaction = SavingsAccountTransaction.withdrawalFee(this, office(), transactionDate, transactionAmount);
}else if (savingsAccountCharge.isAnnualFee()){ } else if (savingsAccountCharge.isAnnualFee()) {
chargeTransaction = SavingsAccountTransaction.annualFee(this, office(), transactionDate, transactionAmount); chargeTransaction = SavingsAccountTransaction.annualFee(this, office(), transactionDate, transactionAmount);
}else { } else {
chargeTransaction = SavingsAccountTransaction.charge(this, office(), transactionDate, transactionAmount); chargeTransaction = SavingsAccountTransaction.charge(this, office(), transactionDate, transactionAmount);
} }
@@ -2002,13 +1992,13 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(SAVINGS_ACCOUNT_RESOURCE_NAME); .resource(SAVINGS_ACCOUNT_RESOURCE_NAME);
if(this.overdraftLimit != null && this.product.overdraftLimit() != null && this.overdraftLimit.compareTo(this.product.overdraftLimit()) == 1){ if (this.overdraftLimit != null && this.product.overdraftLimit() != null
&& this.overdraftLimit.compareTo(this.product.overdraftLimit()) == 1) {
baseDataValidator.reset().parameter(SavingsApiConstants.overdraftLimitParamName).value(this.overdraftLimit) baseDataValidator.reset().parameter(SavingsApiConstants.overdraftLimitParamName).value(this.overdraftLimit)
.failWithCode("cannot.exceed.product.value"); .failWithCode("cannot.exceed.product.value");
} }
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors);} if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
} }
} }