Merge pull request #296 from michalwisniewski/MIFOSX-328

MIFOSX-328 Loan approval date should not be earlier to the Client activa...
This commit is contained in:
Vishwas Babu A J
2013-05-16 07:33:02 -07:00
3 changed files with 27 additions and 2 deletions
@@ -367,7 +367,7 @@ public final class Client extends AbstractPersistable<Long> {
this.displayName = nameBuilder.toString();
}
private LocalDate getActivationLocalDate() {
public LocalDate getActivationLocalDate() {
LocalDate activationLocalDate = null;
if (this.activationDate != null) {
activationLocalDate = LocalDate.fromDateFields(this.activationDate);
@@ -390,4 +390,5 @@ public final class Client extends AbstractPersistable<Long> {
public Long officeId() {
return this.office.getId();
}
}
@@ -244,7 +244,7 @@ public final class Group extends AbstractPersistable<Long> {
return actualChanges;
}
private LocalDate getActivationLocalDate() {
public LocalDate getActivationLocalDate() {
LocalDate activationLocalDate = null;
if (this.activationDate != null) {
activationLocalDate = new LocalDate(this.activationDate);
@@ -942,6 +942,18 @@ public class Loan extends AbstractPersistable<Long> {
final String errorMessage = "The date on which a loan is submitted cannot be in the future.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.a.future.date", errorMessage, getSubmittedOnDate());
}
if (!(client == null)){
if (getSubmittedOnDate().isBefore(client.getActivationLocalDate())) {
final String errorMessage = "The date on which a loan is submitted cannot be earlier than client's activation date.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.client.activation.date", errorMessage, getSubmittedOnDate());
}
}else if (!(group == null)){
if (getSubmittedOnDate().isBefore(group.getActivationLocalDate())) {
final String errorMessage = "The date on which a loan is submitted cannot be earlier than groups's activation date.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.group.activation.date", errorMessage, getSubmittedOnDate());
}
}
if (getSubmittedOnDate().isAfter(getExpectedDisbursedOnLocalDate())) {
final String errorMessage = "The date on which a loan is submitted cannot be after its expected disbursement date: "
@@ -1069,6 +1081,18 @@ public class Loan extends AbstractPersistable<Long> {
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.a.future.date", errorMessage, submittedOn);
}
if (!(client == null)){
if (submittedOn.isBefore(client.getActivationLocalDate())) {
final String errorMessage = "The date on which a loan is submitted cannot be earlier than client's activation date.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.client.activation.date", errorMessage, submittedOn);
}
}else if (!(group == null)){
if (submittedOn.isBefore(group.getActivationLocalDate())) {
final String errorMessage = "The date on which a loan is submitted cannot be earlier than groups's activation date.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.group.activation.date", errorMessage, submittedOn);
}
}
if (submittedOn.isAfter(getExpectedDisbursedOnLocalDate())) {
final String errorMessage = "The date on which a loan is submitted cannot be after its expected disbursement date: "
+ getExpectedDisbursedOnLocalDate().toString();