formatting savings classes
This commit is contained in:
+2
-3
@@ -8,8 +8,7 @@ package org.mifosplatform.portfolio.savings.domain;
|
|||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
|
||||||
|
public interface DepositAccountOnHoldTransactionRepository extends JpaRepository<DepositAccountOnHoldTransaction, Long>,
|
||||||
public interface DepositAccountOnHoldTransactionRepository extends JpaRepository<DepositAccountOnHoldTransaction ,Long>,
|
JpaSpecificationExecutor<DepositAccountOnHoldTransaction> {
|
||||||
JpaSpecificationExecutor<DepositAccountOnHoldTransaction>{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-48
@@ -174,25 +174,33 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
return applicableInterestRate.divide(BigDecimal.valueOf(100l), mc);
|
return applicableInterestRate.divide(BigDecimal.valueOf(100l), mc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMaturityDateAndAmountBeforeAccountActivation(final MathContext mc,
|
public void updateMaturityDateAndAmountBeforeAccountActivation(final MathContext mc, final boolean isPreMatureClosure,
|
||||||
final boolean isPreMatureClosure, final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth) {
|
||||||
final Integer financialYearBeginningMonth) {
|
|
||||||
List<SavingsAccountTransaction> allTransactions = new ArrayList<>();
|
List<SavingsAccountTransaction> allTransactions = new ArrayList<>();
|
||||||
final Money transactionAmountMoney = Money.of(getCurrency(), this.accountTermAndPreClosure.depositAmount());
|
final Money transactionAmountMoney = Money.of(getCurrency(), this.accountTermAndPreClosure.depositAmount());
|
||||||
final SavingsAccountTransaction transaction = SavingsAccountTransaction.deposit(null, office(), null,
|
final SavingsAccountTransaction transaction = SavingsAccountTransaction.deposit(null, office(), null,
|
||||||
this.accountSubmittedOrActivationDate(), transactionAmountMoney, new Date(), null); // TODO: verify if it is ok to pass null for AppUser
|
this.accountSubmittedOrActivationDate(), transactionAmountMoney, new Date(), null); // TODO:
|
||||||
|
// verify
|
||||||
|
// if
|
||||||
|
// it
|
||||||
|
// is
|
||||||
|
// ok
|
||||||
|
// to
|
||||||
|
// pass
|
||||||
|
// null
|
||||||
|
// for
|
||||||
|
// AppUser
|
||||||
transaction.updateRunningBalance(transactionAmountMoney);
|
transaction.updateRunningBalance(transactionAmountMoney);
|
||||||
transaction.updateCumulativeBalanceAndDates(this.getCurrency(), interestCalculatedUpto());
|
transaction.updateCumulativeBalanceAndDates(this.getCurrency(), interestCalculatedUpto());
|
||||||
allTransactions.add(transaction);
|
allTransactions.add(transaction);
|
||||||
updateMaturityDateAndAmount(mc, allTransactions, isPreMatureClosure,
|
updateMaturityDateAndAmount(mc, allTransactions, isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMaturityDateAndAmount(final MathContext mc, final boolean isPreMatureClosure,
|
public void updateMaturityDateAndAmount(final MathContext mc, final boolean isPreMatureClosure,
|
||||||
final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth) {
|
||||||
final Integer financialYearBeginningMonth) {
|
|
||||||
updateMaturityDateAndAmount(mc, retreiveOrderedNonInterestPostingTransactions(), isPreMatureClosure,
|
updateMaturityDateAndAmount(mc, retreiveOrderedNonInterestPostingTransactions(), isPreMatureClosure,
|
||||||
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMaturityDateAndAmount(final MathContext mc, final List<SavingsAccountTransaction> transactions,
|
public void updateMaturityDateAndAmount(final MathContext mc, final List<SavingsAccountTransaction> transactions,
|
||||||
@@ -205,9 +213,8 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
// calculation
|
// calculation
|
||||||
this.resetAccountTransactionsEndOfDayBalances(transactions, maturityDate);
|
this.resetAccountTransactionsEndOfDayBalances(transactions, maturityDate);
|
||||||
|
|
||||||
final List<PostingPeriod> postingPeriods = calculateInterestPayable(mc, interestCalculationUpto,
|
final List<PostingPeriod> postingPeriods = calculateInterestPayable(mc, interestCalculationUpto, transactions, isPreMatureClosure,
|
||||||
transactions, isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd,
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
financialYearBeginningMonth);
|
|
||||||
|
|
||||||
// reset end of day balance back to today's date
|
// reset end of day balance back to today's date
|
||||||
this.resetAccountTransactionsEndOfDayBalances(transactions, DateUtils.getLocalDateOfTenant());
|
this.resetAccountTransactionsEndOfDayBalances(transactions, DateUtils.getLocalDateOfTenant());
|
||||||
@@ -222,8 +229,7 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
this.accountTermAndPreClosure.updateMaturityDetails(maturityAmount.getAmount(), maturityDate);
|
this.accountTermAndPreClosure.updateMaturityDetails(maturityAmount.getAmount(), maturityDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMaturityStatus(final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
public void updateMaturityStatus(final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth) {
|
||||||
final Integer financialYearBeginningMonth) {
|
|
||||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||||
.resource(FIXED_DEPOSIT_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.updateMaturityDetailsAction);
|
.resource(FIXED_DEPOSIT_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.updateMaturityDetailsAction);
|
||||||
@@ -238,8 +244,7 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
if (!this.maturityDate().isAfter(todayDate)) {
|
if (!this.maturityDate().isAfter(todayDate)) {
|
||||||
// update account status
|
// update account status
|
||||||
this.status = SavingsAccountStatusType.MATURED.getValue();
|
this.status = SavingsAccountStatusType.MATURED.getValue();
|
||||||
postMaturityInterest(isSavingsInterestPostingAtCurrentPeriodEnd,
|
postMaturityInterest(isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
financialYearBeginningMonth);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,8 +275,7 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
|
|
||||||
private List<PostingPeriod> calculateInterestPayable(final MathContext mc, final LocalDate maturityDate,
|
private List<PostingPeriod> calculateInterestPayable(final MathContext mc, final LocalDate maturityDate,
|
||||||
final List<SavingsAccountTransaction> transactions, final boolean isPreMatureClosure,
|
final List<SavingsAccountTransaction> transactions, final boolean isPreMatureClosure,
|
||||||
final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth) {
|
||||||
final Integer financialYearBeginningMonth) {
|
|
||||||
|
|
||||||
final SavingsPostingInterestPeriodType postingPeriodType = SavingsPostingInterestPeriodType.fromInt(this.interestPostingPeriodType);
|
final SavingsPostingInterestPeriodType postingPeriodType = SavingsPostingInterestPeriodType.fromInt(this.interestPostingPeriodType);
|
||||||
|
|
||||||
@@ -282,8 +286,7 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
.fromInt(this.interestCalculationDaysInYearType);
|
.fromInt(this.interestCalculationDaysInYearType);
|
||||||
|
|
||||||
final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(
|
final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(
|
||||||
accountSubmittedOrActivationDate(), maturityDate, postingPeriodType,
|
accountSubmittedOrActivationDate(), maturityDate, postingPeriodType, financialYearBeginningMonth);
|
||||||
financialYearBeginningMonth);
|
|
||||||
|
|
||||||
final List<PostingPeriod> allPostingPeriods = new ArrayList<>();
|
final List<PostingPeriod> allPostingPeriods = new ArrayList<>();
|
||||||
|
|
||||||
@@ -470,14 +473,12 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
// this.savingsAccountTransactionSummaryWrapper, this.transactions);
|
// this.savingsAccountTransactionSummaryWrapper, this.transactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postMaturityInterest(final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
public void postMaturityInterest(final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth) {
|
||||||
final Integer financialYearBeginningMonth) {
|
|
||||||
final LocalDate interestPostingUpToDate = maturityDate();
|
final LocalDate interestPostingUpToDate = maturityDate();
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
final boolean isInterestTransfer = false;
|
final boolean isInterestTransfer = false;
|
||||||
final List<PostingPeriod> postingPeriods = calculateInterestUsing(mc, interestPostingUpToDate,
|
final List<PostingPeriod> postingPeriods = calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer,
|
||||||
isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
financialYearBeginningMonth);
|
|
||||||
|
|
||||||
Money interestPostedToDate = Money.zero(this.currency);
|
Money interestPostedToDate = Money.zero(this.currency);
|
||||||
|
|
||||||
@@ -522,15 +523,13 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void postPreMaturityInterest(final LocalDate accountCloseDate, final boolean isPreMatureClosure,
|
public void postPreMaturityInterest(final LocalDate accountCloseDate, final boolean isPreMatureClosure,
|
||||||
final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth) {
|
||||||
final Integer financialYearBeginningMonth) {
|
|
||||||
|
|
||||||
Money interestPostedToDate = totalInterestPosted();
|
Money interestPostedToDate = totalInterestPosted();
|
||||||
// calculate interest before one day of closure date
|
// calculate interest before one day of closure date
|
||||||
final LocalDate interestCalculatedToDate = accountCloseDate.minusDays(1);
|
final LocalDate interestCalculatedToDate = accountCloseDate.minusDays(1);
|
||||||
final Money interestOnMaturity = calculatePreMatureInterest(interestCalculatedToDate,
|
final Money interestOnMaturity = calculatePreMatureInterest(interestCalculatedToDate,
|
||||||
retreiveOrderedNonInterestPostingTransactions(), isPreMatureClosure,
|
retreiveOrderedNonInterestPostingTransactions(), isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
isSavingsInterestPostingAtCurrentPeriodEnd,
|
|
||||||
financialYearBeginningMonth);
|
financialYearBeginningMonth);
|
||||||
boolean recalucateDailyBalance = false;
|
boolean recalucateDailyBalance = false;
|
||||||
|
|
||||||
@@ -554,14 +553,12 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal calculatePreMatureAmount(final LocalDate preMatureDate, final boolean isPreMatureClosure,
|
public BigDecimal calculatePreMatureAmount(final LocalDate preMatureDate, final boolean isPreMatureClosure,
|
||||||
final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth) {
|
||||||
final Integer financialYearBeginningMonth) {
|
|
||||||
|
|
||||||
final Money interestPostedToDate = totalInterestPosted().copy();
|
final Money interestPostedToDate = totalInterestPosted().copy();
|
||||||
|
|
||||||
final Money interestEarnedTillDate = calculatePreMatureInterest(preMatureDate, retreiveOrderedNonInterestPostingTransactions(),
|
final Money interestEarnedTillDate = calculatePreMatureInterest(preMatureDate, retreiveOrderedNonInterestPostingTransactions(),
|
||||||
isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd,
|
isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
financialYearBeginningMonth);
|
|
||||||
|
|
||||||
final Money accountBalance = Money.of(getCurrency(), getAccountBalance());
|
final Money accountBalance = Money.of(getCurrency(), getAccountBalance());
|
||||||
final Money maturityAmount = accountBalance.minus(interestPostedToDate).plus(interestEarnedTillDate);
|
final Money maturityAmount = accountBalance.minus(interestPostedToDate).plus(interestEarnedTillDate);
|
||||||
@@ -573,9 +570,8 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
final boolean isPreMatureClosure, final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
final boolean isPreMatureClosure, final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
final Integer financialYearBeginningMonth) {
|
final Integer financialYearBeginningMonth) {
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
final List<PostingPeriod> postingPeriods = calculateInterestPayable(mc, preMatureDate, transactions,
|
final List<PostingPeriod> postingPeriods = calculateInterestPayable(mc, preMatureDate, transactions, isPreMatureClosure,
|
||||||
isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd,
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
financialYearBeginningMonth);
|
|
||||||
|
|
||||||
Money interestOnMaturity = Money.zero(this.currency);
|
Money interestOnMaturity = Money.zero(this.currency);
|
||||||
|
|
||||||
@@ -589,22 +585,18 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postInterest(final MathContext mc, final LocalDate postingDate, boolean isInterestTransfer,
|
public void postInterest(final MathContext mc, final LocalDate postingDate, boolean isInterestTransfer,
|
||||||
final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth) {
|
||||||
final Integer financialYearBeginningMonth) {
|
|
||||||
final LocalDate interestPostingUpToDate = interestPostingUpToDate(postingDate);
|
final LocalDate interestPostingUpToDate = interestPostingUpToDate(postingDate);
|
||||||
super.postInterest(mc, interestPostingUpToDate, isInterestTransfer,
|
super.postInterest(mc, interestPostingUpToDate, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
isSavingsInterestPostingAtCurrentPeriodEnd,
|
financialYearBeginningMonth);
|
||||||
financialYearBeginningMonth);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PostingPeriod> calculateInterestUsing(final MathContext mc, final LocalDate postingDate,
|
public List<PostingPeriod> calculateInterestUsing(final MathContext mc, final LocalDate postingDate, boolean isInterestTransfer,
|
||||||
boolean isInterestTransfer, final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth) {
|
||||||
final Integer financialYearBeginningMonth) {
|
|
||||||
final LocalDate interestPostingUpToDate = interestPostingUpToDate(postingDate);
|
final LocalDate interestPostingUpToDate = interestPostingUpToDate(postingDate);
|
||||||
return super.calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer,
|
return super.calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
isSavingsInterestPostingAtCurrentPeriodEnd,
|
financialYearBeginningMonth);
|
||||||
financialYearBeginningMonth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private LocalDate interestPostingUpToDate(final LocalDate interestPostingDate) {
|
private LocalDate interestPostingUpToDate(final LocalDate interestPostingDate) {
|
||||||
|
|||||||
+1057
-1437
File diff suppressed because it is too large
Load Diff
+7
-7
@@ -157,8 +157,8 @@ public final class SavingsAccountTransaction extends AbstractPersistable<Long> {
|
|||||||
isReversed, appUser);
|
isReversed, appUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SavingsAccountTransaction initiateTransfer(final SavingsAccount savingsAccount, final Office office, final LocalDate date,
|
public static SavingsAccountTransaction initiateTransfer(final SavingsAccount savingsAccount, final Office office,
|
||||||
final AppUser appUser) {
|
final LocalDate date, final AppUser appUser) {
|
||||||
final boolean isReversed = false;
|
final boolean isReversed = false;
|
||||||
final PaymentDetail paymentDetail = null;
|
final PaymentDetail paymentDetail = null;
|
||||||
return new SavingsAccountTransaction(savingsAccount, office, paymentDetail,
|
return new SavingsAccountTransaction(savingsAccount, office, paymentDetail,
|
||||||
@@ -167,7 +167,7 @@ public final class SavingsAccountTransaction extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static SavingsAccountTransaction approveTransfer(final SavingsAccount savingsAccount, final Office office, final LocalDate date,
|
public static SavingsAccountTransaction approveTransfer(final SavingsAccount savingsAccount, final Office office, final LocalDate date,
|
||||||
final AppUser appUser) {
|
final AppUser appUser) {
|
||||||
final boolean isReversed = false;
|
final boolean isReversed = false;
|
||||||
final PaymentDetail paymentDetail = null;
|
final PaymentDetail paymentDetail = null;
|
||||||
return new SavingsAccountTransaction(savingsAccount, office, paymentDetail,
|
return new SavingsAccountTransaction(savingsAccount, office, paymentDetail,
|
||||||
@@ -175,8 +175,8 @@ public final class SavingsAccountTransaction extends AbstractPersistable<Long> {
|
|||||||
.getAccountBalance(), isReversed, appUser);
|
.getAccountBalance(), isReversed, appUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SavingsAccountTransaction withdrawTransfer(final SavingsAccount savingsAccount, final Office office, final LocalDate date,
|
public static SavingsAccountTransaction withdrawTransfer(final SavingsAccount savingsAccount, final Office office,
|
||||||
final AppUser appUser) {
|
final LocalDate date, final AppUser appUser) {
|
||||||
final boolean isReversed = false;
|
final boolean isReversed = false;
|
||||||
final PaymentDetail paymentDetail = null;
|
final PaymentDetail paymentDetail = null;
|
||||||
return new SavingsAccountTransaction(savingsAccount, office, paymentDetail,
|
return new SavingsAccountTransaction(savingsAccount, office, paymentDetail,
|
||||||
@@ -196,8 +196,8 @@ public final class SavingsAccountTransaction extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SavingsAccountTransaction(final SavingsAccount savingsAccount, final Office office, final PaymentDetail paymentDetail,
|
private SavingsAccountTransaction(final SavingsAccount savingsAccount, final Office office, final PaymentDetail paymentDetail,
|
||||||
final Integer typeOf, final LocalDate transactionLocalDate, final Date createdDate, final Money amount, final boolean isReversed,
|
final Integer typeOf, final LocalDate transactionLocalDate, final Date createdDate, final Money amount,
|
||||||
final AppUser appUser) {
|
final boolean isReversed, final AppUser appUser) {
|
||||||
this(savingsAccount, office, paymentDetail, typeOf, transactionLocalDate, createdDate, amount.getAmount(), isReversed, appUser);
|
this(savingsAccount, office, paymentDetail, typeOf, transactionLocalDate, createdDate, amount.getAmount(), isReversed, appUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+53
-58
@@ -60,70 +60,65 @@ public final class SavingsHelper {
|
|||||||
LocalDate periodEndDate = interestPostingUpToDate;
|
LocalDate periodEndDate = interestPostingUpToDate;
|
||||||
final Integer monthOfYear = periodStartDate.getMonthOfYear();
|
final Integer monthOfYear = periodStartDate.getMonthOfYear();
|
||||||
financialYearBeginningMonth--;
|
financialYearBeginningMonth--;
|
||||||
if(financialYearBeginningMonth == 0)
|
if (financialYearBeginningMonth == 0) financialYearBeginningMonth = 12;
|
||||||
financialYearBeginningMonth = 12;
|
|
||||||
|
|
||||||
final ArrayList<LocalDate> quarterlyDates = new ArrayList<>();
|
final ArrayList<LocalDate> quarterlyDates = new ArrayList<>();
|
||||||
quarterlyDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth).dayOfMonth().withMaximumValue());
|
quarterlyDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth).dayOfMonth().withMaximumValue());
|
||||||
quarterlyDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth)
|
quarterlyDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth).plusMonths(3).withYear(periodStartDate.getYear())
|
||||||
.plusMonths(3).withYear(periodStartDate.getYear()).dayOfMonth().withMaximumValue());
|
.dayOfMonth().withMaximumValue());
|
||||||
quarterlyDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth)
|
quarterlyDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth).plusMonths(6).withYear(periodStartDate.getYear())
|
||||||
.plusMonths(6).withYear(periodStartDate.getYear()).dayOfMonth().withMaximumValue());
|
.dayOfMonth().withMaximumValue());
|
||||||
quarterlyDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth)
|
quarterlyDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth).plusMonths(9).withYear(periodStartDate.getYear())
|
||||||
.plusMonths(9).withYear(periodStartDate.getYear()).dayOfMonth().withMaximumValue());
|
.dayOfMonth().withMaximumValue());
|
||||||
Collections.sort(quarterlyDates);
|
Collections.sort(quarterlyDates);
|
||||||
|
|
||||||
final ArrayList<LocalDate> biannualDates = new ArrayList<>();
|
final ArrayList<LocalDate> biannualDates = new ArrayList<>();
|
||||||
biannualDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth).dayOfMonth().withMaximumValue());
|
biannualDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth).dayOfMonth().withMaximumValue());
|
||||||
biannualDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth).plusMonths(6)
|
biannualDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth).plusMonths(6).withYear(periodStartDate.getYear())
|
||||||
.withYear(periodStartDate.getYear()).dayOfMonth().withMaximumValue());
|
.dayOfMonth().withMaximumValue());
|
||||||
Collections.sort(biannualDates);
|
Collections.sort(biannualDates);
|
||||||
|
|
||||||
boolean isEndDateSet = false;
|
boolean isEndDateSet = false;
|
||||||
|
|
||||||
switch (interestPostingPeriodType) {
|
switch (interestPostingPeriodType) {
|
||||||
case INVALID:
|
case INVALID:
|
||||||
break;
|
break;
|
||||||
case MONTHLY:
|
case MONTHLY:
|
||||||
// produce period end date on last day of current month
|
// produce period end date on last day of current month
|
||||||
periodEndDate = periodStartDate.dayOfMonth().withMaximumValue();
|
periodEndDate = periodStartDate.dayOfMonth().withMaximumValue();
|
||||||
break;
|
break;
|
||||||
case QUATERLY:
|
case QUATERLY:
|
||||||
for(LocalDate quarterlyDate : quarterlyDates) {
|
for (LocalDate quarterlyDate : quarterlyDates) {
|
||||||
if(quarterlyDate.isAfter(periodStartDate)) {
|
if (quarterlyDate.isAfter(periodStartDate)) {
|
||||||
periodEndDate = quarterlyDate;
|
periodEndDate = quarterlyDate;
|
||||||
isEndDateSet = true;
|
isEndDateSet = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isEndDateSet)
|
if (!isEndDateSet) periodEndDate = quarterlyDates.get(0).plusYears(1).dayOfMonth().withMaximumValue();
|
||||||
periodEndDate = quarterlyDates.get(0).plusYears(1).dayOfMonth().withMaximumValue();
|
break;
|
||||||
break;
|
case BIANNUAL:
|
||||||
case BIANNUAL:
|
for (LocalDate biannualDate : biannualDates) {
|
||||||
for(LocalDate biannualDate : biannualDates) {
|
if (biannualDate.isAfter(periodStartDate)) {
|
||||||
if(biannualDate.isAfter(periodStartDate)) {
|
periodEndDate = biannualDate;
|
||||||
periodEndDate = biannualDate;
|
isEndDateSet = true;
|
||||||
isEndDateSet = true;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(!isEndDateSet)
|
if (!isEndDateSet) periodEndDate = biannualDates.get(0).plusYears(1).dayOfMonth().withMaximumValue();
|
||||||
periodEndDate = biannualDates.get(0).plusYears(1).dayOfMonth().withMaximumValue();
|
break;
|
||||||
break;
|
case ANNUAL:
|
||||||
case ANNUAL:
|
if (financialYearBeginningMonth < monthOfYear) {
|
||||||
if (financialYearBeginningMonth < monthOfYear) {
|
periodEndDate = periodStartDate.withMonthOfYear(financialYearBeginningMonth);
|
||||||
periodEndDate = periodStartDate
|
periodEndDate = periodEndDate.plusYears(1);
|
||||||
.withMonthOfYear(financialYearBeginningMonth);
|
} else {
|
||||||
periodEndDate = periodEndDate.plusYears(1);
|
periodEndDate = periodStartDate.withMonthOfYear(financialYearBeginningMonth);
|
||||||
} else {
|
}
|
||||||
periodEndDate = periodStartDate
|
periodEndDate = periodEndDate.dayOfMonth().withMaximumValue();
|
||||||
.withMonthOfYear(financialYearBeginningMonth);
|
break;
|
||||||
}
|
}
|
||||||
periodEndDate = periodEndDate.dayOfMonth().withMaximumValue();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// interest posting always occurs on next day after the period end date.
|
// interest posting always occurs on next day after the period end date.
|
||||||
periodEndDate = periodEndDate.plusDays(1);
|
periodEndDate = periodEndDate.plusDays(1);
|
||||||
|
|||||||
+6
-5
@@ -41,15 +41,17 @@ public class SavingsOfficerAssignmentHistory extends AbstractAuditableCustom<App
|
|||||||
@Column(name = "end_date")
|
@Column(name = "end_date")
|
||||||
private Date endDate;
|
private Date endDate;
|
||||||
|
|
||||||
public static SavingsOfficerAssignmentHistory createNew(final SavingsAccount account, final Staff savingsOfficer,final LocalDate assignmentDate) {
|
public static SavingsOfficerAssignmentHistory createNew(final SavingsAccount account, final Staff savingsOfficer,
|
||||||
return new SavingsOfficerAssignmentHistory(account, savingsOfficer,assignmentDate.toDate(),null);
|
final LocalDate assignmentDate) {
|
||||||
|
return new SavingsOfficerAssignmentHistory(account, savingsOfficer, assignmentDate.toDate(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SavingsOfficerAssignmentHistory() {
|
protected SavingsOfficerAssignmentHistory() {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
private SavingsOfficerAssignmentHistory(final SavingsAccount account, final Staff savingsOfficer,final Date startDate, final Date endDate) {
|
private SavingsOfficerAssignmentHistory(final SavingsAccount account, final Staff savingsOfficer, final Date startDate,
|
||||||
|
final Date endDate) {
|
||||||
this.savingsAccount = account;
|
this.savingsAccount = account;
|
||||||
this.savingsOfficer = savingsOfficer;
|
this.savingsOfficer = savingsOfficer;
|
||||||
this.startDate = startDate;
|
this.startDate = startDate;
|
||||||
@@ -64,7 +66,6 @@ public class SavingsOfficerAssignmentHistory extends AbstractAuditableCustom<App
|
|||||||
return this.savingsOfficer.identifiedBy(staff);
|
return this.savingsOfficer.identifiedBy(staff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void updateStartDate(final LocalDate startDate) {
|
public void updateStartDate(final LocalDate startDate) {
|
||||||
this.startDate = startDate.toDate();
|
this.startDate = startDate.toDate();
|
||||||
}
|
}
|
||||||
@@ -103,4 +104,4 @@ public class SavingsOfficerAssignmentHistory extends AbstractAuditableCustom<App
|
|||||||
return (LocalDate) ObjectUtils.defaultIfNull(new LocalDate(this.endDate), null);
|
return (LocalDate) ObjectUtils.defaultIfNull(new LocalDate(this.endDate), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -131,10 +131,10 @@ public class PostingPeriod {
|
|||||||
this.daysInYear = daysInYear;
|
this.daysInYear = daysInYear;
|
||||||
this.compoundingPeriods = compoundingPeriods;
|
this.compoundingPeriods = compoundingPeriods;
|
||||||
|
|
||||||
if(isSavingsInterestPostingAtCurrentPeriodEnd)
|
if (isSavingsInterestPostingAtCurrentPeriodEnd)
|
||||||
this.dateOfPostingTransaction = periodInterval.endDate();
|
this.dateOfPostingTransaction = periodInterval.endDate();
|
||||||
else
|
else
|
||||||
this.dateOfPostingTransaction = periodInterval.endDate().plusDays(1);
|
this.dateOfPostingTransaction = periodInterval.endDate().plusDays(1);
|
||||||
this.interestTransfered = interestTransfered;
|
this.interestTransfered = interestTransfered;
|
||||||
this.minBalanceForInterestCalculation = minBalanceForInterestCalculation;
|
this.minBalanceForInterestCalculation = minBalanceForInterestCalculation;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user