updates to accounting section of api-docs

This commit is contained in:
Vishwas Babu A J
2014-11-05 18:09:46 +05:30
parent b2e9ab4a9c
commit 1c49096881
5 changed files with 151 additions and 185 deletions
+20 -6
View File
@@ -1460,12 +1460,19 @@
<tr> <tr>
<td><a href="#journalentries">Journal Entries</a></td> <td><a href="#journalentries">Journal Entries</a></td>
<td>journalentries</td> <td>journalentries</td>
<td><a href="#journalentries_create">Create Journal Entries</a><br> <td><a href="#journalentries_create">Create Journal Entries</a></td>
<a href="#journalentries_updatebalance">Update Journal Entries Running Balance</a></td>
<td><a href="#journalentries_list">List Journal Entries</a></td> <td><a href="#journalentries_list">List Journal Entries</a></td>
<td></td> <td></td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td></td>
<td>journalentries?command=updateRunningBalance</td>
<td><a href="#journalentries_updatebalance">Update Running Balance for Journal Entries</a></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr> <tr>
<td></td> <td></td>
<td>journalentries/{entryId}</td> <td>journalentries/{entryId}</td>
@@ -30795,7 +30802,7 @@ Request Body:
POST https://DomainName/api/v1/journalentries?command=updateRunningBalance POST https://DomainName/api/v1/journalentries?command=updateRunningBalance
</code> </code>
<code class="method-request"> <code class="method-request">
POST journalentries POST journalentries?command=updateRunningBalance
Content-Type: application/json Content-Type: application/json
Request Body: Request Body:
{ {
@@ -30893,7 +30900,7 @@ GET https://DomainName/api/v1/journalentries/{entryId}
</div> </div>
<div class="method-example"> <div class="method-example">
<code class="method-declaration"> <code class="method-declaration">
GET https://DomainName/api/v1/journalentries/{transactionId} GET https://DomainName/api/v1/journalentries/{transactionId}?command=reverse
</code> </code>
<code class="method-request"> <code class="method-request">
POST journalentries/C1MAE935K0IAEYA?command=reverse POST journalentries/C1MAE935K0IAEYA?command=reverse
@@ -33203,12 +33210,19 @@ No Request Body:
<tr> <tr>
<td><a href="#journalentries">Journal Entries</a></td> <td><a href="#journalentries">Journal Entries</a></td>
<td>journalentries</td> <td>journalentries</td>
<td><a href="#journalentries_create">Create Journal Entries</a><br> <td><a href="#journalentries_create">Create Journal Entries</a></td>
<a href="#journalentries_updatebalance">Update Journal Entries Running Balance</a></td>
<td><a href="#journalentries_list">List Journal Entries</a></td> <td><a href="#journalentries_list">List Journal Entries</a></td>
<td></td> <td></td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td></td>
<td>journalentries?command=updateRunningBalance</td>
<td><a href="#journalentries_updatebalance">Update Running Balance for Journal Entries</a></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr> <tr>
<td></td> <td></td>
<td>journalentries/{entryId}</td> <td>journalentries/{entryId}</td>
@@ -469,7 +469,7 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
for (final SavingsAccount savingsAccount : this.savingsAccountRepository for (final SavingsAccount savingsAccount : this.savingsAccountRepository
.findSavingAccountByClientId(client.getId())) { .findSavingAccountByClientId(client.getId())) {
if (!savingsAccount.isClosed()) { if (!savingsAccount.isClosed()) {
savingsAccount.update(staff); savingsAccount.reassignSavingsOfficer(staff, loanOfficerReassignmentDate);
} }
} }
} }
@@ -75,8 +75,6 @@ import org.mifosplatform.portfolio.charge.exception.SavingsAccountChargeNotFound
import org.mifosplatform.portfolio.client.domain.Client; import org.mifosplatform.portfolio.client.domain.Client;
import org.mifosplatform.portfolio.common.domain.PeriodFrequencyType; import org.mifosplatform.portfolio.common.domain.PeriodFrequencyType;
import org.mifosplatform.portfolio.group.domain.Group; import org.mifosplatform.portfolio.group.domain.Group;
import org.mifosplatform.portfolio.savings.exception.SavingsOfficerAssignmentDateException;
import org.mifosplatform.portfolio.savings.domain.SavingsOfficerAssignmentHistory;
import org.mifosplatform.portfolio.savings.DepositAccountType; import org.mifosplatform.portfolio.savings.DepositAccountType;
import org.mifosplatform.portfolio.savings.SavingsApiConstants; import org.mifosplatform.portfolio.savings.SavingsApiConstants;
import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType; import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType;
@@ -89,6 +87,7 @@ import org.mifosplatform.portfolio.savings.domain.interest.PostingPeriod;
import org.mifosplatform.portfolio.savings.exception.InsufficientAccountBalanceException; import org.mifosplatform.portfolio.savings.exception.InsufficientAccountBalanceException;
import org.mifosplatform.portfolio.savings.exception.SavingsAccountTransactionNotFoundException; import org.mifosplatform.portfolio.savings.exception.SavingsAccountTransactionNotFoundException;
import org.mifosplatform.portfolio.savings.exception.SavingsActivityPriorToClientTransferException; import org.mifosplatform.portfolio.savings.exception.SavingsActivityPriorToClientTransferException;
import org.mifosplatform.portfolio.savings.exception.SavingsOfficerAssignmentDateException;
import org.mifosplatform.portfolio.savings.exception.SavingsOfficerUnassignmentDateException; import org.mifosplatform.portfolio.savings.exception.SavingsOfficerUnassignmentDateException;
import org.mifosplatform.portfolio.savings.exception.SavingsTransferTransactionsCannotBeUndoneException; import org.mifosplatform.portfolio.savings.exception.SavingsTransferTransactionsCannotBeUndoneException;
import org.mifosplatform.portfolio.savings.service.SavingsEnumerations; import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
@@ -269,7 +268,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
@LazyCollection(LazyCollectionOption.FALSE) @LazyCollection(LazyCollectionOption.FALSE)
@OneToMany(cascade = CascadeType.ALL, mappedBy = "savingsAccount", orphanRemoval = true) @OneToMany(cascade = CascadeType.ALL, mappedBy = "savingsAccount", orphanRemoval = true)
private Set<SavingsOfficerAssignmentHistory> savingsOfficerHistory; private Set<SavingsOfficerAssignmentHistory> savingsOfficerHistory;
@Transient @Transient
protected boolean accountNumberRequiresAutoGeneration = false; protected boolean accountNumberRequiresAutoGeneration = false;
@Transient @Transient
@@ -286,7 +285,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
protected SavingsAccount() { protected SavingsAccount() {
// //
} }
public static SavingsAccount createNewApplicationForSubmittal(final Client client, final Group group, final SavingsProduct product, public static SavingsAccount createNewApplicationForSubmittal(final Client client, final Group group, final SavingsProduct product,
final Staff fieldOfficer, final String accountNo, final String externalId, final AccountType accountType, final Staff fieldOfficer, final String accountNo, final String externalId, final AccountType accountType,
final LocalDate submittedOnDate, final AppUser submittedBy, final BigDecimal interestRate, final LocalDate submittedOnDate, final AppUser submittedBy, final BigDecimal interestRate,
@@ -417,14 +416,11 @@ public class SavingsAccount extends AbstractPersistable<Long> {
return SavingsAccountStatusType.fromInt(this.status).isClosed(); return SavingsAccountStatusType.fromInt(this.status).isClosed();
} }
public void postInterest(final MathContext mc, public void postInterest(final MathContext mc, final LocalDate interestPostingUpToDate, final boolean isInterestTransfer,
final LocalDate interestPostingUpToDate, final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth) {
final boolean isInterestTransfer,
final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
final Integer financialYearBeginningMonth) {
final List<PostingPeriod> postingPeriods = calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer, final List<PostingPeriod> postingPeriods = calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer,
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth); isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
Money interestPostedToDate = Money.zero(this.currency); Money interestPostedToDate = Money.zero(this.currency);
@@ -519,8 +515,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
* TODO * TODO
*/ */
public List<PostingPeriod> calculateInterestUsing(final MathContext mc, final LocalDate upToInterestCalculationDate, public List<PostingPeriod> calculateInterestUsing(final MathContext mc, final LocalDate upToInterestCalculationDate,
boolean isInterestTransfer, final boolean isSavingsInterestPostingAtCurrentPeriodEnd, boolean isInterestTransfer, final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth) {
final Integer financialYearBeginningMonth) {
// no openingBalance concept supported yet but probably will to allow // no openingBalance concept supported yet but probably will to allow
// for migrations. // for migrations.
@@ -544,8 +539,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
.fromInt(this.interestCalculationDaysInYearType); .fromInt(this.interestCalculationDaysInYearType);
final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods( final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(
getStartInterestCalculationDate(), upToInterestCalculationDate, postingPeriodType, getStartInterestCalculationDate(), upToInterestCalculationDate, postingPeriodType, financialYearBeginningMonth);
financialYearBeginningMonth);
final List<PostingPeriod> allPostingPeriods = new ArrayList<>(); final List<PostingPeriod> allPostingPeriods = new ArrayList<>();
@@ -1291,8 +1285,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
} }
return id; return id;
} }
public boolean hasSavingsOfficer(final Staff fromSavingsOfficer) { public boolean hasSavingsOfficer(final Staff fromSavingsOfficer) {
boolean matchesCurrentSavingsOfficer = false; boolean matchesCurrentSavingsOfficer = false;
@@ -1303,12 +1296,13 @@ public class SavingsAccount extends AbstractPersistable<Long> {
} }
return matchesCurrentSavingsOfficer; return matchesCurrentSavingsOfficer;
} }
public void reassignSavingsOfficer(final Staff newSavingsOfficer,final LocalDate assignmentDate) { public void reassignSavingsOfficer(final Staff newSavingsOfficer, final LocalDate assignmentDate) {
final SavingsOfficerAssignmentHistory latestHistoryRecord = findLatestIncompleteHistoryRecord(); final SavingsOfficerAssignmentHistory latestHistoryRecord = findLatestIncompleteHistoryRecord();
final SavingsOfficerAssignmentHistory lastAssignmentRecord = findLastAssignmentHistoryRecord(newSavingsOfficer); final SavingsOfficerAssignmentHistory lastAssignmentRecord = findLastAssignmentHistoryRecord(newSavingsOfficer);
// assignment date should not be less than savings account submitted date // assignment date should not be less than savings account submitted
// date
if (isSubmittedOnDateAfter(assignmentDate)) { if (isSubmittedOnDateAfter(assignmentDate)) {
final String errorMessage = "The Savings Officer assignment date (" + assignmentDate.toString() final String errorMessage = "The Savings Officer assignment date (" + assignmentDate.toString()
@@ -1337,24 +1331,25 @@ public class SavingsAccount extends AbstractPersistable<Long> {
latestHistoryRecord.updateSavingsOfficer(newSavingsOfficer); latestHistoryRecord.updateSavingsOfficer(newSavingsOfficer);
this.savingsOfficer = newSavingsOfficer; this.savingsOfficer = newSavingsOfficer;
} else if (latestHistoryRecord != null && latestHistoryRecord.hasStartDateBefore(assignmentDate)) { } else if (latestHistoryRecord != null && latestHistoryRecord.hasStartDateBefore(assignmentDate)) {
final String errorMessage = "Savings account with identifier " + getId() + " was already assigned before date " + assignmentDate; final String errorMessage = "Savings account with identifier " + getId() + " was already assigned before date "
+ assignmentDate;
throw new SavingsOfficerAssignmentDateException("is.before.last.assignment.date", errorMessage, getId(), assignmentDate); throw new SavingsOfficerAssignmentDateException("is.before.last.assignment.date", errorMessage, getId(), assignmentDate);
} else { } else {
if (latestHistoryRecord != null) { if (latestHistoryRecord != null) {
// savings officer correctly changed from previous savings officer to // savings officer correctly changed from previous savings
// officer to
// new savings officer // new savings officer
latestHistoryRecord.updateEndDate(assignmentDate); latestHistoryRecord.updateEndDate(assignmentDate);
} }
this.savingsOfficer = newSavingsOfficer; this.savingsOfficer = newSavingsOfficer;
if (isNotSubmittedAndPendingApproval()) { if (isNotSubmittedAndPendingApproval()) {
final SavingsOfficerAssignmentHistory savingsOfficerAssignmentHistory = final SavingsOfficerAssignmentHistory savingsOfficerAssignmentHistory = SavingsOfficerAssignmentHistory.createNew(this,
SavingsOfficerAssignmentHistory.createNew(this,this.savingsOfficer,assignmentDate); this.savingsOfficer, assignmentDate);
this.savingsOfficerHistory.add(savingsOfficerAssignmentHistory); this.savingsOfficerHistory.add(savingsOfficerAssignmentHistory);
} }
} }
} }
private SavingsOfficerAssignmentHistory findLastAssignmentHistoryRecord(final Staff newSavingsOfficer) { private SavingsOfficerAssignmentHistory findLastAssignmentHistoryRecord(final Staff newSavingsOfficer) {
SavingsOfficerAssignmentHistory lastAssignmentRecordLatestEndDate = null; SavingsOfficerAssignmentHistory lastAssignmentRecordLatestEndDate = null;
@@ -1374,19 +1369,18 @@ public class SavingsAccount extends AbstractPersistable<Long> {
} }
return lastAssignmentRecordLatestEndDate; return lastAssignmentRecordLatestEndDate;
} }
public boolean isSubmittedOnDateAfter(final LocalDate compareDate) {
return this.submittedOnDate == null ? false : new LocalDate(this.submittedOnDate).isAfter(compareDate);
}
public LocalDate getSubmittedOnDate() { public boolean isSubmittedOnDateAfter(final LocalDate compareDate) {
return (LocalDate) ObjectUtils.defaultIfNull(new LocalDate(this.submittedOnDate), null); return this.submittedOnDate == null ? false : new LocalDate(this.submittedOnDate).isAfter(compareDate);
} }
public LocalDate getSubmittedOnDate() {
return (LocalDate) ObjectUtils.defaultIfNull(new LocalDate(this.submittedOnDate), null);
}
public void removeSavingsOfficer(final LocalDate unassignDate) { public void removeSavingsOfficer(final LocalDate unassignDate) {
final SavingsOfficerAssignmentHistory latestHistoryRecord = findLatestIncompleteHistoryRecord(); final SavingsOfficerAssignmentHistory latestHistoryRecord = findLatestIncompleteHistoryRecord();
if (latestHistoryRecord != null) { if (latestHistoryRecord != null) {
validateUnassignDate(latestHistoryRecord, unassignDate); validateUnassignDate(latestHistoryRecord, unassignDate);
@@ -1394,7 +1388,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
} }
this.savingsOfficer = null; this.savingsOfficer = null;
} }
private SavingsOfficerAssignmentHistory findLatestIncompleteHistoryRecord() { private SavingsOfficerAssignmentHistory findLatestIncompleteHistoryRecord() {
SavingsOfficerAssignmentHistory latestRecordWithNoEndDate = null; SavingsOfficerAssignmentHistory latestRecordWithNoEndDate = null;
@@ -1416,8 +1410,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final String errorMessage = "The Savings officer Unassign date(" + unassignDate + ") cannot be before its assignment date (" final String errorMessage = "The Savings officer Unassign date(" + unassignDate + ") cannot be before its assignment date ("
+ latestHistoryRecord.getStartDate() + ")."; + latestHistoryRecord.getStartDate() + ").";
throw new SavingsOfficerUnassignmentDateException("cannot.be.before.assignment.date", errorMessage, getId(), getSavingsOfficer() throw new SavingsOfficerUnassignmentDateException("cannot.be.before.assignment.date", errorMessage, getId(),
.getId(), latestHistoryRecord.getStartDate(), unassignDate); getSavingsOfficer().getId(), latestHistoryRecord.getStartDate(), unassignDate);
} else if (unassignDate.isAfter(today)) { } else if (unassignDate.isAfter(today)) {
@@ -1426,7 +1420,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
throw new SavingsOfficerUnassignmentDateException("cannot.be.a.future.date", errorMessage, unassignDate); throw new SavingsOfficerUnassignmentDateException("cannot.be.a.future.date", errorMessage, unassignDate);
} }
} }
public MonetaryCurrency getCurrency() { public MonetaryCurrency getCurrency() {
return this.currency; return this.currency;
} }
@@ -1832,9 +1826,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
return actualChanges; return actualChanges;
} }
public void processAccountUponActivation( public void processAccountUponActivation(final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth) {
final Integer financialYearBeginningMonth) {
// update annual fee due date // update annual fee due date
for (SavingsAccountCharge charge : this.charges()) { for (SavingsAccountCharge charge : this.charges()) {
@@ -1842,8 +1835,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
} }
// auto pay the activation time charges // auto pay the activation time charges
this.payActivationCharges(isSavingsInterestPostingAtCurrentPeriodEnd, this.payActivationCharges(isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
financialYearBeginningMonth);
// TODO : AA add activation charges to actual changes list // TODO : AA add activation charges to actual changes list
} }
@@ -1866,8 +1858,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
this.lockedInUntilDate = calculateDateAccountIsLockedUntil(getActivationLocalDate()); this.lockedInUntilDate = calculateDateAccountIsLockedUntil(getActivationLocalDate());
} }
private void payActivationCharges(final boolean isSavingsInterestPostingAtCurrentPeriodEnd, private void payActivationCharges(final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth) {
final Integer financialYearBeginningMonth) {
boolean isSavingsChargeApplied = false; boolean isSavingsChargeApplied = false;
for (SavingsAccountCharge savingsAccountCharge : this.charges()) { for (SavingsAccountCharge savingsAccountCharge : this.charges()) {
if (savingsAccountCharge.isSavingsActivation()) { if (savingsAccountCharge.isSavingsActivation()) {
@@ -1881,12 +1872,11 @@ public class SavingsAccount extends AbstractPersistable<Long> {
boolean isInterestTransfer = false; boolean isInterestTransfer = false;
if (this.isBeforeLastPostingPeriod(getActivationLocalDate())) { if (this.isBeforeLastPostingPeriod(getActivationLocalDate())) {
final LocalDate today = DateUtils.getLocalDateOfTenant(); final LocalDate today = DateUtils.getLocalDateOfTenant();
this.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, this.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
financialYearBeginningMonth);
} else { } else {
final LocalDate today = DateUtils.getLocalDateOfTenant(); final LocalDate today = DateUtils.getLocalDateOfTenant();
this.calculateInterestUsing(mc, today, isInterestTransfer, this.calculateInterestUsing(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth); financialYearBeginningMonth);
} }
} }
} }
@@ -142,8 +142,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
final AccountAssociationsReadPlatformService accountAssociationsReadPlatformService, final AccountAssociationsReadPlatformService accountAssociationsReadPlatformService,
final AccountTransfersWritePlatformService accountTransfersWritePlatformService, final AccountTransfersWritePlatformService accountTransfersWritePlatformService,
final DepositAccountReadPlatformService depositAccountReadPlatformService, final DepositAccountReadPlatformService depositAccountReadPlatformService,
final CalendarInstanceRepository calendarInstanceRepository, final CalendarInstanceRepository calendarInstanceRepository, final ConfigurationDomainService configurationDomainService) {
final ConfigurationDomainService configurationDomainService) {
this.context = context; this.context = context;
this.savingAccountRepository = savingAccountRepository; this.savingAccountRepository = savingAccountRepository;
@@ -173,11 +172,10 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
public CommandProcessingResult activateFDAccount(final Long savingsId, final JsonCommand command) { public CommandProcessingResult activateFDAccount(final Long savingsId, final JsonCommand command) {
final AppUser user = this.context.authenticatedUser(); final AppUser user = this.context.authenticatedUser();
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
.isSavingsInterestPostingAtCurrentPeriodEnd(); .isSavingsInterestPostingAtCurrentPeriodEnd();
final Integer financialYearBeginningMonth = this.configurationDomainService final Integer financialYearBeginningMonth = this.configurationDomainService.retrieveFinancialYearBeginningMonth();
.retrieveFinancialYearBeginningMonth();
this.depositAccountTransactionDataValidator.validateActivation(command); this.depositAccountTransactionDataValidator.validateActivation(command);
final MathContext mc = MathContext.DECIMAL64; final MathContext mc = MathContext.DECIMAL64;
@@ -217,12 +215,12 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
final boolean isInterestTransfer = false; final boolean isInterestTransfer = false;
if (account.isBeforeLastPostingPeriod(account.getActivationLocalDate())) { if (account.isBeforeLastPostingPeriod(account.getActivationLocalDate())) {
final LocalDate today = DateUtils.getLocalDateOfTenant(); final LocalDate today = DateUtils.getLocalDateOfTenant();
account.postInterest(mc, today, isInterestTransfer, account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth); financialYearBeginningMonth);
} else { } else {
final LocalDate today = DateUtils.getLocalDateOfTenant(); final LocalDate today = DateUtils.getLocalDateOfTenant();
account.calculateInterestUsing(mc, today, isInterestTransfer, account.calculateInterestUsing(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth); financialYearBeginningMonth);
} }
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds); updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
@@ -230,7 +228,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
final boolean isPreMatureClosure = false; final boolean isPreMatureClosure = false;
account.updateMaturityDateAndAmount(mc, isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd, account.updateMaturityDateAndAmount(mc, isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd,
financialYearBeginningMonth); financialYearBeginningMonth);
account.validateAccountBalanceDoesNotBecomeNegative(SavingsAccountTransactionType.PAY_CHARGE.name()); account.validateAccountBalanceDoesNotBecomeNegative(SavingsAccountTransactionType.PAY_CHARGE.name());
this.savingAccountRepository.save(account); this.savingAccountRepository.save(account);
} }
@@ -253,11 +251,10 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
boolean isRegularTransaction = false; boolean isRegularTransaction = false;
final AppUser user = this.context.authenticatedUser(); final AppUser user = this.context.authenticatedUser();
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
.isSavingsInterestPostingAtCurrentPeriodEnd(); .isSavingsInterestPostingAtCurrentPeriodEnd();
final Integer financialYearBeginningMonth = this.configurationDomainService final Integer financialYearBeginningMonth = this.configurationDomainService.retrieveFinancialYearBeginningMonth();
.retrieveFinancialYearBeginningMonth();
this.depositAccountTransactionDataValidator.validateActivation(command); this.depositAccountTransactionDataValidator.validateActivation(command);
@@ -307,9 +304,8 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
Integer frequency = CalendarUtils.getInterval(calendar.getRecurrence()); Integer frequency = CalendarUtils.getInterval(calendar.getRecurrence());
frequency = frequency == -1 ? 1 : frequency; frequency = frequency == -1 ? 1 : frequency;
account.generateSchedule(frequencyType, frequency, calendar); account.generateSchedule(frequencyType, frequency, calendar);
account.updateMaturityDateAndAmount(mc, isPreMatureClosure, account.updateMaturityDateAndAmount(mc, isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd,
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
financialYearBeginningMonth);
} }
final LocalDate overdueUptoDate = account.maturityDate().isAfter(DateUtils.getLocalDateOfTenant()) ? DateUtils final LocalDate overdueUptoDate = account.maturityDate().isAfter(DateUtils.getLocalDateOfTenant()) ? DateUtils
@@ -318,14 +314,11 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
final boolean isInterestTransfer = false; final boolean isInterestTransfer = false;
if (account.isBeforeLastPostingPeriod(account.getActivationLocalDate())) { if (account.isBeforeLastPostingPeriod(account.getActivationLocalDate())) {
final LocalDate today = DateUtils.getLocalDateOfTenant(); final LocalDate today = DateUtils.getLocalDateOfTenant();
account.postInterest(mc, today, isInterestTransfer, account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
isSavingsInterestPostingAtCurrentPeriodEnd,
financialYearBeginningMonth);
} else { } else {
final LocalDate today = DateUtils.getLocalDateOfTenant(); final LocalDate today = DateUtils.getLocalDateOfTenant();
account.calculateInterestUsing(mc, today, isInterestTransfer, account.calculateInterestUsing(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
financialYearBeginningMonth);
} }
account.validateAccountBalanceDoesNotBecomeNegative(SavingsAccountTransactionType.PAY_CHARGE.name()); account.validateAccountBalanceDoesNotBecomeNegative(SavingsAccountTransactionType.PAY_CHARGE.name());
@@ -430,11 +423,10 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
@Override @Override
public CommandProcessingResult calculateInterest(final Long savingsId, final DepositAccountType depositAccountType) { public CommandProcessingResult calculateInterest(final Long savingsId, final DepositAccountType depositAccountType) {
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
.isSavingsInterestPostingAtCurrentPeriodEnd(); .isSavingsInterestPostingAtCurrentPeriodEnd();
final Integer financialYearBeginningMonth = this.configurationDomainService final Integer financialYearBeginningMonth = this.configurationDomainService.retrieveFinancialYearBeginningMonth();
.retrieveFinancialYearBeginningMonth();
final SavingsAccount account = this.depositAccountAssembler.assembleFrom(savingsId, depositAccountType); final SavingsAccount account = this.depositAccountAssembler.assembleFrom(savingsId, depositAccountType);
checkClientOrGroupActive(account); checkClientOrGroupActive(account);
@@ -442,9 +434,8 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
final MathContext mc = new MathContext(15, RoundingMode.HALF_EVEN); final MathContext mc = new MathContext(15, RoundingMode.HALF_EVEN);
boolean isInterestTransfer = false; boolean isInterestTransfer = false;
account.calculateInterestUsing(mc, today, isInterestTransfer, account.calculateInterestUsing(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
financialYearBeginningMonth);
this.savingAccountRepository.save(account); this.savingAccountRepository.save(account);
@@ -475,21 +466,18 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
@Transactional @Transactional
private void postInterest(final SavingsAccount account) { private void postInterest(final SavingsAccount account) {
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
.isSavingsInterestPostingAtCurrentPeriodEnd(); .isSavingsInterestPostingAtCurrentPeriodEnd();
final Integer financialYearBeginningMonth = this.configurationDomainService final Integer financialYearBeginningMonth = this.configurationDomainService.retrieveFinancialYearBeginningMonth();
.retrieveFinancialYearBeginningMonth();
final Set<Long> existingTransactionIds = new HashSet<>(); final Set<Long> existingTransactionIds = new HashSet<>();
final Set<Long> existingReversedTransactionIds = new HashSet<>(); final Set<Long> existingReversedTransactionIds = new HashSet<>();
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds); updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
final LocalDate today = DateUtils.getLocalDateOfTenant(); final LocalDate today = DateUtils.getLocalDateOfTenant();
final MathContext mc = new MathContext(10, RoundingMode.HALF_EVEN); final MathContext mc = new MathContext(10, RoundingMode.HALF_EVEN);
boolean isInterestTransfer = false; boolean isInterestTransfer = false;
account.postInterest(mc, today, isInterestTransfer, account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
isSavingsInterestPostingAtCurrentPeriodEnd,
financialYearBeginningMonth);
this.savingAccountRepository.save(account); this.savingAccountRepository.save(account);
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
@@ -525,11 +513,10 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
@Override @Override
public CommandProcessingResult undoRDTransaction(final Long savingsId, final Long transactionId, public CommandProcessingResult undoRDTransaction(final Long savingsId, final Long transactionId,
final boolean allowAccountTransferModification) { final boolean allowAccountTransferModification) {
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
.isSavingsInterestPostingAtCurrentPeriodEnd(); .isSavingsInterestPostingAtCurrentPeriodEnd();
final Integer financialYearBeginningMonth = this.configurationDomainService final Integer financialYearBeginningMonth = this.configurationDomainService.retrieveFinancialYearBeginningMonth();
.retrieveFinancialYearBeginningMonth();
final RecurringDepositAccount account = (RecurringDepositAccount) this.depositAccountAssembler.assembleFrom(savingsId, final RecurringDepositAccount account = (RecurringDepositAccount) this.depositAccountAssembler.assembleFrom(savingsId,
DepositAccountType.RECURRING_DEPOSIT); DepositAccountType.RECURRING_DEPOSIT);
@@ -557,20 +544,15 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
checkClientOrGroupActive(account); checkClientOrGroupActive(account);
if (savingsAccountTransaction.isPostInterestCalculationRequired() if (savingsAccountTransaction.isPostInterestCalculationRequired()
&& account.isBeforeLastPostingPeriod(savingsAccountTransaction.transactionLocalDate())) { && account.isBeforeLastPostingPeriod(savingsAccountTransaction.transactionLocalDate())) {
account.postInterest(mc, today, isInterestTransfer, account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
isSavingsInterestPostingAtCurrentPeriodEnd,
financialYearBeginningMonth);
} else { } else {
account.calculateInterestUsing(mc, today, isInterestTransfer, account.calculateInterestUsing(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
financialYearBeginningMonth);
} }
account.validateAccountBalanceDoesNotBecomeNegative(SavingsApiConstants.undoTransactionAction); account.validateAccountBalanceDoesNotBecomeNegative(SavingsApiConstants.undoTransactionAction);
// account.activateAccountBasedOnBalance(); // account.activateAccountBasedOnBalance();
final boolean isPreMatureClosure = false; final boolean isPreMatureClosure = false;
account.updateMaturityDateAndAmount(mc, isPreMatureClosure, account.updateMaturityDateAndAmount(mc, isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
isSavingsInterestPostingAtCurrentPeriodEnd,
financialYearBeginningMonth);
final LocalDate overdueUptoDate = account.maturityDate().isAfter(DateUtils.getLocalDateOfTenant()) ? DateUtils final LocalDate overdueUptoDate = account.maturityDate().isAfter(DateUtils.getLocalDateOfTenant()) ? DateUtils
.getLocalDateOfTenant() : account.maturityDate(); .getLocalDateOfTenant() : account.maturityDate();
@@ -602,11 +584,10 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
@Override @Override
public CommandProcessingResult adjustRDTransaction(final Long savingsId, final Long transactionId, final JsonCommand command) { public CommandProcessingResult adjustRDTransaction(final Long savingsId, final Long transactionId, final JsonCommand command) {
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
.isSavingsInterestPostingAtCurrentPeriodEnd(); .isSavingsInterestPostingAtCurrentPeriodEnd();
final Integer financialYearBeginningMonth = this.configurationDomainService final Integer financialYearBeginningMonth = this.configurationDomainService.retrieveFinancialYearBeginningMonth();
.retrieveFinancialYearBeginningMonth();
this.depositAccountTransactionDataValidator.validate(command, DepositAccountType.RECURRING_DEPOSIT); this.depositAccountTransactionDataValidator.validate(command, DepositAccountType.RECURRING_DEPOSIT);
final SavingsAccountTransaction savingsAccountTransaction = this.savingsAccountTransactionRepository final SavingsAccountTransaction savingsAccountTransaction = this.savingsAccountTransactionRepository
@@ -655,13 +636,10 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
boolean isInterestTransfer = false; boolean isInterestTransfer = false;
if (account.isBeforeLastPostingPeriod(transactionDate) if (account.isBeforeLastPostingPeriod(transactionDate)
|| account.isBeforeLastPostingPeriod(savingsAccountTransaction.transactionLocalDate())) { || account.isBeforeLastPostingPeriod(savingsAccountTransaction.transactionLocalDate())) {
account.postInterest(mc, today, isInterestTransfer, account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
isSavingsInterestPostingAtCurrentPeriodEnd,
financialYearBeginningMonth);
} else { } else {
account.calculateInterestUsing(mc, today, isInterestTransfer, account.calculateInterestUsing(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
financialYearBeginningMonth);
} }
account.validateAccountBalanceDoesNotBecomeNegative(SavingsApiConstants.adjustTransactionAction); account.validateAccountBalanceDoesNotBecomeNegative(SavingsApiConstants.adjustTransactionAction);
@@ -846,12 +824,11 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
@Override @Override
public SavingsAccountTransaction initiateSavingsTransfer(final Long accountId, final LocalDate transferDate, public SavingsAccountTransaction initiateSavingsTransfer(final Long accountId, final LocalDate transferDate,
final DepositAccountType depositAccountType) { final DepositAccountType depositAccountType) {
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
.isSavingsInterestPostingAtCurrentPeriodEnd(); .isSavingsInterestPostingAtCurrentPeriodEnd();
final Integer financialYearBeginningMonth = this.configurationDomainService final Integer financialYearBeginningMonth = this.configurationDomainService.retrieveFinancialYearBeginningMonth();
.retrieveFinancialYearBeginningMonth();
final SavingsAccount savingsAccount = this.depositAccountAssembler.assembleFrom(accountId, depositAccountType); final SavingsAccount savingsAccount = this.depositAccountAssembler.assembleFrom(accountId, depositAccountType);
final Set<Long> existingTransactionIds = new HashSet<>(); final Set<Long> existingTransactionIds = new HashSet<>();
@@ -864,9 +841,8 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
savingsAccount.setStatus(SavingsAccountStatusType.TRANSFER_IN_PROGRESS.getValue()); savingsAccount.setStatus(SavingsAccountStatusType.TRANSFER_IN_PROGRESS.getValue());
final MathContext mc = MathContext.DECIMAL64; final MathContext mc = MathContext.DECIMAL64;
boolean isInterestTransfer = false; boolean isInterestTransfer = false;
savingsAccount.calculateInterestUsing(mc, transferDate, isInterestTransfer, savingsAccount.calculateInterestUsing(mc, transferDate, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
financialYearBeginningMonth);
this.savingsAccountTransactionRepository.save(newTransferTransaction); this.savingsAccountTransactionRepository.save(newTransferTransaction);
this.savingAccountRepository.save(savingsAccount); this.savingAccountRepository.save(savingsAccount);
@@ -879,12 +855,11 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
@Override @Override
public SavingsAccountTransaction withdrawSavingsTransfer(final Long accountId, final LocalDate transferDate, public SavingsAccountTransaction withdrawSavingsTransfer(final Long accountId, final LocalDate transferDate,
final DepositAccountType depositAccountType) { final DepositAccountType depositAccountType) {
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
.isSavingsInterestPostingAtCurrentPeriodEnd(); .isSavingsInterestPostingAtCurrentPeriodEnd();
final Integer financialYearBeginningMonth = this.configurationDomainService final Integer financialYearBeginningMonth = this.configurationDomainService.retrieveFinancialYearBeginningMonth();
.retrieveFinancialYearBeginningMonth();
final SavingsAccount savingsAccount = this.depositAccountAssembler.assembleFrom(accountId, depositAccountType); final SavingsAccount savingsAccount = this.depositAccountAssembler.assembleFrom(accountId, depositAccountType);
final Set<Long> existingTransactionIds = new HashSet<>(); final Set<Long> existingTransactionIds = new HashSet<>();
@@ -897,9 +872,8 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
savingsAccount.setStatus(SavingsAccountStatusType.ACTIVE.getValue()); savingsAccount.setStatus(SavingsAccountStatusType.ACTIVE.getValue());
final MathContext mc = MathContext.DECIMAL64; final MathContext mc = MathContext.DECIMAL64;
boolean isInterestTransfer = false; boolean isInterestTransfer = false;
savingsAccount.calculateInterestUsing(mc, transferDate, isInterestTransfer, savingsAccount.calculateInterestUsing(mc, transferDate, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
financialYearBeginningMonth);
this.savingsAccountTransactionRepository.save(withdrawtransferTransaction); this.savingsAccountTransactionRepository.save(withdrawtransferTransaction);
this.savingAccountRepository.save(savingsAccount); this.savingAccountRepository.save(savingsAccount);
@@ -919,13 +893,12 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
@Override @Override
public SavingsAccountTransaction acceptSavingsTransfer(final Long accountId, final LocalDate transferDate, public SavingsAccountTransaction acceptSavingsTransfer(final Long accountId, final LocalDate transferDate,
final Office acceptedInOffice, final Staff fieldOfficer, final DepositAccountType depositAccountType) { final Office acceptedInOffice, final Staff fieldOfficer, final DepositAccountType depositAccountType) {
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
.isSavingsInterestPostingAtCurrentPeriodEnd(); .isSavingsInterestPostingAtCurrentPeriodEnd();
final Integer financialYearBeginningMonth = this.configurationDomainService final Integer financialYearBeginningMonth = this.configurationDomainService.retrieveFinancialYearBeginningMonth();
.retrieveFinancialYearBeginningMonth();
final SavingsAccount savingsAccount = this.depositAccountAssembler.assembleFrom(accountId, depositAccountType);
final SavingsAccount savingsAccount = this.depositAccountAssembler.assembleFrom(accountId, depositAccountType);
final Set<Long> existingTransactionIds = new HashSet<>(); final Set<Long> existingTransactionIds = new HashSet<>();
final Set<Long> existingReversedTransactionIds = new HashSet<>(); final Set<Long> existingReversedTransactionIds = new HashSet<>();
@@ -936,13 +909,12 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
savingsAccount.getTransactions().add(acceptTransferTransaction); savingsAccount.getTransactions().add(acceptTransferTransaction);
savingsAccount.setStatus(SavingsAccountStatusType.ACTIVE.getValue()); savingsAccount.setStatus(SavingsAccountStatusType.ACTIVE.getValue());
if (fieldOfficer != null) { if (fieldOfficer != null) {
savingsAccount.update(fieldOfficer); savingsAccount.reassignSavingsOfficer(fieldOfficer, transferDate);
} }
boolean isInterestTransfer = false; boolean isInterestTransfer = false;
final MathContext mc = MathContext.DECIMAL64; final MathContext mc = MathContext.DECIMAL64;
savingsAccount.calculateInterestUsing(mc, transferDate, isInterestTransfer, savingsAccount.calculateInterestUsing(mc, transferDate, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
financialYearBeginningMonth);
this.savingsAccountTransactionRepository.save(acceptTransferTransaction); this.savingsAccountTransactionRepository.save(acceptTransferTransaction);
this.savingAccountRepository.save(savingsAccount); this.savingAccountRepository.save(savingsAccount);
@@ -1067,11 +1039,10 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
@SuppressWarnings("unused") final DepositAccountType depositAccountType) { @SuppressWarnings("unused") final DepositAccountType depositAccountType) {
this.context.authenticatedUser(); this.context.authenticatedUser();
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
.isSavingsInterestPostingAtCurrentPeriodEnd(); .isSavingsInterestPostingAtCurrentPeriodEnd();
final Integer financialYearBeginningMonth = this.configurationDomainService final Integer financialYearBeginningMonth = this.configurationDomainService.retrieveFinancialYearBeginningMonth();
.retrieveFinancialYearBeginningMonth();
final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository.findOneWithNotFoundDetection( final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository.findOneWithNotFoundDetection(
savingsAccountChargeId, savingsAccountId); savingsAccountChargeId, savingsAccountId);
@@ -1089,14 +1060,11 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
final MathContext mc = MathContext.DECIMAL64; final MathContext mc = MathContext.DECIMAL64;
if (account.isBeforeLastPostingPeriod(savingsAccountCharge.getDueLocalDate())) { if (account.isBeforeLastPostingPeriod(savingsAccountCharge.getDueLocalDate())) {
final LocalDate today = DateUtils.getLocalDateOfTenant(); final LocalDate today = DateUtils.getLocalDateOfTenant();
account.postInterest(mc, today, isInterestTransfer, account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
isSavingsInterestPostingAtCurrentPeriodEnd,
financialYearBeginningMonth);
} else { } else {
final LocalDate today = DateUtils.getLocalDateOfTenant(); final LocalDate today = DateUtils.getLocalDateOfTenant();
account.calculateInterestUsing(mc, today, isInterestTransfer, account.calculateInterestUsing(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
financialYearBeginningMonth);
} }
account.validateAccountBalanceDoesNotBecomeNegative(SavingsApiConstants.waiveChargeTransactionAction); account.validateAccountBalanceDoesNotBecomeNegative(SavingsApiConstants.waiveChargeTransactionAction);
@@ -1200,12 +1168,11 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
@Transactional @Transactional
private void payCharge(final SavingsAccountCharge savingsAccountCharge, final LocalDate transactionDate, final BigDecimal amountPaid, private void payCharge(final SavingsAccountCharge savingsAccountCharge, final LocalDate transactionDate, final BigDecimal amountPaid,
final DateTimeFormatter formatter) { final DateTimeFormatter formatter) {
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
.isSavingsInterestPostingAtCurrentPeriodEnd(); .isSavingsInterestPostingAtCurrentPeriodEnd();
final Integer financialYearBeginningMonth = this.configurationDomainService final Integer financialYearBeginningMonth = this.configurationDomainService.retrieveFinancialYearBeginningMonth();
.retrieveFinancialYearBeginningMonth();
// Get Savings account from savings charge // Get Savings account from savings charge
final SavingsAccount account = savingsAccountCharge.savingsAccount(); final SavingsAccount account = savingsAccountCharge.savingsAccount();
this.depositAccountAssembler.assignSavingAccountHelpers(account); this.depositAccountAssembler.assignSavingAccountHelpers(account);
@@ -1217,14 +1184,11 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
final MathContext mc = MathContext.DECIMAL64; final MathContext mc = MathContext.DECIMAL64;
if (account.isBeforeLastPostingPeriod(transactionDate)) { if (account.isBeforeLastPostingPeriod(transactionDate)) {
final LocalDate today = DateUtils.getLocalDateOfTenant(); final LocalDate today = DateUtils.getLocalDateOfTenant();
account.postInterest(mc, today, isInterestTransfer, account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
isSavingsInterestPostingAtCurrentPeriodEnd,
financialYearBeginningMonth);
} else { } else {
final LocalDate today = DateUtils.getLocalDateOfTenant(); final LocalDate today = DateUtils.getLocalDateOfTenant();
account.calculateInterestUsing(mc, today, isInterestTransfer, account.calculateInterestUsing(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
financialYearBeginningMonth);
} }
account.validateAccountBalanceDoesNotBecomeNegative("." + SavingsAccountTransactionType.PAY_CHARGE.getCode()); account.validateAccountBalanceDoesNotBecomeNegative("." + SavingsAccountTransactionType.PAY_CHARGE.getCode());
@@ -1237,23 +1201,21 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
@Transactional @Transactional
@Override @Override
public void updateMaturityDetails(Long depositAccountId, DepositAccountType depositAccountType) { public void updateMaturityDetails(Long depositAccountId, DepositAccountType depositAccountType) {
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
.isSavingsInterestPostingAtCurrentPeriodEnd(); .isSavingsInterestPostingAtCurrentPeriodEnd();
final Integer financialYearBeginningMonth = this.configurationDomainService final Integer financialYearBeginningMonth = this.configurationDomainService.retrieveFinancialYearBeginningMonth();
.retrieveFinancialYearBeginningMonth();
final SavingsAccount account = this.depositAccountAssembler.assembleFrom(depositAccountId, depositAccountType); final SavingsAccount account = this.depositAccountAssembler.assembleFrom(depositAccountId, depositAccountType);
final Set<Long> existingTransactionIds = new HashSet<>(); final Set<Long> existingTransactionIds = new HashSet<>();
final Set<Long> existingReversedTransactionIds = new HashSet<>(); final Set<Long> existingReversedTransactionIds = new HashSet<>();
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds); updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
if (depositAccountType.isFixedDeposit()) { if (depositAccountType.isFixedDeposit()) {
((FixedDepositAccount) account).updateMaturityStatus(isSavingsInterestPostingAtCurrentPeriodEnd, ((FixedDepositAccount) account).updateMaturityStatus(isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
financialYearBeginningMonth);
} else if (depositAccountType.isRecurringDeposit()) { } else if (depositAccountType.isRecurringDeposit()) {
((RecurringDepositAccount) account).updateMaturityStatus(isSavingsInterestPostingAtCurrentPeriodEnd, ((RecurringDepositAccount) account).updateMaturityStatus(isSavingsInterestPostingAtCurrentPeriodEnd,
financialYearBeginningMonth); financialYearBeginningMonth);
} }
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
@@ -708,7 +708,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
savingsAccount.getTransactions().add(acceptTransferTransaction); savingsAccount.getTransactions().add(acceptTransferTransaction);
savingsAccount.setStatus(SavingsAccountStatusType.ACTIVE.getValue()); savingsAccount.setStatus(SavingsAccountStatusType.ACTIVE.getValue());
if (fieldOfficer != null) { if (fieldOfficer != null) {
savingsAccount.update(fieldOfficer); savingsAccount.reassignSavingsOfficer(fieldOfficer, transferDate);
} }
boolean isInterestTransfer = false; boolean isInterestTransfer = false;
final MathContext mc = MathContext.DECIMAL64; final MathContext mc = MathContext.DECIMAL64;