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;
} }
} }
@@ -262,8 +262,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
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);
} }
@@ -549,8 +549,6 @@ public class SavingsAccount extends AbstractPersistable<Long> {
isTransactionsModified = true; isTransactionsModified = true;
} }
} }
} }
@@ -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,7 +682,7 @@ 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) {
@@ -737,14 +735,11 @@ public class SavingsAccount extends AbstractPersistable<Long> {
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) {
@@ -948,8 +943,7 @@ 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);
@@ -1476,9 +1470,9 @@ 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());
@@ -1541,7 +1535,6 @@ 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());
@@ -1812,16 +1805,14 @@ 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);
} }
} }
@@ -1829,8 +1820,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
// 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);
} }
@@ -2002,7 +1992,8 @@ 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");
} }
@@ -2010,5 +2001,4 @@ public class SavingsAccount extends AbstractPersistable<Long> {
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
} }
} }