update loan creation and retrieval.

This commit is contained in:
Keith Woodlock
2012-12-21 15:28:39 +00:00
parent e4ee41174d
commit c99053d2a4
7 changed files with 767 additions and 764 deletions
+106 -105
View File
@@ -626,7 +626,7 @@ Request Body:
</code> </code>
<code class="method-response"> <code class="method-response">
{ {
"entityId":23 "resourceId":23
} }
</code> </code>
</div> </div>
@@ -644,7 +644,7 @@ Request Body:
</code> </code>
<code class="method-response"> <code class="method-response">
{ {
"entityId":26 "resourceId":26
} }
</code> </code>
</div> </div>
@@ -666,7 +666,7 @@ Request Body:
"joiningDate": "09 June 2006" "joiningDate": "09 June 2006"
} }
</code> </code>
<code class="method-response">{ "entityId": 23}</code> <code class="method-response">{ "resourceId": 23}</code>
</div> </div>
</div> </div>
@@ -794,7 +794,7 @@ Request Body:
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": 40 "resourceId": 40
} }
</code> </code>
</div> </div>
@@ -848,7 +848,7 @@ Request Body:
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": 20 "resourceId": 20
} }
</code> </code>
</div> </div>
@@ -1150,70 +1150,67 @@ Request Body:
<div class="method-example"> <div class="method-example">
<code class="method-declaration">GET https://Domain Name/api/v1/loans/{loanId}</code> <code class="method-declaration">GET https://Domain Name/api/v1/loans/{loanId}</code>
<code class="method-response">{ <code class="method-response">{
"id" : 1, {
"externalId" : null, "id": 1,
"loanProductName" : "Agricultural Loan", "clientId": 1,
"submittedOnDate" : [ 2009, 1, 5 ], "clientName": "Willie O'Meara",
"approvedOnDate" : [ 2009, 1, 8 ], "loanProductId": 1,
"expectedDisbursementDate" : [ 2009, 1, 15 ], "loanProductName": "Agricultural Loan",
"actualDisbursementDate" : [ 2009, 1, 15 ], "loanProductDescription": "An agricultural loan given to farmers to help buy crop, stock and machinery. With an arrears tolerance setting of 1,000 CFA, loans are not marked as 'in arrears' or 'in bad standing' if the amount outstanding is less than this. Interest rate is described using monthly percentage rate (MPR) even though the loan typically lasts a year and requires one repayment (typically at time when farmer sells crop)",
"expectedFirstRepaymentOnDate" : null, "status": {
"interestChargedFromDate" : null, "id": 100,
"closedOnDate" : [ 2009, 11, 13 ], "code": "loanStatusType.submitted.and.pending.approval",
"expectedMaturityDate" : [ 2009, 11, 15 ], "value": "Submitted and pending approval"
"principal" : {
"currencyCode" : "XOF",
"digitsAfterDecimal" : 0,
"amount" : 100000,
"defaultName" : "CFA Franc BCEAO",
"nameCode" : "currency.XOF",
"displaySymbol" : "CFA",
"zero" : false,
"greaterThanZero" : true,
"displaySymbolValue" : "100000 CFA"
}, },
"inArrearsTolerance" : { "currency": {
"currencyCode" : "XOF", "code": "XOF",
"digitsAfterDecimal" : 0, "name": "CFA Franc BCEAO",
"amount" : 1000, "decimalPlaces": 0,
"defaultName" : "CFA Franc BCEAO", "displaySymbol": "CFA",
"nameCode" : "currency.XOF", "nameCode": "currency.XOF",
"displaySymbol" : "CFA", "displayLabel": "CFA Franc BCEAO (CFA)"
"zero" : false,
"greaterThanZero" : true,
"displaySymbolValue" : "1000 CFA"
}, },
"numberOfRepayments" : 1, "principal": 100000,
"repaymentEvery" : 10, "termFrequency": 12,
"interestRatePerPeriod" : 1.75, "termPeriodFrequencyType": {
"annualInterestRate" : 21.0, "id": 2,
"repaymentFrequencyType" : { "code": "termFrequency.periodFrequencyType.months",
"id" : 2, "value": "Months"
"code" : "repaymentFrequency.periodFrequencyType.months",
"value" : "Months"
}, },
"interestRateFrequencyType" : { "numberOfRepayments": 12,
"id" : 2, "repaymentEvery": 1,
"code" : "interestRateFrequency.periodFrequencyType.months", "repaymentFrequencyType": {
"value" : "Per month" "id": 2,
"code": "repaymentFrequency.periodFrequencyType.months",
"value": "Months"
}, },
"amortizationType" : { "transactionProcessingStrategyId": 1,
"id" : 1, "amortizationType": {
"code" : "amortizationType.equal.installments", "id": 1,
"value" : "Equal installments" "code": "amortizationType.equal.installments",
"value": "Equal installments"
}, },
"interestType" : { "interestRatePerPeriod": 2,
"id" : 0, "interestRateFrequencyType": {
"code" : "interestType.declining.balance", "id": 2,
"value" : "Declining Balance" "code": "interestRateFrequency.periodFrequencyType.months",
"value": "Per month"
}, },
"interestCalculationPeriodType" : { "annualInterestRate": 24,
"id" : 1, "interestType": {
"code" : "interestCalculationPeriodType.same.as.repayment.period", "id": 0,
"value" : "Same as repayment period" "code": "interestType.declining.balance",
"value": "Declining Balance"
}, },
"lifeCycleStatusText" : "Closed", "interestCalculationPeriodType": {
"lifeCycleStatusDate" : [ 2009, 11, 13 ] "id": 1,
"code": "interestCalculationPeriodType.same.as.repayment.period",
"value": "Same as repayment period"
},
"submittedOnDate": [2011,9,20],
"expectedDisbursementDate": [2011,9,20],
"expectedMaturityDate": [2012,9,20],
"lifeCycleStatusDate": [2011,9,20]
} }
</code> </code>
</div> </div>
@@ -1235,9 +1232,9 @@ Request Body:
<br> <br>
<table class=matrixHeading> <table class=matrixHeading>
<tr class="matrixHeadingBG"><td><div class="mifosXHeading2">Mandatory Fields</div></td></tr> <tr class="matrixHeadingBG"><td><div class="mifosXHeading2">Mandatory Fields</div></td></tr>
<tr class=alt><td>clientId, productId, inArrearsTolerance, submittedOnDate, principal, <tr class=alt><td>clientId, productId, principal, loanTermFrequency, loanTermFrequencyType, numberOfRepayments,
repaymentFrequencyType, repaymentEvery, numberOfRepayments, interestRatePerPeriod, interestRateFrequencyType, amortizationType, repaymentEvery, repaymentFrequencyType, interestRatePerPeriod, interestRateFrequencyType, amortizationType,
interestType, interestCalculationPeriodType, expectedDisbursementDate</td></tr> interestType, interestCalculationPeriodType, expectedDisbursementDate, submittedOnDate, transactionProcessingStrategyId</td></tr>
</table> </table>
</div> </div>
<div class="method-example"> <div class="method-example">
@@ -1246,26 +1243,29 @@ Request Body:
Content-Type: application/json Content-Type: application/json
Request Body: Request Body:
{ {
"clientId": 1, "dateFormat": "dd MMMM yyyy",
"productId": 1, "locale": "en_GB",
"locale": "en_GB", "clientId": 1,
"principal": "100,000.00", "productId": 1,
"inArrearsTolerance": "1,000.00", "principal": "100,000.00",
"repaymentFrequencyType": 2, "loanTermFrequency": 12,
"repaymentEvery": "1", "loanTermFrequencyType": 2,
"numberOfRepayments": "12", "numberOfRepayments": 12,
"interestRatePerPeriod": "1.75", "repaymentEvery": 1,
"interestRateFrequencyType": 2, "repaymentFrequencyType": 2,
"amortizationType": 1, "interestRatePerPeriod": 2,
"interestCalculationPeriodType": 1, "interestRateFrequencyType": 2,
"interestType": 0, "amortizationType": 1,
"dateFormat": "dd MMMM yyyy", "interestType": 0,
"expectedDisbursementDate": "01 July 2007", "interestCalculationPeriodType": 1,
"submittedOnDate": "25 June 2007" "expectedDisbursementDate": "20 September 2011",
"submittedOnDate": "20 September 2011",
"transactionProcessingStrategyId": 1
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": 42 "resourceId": 42
} }
</code> </code>
</div> </div>
@@ -1274,7 +1274,7 @@ Request Body:
<a id="loans_approve_etc" name="loans_approve_etc" class="old-syle-anchor">&nbsp;</a> <a id="loans_approve_etc" name="loans_approve_etc" class="old-syle-anchor">&nbsp;</a>
<div class="method-section"> <div class="method-section">
<div class="method-description"> <div class="method-description">
<h4>Approve, Undo Approval, Disburse, Undo Disbursal, Reject a Loan or Withdraw a Loan Application</h4> <h4>Approve, Undo Approval, Disburse, Undo Disbursal, Reject or Withdraw a Loan Application</h4>
<h5>Arguments</h5> <h5>Arguments</h5>
<dl class="argument-list"> <dl class="argument-list">
<dt>command</dt> <dt>command</dt>
@@ -1302,8 +1302,9 @@ Request Body:
"eventDate": "07 May 2012", "eventDate": "07 May 2012",
"note": "and event note is added" "note": "and event note is added"
} </code> } </code>
<code class="method-response">{ <code class="method-response">
"entityId": 37 {
"resourceId": 37
} }
</code> </code>
</div> </div>
@@ -1323,7 +1324,7 @@ Content-Type: application/json
No Request Body: No Request Body:
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": 1 "resourceId": 1
} }
</code> </code>
</div> </div>
@@ -1403,7 +1404,7 @@ Request Body:
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": 37 "resourceId": 37
} }
</code> </code>
</div> </div>
@@ -1465,7 +1466,7 @@ Request Body:
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": 16 "resourceId": 16
} }
</code> </code>
</div> </div>
@@ -1618,7 +1619,7 @@ Request Body:
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": 9 "resourceId": 9
} }
</code> </code>
</div> </div>
@@ -1639,7 +1640,7 @@ Request Body:
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": 1 "resourceId": 1
} }
</code> </code>
</div> </div>
@@ -2105,7 +2106,7 @@ Request Body:
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": 9 "resourceId": 9
} }
</code> </code>
</div> </div>
@@ -2128,7 +2129,7 @@ Request Body:
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": 1 "resourceId": 1
} }
</code> </code>
</div> </div>
@@ -2299,7 +2300,7 @@ Request Body:
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": null "resourceId": null
} }
</code> </code>
</div> </div>
@@ -2323,7 +2324,7 @@ Request Body:
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": null "resourceId": null
} }
</code> </code>
</div> </div>
@@ -2361,7 +2362,7 @@ Request Body:
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": 1 "resourceId": 1
} }
</code> </code>
</div> </div>
@@ -2439,7 +2440,7 @@ Request Body:
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": 1 "resourceId": 1
} }
</code> </code>
</div> </div>
@@ -2469,7 +2470,7 @@ Request Body:
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": 1 "resourceId": 1
} }
</code> </code>
</div> </div>
@@ -2493,7 +2494,7 @@ Request Body:
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": 1 "resourceId": 1
} }
</code> </code>
</div> </div>
@@ -2516,7 +2517,7 @@ Request Body:
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": 1 "resourceId": 1
} }
</code> </code>
</div> </div>
@@ -2992,7 +2993,7 @@ Request body:
</code> </code>
<code class="method-response"> <code class="method-response">
{ {
"entityId": 11 "resourceId": 11
} }
</code> </code>
</div> </div>
@@ -3019,7 +3020,7 @@ Request body:
</code> </code>
<code class="method-response"> <code class="method-response">
{ {
"entityId": 3 "resourceId": 3
} }
</code> </code>
</div> </div>
@@ -3038,7 +3039,7 @@ Content-Type: application/json
No Request Body No Request Body
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": 20 "resourceId": 20
} }
</code> </code>
</div> </div>
@@ -3131,7 +3132,7 @@ Request body:
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": 8 "resourceId": 8
} }
</code> </code>
</div> </div>
@@ -3152,7 +3153,7 @@ Request body:
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": 8 "resourceId": 8
} }
</code> </code>
</div> </div>
@@ -3218,7 +3219,7 @@ ALL_FUNCTIONS_READ: "true"
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
"entityId": 8 "resourceId": 8
} }
</code> </code>
</div> </div>
@@ -5,20 +5,20 @@ package org.mifosplatform.audit.api;
*/ */
public class ProcessingResultLookup { public class ProcessingResultLookup {
private final Long id; private final Long id;
private final String processingResult; private final String processingResult;
public ProcessingResultLookup(final Long id, final String processingResult) { public ProcessingResultLookup(final Long id, final String processingResult) {
this.id = id; this.id = id;
this.processingResult = processingResult; this.processingResult = processingResult;
} }
public Long getId() { public Long getId() {
return this.id; return this.id;
} }
public String getProcessingResult() { public String getProcessingResult() {
return this.processingResult; return this.processingResult;
} }
} }
@@ -0,0 +1,48 @@
package org.mifosplatform.infrastructure.security.data;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.time.StopWatch;
/**
* Immutable data object representing platform API request used for
* logging/debugging.
*/
public class PlatformRequestLog {
@SuppressWarnings("unused")
private long startTime;
@SuppressWarnings("unused")
private long totalTime;
@SuppressWarnings("unused")
private final String method;
@SuppressWarnings("unused")
private String url;
@SuppressWarnings("unused")
private Map<String, String> parameters;
public static PlatformRequestLog from(final StopWatch task, final HttpServletRequest request) throws IOException {
final String requestUrl = request.getRequestURL().toString();
@SuppressWarnings("unchecked")
Map<String, String> parameters = new HashMap<String, String>(request.getParameterMap());
parameters.remove("password");
parameters.remove("_");
return new PlatformRequestLog(task.getStartTime(), task.getTime(), request.getMethod(), requestUrl, parameters);
}
private PlatformRequestLog(final long startTime, final long time, final String method, final String requestUrl,
final Map<String, String> parameters) {
this.startTime = startTime;
this.totalTime = time;
this.method = method;
this.url = requestUrl;
this.parameters = parameters;
}
}
@@ -9,10 +9,15 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.time.StopWatch;
import org.mifosplatform.infrastructure.core.domain.MifosPlatformTenant; import org.mifosplatform.infrastructure.core.domain.MifosPlatformTenant;
import org.mifosplatform.infrastructure.core.serialization.ToApiJsonSerializer;
import org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil; import org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil;
import org.mifosplatform.infrastructure.security.data.PlatformRequestLog;
import org.mifosplatform.infrastructure.security.exception.InvalidTenantIdentiferException; import org.mifosplatform.infrastructure.security.exception.InvalidTenantIdentiferException;
import org.mifosplatform.infrastructure.security.service.TenantDetailsService; import org.mifosplatform.infrastructure.security.service.TenantDetailsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
@@ -36,9 +41,14 @@ import org.springframework.security.web.authentication.www.BasicAuthenticationFi
*/ */
public class TenantAwareBasicAuthenticationFilter extends BasicAuthenticationFilter { public class TenantAwareBasicAuthenticationFilter extends BasicAuthenticationFilter {
private final static Logger logger = LoggerFactory.getLogger(TenantAwareBasicAuthenticationFilter.class);
@Autowired @Autowired
private TenantDetailsService tenantDetailsService; private TenantDetailsService tenantDetailsService;
@Autowired
private ToApiJsonSerializer<PlatformRequestLog> toApiJsonSerializer;
private String tenantRequestHeader = "X-Mifos-Platform-TenantId"; private String tenantRequestHeader = "X-Mifos-Platform-TenantId";
private boolean exceptionIfHeaderMissing = true; private boolean exceptionIfHeaderMissing = true;
@@ -53,6 +63,9 @@ public class TenantAwareBasicAuthenticationFilter extends BasicAuthenticationFil
HttpServletRequest request = (HttpServletRequest) req; HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res; HttpServletResponse response = (HttpServletResponse) res;
StopWatch task = new StopWatch();
task.start();
try { try {
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) { if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
@@ -83,7 +96,9 @@ public class TenantAwareBasicAuthenticationFilter extends BasicAuthenticationFil
response.addHeader("WWW-Authenticate", "Basic realm=\"" + "Mifos Platform API" + "\""); response.addHeader("WWW-Authenticate", "Basic realm=\"" + "Mifos Platform API" + "\"");
response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
} finally { } finally {
task.stop();
final PlatformRequestLog log = PlatformRequestLog.from(task, request);
logger.info(toApiJsonSerializer.serialize(log));
} }
} }
} }
@@ -116,6 +116,12 @@ public class LoanApplicationCommand {
baseDataValidator.reset().parameter("groupId").value(this.groupId).mustBeBlankWhenParameterProvided("clientId", this.clientId) baseDataValidator.reset().parameter("groupId").value(this.groupId).mustBeBlankWhenParameterProvided("clientId", this.clientId)
.longGreaterThanZero(); .longGreaterThanZero();
} }
if (this.clientId == null && this.groupId == null) {
baseDataValidator.reset().parameter("clientId").value(this.clientId).notNull().integerGreaterThanZero();
}
baseDataValidator.reset().parameter("productId").value(this.productId).notNull().integerGreaterThanZero();
if (this.submittedOnDate == null) { if (this.submittedOnDate == null) {
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.submitted.on.date.cannot.be.blank", ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.submitted.on.date.cannot.be.blank",
@@ -20,174 +20,155 @@ import org.mifosplatform.portfolio.loanproduct.data.TransactionProcessingStrateg
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class LoanAccountData { public class LoanAccountData {
// basic loan details // basic loan details
private final Long id; private final Long id;
private final String externalId; private final String externalId;
private final Long clientId; private final Long clientId;
private final String clientName; private final String clientName;
private final Long groupId; private final Long groupId;
private final String groupName; private final String groupName;
private final Long loanProductId; private final Long loanProductId;
private final String loanProductName; private final String loanProductName;
private final String loanProductDescription; private final String loanProductDescription;
private final EnumOptionData status; private final EnumOptionData status;
private final Long fundId; private final Long fundId;
private final String fundName; private final String fundName;
private final Long loanOfficerId; private final Long loanOfficerId;
private final String loanOfficerName; private final String loanOfficerName;
private final CurrencyData currency; private final CurrencyData currency;
private final BigDecimal principal; private final BigDecimal principal;
private final BigDecimal inArrearsTolerance; private final BigDecimal inArrearsTolerance;
private final Integer termFrequency; private final Integer termFrequency;
private final EnumOptionData termPeriodFrequencyType; private final EnumOptionData termPeriodFrequencyType;
private final Integer numberOfRepayments; private final Integer numberOfRepayments;
private final Integer repaymentEvery; private final Integer repaymentEvery;
private final EnumOptionData repaymentFrequencyType; private final EnumOptionData repaymentFrequencyType;
private final Integer transactionStrategyId; private final Integer transactionProcessingStrategyId;
private final EnumOptionData amortizationType; private final EnumOptionData amortizationType;
private final BigDecimal interestRatePerPeriod; private final BigDecimal interestRatePerPeriod;
private final EnumOptionData interestRateFrequencyType; private final EnumOptionData interestRateFrequencyType;
private final BigDecimal annualInterestRate; private final BigDecimal annualInterestRate;
private final EnumOptionData interestType; private final EnumOptionData interestType;
private final EnumOptionData interestCalculationPeriodType; private final EnumOptionData interestCalculationPeriodType;
private final LocalDate submittedOnDate; private final LocalDate submittedOnDate;
private final LocalDate approvedOnDate; private final LocalDate approvedOnDate;
private final LocalDate expectedDisbursementDate; private final LocalDate expectedDisbursementDate;
private final LocalDate actualDisbursementDate; private final LocalDate actualDisbursementDate;
private final LocalDate repaymentsStartingFromDate; private final LocalDate repaymentsStartingFromDate;
private final LocalDate interestChargedFromDate; private final LocalDate interestChargedFromDate;
private final LocalDate closedOnDate; private final LocalDate closedOnDate;
private final LocalDate expectedMaturityDate; private final LocalDate expectedMaturityDate;
private final LocalDate lifeCycleStatusDate; private final LocalDate lifeCycleStatusDate;
// associations // associations
private final LoanScheduleData repaymentSchedule; private final LoanScheduleData repaymentSchedule;
private final Collection<LoanTransactionData> transactions; private final Collection<LoanTransactionData> transactions;
private final Collection<LoanChargeData> charges; private final Collection<LoanChargeData> charges;
private final LoanPermissionData permissions; private final LoanPermissionData permissions;
private final LoanConvenienceData convenienceData; private final LoanConvenienceData convenienceData;
private final GuarantorData guarantorData; private final GuarantorData guarantorData;
// template // template
private final Collection<StaffData> loanOfficerOptions; private final Collection<StaffData> loanOfficerOptions;
private final Collection<LoanProductData> productOptions; private final Collection<LoanProductData> productOptions;
private final Collection<EnumOptionData> termFrequencyTypeOptions; private final Collection<EnumOptionData> termFrequencyTypeOptions;
private final Collection<EnumOptionData> repaymentFrequencyTypeOptions; private final Collection<EnumOptionData> repaymentFrequencyTypeOptions;
private final Collection<TransactionProcessingStrategyData> repaymentStrategyOptions; private final Collection<TransactionProcessingStrategyData> repaymentStrategyOptions;
private final Collection<EnumOptionData> interestRateFrequencyTypeOptions; private final Collection<EnumOptionData> interestRateFrequencyTypeOptions;
private final Collection<EnumOptionData> amortizationTypeOptions; private final Collection<EnumOptionData> amortizationTypeOptions;
private final Collection<EnumOptionData> interestTypeOptions; private final Collection<EnumOptionData> interestTypeOptions;
private final Collection<EnumOptionData> interestCalculationPeriodTypeOptions; private final Collection<EnumOptionData> interestCalculationPeriodTypeOptions;
private final Collection<FundData> fundOptions; private final Collection<FundData> fundOptions;
private final Collection<ChargeData> chargeOptions; private final Collection<ChargeData> chargeOptions;
private final ChargeData chargeTemplate; private final ChargeData chargeTemplate;
public LoanAccountData( public LoanAccountData(final LoanBasicDetailsData basicDetails, final boolean convenienceDataRequired,
final LoanBasicDetailsData basicDetails, final LoanScheduleData repaymentSchedule, final Collection<LoanTransactionData> transactions,
final boolean convenienceDataRequired, final LoanPermissionData permissions, final Collection<LoanChargeData> charges,
final LoanScheduleData repaymentSchedule, final Collection<LoanProductData> productOptions, final Collection<EnumOptionData> termFrequencyTypeOptions,
final Collection<LoanTransactionData> transactions, final Collection<EnumOptionData> repaymentFrequencyTypeOptions,
final LoanPermissionData permissions, final Collection<TransactionProcessingStrategyData> repaymentStrategyOptions,
final Collection<LoanChargeData> charges, final Collection<EnumOptionData> interestRateFrequencyTypeOptions, final Collection<EnumOptionData> amortizationTypeOptions,
final Collection<LoanProductData> productOptions, final Collection<EnumOptionData> interestTypeOptions, final Collection<EnumOptionData> interestCalculationPeriodTypeOptions,
final Collection<EnumOptionData> termFrequencyTypeOptions, final Collection<FundData> fundOptions, final Collection<ChargeData> chargeOptions, final ChargeData chargeTemplate,
final Collection<EnumOptionData> repaymentFrequencyTypeOptions, final Collection<StaffData> loanOfficerOptions, final GuarantorData guarantorData) {
final Collection<TransactionProcessingStrategyData> repaymentStrategyOptions, this.repaymentSchedule = repaymentSchedule;
final Collection<EnumOptionData> interestRateFrequencyTypeOptions, this.transactions = transactions;
final Collection<EnumOptionData> amortizationTypeOptions, this.permissions = permissions;
final Collection<EnumOptionData> interestTypeOptions,
final Collection<EnumOptionData> interestCalculationPeriodTypeOptions,
final Collection<FundData> fundOptions,
final Collection<ChargeData> chargeOptions,
final ChargeData chargeTemplate,
final Collection<StaffData> loanOfficerOptions,
final GuarantorData guarantorData) {
this.repaymentSchedule = repaymentSchedule;
this.transactions = transactions;
this.permissions = permissions;
this.charges = charges; this.charges = charges;
this.productOptions = productOptions; this.productOptions = productOptions;
this.termFrequencyTypeOptions = termFrequencyTypeOptions; this.termFrequencyTypeOptions = termFrequencyTypeOptions;
this.repaymentFrequencyTypeOptions = repaymentFrequencyTypeOptions; this.repaymentFrequencyTypeOptions = repaymentFrequencyTypeOptions;
this.repaymentStrategyOptions = repaymentStrategyOptions; this.repaymentStrategyOptions = repaymentStrategyOptions;
this.interestRateFrequencyTypeOptions = interestRateFrequencyTypeOptions; this.interestRateFrequencyTypeOptions = interestRateFrequencyTypeOptions;
this.amortizationTypeOptions = amortizationTypeOptions; this.amortizationTypeOptions = amortizationTypeOptions;
this.interestTypeOptions = interestTypeOptions; this.interestTypeOptions = interestTypeOptions;
this.interestCalculationPeriodTypeOptions = interestCalculationPeriodTypeOptions; this.interestCalculationPeriodTypeOptions = interestCalculationPeriodTypeOptions;
this.fundOptions = fundOptions; this.fundOptions = fundOptions;
this.chargeOptions = chargeOptions; this.chargeOptions = chargeOptions;
this.chargeTemplate = chargeTemplate; this.chargeTemplate = chargeTemplate;
this.loanOfficerOptions = loanOfficerOptions; this.loanOfficerOptions = loanOfficerOptions;
this.guarantorData = guarantorData; this.guarantorData = guarantorData;
if (convenienceDataRequired) { if (convenienceDataRequired) {
int maxSubmittedOnOffsetFromToday = basicDetails int maxSubmittedOnOffsetFromToday = basicDetails.getMaxSubmittedOnOffsetFromToday();
.getMaxSubmittedOnOffsetFromToday(); int maxApprovedOnOffsetFromToday = basicDetails.getMaxApprovedOnOffsetFromToday();
int maxApprovedOnOffsetFromToday = basicDetails int maxDisbursedOnOffsetFromToday = basicDetails.getMaxDisbursedOnOffsetFromToday();
.getMaxApprovedOnOffsetFromToday(); int expectedLoanTermInDays = basicDetails.getLoanTermInDays();
int maxDisbursedOnOffsetFromToday = basicDetails int expectedLoanTermInMonths = basicDetails.getLoanTermInMonths();
.getMaxDisbursedOnOffsetFromToday(); int actualLoanTermInDays = basicDetails.getActualLoanTermInDays();
int expectedLoanTermInDays = basicDetails.getLoanTermInDays(); int actualLoanTermInMonths = basicDetails.getActualLoanTermInMonths();
int expectedLoanTermInMonths = basicDetails.getLoanTermInMonths();
int actualLoanTermInDays = basicDetails.getActualLoanTermInDays();
int actualLoanTermInMonths = basicDetails.getActualLoanTermInMonths();
this.convenienceData = new LoanConvenienceData(
maxSubmittedOnOffsetFromToday, maxApprovedOnOffsetFromToday,
maxDisbursedOnOffsetFromToday, expectedLoanTermInDays,
actualLoanTermInDays, expectedLoanTermInMonths,
actualLoanTermInMonths);
} else {
this.convenienceData = null;
}
this.id = basicDetails.getId(); this.convenienceData = new LoanConvenienceData(maxSubmittedOnOffsetFromToday, maxApprovedOnOffsetFromToday,
this.externalId = basicDetails.getExternalId(); maxDisbursedOnOffsetFromToday, expectedLoanTermInDays, actualLoanTermInDays, expectedLoanTermInMonths,
this.clientId = basicDetails.getClientId(); actualLoanTermInMonths);
this.clientName = basicDetails.getClientName(); } else {
this.groupId = basicDetails.getGroupId(); this.convenienceData = null;
this.groupName = basicDetails.getGroupName(); }
this.loanProductId = basicDetails.getLoanProductId();
this.loanProductName = basicDetails.getLoanProductName();
this.loanProductDescription = basicDetails.getLoanProductDescription();
this.fundId = basicDetails.getFundId();
this.fundName = basicDetails.getFundName();
this.loanOfficerId = basicDetails.getLoanOfficerId();
this.loanOfficerName = basicDetails.getLoanOfficerName();
this.id = basicDetails.getId();
this.submittedOnDate = basicDetails.getSubmittedOnDate(); this.externalId = basicDetails.getExternalId();
this.approvedOnDate = basicDetails.getApprovedOnDate(); this.clientId = basicDetails.getClientId();
this.expectedDisbursementDate = basicDetails this.clientName = basicDetails.getClientName();
.getExpectedDisbursementDate(); this.groupId = basicDetails.getGroupId();
this.actualDisbursementDate = basicDetails.getActualDisbursementDate(); this.groupName = basicDetails.getGroupName();
this.closedOnDate = basicDetails.getClosedOnDate(); this.loanProductId = basicDetails.getLoanProductId();
this.expectedMaturityDate = basicDetails.getExpectedMaturityDate(); this.loanProductName = basicDetails.getLoanProductName();
this.repaymentsStartingFromDate = basicDetails.getRepaymentsStartingFromDate(); this.loanProductDescription = basicDetails.getLoanProductDescription();
this.interestChargedFromDate = basicDetails.getInterestChargedFromDate(); this.fundId = basicDetails.getFundId();
this.fundName = basicDetails.getFundName();
this.currency = basicDetails.getCurrency(); this.loanOfficerId = basicDetails.getLoanOfficerId();
this.principal = basicDetails.getPrincipal(); this.loanOfficerName = basicDetails.getLoanOfficerName();
this.inArrearsTolerance = basicDetails.getInArrearsTolerance();
this.submittedOnDate = basicDetails.getSubmittedOnDate();
this.termFrequency = basicDetails.getTermFrequency(); this.approvedOnDate = basicDetails.getApprovedOnDate();
this.termPeriodFrequencyType = basicDetails.getTermPeriodFrequencyType(); this.expectedDisbursementDate = basicDetails.getExpectedDisbursementDate();
this.numberOfRepayments = basicDetails.getNumberOfRepayments(); this.actualDisbursementDate = basicDetails.getActualDisbursementDate();
this.repaymentEvery = basicDetails.getRepaymentEvery(); this.closedOnDate = basicDetails.getClosedOnDate();
this.transactionStrategyId = basicDetails.getTransactionStrategyId(); this.expectedMaturityDate = basicDetails.getExpectedMaturityDate();
this.interestRatePerPeriod = basicDetails.getInterestRatePerPeriod(); this.repaymentsStartingFromDate = basicDetails.getRepaymentsStartingFromDate();
this.annualInterestRate = basicDetails.getAnnualInterestRate(); this.interestChargedFromDate = basicDetails.getInterestChargedFromDate();
this.repaymentFrequencyType = basicDetails.getRepaymentFrequencyType();
this.interestRateFrequencyType = basicDetails this.currency = basicDetails.getCurrency();
.getInterestRateFrequencyType(); this.principal = basicDetails.getPrincipal();
this.amortizationType = basicDetails.getAmortizationType(); this.inArrearsTolerance = basicDetails.getInArrearsTolerance();
this.interestType = basicDetails.getInterestType();
this.interestCalculationPeriodType = basicDetails this.termFrequency = basicDetails.getTermFrequency();
.getInterestCalculationPeriodType(); this.termPeriodFrequencyType = basicDetails.getTermPeriodFrequencyType();
this.numberOfRepayments = basicDetails.getNumberOfRepayments();
this.status = basicDetails.getStatus(); this.repaymentEvery = basicDetails.getRepaymentEvery();
this.lifeCycleStatusDate = basicDetails.getLifeCycleStatusDate(); this.transactionProcessingStrategyId = basicDetails.getTransactionStrategyId();
} this.interestRatePerPeriod = basicDetails.getInterestRatePerPeriod();
this.annualInterestRate = basicDetails.getAnnualInterestRate();
this.repaymentFrequencyType = basicDetails.getRepaymentFrequencyType();
this.interestRateFrequencyType = basicDetails.getInterestRateFrequencyType();
this.amortizationType = basicDetails.getAmortizationType();
this.interestType = basicDetails.getInterestType();
this.interestCalculationPeriodType = basicDetails.getInterestCalculationPeriodType();
this.status = basicDetails.getStatus();
this.lifeCycleStatusDate = basicDetails.getLifeCycleStatusDate();
}
} }
@@ -14,561 +14,513 @@ import org.mifosplatform.portfolio.charge.data.ChargeData;
import org.mifosplatform.portfolio.loanproduct.data.LoanProductData; import org.mifosplatform.portfolio.loanproduct.data.LoanProductData;
/** /**
* Immutable data object for core details of loan to be combined with {@link LoanAccountData} usage. * Immutable data object for core details of loan to be combined with
* {@link LoanAccountData} usage.
*/ */
public class LoanBasicDetailsData { public class LoanBasicDetailsData {
private final Long id; private final Long id;
private final String externalId; private final String externalId;
private final Long clientId; private final Long clientId;
private final Long clientOfficeId; private final Long clientOfficeId;
private final String clientName; private final String clientName;
private final Long groupId; private final Long groupId;
private final Long groupOfficeId; private final Long groupOfficeId;
private final String groupName; private final String groupName;
private final Long loanProductId; private final Long loanProductId;
private final String loanProductName; private final String loanProductName;
private final String loanProductDescription; private final String loanProductDescription;
private final EnumOptionData status; private final EnumOptionData status;
private final Long fundId; private final Long fundId;
private final String fundName; private final String fundName;
private final Long loanOfficerId; private final Long loanOfficerId;
private final String loanOfficerName; private final String loanOfficerName;
private final CurrencyData currency; private final CurrencyData currency;
private final BigDecimal principal; private final BigDecimal principal;
private final BigDecimal inArrearsTolerance; private final BigDecimal inArrearsTolerance;
private final Integer termFrequency;
private final EnumOptionData termPeriodFrequencyType;
private final Integer numberOfRepayments;
private final Integer repaymentEvery;
private final EnumOptionData repaymentFrequencyType;
private final Integer transactionStrategyId;
private final EnumOptionData amortizationType;
private final BigDecimal interestRatePerPeriod;
private final EnumOptionData interestRateFrequencyType;
private final BigDecimal annualInterestRate;
private final EnumOptionData interestType;
private final EnumOptionData interestCalculationPeriodType;
private final LocalDate submittedOnDate;
private final LocalDate approvedOnDate;
private final LocalDate expectedDisbursementDate;
private final LocalDate actualDisbursementDate;
private final LocalDate repaymentsStartingFromDate;
private final LocalDate interestChargedFromDate;
private final LocalDate closedOnDate;
private final LocalDate expectedMaturityDate;
private final LocalDate lifeCycleStatusDate;
private final BigDecimal totalDisbursementCharges;
private final Collection<LoanChargeData> charges;
public static LoanBasicDetailsData populateForNewIndividualClientLoanCreation(final Long clientId, final String clientName, final LocalDate expectedDisbursementDate,
final Long clientOfficeId) {
return new LoanBasicDetailsData(clientId, clientName, clientOfficeId, null, null, null, expectedDisbursementDate);
}
public static LoanBasicDetailsData populateForNewGroupLoanCreation(final Long groupId, final String groupName, private final Integer termFrequency;
final LocalDate expectedDisbursementDate, private final EnumOptionData termPeriodFrequencyType;
final Long groupOfficeId){ private final Integer numberOfRepayments;
return new LoanBasicDetailsData(null, null, null, groupId, groupName, groupOfficeId, expectedDisbursementDate); private final Integer repaymentEvery;
} private final EnumOptionData repaymentFrequencyType;
private final Integer transactionProcessingStrategyId;
private final EnumOptionData amortizationType;
private final BigDecimal interestRatePerPeriod;
private final EnumOptionData interestRateFrequencyType;
private final BigDecimal annualInterestRate;
private final EnumOptionData interestType;
private final EnumOptionData interestCalculationPeriodType;
public static LoanBasicDetailsData populateForNewLoanCreation(final LoanBasicDetailsData loanAccount, final LoanProductData product) { private final LocalDate submittedOnDate;
private final LocalDate approvedOnDate;
final Integer termFrequency = product.getNumberOfRepayments() * product.getRepaymentEvery(); private final LocalDate expectedDisbursementDate;
final EnumOptionData termPeriodFrequencyType = product.getRepaymentFrequencyType(); private final LocalDate actualDisbursementDate;
private final LocalDate repaymentsStartingFromDate;
private final LocalDate interestChargedFromDate;
private final LocalDate closedOnDate;
private final LocalDate expectedMaturityDate;
private final LocalDate lifeCycleStatusDate;
private final BigDecimal totalDisbursementCharges;
private final Collection<LoanChargeData> charges;
public static LoanBasicDetailsData populateForNewIndividualClientLoanCreation(final Long clientId, final String clientName,
final LocalDate expectedDisbursementDate, final Long clientOfficeId) {
return new LoanBasicDetailsData(clientId, clientName, clientOfficeId, null, null, null, expectedDisbursementDate);
}
public static LoanBasicDetailsData populateForNewGroupLoanCreation(final Long groupId, final String groupName,
final LocalDate expectedDisbursementDate, final Long groupOfficeId) {
return new LoanBasicDetailsData(null, null, null, groupId, groupName, groupOfficeId, expectedDisbursementDate);
}
public static LoanBasicDetailsData populateForNewLoanCreation(final LoanBasicDetailsData loanAccount, final LoanProductData product) {
final Integer termFrequency = product.getNumberOfRepayments() * product.getRepaymentEvery();
final EnumOptionData termPeriodFrequencyType = product.getRepaymentFrequencyType();
final Collection<LoanChargeData> charges = new ArrayList<LoanChargeData>(); final Collection<LoanChargeData> charges = new ArrayList<LoanChargeData>();
for (ChargeData charge : product.charges()) { for (ChargeData charge : product.charges()) {
charges.add(LoanChargeData.newLoanChargeDetails(charge.getId(), charge.getName(), charge.getCurrency(), charges.add(LoanChargeData.newLoanChargeDetails(charge.getId(), charge.getName(), charge.getCurrency(), charge.getAmount(),
charge.getAmount(), charge.getChargeTimeType(), charge.getChargeCalculationType(), charge.isPenalty())); charge.getChargeTimeType(), charge.getChargeCalculationType(), charge.isPenalty()));
} }
return new LoanBasicDetailsData( return new LoanBasicDetailsData(loanAccount.clientId, loanAccount.clientName, loanAccount.clientOfficeId, loanAccount.groupId,
loanAccount.clientId, loanAccount.clientName, loanAccount.clientOfficeId, loanAccount.groupName, loanAccount.groupOfficeId, product.getId(), product.getName(), product.getDescription(),
loanAccount.groupId, loanAccount.groupName, loanAccount.groupOfficeId, product.getFundId(), product.getFundName(), product.getCurrency(), product.getPrincipal(), product.getInArrearsTolerance(),
product.getId(), product.getName(), product.getDescription(), product.getFundId(), product.getFundName(), termFrequency, termPeriodFrequencyType, product.getNumberOfRepayments(), product.getRepaymentEvery(),
product.getCurrency(), product.getPrincipal(), product.getInArrearsTolerance(), product.getRepaymentFrequencyType(), product.getTransactionProcessingStrategyId(), product.getAmortizationType(),
termFrequency, termPeriodFrequencyType, product.getNumberOfRepayments(), product.getRepaymentEvery(), product.getRepaymentFrequencyType(), product.getInterestRatePerPeriod(), product.getInterestRateFrequencyType(), product.getInterestType(),
product.getTransactionProcessingStrategyId(), product.getAmortizationType(), product.getInterestCalculationPeriodType(), loanAccount.expectedDisbursementDate, charges);
product.getInterestRatePerPeriod(), product.getInterestRateFrequencyType(), product.getInterestType(), product.getInterestCalculationPeriodType(), }
loanAccount.expectedDisbursementDate, charges);
}
private LoanBasicDetailsData(
final Long clientId, final String clientName, final Long clientOfficeId,
final Long groupId, final String groupName, final Long groupOfficeId,
final Long productId, final String productName, final String productDescription, final Long fundId, final String fundName,
final CurrencyData currency, final BigDecimal principal, final BigDecimal inArrearsTolerance,
final Integer termFrequency,
final EnumOptionData termPeriodFrequencyType,
final Integer numberOfRepayments,
final Integer repaymentEvery,
final EnumOptionData repaymentFrequencyType,
final Long transactionStrategyId,
final EnumOptionData amortizationType,
final BigDecimal interestRatePerPeriod,
final EnumOptionData interestRateFrequencyType,
final EnumOptionData interestType,
final EnumOptionData interestCalculationPeriodType,
final LocalDate expectedDisbursementDate, final Collection<LoanChargeData> charges) {
this.id = null;
this.externalId = null;
this.clientId = clientId;
this.clientName = clientName;
this.clientOfficeId = clientOfficeId;
this.groupId = groupId;
this.groupName = groupName;
this.groupOfficeId = groupOfficeId;
this.loanProductId = productId;
this.loanProductName = productName;
this.loanProductDescription= productDescription;
this.status = null;
this.fundId = fundId;
this.fundName = fundName;
this.loanOfficerId = null;
this.loanOfficerName = null;
this.currency = currency;
this.principal = principal;
this.inArrearsTolerance = inArrearsTolerance;
this.termFrequency = termFrequency;
this.termPeriodFrequencyType = termPeriodFrequencyType;
this.numberOfRepayments = numberOfRepayments;
this.repaymentEvery = repaymentEvery;
this.repaymentFrequencyType = repaymentFrequencyType;
// FIXME - kw - settle on using either long or integer for this throughout product and account fields for loan.
if (transactionStrategyId != null) {
this.transactionStrategyId = transactionStrategyId.intValue();
} else {
this.transactionStrategyId = null;
}
this.amortizationType = amortizationType;
this.interestRatePerPeriod = interestRatePerPeriod;
this.annualInterestRate = null;
this.interestRateFrequencyType = interestRateFrequencyType;
this.interestType = interestType;
this.interestCalculationPeriodType = interestCalculationPeriodType;
this.submittedOnDate = null;
this.approvedOnDate = null;
this.expectedDisbursementDate = expectedDisbursementDate;
this.actualDisbursementDate = null;
this.closedOnDate = null;
this.expectedMaturityDate = null;
this.repaymentsStartingFromDate = null;
this.interestChargedFromDate = null;
this.lifeCycleStatusDate = null;
this.charges = charges;
this.totalDisbursementCharges = BigDecimal.ZERO;
}
private LoanBasicDetailsData(final Long clientId, final String clientName, final Long clientOfficeId,
final Long groupId, final String groupName, final Long groupOfficeId,
final LocalDate expectedDisbursementDate) {
this.id = null;
this.externalId = null;
this.clientId = clientId;
this.clientName = clientName;
this.clientOfficeId = clientOfficeId;
this.groupId = groupId;
this.groupName = groupName;
this.groupOfficeId = groupOfficeId;
this.loanProductId = null;
this.loanProductName = null;
this.loanProductDescription= null;
this.status = null;
this.fundId = null;
this.fundName = null;
this.loanOfficerId = null;
this.loanOfficerName = null;
this.currency = null;
this.principal = null;
this.inArrearsTolerance = null;
this.termFrequency = null;
this.termPeriodFrequencyType = null;
this.numberOfRepayments = null;
this.repaymentEvery = null;
this.transactionStrategyId = null;
this.interestRatePerPeriod = null;
this.annualInterestRate = null;
this.repaymentFrequencyType = null;
this.interestRateFrequencyType = null;
this.amortizationType = null;
this.interestType = null;
this.interestCalculationPeriodType = null;
this.lifeCycleStatusDate = null;
this.submittedOnDate = null;
this.approvedOnDate = null;
this.expectedDisbursementDate = expectedDisbursementDate;
this.actualDisbursementDate = null;
this.closedOnDate = null;
this.expectedMaturityDate = null;
this.repaymentsStartingFromDate = null;
this.interestChargedFromDate = null;
this.charges = null;
this.totalDisbursementCharges = BigDecimal.ZERO;
}
public LoanBasicDetailsData( private LoanBasicDetailsData(final Long clientId, final String clientName, final Long clientOfficeId, final Long groupId,
final Long id, final String groupName, final Long groupOfficeId, final Long productId, final String productName,
final String externalId, final String productDescription, final Long fundId, final String fundName, final CurrencyData currency,
final Long clientId, final String clientName, final BigDecimal principal, final BigDecimal inArrearsTolerance, final Integer termFrequency,
final Long clientOfficeId, final EnumOptionData termPeriodFrequencyType, final Integer numberOfRepayments, final Integer repaymentEvery,
final Long groupId, final EnumOptionData repaymentFrequencyType, final Long transactionStrategyId, final EnumOptionData amortizationType,
final String groupName, final BigDecimal interestRatePerPeriod, final EnumOptionData interestRateFrequencyType, final EnumOptionData interestType,
final Long groupOfficeId, final EnumOptionData interestCalculationPeriodType, final LocalDate expectedDisbursementDate,
final Long loanProductId, final Collection<LoanChargeData> charges) {
final String loanProductName, this.id = null;
final String loanProductDescription, this.externalId = null;
final Long fundId, String fundName, this.clientId = clientId;
final LocalDate closedOnDate, this.clientName = clientName;
final LocalDate submittedOnDate, this.clientOfficeId = clientOfficeId;
final LocalDate approvedOnDate, this.groupId = groupId;
final LocalDate expectedDisbursementDate, this.groupName = groupName;
final LocalDate actualDisbursementDate, this.groupOfficeId = groupOfficeId;
final LocalDate expectedMaturityDate, this.loanProductId = productId;
final LocalDate repaymentsStartingFromDate, this.loanProductName = productName;
final LocalDate interestChargedFromDate, this.loanProductDescription = productDescription;
final CurrencyData currency, this.status = null;
final BigDecimal principal, this.fundId = fundId;
final BigDecimal inArrearsTolerance, this.fundName = fundName;
final Integer numberOfRepayments, this.loanOfficerId = null;
final Integer repaymentEvery, this.loanOfficerName = null;
final BigDecimal interestRatePerPeriod, this.currency = currency;
final BigDecimal annualInterestRate, this.principal = principal;
final EnumOptionData repaymentFrequencyType, this.inArrearsTolerance = inArrearsTolerance;
final EnumOptionData interestRateFrequencyType,
final EnumOptionData amortizationType,
final EnumOptionData interestType,
final EnumOptionData interestCalculationPeriodType,
final EnumOptionData status,
final LocalDate lifeCycleStatusDate,
final Integer termFrequency,
final EnumOptionData termPeriodFrequencyType,
final Integer transactionStrategyId,
final Collection<LoanChargeData> charges,
final Long loanOfficerId, String loanOfficerName,
final BigDecimal totalDisbursementCharges) {
this.id = id;
this.externalId = externalId;
this.clientId = clientId;
this.clientName = clientName;
this.clientOfficeId = clientOfficeId;
this.groupId = groupId;
this.groupName = groupName;
this.groupOfficeId = groupOfficeId;
this.loanProductId = loanProductId;
this.loanProductName = loanProductName;
this.loanProductDescription = loanProductDescription;
this.fundId = fundId;
this.fundName = fundName;
this.loanOfficerId = loanOfficerId;
this.loanOfficerName = loanOfficerName;
this.closedOnDate = closedOnDate;
this.submittedOnDate = submittedOnDate;
this.approvedOnDate = approvedOnDate;
this.expectedDisbursementDate = expectedDisbursementDate;
this.actualDisbursementDate = actualDisbursementDate;
this.expectedMaturityDate = expectedMaturityDate;
this.repaymentsStartingFromDate = repaymentsStartingFromDate;
this.interestChargedFromDate = interestChargedFromDate;
this.currency = currency;
this.principal = principal;
this.inArrearsTolerance = inArrearsTolerance;
this.numberOfRepayments = numberOfRepayments;
this.repaymentEvery = repaymentEvery;
this.interestRatePerPeriod = interestRatePerPeriod;
this.annualInterestRate = annualInterestRate;
this.repaymentFrequencyType = repaymentFrequencyType;
this.interestRateFrequencyType = interestRateFrequencyType;
this.amortizationType = amortizationType;
this.interestType = interestType;
this.interestCalculationPeriodType = interestCalculationPeriodType;
this.status = status;
this.lifeCycleStatusDate = lifeCycleStatusDate;
this.termFrequency = termFrequency;
this.termPeriodFrequencyType = termPeriodFrequencyType;
this.transactionStrategyId = transactionStrategyId;
this.charges = charges;
this.totalDisbursementCharges = totalDisbursementCharges;
}
public int getMaxSubmittedOnOffsetFromToday() { this.termFrequency = termFrequency;
return Days.daysBetween(new DateTime(), this.termPeriodFrequencyType = termPeriodFrequencyType;
this.getSubmittedOnDate().toDateMidnight().toDateTime()) this.numberOfRepayments = numberOfRepayments;
.getDays(); this.repaymentEvery = repaymentEvery;
} this.repaymentFrequencyType = repaymentFrequencyType;
public int getMaxApprovedOnOffsetFromToday() { // FIXME - kw - settle on using either long or integer for this
// throughout product and account fields for loan.
if (transactionStrategyId != null) {
this.transactionProcessingStrategyId = transactionStrategyId.intValue();
} else {
this.transactionProcessingStrategyId = null;
}
this.amortizationType = amortizationType;
int offset = 0; this.interestRatePerPeriod = interestRatePerPeriod;
if (this.getApprovedOnDate() != null) { this.annualInterestRate = null;
offset = Days.daysBetween(new DateTime(), this.interestRateFrequencyType = interestRateFrequencyType;
this.getApprovedOnDate().toDateMidnight().toDateTime()) this.interestType = interestType;
.getDays(); this.interestCalculationPeriodType = interestCalculationPeriodType;
}
return offset; this.submittedOnDate = null;
} this.approvedOnDate = null;
this.expectedDisbursementDate = expectedDisbursementDate;
public int getMaxDisbursedOnOffsetFromToday() { this.actualDisbursementDate = null;
this.closedOnDate = null;
this.expectedMaturityDate = null;
this.repaymentsStartingFromDate = null;
this.interestChargedFromDate = null;
this.lifeCycleStatusDate = null;
int offset = 0; this.charges = charges;
if (this.getActualDisbursementDate() != null) { this.totalDisbursementCharges = BigDecimal.ZERO;
offset = Days.daysBetween( }
new DateTime(),
this.getActualDisbursementDate().toDateMidnight()
.toDateTime()).getDays();
}
return offset; private LoanBasicDetailsData(final Long clientId, final String clientName, final Long clientOfficeId, final Long groupId,
} final String groupName, final Long groupOfficeId, final LocalDate expectedDisbursementDate) {
this.id = null;
this.externalId = null;
this.clientId = clientId;
this.clientName = clientName;
this.clientOfficeId = clientOfficeId;
this.groupId = groupId;
this.groupName = groupName;
this.groupOfficeId = groupOfficeId;
this.loanProductId = null;
this.loanProductName = null;
this.loanProductDescription = null;
this.status = null;
this.fundId = null;
this.fundName = null;
this.loanOfficerId = null;
this.loanOfficerName = null;
this.currency = null;
this.principal = null;
this.inArrearsTolerance = null;
this.termFrequency = null;
this.termPeriodFrequencyType = null;
this.numberOfRepayments = null;
this.repaymentEvery = null;
this.transactionProcessingStrategyId = null;
this.interestRatePerPeriod = null;
this.annualInterestRate = null;
this.repaymentFrequencyType = null;
this.interestRateFrequencyType = null;
this.amortizationType = null;
this.interestType = null;
this.interestCalculationPeriodType = null;
public int getActualLoanTermInDays() { this.lifeCycleStatusDate = null;
LocalDate dateToUse = getExpectedDisbursementDate(); this.submittedOnDate = null;
if (getActualDisbursementDate() != null) { this.approvedOnDate = null;
dateToUse = getActualDisbursementDate(); this.expectedDisbursementDate = expectedDisbursementDate;
}
LocalDate closingDateToUse = getExpectedMaturityDate(); this.actualDisbursementDate = null;
if (getClosedOnDate() != null) { this.closedOnDate = null;
closingDateToUse = getClosedOnDate(); this.expectedMaturityDate = null;
} this.repaymentsStartingFromDate = null;
this.interestChargedFromDate = null;
return Days.daysBetween(dateToUse.toDateMidnight().toDateTime(), this.charges = null;
closingDateToUse.toDateMidnight().toDateTime()).getDays(); this.totalDisbursementCharges = BigDecimal.ZERO;
} }
public int getActualLoanTermInMonths() { public LoanBasicDetailsData(final Long id, final String externalId, final Long clientId, final String clientName,
final Long clientOfficeId, final Long groupId, final String groupName, final Long groupOfficeId, final Long loanProductId,
final String loanProductName, final String loanProductDescription, final Long fundId, String fundName,
final LocalDate closedOnDate, final LocalDate submittedOnDate, final LocalDate approvedOnDate,
final LocalDate expectedDisbursementDate, final LocalDate actualDisbursementDate, final LocalDate expectedMaturityDate,
final LocalDate repaymentsStartingFromDate, final LocalDate interestChargedFromDate, final CurrencyData currency,
final BigDecimal principal, final BigDecimal inArrearsTolerance, final Integer numberOfRepayments,
final Integer repaymentEvery, final BigDecimal interestRatePerPeriod, final BigDecimal annualInterestRate,
final EnumOptionData repaymentFrequencyType, final EnumOptionData interestRateFrequencyType,
final EnumOptionData amortizationType, final EnumOptionData interestType, final EnumOptionData interestCalculationPeriodType,
final EnumOptionData status, final LocalDate lifeCycleStatusDate, final Integer termFrequency,
final EnumOptionData termPeriodFrequencyType, final Integer transactionStrategyId, final Collection<LoanChargeData> charges,
final Long loanOfficerId, String loanOfficerName, final BigDecimal totalDisbursementCharges) {
this.id = id;
this.externalId = externalId;
this.clientId = clientId;
this.clientName = clientName;
this.clientOfficeId = clientOfficeId;
this.groupId = groupId;
this.groupName = groupName;
this.groupOfficeId = groupOfficeId;
this.loanProductId = loanProductId;
this.loanProductName = loanProductName;
this.loanProductDescription = loanProductDescription;
this.fundId = fundId;
this.fundName = fundName;
this.loanOfficerId = loanOfficerId;
this.loanOfficerName = loanOfficerName;
this.closedOnDate = closedOnDate;
this.submittedOnDate = submittedOnDate;
this.approvedOnDate = approvedOnDate;
this.expectedDisbursementDate = expectedDisbursementDate;
this.actualDisbursementDate = actualDisbursementDate;
this.expectedMaturityDate = expectedMaturityDate;
this.repaymentsStartingFromDate = repaymentsStartingFromDate;
this.interestChargedFromDate = interestChargedFromDate;
this.currency = currency;
this.principal = principal;
this.inArrearsTolerance = inArrearsTolerance;
this.numberOfRepayments = numberOfRepayments;
this.repaymentEvery = repaymentEvery;
this.interestRatePerPeriod = interestRatePerPeriod;
this.annualInterestRate = annualInterestRate;
this.repaymentFrequencyType = repaymentFrequencyType;
this.interestRateFrequencyType = interestRateFrequencyType;
this.amortizationType = amortizationType;
this.interestType = interestType;
this.interestCalculationPeriodType = interestCalculationPeriodType;
this.status = status;
this.lifeCycleStatusDate = lifeCycleStatusDate;
this.termFrequency = termFrequency;
this.termPeriodFrequencyType = termPeriodFrequencyType;
this.transactionProcessingStrategyId = transactionStrategyId;
this.charges = charges;
this.totalDisbursementCharges = totalDisbursementCharges;
}
LocalDate dateToUse = getExpectedDisbursementDate(); public int getMaxSubmittedOnOffsetFromToday() {
if (getActualDisbursementDate() != null) { return Days.daysBetween(new DateTime(), this.getSubmittedOnDate().toDateMidnight().toDateTime()).getDays();
dateToUse = getActualDisbursementDate(); }
}
LocalDate closingDateToUse = getExpectedMaturityDate(); public int getMaxApprovedOnOffsetFromToday() {
if (getClosedOnDate() != null) {
closingDateToUse = getClosedOnDate();
}
return Months.monthsBetween(dateToUse.toDateMidnight().toDateTime(), int offset = 0;
closingDateToUse.toDateMidnight().toDateTime()).getMonths(); if (this.getApprovedOnDate() != null) {
} offset = Days.daysBetween(new DateTime(), this.getApprovedOnDate().toDateMidnight().toDateTime()).getDays();
}
public int getLoanTermInDays() { return offset;
}
LocalDate dateToUse = getExpectedDisbursementDate(); public int getMaxDisbursedOnOffsetFromToday() {
if (getActualDisbursementDate() != null) {
dateToUse = getActualDisbursementDate();
}
LocalDate closingDateToUse = getExpectedMaturityDate(); int offset = 0;
if (this.getActualDisbursementDate() != null) {
offset = Days.daysBetween(new DateTime(), this.getActualDisbursementDate().toDateMidnight().toDateTime()).getDays();
}
return Days.daysBetween(dateToUse.toDateMidnight().toDateTime(), return offset;
closingDateToUse.toDateMidnight().toDateTime()).getDays(); }
}
public int getLoanTermInMonths() { public int getActualLoanTermInDays() {
LocalDate dateToUse = getExpectedDisbursementDate(); LocalDate dateToUse = getExpectedDisbursementDate();
if (getActualDisbursementDate() != null) { if (getActualDisbursementDate() != null) {
dateToUse = getActualDisbursementDate(); dateToUse = getActualDisbursementDate();
} }
LocalDate closingDateToUse = getExpectedMaturityDate(); LocalDate closingDateToUse = getExpectedMaturityDate();
if (getClosedOnDate() != null) {
closingDateToUse = getClosedOnDate();
}
return Months.monthsBetween(dateToUse.toDateMidnight().toDateTime(), return Days.daysBetween(dateToUse.toDateMidnight().toDateTime(), closingDateToUse.toDateMidnight().toDateTime()).getDays();
closingDateToUse.toDateMidnight().toDateTime()).getMonths(); }
}
public Long getId() { public int getActualLoanTermInMonths() {
return id;
}
public String getExternalId() { LocalDate dateToUse = getExpectedDisbursementDate();
return externalId; if (getActualDisbursementDate() != null) {
} dateToUse = getActualDisbursementDate();
}
public Long getClientId() { LocalDate closingDateToUse = getExpectedMaturityDate();
return clientId; if (getClosedOnDate() != null) {
} closingDateToUse = getClosedOnDate();
}
public String getClientName() { return Months.monthsBetween(dateToUse.toDateMidnight().toDateTime(), closingDateToUse.toDateMidnight().toDateTime()).getMonths();
return clientName; }
}
public Long getClientOfficeId() {
return clientOfficeId;
}
public Long getGroupId() { public int getLoanTermInDays() {
return groupId;
}
public Long getGroupOfficeId() { LocalDate dateToUse = getExpectedDisbursementDate();
return groupOfficeId; if (getActualDisbursementDate() != null) {
} dateToUse = getActualDisbursementDate();
}
public String getGroupName() { LocalDate closingDateToUse = getExpectedMaturityDate();
return groupName;
}
public Long getFundId() { return Days.daysBetween(dateToUse.toDateMidnight().toDateTime(), closingDateToUse.toDateMidnight().toDateTime()).getDays();
return fundId; }
}
public String getFundName() { public int getLoanTermInMonths() {
return fundName;
}
public Long getLoanProductId() { LocalDate dateToUse = getExpectedDisbursementDate();
return loanProductId; if (getActualDisbursementDate() != null) {
} dateToUse = getActualDisbursementDate();
}
public String getLoanProductName() { LocalDate closingDateToUse = getExpectedMaturityDate();
return loanProductName;
}
public String getLoanProductDescription() { return Months.monthsBetween(dateToUse.toDateMidnight().toDateTime(), closingDateToUse.toDateMidnight().toDateTime()).getMonths();
return loanProductDescription; }
}
public EnumOptionData getStatus() {
return status;
}
public Integer getTermFrequency() {
return termFrequency;
}
public EnumOptionData getTermPeriodFrequencyType() { public Long getId() {
return termPeriodFrequencyType; return id;
} }
public LocalDate getSubmittedOnDate() { public String getExternalId() {
return submittedOnDate; return externalId;
} }
public LocalDate getApprovedOnDate() { public Long getClientId() {
return approvedOnDate; return clientId;
} }
public LocalDate getExpectedDisbursementDate() { public String getClientName() {
return expectedDisbursementDate; return clientName;
} }
public LocalDate getActualDisbursementDate() { public Long getClientOfficeId() {
return actualDisbursementDate; return clientOfficeId;
} }
public LocalDate getRepaymentsStartingFromDate() {
return repaymentsStartingFromDate;
}
public LocalDate getInterestChargedFromDate() { public Long getGroupId() {
return interestChargedFromDate; return groupId;
} }
public LocalDate getClosedOnDate() { public Long getGroupOfficeId() {
return closedOnDate; return groupOfficeId;
} }
public LocalDate getExpectedMaturityDate() { public String getGroupName() {
return expectedMaturityDate; return groupName;
} }
public CurrencyData getCurrency() {
return currency;
}
public BigDecimal getPrincipal() { public Long getFundId() {
return principal; return fundId;
} }
public BigDecimal getInArrearsTolerance() { public String getFundName() {
return inArrearsTolerance; return fundName;
} }
public Integer getNumberOfRepayments() { public Long getLoanProductId() {
return numberOfRepayments; return loanProductId;
} }
public Integer getRepaymentEvery() { public String getLoanProductName() {
return repaymentEvery; return loanProductName;
} }
public BigDecimal getInterestRatePerPeriod() { public String getLoanProductDescription() {
return interestRatePerPeriod; return loanProductDescription;
} }
public BigDecimal getAnnualInterestRate() { public EnumOptionData getStatus() {
return annualInterestRate; return status;
} }
public EnumOptionData getRepaymentFrequencyType() { public Integer getTermFrequency() {
return repaymentFrequencyType; return termFrequency;
} }
public EnumOptionData getInterestRateFrequencyType() { public EnumOptionData getTermPeriodFrequencyType() {
return interestRateFrequencyType; return termPeriodFrequencyType;
} }
public EnumOptionData getAmortizationType() { public LocalDate getSubmittedOnDate() {
return amortizationType; return submittedOnDate;
} }
public EnumOptionData getInterestType() { public LocalDate getApprovedOnDate() {
return interestType; return approvedOnDate;
} }
public EnumOptionData getInterestCalculationPeriodType() { public LocalDate getExpectedDisbursementDate() {
return interestCalculationPeriodType; return expectedDisbursementDate;
} }
public LocalDate getLifeCycleStatusDate() { public LocalDate getActualDisbursementDate() {
return lifeCycleStatusDate; return actualDisbursementDate;
} }
public Integer getTransactionStrategyId() { public LocalDate getRepaymentsStartingFromDate() {
return transactionStrategyId; return repaymentsStartingFromDate;
} }
public Collection<LoanChargeData> getCharges() { public LocalDate getInterestChargedFromDate() {
return charges; return interestChargedFromDate;
} }
public Long getLoanOfficerId() { public LocalDate getClosedOnDate() {
return loanOfficerId; return closedOnDate;
} }
public String getLoanOfficerName() { public LocalDate getExpectedMaturityDate() {
return loanOfficerName; return expectedMaturityDate;
} }
public BigDecimal getTotalDisbursementCharges() { public CurrencyData getCurrency() {
return totalDisbursementCharges; return currency;
} }
public DisbursementData toDisburementData() { public BigDecimal getPrincipal() {
return new DisbursementData(this.expectedDisbursementDate, this.actualDisbursementDate, this.principal); return principal;
} }
public Long getOfficeId(){ public BigDecimal getInArrearsTolerance() {
return inArrearsTolerance;
}
public Integer getNumberOfRepayments() {
return numberOfRepayments;
}
public Integer getRepaymentEvery() {
return repaymentEvery;
}
public BigDecimal getInterestRatePerPeriod() {
return interestRatePerPeriod;
}
public BigDecimal getAnnualInterestRate() {
return annualInterestRate;
}
public EnumOptionData getRepaymentFrequencyType() {
return repaymentFrequencyType;
}
public EnumOptionData getInterestRateFrequencyType() {
return interestRateFrequencyType;
}
public EnumOptionData getAmortizationType() {
return amortizationType;
}
public EnumOptionData getInterestType() {
return interestType;
}
public EnumOptionData getInterestCalculationPeriodType() {
return interestCalculationPeriodType;
}
public LocalDate getLifeCycleStatusDate() {
return lifeCycleStatusDate;
}
public Integer getTransactionStrategyId() {
return this.transactionProcessingStrategyId;
}
public Collection<LoanChargeData> getCharges() {
return charges;
}
public Long getLoanOfficerId() {
return loanOfficerId;
}
public String getLoanOfficerName() {
return loanOfficerName;
}
public BigDecimal getTotalDisbursementCharges() {
return totalDisbursementCharges;
}
public DisbursementData toDisburementData() {
return new DisbursementData(this.expectedDisbursementDate, this.actualDisbursementDate, this.principal);
}
public Long getOfficeId() {
Long officeId = this.clientOfficeId; Long officeId = this.clientOfficeId;
if (officeId == null){ if (officeId == null) {
officeId = this.groupOfficeId; officeId = this.groupOfficeId;
} }