add behaviour for checking if accounting enabled for loan product to loan and product rather than ask for data each time.
This commit is contained in:
+1
-1
@@ -130,7 +130,7 @@ public class GLJournalEntryWritePlatformServiceJpaRepositoryImpl implements GLJo
|
|||||||
// shouldn't be before an accounting closure
|
// shouldn't be before an accounting closure
|
||||||
GLClosure latestGLClosure = glClosureRepository.getLatestGLClosureByBranch(loan.getOfficeId());
|
GLClosure latestGLClosure = glClosureRepository.getLatestGLClosureByBranch(loan.getOfficeId());
|
||||||
Office office = loan.getClient().getOffice();
|
Office office = loan.getClient().getOffice();
|
||||||
Long loanProductId = loan.loanProduct().getId();
|
Long loanProductId = loan.productId();
|
||||||
// TODO: Check for accounting type
|
// TODO: Check for accounting type
|
||||||
for (LoanTransaction loanTransaction : loanTransactions) {
|
for (LoanTransaction loanTransaction : loanTransactions) {
|
||||||
Date entryDate = loanTransaction.getDateOf();
|
Date entryDate = loanTransaction.getDateOf();
|
||||||
|
|||||||
+8
-5
@@ -495,10 +495,6 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
return this.client;
|
return this.client;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanProduct loanProduct() {
|
|
||||||
return this.loanProduct;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoanProductRelatedDetail repaymentScheduleDetail() {
|
public LoanProductRelatedDetail repaymentScheduleDetail() {
|
||||||
return this.loanRepaymentScheduleDetail;
|
return this.loanRepaymentScheduleDetail;
|
||||||
}
|
}
|
||||||
@@ -2003,5 +1999,12 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
public List<LoanTransaction> getLoanTransactions() {
|
public List<LoanTransaction> getLoanTransactions() {
|
||||||
return this.loanTransactions;
|
return this.loanTransactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAccountingEnabledOnLoanProduct() {
|
||||||
|
return this.loanProduct.isAccountingEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long productId() {
|
||||||
|
return this.loanProduct.getId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+12
-13
@@ -45,7 +45,6 @@ import org.mifosplatform.portfolio.loanaccount.exception.LoanTransactionNotFound
|
|||||||
import org.mifosplatform.portfolio.loanaccount.serialization.LoanChargeCommandFromApiJsonDeserializer;
|
import org.mifosplatform.portfolio.loanaccount.serialization.LoanChargeCommandFromApiJsonDeserializer;
|
||||||
import org.mifosplatform.portfolio.loanaccount.serialization.LoanStateTransitionCommandFromApiJsonDeserializer;
|
import org.mifosplatform.portfolio.loanaccount.serialization.LoanStateTransitionCommandFromApiJsonDeserializer;
|
||||||
import org.mifosplatform.portfolio.loanaccount.serialization.LoanTransactionCommandFromApiJsonDeserializer;
|
import org.mifosplatform.portfolio.loanaccount.serialization.LoanTransactionCommandFromApiJsonDeserializer;
|
||||||
import org.mifosplatform.portfolio.loanproduct.domain.AccountingRuleType;
|
|
||||||
import org.mifosplatform.portfolio.loanproduct.exception.InvalidCurrencyException;
|
import org.mifosplatform.portfolio.loanproduct.exception.InvalidCurrencyException;
|
||||||
import org.mifosplatform.useradministration.domain.AppUser;
|
import org.mifosplatform.useradministration.domain.AppUser;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -119,12 +118,12 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
|
|
||||||
final ApplicationCurrency currency = this.applicationCurrencyRepository.findOneByCode(loan.getPrincpal().getCurrencyCode());
|
final ApplicationCurrency currency = this.applicationCurrencyRepository.findOneByCode(loan.getPrincpal().getCurrencyCode());
|
||||||
|
|
||||||
|
|
||||||
final Map<String, Object> changes = loan.disburse(command, defaultLoanLifecycleStateMachine(), currency);
|
final Map<String, Object> changes = loan.disburse(command, defaultLoanLifecycleStateMachine(), currency);
|
||||||
//variable stores Id's of all existing loan transactions (newly created loan transactions would not have an Id before save)
|
// variable stores Id's of all existing loan transactions (newly created
|
||||||
|
// loan transactions would not have an Id before save)
|
||||||
Set<Long> existingLoanTransactionIds = new HashSet<Long>();
|
Set<Long> existingLoanTransactionIds = new HashSet<Long>();
|
||||||
for(LoanTransaction loanTransaction:loan.getLoanTransactions()){
|
for (LoanTransaction loanTransaction : loan.getLoanTransactions()) {
|
||||||
if(loanTransaction.getId()==null){
|
if (loanTransaction.getId() == null) {
|
||||||
existingLoanTransactionIds.add(loanTransaction.getId());
|
existingLoanTransactionIds.add(loanTransaction.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,16 +133,16 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
Note note = Note.loanNote(loan, noteText);
|
Note note = Note.loanNote(loan, noteText);
|
||||||
this.noteRepository.save(note);
|
this.noteRepository.save(note);
|
||||||
}
|
}
|
||||||
|
|
||||||
// make a call to accounting
|
// make a call to accounting
|
||||||
if (loan.loanProduct().getAccountingType() != AccountingRuleType.NONE.getValue()) {
|
if (loan.isAccountingEnabledOnLoanProduct()) {
|
||||||
/***
|
/***
|
||||||
* Variable holds list of all newly created loan transactions during this
|
* Variable holds list of all newly created loan transactions during
|
||||||
* disbursal
|
* this disbursal
|
||||||
**/
|
**/
|
||||||
List<LoanTransaction> newLoanTransactions = new ArrayList<LoanTransaction>();
|
List<LoanTransaction> newLoanTransactions = new ArrayList<LoanTransaction>();
|
||||||
for(LoanTransaction loanTransaction:loan.getLoanTransactions()){
|
for (LoanTransaction loanTransaction : loan.getLoanTransactions()) {
|
||||||
if(!existingLoanTransactionIds.contains(loanTransaction.getId())){
|
if (!existingLoanTransactionIds.contains(loanTransaction.getId())) {
|
||||||
newLoanTransactions.add(loanTransaction);
|
newLoanTransactions.add(loanTransaction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,9 +223,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
|
|
||||||
changes.put("locale", command.locale());
|
changes.put("locale", command.locale());
|
||||||
changes.put("dateFormat", command.dateFormat());
|
changes.put("dateFormat", command.dateFormat());
|
||||||
|
|
||||||
// make a call to accounting
|
// make a call to accounting
|
||||||
if (loan.loanProduct().getAccountingType() != AccountingRuleType.NONE.getValue()) {
|
if (loan.isAccountingEnabledOnLoanProduct()) {
|
||||||
journalEntryWritePlatformService.createJournalEntriesForLoan(loan, loanRepayment);
|
journalEntryWritePlatformService.createJournalEntriesForLoan(loan, loanRepayment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-2
@@ -146,7 +146,7 @@ public class LoanProduct extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
public void update(final Set<Charge> charges) {
|
public void update(final Set<Charge> charges) {
|
||||||
this.charges = charges;
|
this.charges = charges;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getAccountingType() {
|
public Integer getAccountingType() {
|
||||||
return this.accountingType;
|
return this.accountingType;
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ public class LoanProduct extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
actualChanges.put(accountingTypeParamName, newValue);
|
actualChanges.put(accountingTypeParamName, newValue);
|
||||||
this.accountingType = newValue;
|
this.accountingType = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String nameParamName = "name";
|
final String nameParamName = "name";
|
||||||
if (command.isChangeInStringParameterNamed(nameParamName, this.name)) {
|
if (command.isChangeInStringParameterNamed(nameParamName, this.name)) {
|
||||||
final String newValue = command.stringValueOfParameterNamed(nameParamName);
|
final String newValue = command.stringValueOfParameterNamed(nameParamName);
|
||||||
@@ -216,4 +216,8 @@ public class LoanProduct extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
|
|
||||||
return chargeIds.toArray(new String[chargeIds.size()]);
|
return chargeIds.toArray(new String[chargeIds.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAccountingEnabled() {
|
||||||
|
return AccountingRuleType.NONE.getValue().equals(this.accountingType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user