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