wip: updates to accounting documentation
This commit is contained in:
+1
@@ -61,6 +61,7 @@ public class GLClosureData {
|
||||
this.lastUpdatedByUserId = lastUpdatedByUserId;
|
||||
this.lastUpdatedByUsername = lastUpdatedByUsername;
|
||||
this.comments = comments;
|
||||
this.allowedOffices = null;
|
||||
}
|
||||
|
||||
public List<OfficeLookup> getAllowedOffices() {
|
||||
|
||||
+2
-4
@@ -23,7 +23,6 @@ import org.mifosplatform.accounting.closure.api.GLClosureJsonInputParams;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom;
|
||||
import org.mifosplatform.organisation.office.domain.Office;
|
||||
import org.mifosplatform.portfolio.loanaccount.guarantor.GuarantorConstants.GUARANTOR_JSON_INPUT_PARAMS;
|
||||
import org.mifosplatform.useradministration.domain.AppUser;
|
||||
|
||||
@Entity
|
||||
@@ -65,7 +64,7 @@ public class GLClosure extends AbstractAuditableCustom<AppUser, Long> {
|
||||
|
||||
public static GLClosure fromJson(Office office, final JsonCommand command) {
|
||||
Date closingDate = command.DateValueOfParameterNamed(GLClosureJsonInputParams.CLOSING_DATE.getValue());
|
||||
String comments = command.stringValueOfParameterNamed(GUARANTOR_JSON_INPUT_PARAMS.COMMENT.getValue());
|
||||
String comments = command.stringValueOfParameterNamed(GLClosureJsonInputParams.COMMENTS.getValue());
|
||||
return new GLClosure(office, closingDate, comments);
|
||||
}
|
||||
|
||||
@@ -80,9 +79,8 @@ public class GLClosure extends AbstractAuditableCustom<AppUser, Long> {
|
||||
if (command.isChangeInStringParameterNamed(paramName, propertyToBeUpdated)) {
|
||||
final String newValue = command.stringValueOfParameterNamed(paramName);
|
||||
actualChanges.put(paramName, newValue);
|
||||
propertyToBeUpdated = newValue;
|
||||
// now update actual property
|
||||
if (paramName.equals(GUARANTOR_JSON_INPUT_PARAMS.COMMENT.getValue())) {
|
||||
if (paramName.equals(GLClosureJsonInputParams.COMMENTS.getValue())) {
|
||||
this.comments = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ public class GLClosureWritePlatformServiceJpaRepositoryImpl implements GLClosure
|
||||
}
|
||||
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withOfficeId(glClosure.getOffice().getId())
|
||||
.withEntityId(glClosure.getId()).build();
|
||||
.withEntityId(glClosure.getId()).with(changesOnly).build();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
-8
@@ -121,8 +121,6 @@ public class GLAccount extends AbstractPersistable<Long> {
|
||||
newValue = command.integerValueOfParameterNamed(paramName);
|
||||
}
|
||||
actualChanges.put(paramName, newValue);
|
||||
propertyToBeUpdated = newValue;
|
||||
|
||||
// now update actual property
|
||||
if (paramName.equals(GLAccountJsonInputParams.TYPE.getValue())) {
|
||||
this.type = newValue;
|
||||
@@ -137,8 +135,6 @@ public class GLAccount extends AbstractPersistable<Long> {
|
||||
if (command.isChangeInStringParameterNamed(paramName, propertyToBeUpdated)) {
|
||||
final String newValue = command.stringValueOfParameterNamed(paramName);
|
||||
actualChanges.put(paramName, newValue);
|
||||
propertyToBeUpdated = newValue;
|
||||
|
||||
// now update actual property
|
||||
if (paramName.equals(GLAccountJsonInputParams.DESCRIPTION.getValue())) {
|
||||
this.description = newValue;
|
||||
@@ -155,8 +151,6 @@ public class GLAccount extends AbstractPersistable<Long> {
|
||||
if (command.isChangeInLongParameterNamed(paramName, propertyToBeUpdated)) {
|
||||
final Long newValue = command.longValueOfParameterNamed(paramName);
|
||||
actualChanges.put(paramName, newValue);
|
||||
propertyToBeUpdated = newValue;
|
||||
|
||||
// now update actual property
|
||||
if (paramName.equals(GLAccountJsonInputParams.PARENT_ID.getValue())) {
|
||||
// do nothing as this is a nested property
|
||||
@@ -169,8 +163,6 @@ public class GLAccount extends AbstractPersistable<Long> {
|
||||
if (command.isChangeInBooleanParameterNamed(paramName, propertyToBeUpdated)) {
|
||||
final Boolean newValue = command.booleanObjectValueOfParameterNamed(paramName);
|
||||
actualChanges.put(paramName, newValue);
|
||||
propertyToBeUpdated = newValue;
|
||||
|
||||
// now update actual property
|
||||
if (paramName.equals(GLAccountJsonInputParams.MANUAL_ENTRIES_ALLOWED.getValue())) {
|
||||
this.manualEntriesAllowed = newValue;
|
||||
|
||||
+8
-3
@@ -1106,7 +1106,7 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
||||
handleDisbursementTransaction(expectedDisbursedOnLocalDate);
|
||||
}
|
||||
|
||||
public Map<String, Object> deriveDisbursementData(final CurrencyData currencyData) {
|
||||
public Map<String, Object> deriveDisbursementData(final CurrencyData currencyData, final List<Long> existingTransactionIds) {
|
||||
|
||||
final Map<String, Object> accountingBridgeData = new LinkedHashMap<String, Object>(20);
|
||||
|
||||
@@ -1119,7 +1119,9 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
||||
final List<Map<String, Object>> newLoanTransactions = new ArrayList<Map<String, Object>>();
|
||||
final List<LoanTransaction> disbursementTransactions = findDisbursementTransactions();
|
||||
for (LoanTransaction loanTransaction : disbursementTransactions) {
|
||||
newLoanTransactions.add(loanTransaction.toMapData(currencyData));
|
||||
if (!existingTransactionIds.contains(loanTransaction.getId())) {
|
||||
newLoanTransactions.add(loanTransaction.toMapData(currencyData));
|
||||
}
|
||||
}
|
||||
|
||||
accountingBridgeData.put("newLoanTransactions", newLoanTransactions);
|
||||
@@ -1150,7 +1152,8 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
||||
}
|
||||
|
||||
public Map<String, Object> disburse(final AppUser currentUser, final JsonCommand command,
|
||||
final LoanLifecycleStateMachine loanLifecycleStateMachine, final ApplicationCurrency currency) {
|
||||
final LoanLifecycleStateMachine loanLifecycleStateMachine, final ApplicationCurrency currency,
|
||||
final List<Long> existingTransactionIds) {
|
||||
|
||||
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>();
|
||||
|
||||
@@ -1183,6 +1186,8 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
||||
if (isRepaymentScheduleRegenerationRequiredForDisbursement(disbursedOn)) {
|
||||
regenerateRepaymentSchedule(currency);
|
||||
}
|
||||
|
||||
existingTransactionIds.addAll(findExistingTransactionIds());
|
||||
}
|
||||
|
||||
return actualChanges;
|
||||
|
||||
+10
-4
@@ -130,7 +130,13 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
|
||||
final ApplicationCurrency currency = this.applicationCurrencyRepository.findOneByCode(loan.getPrincpal().getCurrencyCode());
|
||||
|
||||
final Map<String, Object> changes = loan.disburse(currentUser, command, defaultLoanLifecycleStateMachine(), currency);
|
||||
/***
|
||||
* In cases where an "Undo disbursement is done and the loan is
|
||||
* disbursed again, we need to ensure the old transactions are entered
|
||||
* again in accounting
|
||||
***/
|
||||
final List<Long> existingTransactionIds = new ArrayList<Long>();
|
||||
final Map<String, Object> changes = loan.disburse(currentUser, command, defaultLoanLifecycleStateMachine(), currency, existingTransactionIds);
|
||||
if (!changes.isEmpty()) {
|
||||
this.loanRepository.save(loan);
|
||||
|
||||
@@ -139,7 +145,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
final Map<String, Object> accountingBridgeData = loan.deriveDisbursementData(currency.toData());
|
||||
final Map<String, Object> accountingBridgeData = loan.deriveDisbursementData(currency.toData(), existingTransactionIds);
|
||||
journalEntryWritePlatformService.createJournalEntriesForLoan(accountingBridgeData);
|
||||
}
|
||||
|
||||
@@ -271,10 +277,10 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
final LoanTransaction newTransactionDetail = loan.adjustExistingTransaction(transactionDate, transactionAmount,
|
||||
defaultLoanLifecycleStateMachine(), transactionToAdjust);
|
||||
if (newTransactionDetail.isGreaterThanZero(loan.getPrincpal().getCurrency())) {
|
||||
this.loanTransactionRepository.save(newTransactionDetail);
|
||||
this.loanTransactionRepository.saveAndFlush(newTransactionDetail);
|
||||
}
|
||||
|
||||
this.loanRepository.save(loan);
|
||||
this.loanRepository.saveAndFlush(loan);
|
||||
|
||||
final String noteText = command.stringValueOfParameterNamed("note");
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
|
||||
Reference in New Issue
Block a user