tidy up new loan data returned for submit loan flow and ensure locale is posted for forms with numbers and monetary values in them.
This commit is contained in:
@@ -4,63 +4,30 @@ import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
import org.codehaus.jackson.map.annotate.JsonFilter;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.data.LoanSchedule;
|
||||
|
||||
@JsonIgnoreProperties({ "organisationId", "organisationName" })
|
||||
@JsonFilter("myFilter")
|
||||
public class NewLoanData implements Serializable {
|
||||
|
||||
private Long organisationId;
|
||||
private String organisationName;
|
||||
private Long clientId;
|
||||
private String clientName;
|
||||
private Long productId;
|
||||
private String productName;
|
||||
|
||||
private List<LoanProductLookup> allowedProducts = new ArrayList<LoanProductLookup>();
|
||||
|
||||
// extra
|
||||
private String dateFormat;
|
||||
private String submittedOnDateFormatted;
|
||||
private LocalDate submittedOnDate;
|
||||
private String submittedOnNote = "";
|
||||
|
||||
private String expectedDisbursementDateFormatted;
|
||||
private LocalDate expectedDisbursementDate = new LocalDate();
|
||||
|
||||
private String repaymentsStartingFromDateFormatted;
|
||||
private LocalDate repaymentsStartingFromDate;
|
||||
|
||||
private String interestCalculatedFromDateFormatted;
|
||||
private LocalDate interestCalculatedFromDate;
|
||||
private LoanProductData selectedProduct;
|
||||
|
||||
private LocalDate expectedDisbursementDate;
|
||||
|
||||
private LoanSchedule repaymentSchedule;
|
||||
|
||||
private LoanProductData selectedProduct;
|
||||
|
||||
|
||||
private List<LoanProductLookup> allowedProducts = new ArrayList<LoanProductLookup>();
|
||||
|
||||
public NewLoanData() {
|
||||
//
|
||||
}
|
||||
|
||||
public Long getOrganisationId() {
|
||||
return organisationId;
|
||||
}
|
||||
|
||||
public void setOrganisationId(Long organisationId) {
|
||||
this.organisationId = organisationId;
|
||||
}
|
||||
|
||||
public String getOrganisationName() {
|
||||
return organisationName;
|
||||
}
|
||||
|
||||
public void setOrganisationName(String organisationName) {
|
||||
this.organisationName = organisationName;
|
||||
}
|
||||
|
||||
public Long getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
@@ -101,22 +68,6 @@ public class NewLoanData implements Serializable {
|
||||
this.allowedProducts = allowedProducts;
|
||||
}
|
||||
|
||||
public LocalDate getSubmittedOnDate() {
|
||||
return submittedOnDate;
|
||||
}
|
||||
|
||||
public void setSubmittedOnDate(LocalDate submittedOnDate) {
|
||||
this.submittedOnDate = submittedOnDate;
|
||||
}
|
||||
|
||||
public String getSubmittedOnNote() {
|
||||
return submittedOnNote;
|
||||
}
|
||||
|
||||
public void setSubmittedOnNote(String submittedOnNote) {
|
||||
this.submittedOnNote = submittedOnNote;
|
||||
}
|
||||
|
||||
public LoanProductData getSelectedProduct() {
|
||||
return selectedProduct;
|
||||
}
|
||||
@@ -125,32 +76,6 @@ public class NewLoanData implements Serializable {
|
||||
this.selectedProduct = selectedProduct;
|
||||
}
|
||||
|
||||
public LocalDate getExpectedDisbursementDate() {
|
||||
return expectedDisbursementDate;
|
||||
}
|
||||
|
||||
public void setExpectedDisbursementDate(LocalDate expectedDisbursementDate) {
|
||||
this.expectedDisbursementDate = expectedDisbursementDate;
|
||||
}
|
||||
|
||||
public LocalDate getRepaymentsStartingFromDate() {
|
||||
return repaymentsStartingFromDate;
|
||||
}
|
||||
|
||||
public void setRepaymentsStartingFromDate(
|
||||
LocalDate repaymentsStartingFromDate) {
|
||||
this.repaymentsStartingFromDate = repaymentsStartingFromDate;
|
||||
}
|
||||
|
||||
public LocalDate getInterestCalculatedFromDate() {
|
||||
return interestCalculatedFromDate;
|
||||
}
|
||||
|
||||
public void setInterestCalculatedFromDate(
|
||||
LocalDate interestCalculatedFromDate) {
|
||||
this.interestCalculatedFromDate = interestCalculatedFromDate;
|
||||
}
|
||||
|
||||
public LoanSchedule getRepaymentSchedule() {
|
||||
return repaymentSchedule;
|
||||
}
|
||||
@@ -159,46 +84,11 @@ public class NewLoanData implements Serializable {
|
||||
this.repaymentSchedule = repaymentSchedule;
|
||||
}
|
||||
|
||||
public String getDateFormat() {
|
||||
return dateFormat;
|
||||
public LocalDate getExpectedDisbursementDate() {
|
||||
return expectedDisbursementDate;
|
||||
}
|
||||
|
||||
public void setDateFormat(String dateFormat) {
|
||||
this.dateFormat = dateFormat;
|
||||
}
|
||||
|
||||
public String getSubmittedOnDateFormatted() {
|
||||
return submittedOnDateFormatted;
|
||||
}
|
||||
|
||||
public void setSubmittedOnDateFormatted(String submittedOnDateFormatted) {
|
||||
this.submittedOnDateFormatted = submittedOnDateFormatted;
|
||||
}
|
||||
|
||||
public String getExpectedDisbursementDateFormatted() {
|
||||
return expectedDisbursementDateFormatted;
|
||||
}
|
||||
|
||||
public void setExpectedDisbursementDateFormatted(
|
||||
String expectedDisbursementDateFormatted) {
|
||||
this.expectedDisbursementDateFormatted = expectedDisbursementDateFormatted;
|
||||
}
|
||||
|
||||
public String getRepaymentsStartingFromDateFormatted() {
|
||||
return repaymentsStartingFromDateFormatted;
|
||||
}
|
||||
|
||||
public void setRepaymentsStartingFromDateFormatted(
|
||||
String repaymentsStartingFromDateFormatted) {
|
||||
this.repaymentsStartingFromDateFormatted = repaymentsStartingFromDateFormatted;
|
||||
}
|
||||
|
||||
public String getInterestCalculatedFromDateFormatted() {
|
||||
return interestCalculatedFromDateFormatted;
|
||||
}
|
||||
|
||||
public void setInterestCalculatedFromDateFormatted(
|
||||
String interestCalculatedFromDateFormatted) {
|
||||
this.interestCalculatedFromDateFormatted = interestCalculatedFromDateFormatted;
|
||||
public void setExpectedDisbursementDate(LocalDate expectedDisbursementDate) {
|
||||
this.expectedDisbursementDate = expectedDisbursementDate;
|
||||
}
|
||||
}
|
||||
+14
-31
@@ -22,7 +22,6 @@ import org.mifosng.platform.currency.domain.ApplicationCurrencyRepository;
|
||||
import org.mifosng.platform.currency.domain.Money;
|
||||
import org.mifosng.platform.exceptions.CurrencyNotFoundException;
|
||||
import org.mifosng.platform.exceptions.LoanNotFoundException;
|
||||
import org.mifosng.platform.exceptions.LoanProductNotFoundException;
|
||||
import org.mifosng.platform.exceptions.LoanTransactionNotFoundException;
|
||||
import org.mifosng.platform.loan.domain.Loan;
|
||||
import org.mifosng.platform.loan.domain.LoanRepository;
|
||||
@@ -176,60 +175,44 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NewLoanData retrieveClientAndProductDetails(final Long clientId,
|
||||
final Long productId) {
|
||||
public NewLoanData retrieveClientAndProductDetails(final Long clientId, final Long productId) {
|
||||
|
||||
AppUser currentUser = context.authenticatedUser();
|
||||
context.authenticatedUser();
|
||||
|
||||
NewLoanData workflowData = new NewLoanData();
|
||||
workflowData.setOrganisationId(currentUser.getOrganisation().getId());
|
||||
workflowData.setOrganisationName(currentUser.getOrganisation()
|
||||
.getName());
|
||||
|
||||
Collection<LoanProductLookup> loanProducts = this.loanProductReadPlatformService
|
||||
.retrieveAllLoanProductsForLookup();
|
||||
workflowData.setAllowedProducts(new ArrayList<LoanProductLookup>(
|
||||
loanProducts));
|
||||
Collection<LoanProductLookup> loanProducts = this.loanProductReadPlatformService.retrieveAllLoanProductsForLookup();
|
||||
workflowData.setAllowedProducts(new ArrayList<LoanProductLookup>(loanProducts));
|
||||
|
||||
if (loanProducts.size() == 1) {
|
||||
Long allowedProductId = workflowData.getAllowedProducts().get(0)
|
||||
.getId();
|
||||
LoanProductData selectedProduct = this.loanProductReadPlatformService
|
||||
.retrieveLoanProduct(allowedProductId);
|
||||
if (selectedProduct == null) {
|
||||
throw new LoanProductNotFoundException(allowedProductId);
|
||||
}
|
||||
Long allowedProductId = workflowData.getAllowedProducts().get(0).getId();
|
||||
LoanProductData selectedProduct = this.loanProductReadPlatformService.retrieveLoanProduct(allowedProductId);
|
||||
|
||||
workflowData.setProductId(selectedProduct.getId());
|
||||
workflowData.setProductName(selectedProduct.getName());
|
||||
workflowData.setSelectedProduct(selectedProduct);
|
||||
} else {
|
||||
LoanProductData selectedProduct = findLoanProductById(loanProducts,
|
||||
productId);
|
||||
if (selectedProduct == null) {
|
||||
throw new LoanProductNotFoundException(productId);
|
||||
}
|
||||
LoanProductData selectedProduct = findLoanProductById(loanProducts, productId);
|
||||
|
||||
workflowData.setProductId(selectedProduct.getId());
|
||||
workflowData.setProductName(selectedProduct.getName());
|
||||
workflowData.setSelectedProduct(selectedProduct);
|
||||
}
|
||||
|
||||
ClientData clientAccount = this.clientReadPlatformService
|
||||
.retrieveIndividualClient(clientId);
|
||||
ClientData clientAccount = this.clientReadPlatformService.retrieveIndividualClient(clientId);
|
||||
workflowData.setClientId(clientAccount.getId());
|
||||
workflowData.setClientName(clientAccount.getDisplayName());
|
||||
|
||||
workflowData.setExpectedDisbursementDate(new LocalDate());
|
||||
|
||||
return workflowData;
|
||||
}
|
||||
|
||||
private LoanProductData findLoanProductById(
|
||||
Collection<LoanProductLookup> loanProducts, Long productId) {
|
||||
LoanProductData match = this.loanProductReadPlatformService
|
||||
.retrieveNewLoanProductDetails();
|
||||
private LoanProductData findLoanProductById(Collection<LoanProductLookup> loanProducts, Long productId) {
|
||||
LoanProductData match = this.loanProductReadPlatformService.retrieveNewLoanProductDetails();
|
||||
for (LoanProductLookup loanProductLookup : loanProducts) {
|
||||
if (loanProductLookup.getId().equals(productId)) {
|
||||
match = this.loanProductReadPlatformService
|
||||
.retrieveLoanProduct(loanProductLookup.getId());
|
||||
match = this.loanProductReadPlatformService.retrieveLoanProduct(loanProductLookup.getId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user