update tomcat plugin, handle change of disbursement date when modifying loan application for now.

This commit is contained in:
Keith Woodlock
2012-10-20 14:11:55 +01:00
parent 09165cbb04
commit 0b55ef9149
3 changed files with 22 additions and 8 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ buildscript {
}
dependencies {
classpath 'bmuschko:gradle-tomcat-plugin:0.9.3'
classpath 'bmuschko:gradle-tomcat-plugin:0.9.5'
}
}
@@ -274,7 +274,8 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
public void modifyLoanApplication(final LoanApplicationCommand command, final Client client, final LoanProduct loanProduct,
final Fund fund, final LoanTransactionProcessingStrategy strategy, final LoanScheduleData modifiedLoanSchedule, final Set<LoanCharge> charges,
final Staff loanOfficer) {
final Staff loanOfficer,
final LoanLifecycleStateMachine loanLifecycleStateMachine) {
if (command.isClientChanged()) {
this.client = client;
@@ -307,6 +308,8 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
if (command.isExpectedDisbursementDateChanged()) {
if (command.getExpectedDisbursementDate() != null) {
this.expectedDisbursedOnDate = command.getExpectedDisbursementDate().toDate();
removeFirstDisbursementTransaction();
disburse(command.getExpectedDisbursementDate(), loanLifecycleStateMachine, false);
} else {
this.expectedDisbursedOnDate = null;
}
@@ -358,6 +361,15 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
loanRepaymentScheduleTransactionProcessor.handleTransaction(repaymentsOrWaivers, getCurrency(), this.repaymentScheduleInstallments);
}
private void removeFirstDisbursementTransaction() {
for (LoanTransaction loanTransaction : loanTransactions) {
if (loanTransaction.isDisbursement()) {
loanTransactions.remove(loanTransaction);
break;
}
}
}
public void submitApplication(
final Integer loanTermFrequency,
final PeriodFrequencyType loanTermFrequencyType,
@@ -502,13 +514,15 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
modifiedInstallment.updateLoan(this);
this.repaymentScheduleInstallments.add(modifiedInstallment);
}
disburse(disbursedOn, loanLifecycleStateMachine);
disburse(disbursedOn, loanLifecycleStateMachine, true);
}
public void disburse(final LocalDate disbursedOn, final LoanLifecycleStateMachine loanLifecycleStateMachine) {
public void disburse(final LocalDate disbursedOn, final LoanLifecycleStateMachine loanLifecycleStateMachine, final boolean statusTransition) {
LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.LOAN_DISBURSED, LoanStatus.fromInt(this.loanStatus));
this.loanStatus = statusEnum.getValue();
if (statusTransition) {
LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.LOAN_DISBURSED, LoanStatus.fromInt(this.loanStatus));
this.loanStatus = statusEnum.getValue();
}
this.disbursedOnDate = disbursedOn.toDateTimeAtCurrentTime().toDate();
this.expectedMaturityDate = this.repaymentScheduleInstallments
@@ -163,7 +163,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Set<LoanCharge> charges = this.loanChargeAssembler.assembleFrom(command.getCharges(), loanProduct.getCharges(), loan.getPrincpal().getAmount());
final LoanScheduleData loanSchedule = this.calculationPlatformService.calculateLoanScheduleNew(command.toCalculateLoanScheduleCommand());
loan.modifyLoanApplication(command, client, loanProduct, fund, strategy, loanSchedule, charges, loanOfficer);
loan.modifyLoanApplication(command, client, loanProduct, fund, strategy, loanSchedule, charges, loanOfficer, defaultLoanLifecycleStateMachine());
this.loanRepository.save(loan);
@@ -391,7 +391,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
}
loan.disburseWithModifiedRepaymentSchedule(actualDisbursementDate, modifiedLoanRepaymentSchedule, defaultLoanLifecycleStateMachine());
} else {
loan.disburse(actualDisbursementDate, defaultLoanLifecycleStateMachine());
loan.disburse(actualDisbursementDate, defaultLoanLifecycleStateMachine(), true);
}
this.loanRepository.save(loan);