update api docs and comments on joda usuage in loan officer history.
This commit is contained in:
+615
-395
File diff suppressed because it is too large
Load Diff
+32
-22
@@ -252,7 +252,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
private boolean accountNumberRequiresAutoGeneration = false;
|
private boolean accountNumberRequiresAutoGeneration = false;
|
||||||
@Transient
|
@Transient
|
||||||
private LoanRepaymentScheduleTransactionProcessorFactory transactionProcessorFactory;
|
private LoanRepaymentScheduleTransactionProcessorFactory transactionProcessorFactory;
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
private LoanLifecycleStateMachine loanLifecycleStateMachine;
|
private LoanLifecycleStateMachine loanLifecycleStateMachine;
|
||||||
@Transient
|
@Transient
|
||||||
@@ -555,7 +555,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateSummaryWithTotalFeeChargesDueAtDisbursement(deriveSumTotalOfChargesDueAtDisbursement());
|
updateSummaryWithTotalFeeChargesDueAtDisbursement(deriveSumTotalOfChargesDueAtDisbursement());
|
||||||
|
|
||||||
existingTransactionIds.addAll(findExistingTransactionIds());
|
existingTransactionIds.addAll(findExistingTransactionIds());
|
||||||
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
|
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
|
||||||
|
|
||||||
@@ -1238,8 +1238,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
final Money totalFeeChargesDueAtDisbursement = this.summary.getTotalFeeChargesDueAtDisbursement(loanCurrency());
|
final Money totalFeeChargesDueAtDisbursement = this.summary.getTotalFeeChargesDueAtDisbursement(loanCurrency());
|
||||||
if (totalFeeChargesDueAtDisbursement.isGreaterThanZero()) {
|
if (totalFeeChargesDueAtDisbursement.isGreaterThanZero()) {
|
||||||
|
|
||||||
LoanTransaction chargesPayment = LoanTransaction.repaymentAtDisbursement(totalFeeChargesDueAtDisbursement,
|
LoanTransaction chargesPayment = LoanTransaction.repaymentAtDisbursement(totalFeeChargesDueAtDisbursement, disbursedOn);
|
||||||
disbursedOn);
|
|
||||||
Money zero = Money.zero(getCurrency());
|
Money zero = Money.zero(getCurrency());
|
||||||
chargesPayment.updateComponents(zero, zero, totalFeeChargesDueAtDisbursement, zero);
|
chargesPayment.updateComponents(zero, zero, totalFeeChargesDueAtDisbursement, zero);
|
||||||
chargesPayment.updateLoan(this);
|
chargesPayment.updateLoan(this);
|
||||||
@@ -1324,15 +1323,15 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanTransaction waiveInterest(final JsonCommand command, final LoanLifecycleStateMachine loanLifecycleStateMachine,final List<Long> existingTransactionIds,
|
public LoanTransaction waiveInterest(final JsonCommand command, final LoanLifecycleStateMachine loanLifecycleStateMachine,
|
||||||
final List<Long> existingReversedTransactionIds) {
|
final List<Long> existingTransactionIds, final List<Long> existingReversedTransactionIds) {
|
||||||
|
|
||||||
final LocalDate transactionDate = command.localDateValueOfParameterNamed("transactionDate");
|
final LocalDate transactionDate = command.localDateValueOfParameterNamed("transactionDate");
|
||||||
final BigDecimal transactionAmount = command.bigDecimalValueOfParameterNamed("transactionAmount");
|
final BigDecimal transactionAmount = command.bigDecimalValueOfParameterNamed("transactionAmount");
|
||||||
|
|
||||||
final Money amountToWaive = Money.of(loanCurrency(), transactionAmount);
|
final Money amountToWaive = Money.of(loanCurrency(), transactionAmount);
|
||||||
final LoanTransaction waiveInterestTransaction = LoanTransaction.waiver(this, amountToWaive, transactionDate);
|
final LoanTransaction waiveInterestTransaction = LoanTransaction.waiver(this, amountToWaive, transactionDate);
|
||||||
|
|
||||||
existingTransactionIds.addAll(findExistingTransactionIds());
|
existingTransactionIds.addAll(findExistingTransactionIds());
|
||||||
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
|
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
|
||||||
|
|
||||||
@@ -1702,7 +1701,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
final Money totalOutstanding = this.summary.getTotalOutstanding(loanCurrency());
|
final Money totalOutstanding = this.summary.getTotalOutstanding(loanCurrency());
|
||||||
if (totalOutstanding.isGreaterThanZero() && getInArrearsTolerance().isGreaterThanOrEqualTo(totalOutstanding)) {
|
if (totalOutstanding.isGreaterThanZero() && getInArrearsTolerance().isGreaterThanOrEqualTo(totalOutstanding)) {
|
||||||
|
|
||||||
final LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.REPAID_IN_FULL, LoanStatus.fromInt(this.loanStatus));
|
final LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.REPAID_IN_FULL,
|
||||||
|
LoanStatus.fromInt(this.loanStatus));
|
||||||
if (!statusEnum.hasStateOf(LoanStatus.fromInt(this.loanStatus))) {
|
if (!statusEnum.hasStateOf(LoanStatus.fromInt(this.loanStatus))) {
|
||||||
this.loanStatus = statusEnum.getValue();
|
this.loanStatus = statusEnum.getValue();
|
||||||
changes.put("status", LoanEnumerations.status(this.loanStatus));
|
changes.put("status", LoanEnumerations.status(this.loanStatus));
|
||||||
@@ -1727,7 +1727,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
} else if (totalOutstanding.isGreaterThanZero()) {
|
} else if (totalOutstanding.isGreaterThanZero()) {
|
||||||
final String errorMessage = "A loan with money outstanding cannot be closed";
|
final String errorMessage = "A loan with money outstanding cannot be closed";
|
||||||
throw new InvalidLoanStateTransitionException("close", "loan.has.money.outstanding", errorMessage, totalOutstanding.toString());
|
throw new InvalidLoanStateTransitionException("close", "loan.has.money.outstanding", errorMessage,
|
||||||
|
totalOutstanding.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1737,7 +1738,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
// TODO - KW - technically should set somewhere that this loan
|
// TODO - KW - technically should set somewhere that this loan
|
||||||
// has
|
// has
|
||||||
// 'overpaid' amount
|
// 'overpaid' amount
|
||||||
final LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.REPAID_IN_FULL, LoanStatus.fromInt(this.loanStatus));
|
final LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.REPAID_IN_FULL,
|
||||||
|
LoanStatus.fromInt(this.loanStatus));
|
||||||
if (!statusEnum.hasStateOf(LoanStatus.fromInt(this.loanStatus))) {
|
if (!statusEnum.hasStateOf(LoanStatus.fromInt(this.loanStatus))) {
|
||||||
this.loanStatus = statusEnum.getValue();
|
this.loanStatus = statusEnum.getValue();
|
||||||
changes.put("status", LoanEnumerations.status(this.loanStatus));
|
changes.put("status", LoanEnumerations.status(this.loanStatus));
|
||||||
@@ -1971,24 +1973,32 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
public void reassignLoanOfficer(final Staff newLoanOfficer, final LocalDate assignmentDate) {
|
public void reassignLoanOfficer(final Staff newLoanOfficer, final LocalDate assignmentDate) {
|
||||||
|
|
||||||
final LoanOfficerAssignmentHistory latestHistoryRecord = findLatestIncompleteHistoryRecord();
|
final LoanOfficerAssignmentHistory latestHistoryRecord = findLatestIncompleteHistoryRecord();
|
||||||
final LoanOfficerAssignmentHistory lastAssignmentRecordWithNoEndDate = findLastAssignmentHistoryRecord();
|
final LoanOfficerAssignmentHistory lastAssignmentRecordWithNoEndDate = findLastAssignmentHistoryRecord();
|
||||||
|
|
||||||
//assignment date should not be less than loan submitted date
|
// assignment date should not be less than loan submitted date
|
||||||
if (getSubmittedOnDate().isAfter(assignmentDate)) {
|
if (getSubmittedOnDate().isAfter(assignmentDate)) {
|
||||||
final String errorMessage = "The Loan Officer assignment date (" + assignmentDate.toString() + ") cannot be before loan submitted date (" + getSubmittedOnDate().toString() + ").";
|
final String errorMessage = "The Loan Officer assignment date (" + assignmentDate.toString()
|
||||||
throw new LoanOfficerAssignmentDateException("cannot.be.before.loan.submittal.date", errorMessage, assignmentDate, getSubmittedOnDate());
|
+ ") cannot be before loan submitted date (" + getSubmittedOnDate().toString() + ").";
|
||||||
|
throw new LoanOfficerAssignmentDateException("cannot.be.before.loan.submittal.date", errorMessage, assignmentDate,
|
||||||
|
getSubmittedOnDate());
|
||||||
|
|
||||||
//assignment date should not be less than latest unassignment date
|
// assignment date should not be less than latest unassignment date
|
||||||
|
// FIXME - rather then fetching the data from the object all the
|
||||||
|
// time e.g
|
||||||
|
// getEndDate() and asking questions of it - move the operation to
|
||||||
|
// the object e.g. obj.isEndDateAfter(date)
|
||||||
} else if (lastAssignmentRecordWithNoEndDate != null && lastAssignmentRecordWithNoEndDate.getEndDate() != null
|
} else if (lastAssignmentRecordWithNoEndDate != null && lastAssignmentRecordWithNoEndDate.getEndDate() != null
|
||||||
&& lastAssignmentRecordWithNoEndDate.getEndDate().isAfter(assignmentDate)) {
|
&& lastAssignmentRecordWithNoEndDate.getEndDate().isAfter(assignmentDate)) {
|
||||||
final String errorMessage = "The Loan Officer assignment date (" + assignmentDate + ") cannot be before previous Loan Officer unassigned date (" + lastAssignmentRecordWithNoEndDate.getEndDate() + ").";
|
final String errorMessage = "The Loan Officer assignment date (" + assignmentDate
|
||||||
throw new LoanOfficerAssignmentDateException("cannot.be.before.previous.unassignement.date", errorMessage, assignmentDate, lastAssignmentRecordWithNoEndDate.getEndDate());
|
+ ") cannot be before previous Loan Officer unassigned date (" + lastAssignmentRecordWithNoEndDate.getEndDate() + ").";
|
||||||
|
throw new LoanOfficerAssignmentDateException("cannot.be.before.previous.unassignement.date", errorMessage, assignmentDate,
|
||||||
|
lastAssignmentRecordWithNoEndDate.getEndDate());
|
||||||
|
|
||||||
//assignment date should not be in the future
|
// assignment date should not be in the future
|
||||||
} else if (DateUtils.getLocalDateOfTenant().isBefore(assignmentDate)) {
|
} else if (DateUtils.getLocalDateOfTenant().isBefore(assignmentDate)) {
|
||||||
final String errorMessage = "The Loan Officer assignment date (" + assignmentDate + ") cannot be in the future.";
|
final String errorMessage = "The Loan Officer assignment date (" + assignmentDate + ") cannot be in the future.";
|
||||||
throw new LoanOfficerAssignmentDateException("cannot.be.a.future.date", errorMessage, assignmentDate);
|
throw new LoanOfficerAssignmentDateException("cannot.be.a.future.date", errorMessage, assignmentDate);
|
||||||
}else if (latestHistoryRecord != null && this.loanOfficer.identifiedBy(newLoanOfficer)) {
|
} else if (latestHistoryRecord != null && this.loanOfficer.identifiedBy(newLoanOfficer)) {
|
||||||
latestHistoryRecord.updateStartDate(assignmentDate);
|
latestHistoryRecord.updateStartDate(assignmentDate);
|
||||||
} else if (latestHistoryRecord != null && latestHistoryRecord.matchesStartDateOf(assignmentDate)) {
|
} else if (latestHistoryRecord != null && latestHistoryRecord.matchesStartDateOf(assignmentDate)) {
|
||||||
latestHistoryRecord.updateLoanOfficer(newLoanOfficer);
|
latestHistoryRecord.updateLoanOfficer(newLoanOfficer);
|
||||||
@@ -2065,9 +2075,9 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lastAssignmentRecordWithNoEndDate == null){
|
if (lastAssignmentRecordWithNoEndDate == null) {
|
||||||
lastAssignmentRecordWithNoEndDate = historyRecord;
|
lastAssignmentRecordWithNoEndDate = historyRecord;
|
||||||
} else if(historyRecord.getEndDate().isAfter(lastAssignmentRecordWithNoEndDate.getEndDate())){
|
} else if (historyRecord.getEndDate().isAfter(lastAssignmentRecordWithNoEndDate.getEndDate())) {
|
||||||
lastAssignmentRecordWithNoEndDate = historyRecord;
|
lastAssignmentRecordWithNoEndDate = historyRecord;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2115,7 +2125,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
public Staff getLoanOfficer() {
|
public Staff getLoanOfficer() {
|
||||||
return this.loanOfficer;
|
return this.loanOfficer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanSummary getSummary() {
|
public LoanSummary getSummary() {
|
||||||
return this.summary;
|
return this.summary;
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-26
@@ -5,10 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.mifosplatform.portfolio.loanaccount.domain;
|
package org.mifosplatform.portfolio.loanaccount.domain;
|
||||||
|
|
||||||
import org.joda.time.LocalDate;
|
import java.util.Date;
|
||||||
import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom;
|
|
||||||
import org.mifosplatform.organisation.staff.domain.Staff;
|
|
||||||
import org.mifosplatform.useradministration.domain.AppUser;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
@@ -17,13 +14,17 @@ import javax.persistence.ManyToOne;
|
|||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
import java.util.Date;
|
|
||||||
|
import org.joda.time.LocalDate;
|
||||||
|
import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom;
|
||||||
|
import org.mifosplatform.organisation.staff.domain.Staff;
|
||||||
|
import org.mifosplatform.useradministration.domain.AppUser;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "m_loan_officer_assignment_history")
|
@Table(name = "m_loan_officer_assignment_history")
|
||||||
public class LoanOfficerAssignmentHistory extends AbstractAuditableCustom<AppUser, Long> {
|
public class LoanOfficerAssignmentHistory extends AbstractAuditableCustom<AppUser, Long> {
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "loan_id", nullable = false)
|
@JoinColumn(name = "loan_id", nullable = false)
|
||||||
private Loan loan;
|
private Loan loan;
|
||||||
@@ -37,7 +38,7 @@ public class LoanOfficerAssignmentHistory extends AbstractAuditableCustom<AppUse
|
|||||||
@Column(name = "start_date")
|
@Column(name = "start_date")
|
||||||
private Date startDate;
|
private Date startDate;
|
||||||
|
|
||||||
@Temporal(TemporalType.DATE)
|
@Temporal(TemporalType.DATE)
|
||||||
@Column(name = "end_date")
|
@Column(name = "end_date")
|
||||||
private Date endDate;
|
private Date endDate;
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ public class LoanOfficerAssignmentHistory extends AbstractAuditableCustom<AppUse
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected LoanOfficerAssignmentHistory() {
|
protected LoanOfficerAssignmentHistory() {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
private LoanOfficerAssignmentHistory(final Loan loan, final Staff loanOfficer, final Date startDate, final Date endDate) {
|
private LoanOfficerAssignmentHistory(final Loan loan, final Staff loanOfficer, final Date startDate, final Date endDate) {
|
||||||
@@ -56,35 +57,37 @@ public class LoanOfficerAssignmentHistory extends AbstractAuditableCustom<AppUse
|
|||||||
this.endDate = endDate;
|
this.endDate = endDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLoanOfficer(Staff loanOfficer) {
|
public void updateLoanOfficer(final Staff loanOfficer) {
|
||||||
this.loanOfficer = loanOfficer;
|
this.loanOfficer = loanOfficer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateStartDate(LocalDate startDate) {
|
public void updateStartDate(final LocalDate startDate) {
|
||||||
this.startDate = startDate.toDate();
|
this.startDate = startDate.toDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateEndDate(LocalDate endDate) {
|
public void updateEndDate(final LocalDate endDate) {
|
||||||
this.endDate = endDate.toDate();
|
this.endDate = endDate.toDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean matchesStartDateOf(final LocalDate matchingDate) {
|
public boolean matchesStartDateOf(final LocalDate matchingDate) {
|
||||||
return getStartDate().isEqual(matchingDate);
|
return getStartDate().isEqual(matchingDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDate getStartDate() {
|
|
||||||
return new LocalDate(startDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasStartDateBefore(final LocalDate matchingDate) {
|
public LocalDate getStartDate() {
|
||||||
return matchingDate.isBefore(getStartDate());
|
return new LocalDate(startDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCurrentRecord() {
|
public boolean hasStartDateBefore(final LocalDate matchingDate) {
|
||||||
return this.endDate == null;
|
return matchingDate.isBefore(getStartDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDate getEndDate() {
|
public boolean isCurrentRecord() {
|
||||||
return new LocalDate(endDate);
|
return this.endDate == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getEndDate() {
|
||||||
|
// FIXME - new LocalDate(null) will return todays date and endDate is
|
||||||
|
// likely to be null so you need to test for it.
|
||||||
|
return new LocalDate(endDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user