Retrieve writeoff date for writtenoff loan

This commit is contained in:
mifoscontributer
2013-07-31 18:33:31 +05:30
parent e8975d93f4
commit 33345378d4
4 changed files with 25 additions and 7 deletions
@@ -39,6 +39,10 @@ public class LoanApplicationTimelineData {
private final String disbursedByFirstname;
private final String disbursedByLastname;
private final LocalDate expectedMaturityDate;
private final LocalDate writeOffOnDate;
private final String writeOffByUsername;
private final String writeOffByFirstname;
private final String writeOffByLastname;
public static LoanApplicationTimelineData templateDefault(final LocalDate expectedDisbursementDate) {
@@ -67,12 +71,17 @@ public class LoanApplicationTimelineData {
final String closedByFirstname = null;
final String closedByLastname = null;
final LocalDate expectedMaturityDate = null;
final LocalDate writeOffOnDate = null;
final String writeOffByUsername = null;
final String writeOffByFirstname = null;
final String writeOffByLastname = null;
return new LoanApplicationTimelineData(submittedOnDate, submittedByUsername, submittedByFirstname, submittedByLastname,
rejectedOnDate, rejectedByUsername, rejectedByFirstname, rejectedByLastname, withdrawnOnDate, withdrawnByUsername,
withdrawnByFirstname, withdrawnByLastname, approvedOnDate, approvedByUsername, approvedByFirstname, approvedByLastname,
expectedDisbursementDate, actualDisbursementDate, disbursedByUsername, disbursedByFirstname, disbursedByLastname,
closedOnDate, closedByUsername, closedByFirstname, closedByLastname, expectedMaturityDate);
closedOnDate, closedByUsername, closedByFirstname, closedByLastname, expectedMaturityDate, writeOffOnDate,
writeOffByUsername, writeOffByFirstname, writeOffByLastname);
}
public LoanApplicationTimelineData(final LocalDate submittedOnDate, final String submittedByUsername,
@@ -83,7 +92,8 @@ public class LoanApplicationTimelineData {
final String approvedByFirstname, final String approvedByLastname, final LocalDate expectedDisbursementDate,
final LocalDate actualDisbursementDate, final String disbursedByUsername, final String disbursedByFirstname,
final String disbursedByLastname, final LocalDate closedOnDate, final String closedByUsername, final String closedByFirstname,
final String closedByLastname, final LocalDate expectedMaturityDate) {
final String closedByLastname, final LocalDate expectedMaturityDate, final LocalDate writeOffOnDate,
final String writeOffByUsername, final String writeOffByFirstname, final String writeOffByLastname) {
this.submittedOnDate = submittedOnDate;
this.submittedByUsername = submittedByUsername;
this.submittedByFirstname = submittedByFirstname;
@@ -106,6 +116,10 @@ public class LoanApplicationTimelineData {
this.disbursedByFirstname = disbursedByFirstname;
this.disbursedByLastname = disbursedByLastname;
this.expectedMaturityDate = expectedMaturityDate;
this.writeOffOnDate = writeOffOnDate;
this.writeOffByUsername = writeOffByUsername;
this.writeOffByFirstname = writeOffByFirstname;
this.writeOffByLastname = writeOffByLastname;
}
public RepaymentScheduleRelatedLoanData repaymentScheduleRelatedData(final CurrencyData currency, final BigDecimal principal,
@@ -1815,7 +1815,8 @@ public class Loan extends AbstractPersistable<Long> {
}
public LoanTransaction closeAsWrittenOff(final JsonCommand command, final LoanLifecycleStateMachine loanLifecycleStateMachine,
final Map<String, Object> changes, final List<Long> existingTransactionIds, final List<Long> existingReversedTransactionIds) {
final Map<String, Object> changes, final List<Long> existingTransactionIds, final List<Long> existingReversedTransactionIds,
final AppUser currentUser) {
final LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.WRITE_OFF_OUTSTANDING,
LoanStatus.fromInt(this.loanStatus));
@@ -1832,6 +1833,7 @@ public class Loan extends AbstractPersistable<Long> {
this.closedOnDate = writtenOffOnLocalDate.toDate();
this.writtenOffOnDate = writtenOffOnLocalDate.toDate();
this.closedBy = currentUser;
changes.put("closedOnDate", command.stringValueOfParameterNamed("transactionDate"));
changes.put("writtenOffOnDate", command.stringValueOfParameterNamed("transactionDate"));
@@ -398,7 +398,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
+ " l.withdrawnon_date as withdrawnOnDate, wbu.username as withdrawnByUsername, wbu.firstname as withdrawnByFirstname, wbu.lastname as withdrawnByLastname,"
+ " l.approvedon_date as approvedOnDate, abu.username as approvedByUsername, abu.firstname as approvedByFirstname, abu.lastname as approvedByLastname,"
+ " l.expected_disbursedon_date as expectedDisbursementDate, l.disbursedon_date as actualDisbursementDate, dbu.username as disbursedByUsername, dbu.firstname as disbursedByFirstname, dbu.lastname as disbursedByLastname,"
+ " l.closedon_date as closedOnDate, cbu.username as closedByUsername, cbu.firstname as closedByFirstname, cbu.lastname as closedByLastname,"
+ " l.closedon_date as closedOnDate, cbu.username as closedByUsername, cbu.firstname as closedByFirstname, cbu.lastname as closedByLastname, l.writtenoffon_date as writtenOffOnDate, "
+ " l.expected_firstrepaymenton_date as expectedFirstRepaymentOnDate, l.interest_calculated_from_date as interestChargedFromDate, l.expected_maturedon_date as expectedMaturityDate, "
+ " l.principal_amount as principal, l.arrearstolerance_amount as inArrearsTolerance, l.number_of_repayments as numberOfRepayments, l.repay_every as repaymentEvery,"
+ " l.grace_on_principal_periods as graceOnPrincipalPayment, l.grace_on_interest_periods as graceOnInterestPayment, l.grace_interest_free_periods as graceOnInterestCharged,"
@@ -538,6 +538,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final String closedByFirstname = rs.getString("closedByFirstname");
final String closedByLastname = rs.getString("closedByLastname");
final LocalDate writtenOffOnDate = JdbcSupport.getLocalDate(rs, "writtenOffOnDate");
final LocalDate expectedMaturityDate = JdbcSupport.getLocalDate(rs, "expectedMaturityDate");
final LoanApplicationTimelineData timeline = new LoanApplicationTimelineData(submittedOnDate, submittedByUsername,
@@ -545,7 +547,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
withdrawnOnDate, withdrawnByUsername, withdrawnByFirstname, withdrawnByLastname, approvedOnDate, approvedByUsername,
approvedByFirstname, approvedByLastname, expectedDisbursementDate, actualDisbursementDate, disbursedByUsername,
disbursedByFirstname, disbursedByLastname, closedOnDate, closedByUsername, closedByFirstname, closedByLastname,
expectedMaturityDate);
expectedMaturityDate, writtenOffOnDate, closedByUsername, closedByFirstname, closedByLastname);
final BigDecimal principal = rs.getBigDecimal("principal");
final BigDecimal totalOverpaid = rs.getBigDecimal("totalOverpaid");
@@ -607,7 +607,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
@Transactional
@Override
public CommandProcessingResult writeOff(final Long loanId, final JsonCommand command) {
context.authenticatedUser();
final AppUser currentUser = this.context.authenticatedUser();
this.loanEventApiJsonValidator.validateTransactionWithNoAmount(command.json());
@@ -622,7 +622,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final List<Long> existingTransactionIds = new ArrayList<Long>();
final List<Long> existingReversedTransactionIds = new ArrayList<Long>();
final LoanTransaction writeoff = loan.closeAsWrittenOff(command, defaultLoanLifecycleStateMachine(), changes,
existingTransactionIds, existingReversedTransactionIds);
existingTransactionIds, existingReversedTransactionIds, currentUser);
this.loanTransactionRepository.save(writeoff);
this.loanRepository.save(loan);