tidy up unneeded pass back of permissions with loan account data.
This commit is contained in:
@@ -501,7 +501,6 @@ CREATE TABLE `m_loan` (
|
||||
`product_id` bigint(20) DEFAULT NULL,
|
||||
`fund_id` bigint(20) DEFAULT NULL,
|
||||
`loan_officer_id` bigint(20) DEFAULT NULL,
|
||||
`guarantor_id` bigint(20) DEFAULT NULL,
|
||||
`loanpurpose_cv_id` INT(11) DEFAULT NULL,
|
||||
`loan_status_id` smallint(5) NOT NULL,
|
||||
`currency_code` varchar(3) NOT NULL,
|
||||
|
||||
+6
-8
@@ -5,6 +5,12 @@
|
||||
*/
|
||||
package org.mifosplatform.infrastructure.core.data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Immutable data object represent generic enumeration value.
|
||||
* </p>
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class EnumOptionData {
|
||||
|
||||
private final Long id;
|
||||
@@ -20,12 +26,4 @@ public class EnumOptionData {
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
package org.mifosplatform.portfolio.client.data;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanStatusEnumData;
|
||||
|
||||
/**
|
||||
* Immutable data object for client loan accounts.
|
||||
@@ -24,7 +24,7 @@ public class ClientAccountSummaryData {
|
||||
private final String productName;
|
||||
|
||||
private final Integer accountStatusId;
|
||||
private final EnumOptionData status;
|
||||
private final LoanStatusEnumData status;
|
||||
|
||||
public ClientAccountSummaryData(final Long id, final String externalId, final Long productId, final String loanProductName,
|
||||
final Integer loanStatusId) {
|
||||
@@ -37,8 +37,8 @@ public class ClientAccountSummaryData {
|
||||
this.status = null;
|
||||
}
|
||||
|
||||
public ClientAccountSummaryData(final Long id, final String accountNo, final String externalId, final Long productId, final String loanProductName,
|
||||
final EnumOptionData loanStatus) {
|
||||
public ClientAccountSummaryData(final Long id, final String accountNo, final String externalId, final Long productId,
|
||||
final String loanProductName, final LoanStatusEnumData loanStatus) {
|
||||
this.id = id;
|
||||
this.accountNo = accountNo;
|
||||
this.externalId = externalId;
|
||||
@@ -51,7 +51,7 @@ public class ClientAccountSummaryData {
|
||||
public Integer accountStatusId() {
|
||||
Integer accountStatus = this.accountStatusId;
|
||||
if (accountStatus == null && this.status != null) {
|
||||
accountStatus = this.status.getId().intValue();
|
||||
accountStatus = this.status.id().intValue();
|
||||
}
|
||||
return accountStatus;
|
||||
}
|
||||
|
||||
+2
-1
@@ -30,6 +30,7 @@ import org.mifosplatform.portfolio.client.domain.NoteEnumerations;
|
||||
import org.mifosplatform.portfolio.client.exception.ClientIdentifierNotFoundException;
|
||||
import org.mifosplatform.portfolio.client.exception.ClientNotFoundException;
|
||||
import org.mifosplatform.portfolio.client.exception.NoteNotFoundException;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanStatusEnumData;
|
||||
import org.mifosplatform.portfolio.loanproduct.service.LoanEnumerations;
|
||||
import org.mifosplatform.useradministration.data.AppUserData;
|
||||
import org.mifosplatform.useradministration.domain.AppUser;
|
||||
@@ -325,7 +326,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
final Long productId = JdbcSupport.getLong(rs, "productId");
|
||||
final String loanProductName = rs.getString("productName");
|
||||
final Integer loanStatusId = JdbcSupport.getInteger(rs, "statusId");
|
||||
final EnumOptionData loanStatus = LoanEnumerations.status(loanStatusId);
|
||||
final LoanStatusEnumData loanStatus = LoanEnumerations.status(loanStatusId);
|
||||
|
||||
return new ClientAccountSummaryData(id, accountNo, externalId, productId, loanProductName, loanStatus);
|
||||
}
|
||||
|
||||
+7
-52
@@ -40,8 +40,6 @@ import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSeriali
|
||||
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
|
||||
import org.mifosplatform.organisation.monetary.domain.Money;
|
||||
import org.mifosplatform.organisation.staff.data.BulkTransferLoanOfficerData;
|
||||
import org.mifosplatform.organisation.staff.data.StaffData;
|
||||
import org.mifosplatform.organisation.staff.service.StaffReadPlatformService;
|
||||
@@ -54,7 +52,6 @@ import org.mifosplatform.portfolio.loanaccount.data.LoanAccountData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanBasicDetailsData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanChargeData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanCollateralData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanPermissionData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanTransactionData;
|
||||
import org.mifosplatform.portfolio.loanaccount.guarantor.data.GuarantorData;
|
||||
import org.mifosplatform.portfolio.loanaccount.guarantor.service.GuarantorReadPlatformService;
|
||||
@@ -86,11 +83,11 @@ public class LoansApiResource {
|
||||
"interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType", "submittedOnDate",
|
||||
"approvedOnDate", "expectedDisbursementDate", "actualDisbursementDate", "expectedFirstRepaymentOnDate",
|
||||
"interestChargedFromDate", "closedOnDate", "expectedMaturityDate", "status", "lifeCycleStatusDate", "repaymentSchedule",
|
||||
"transactions", "permissions", "convenienceData", "charges", "guarantor", "collateral", "productOptions",
|
||||
"amortizationTypeOptions", "interestTypeOptions", "interestCalculationPeriodTypeOptions", "repaymentFrequencyTypeOptions",
|
||||
"termFrequencyTypeOptions", "interestRateFrequencyTypeOptions", "fundOptions", "repaymentStrategyOptions", "chargeOptions",
|
||||
"loanOfficerOptions", "chargeTemplate", "transactionProcessingStrategyId", "termFrequency", "termPeriodFrequencyType",
|
||||
"loanPurposeOptions", "loanCollateralOptions"));
|
||||
"transactions", "convenienceData", "charges", "guarantor", "collateral", "productOptions", "amortizationTypeOptions",
|
||||
"interestTypeOptions", "interestCalculationPeriodTypeOptions", "repaymentFrequencyTypeOptions", "termFrequencyTypeOptions",
|
||||
"interestRateFrequencyTypeOptions", "fundOptions", "repaymentStrategyOptions", "chargeOptions", "loanOfficerOptions",
|
||||
"chargeTemplate", "transactionProcessingStrategyId", "termFrequency", "termPeriodFrequencyType", "loanPurposeOptions",
|
||||
"loanCollateralOptions"));
|
||||
|
||||
private final String resourceNameForPermissions = "LOAN";
|
||||
|
||||
@@ -198,7 +195,7 @@ public class LoansApiResource {
|
||||
.retrieveCodeValuesByCode("LoanCollateral");
|
||||
|
||||
final boolean convenienceDataRequired = false;
|
||||
final LoanAccountData newLoanAccount = new LoanAccountData(loanBasicDetails, convenienceDataRequired, null, null, null, charges,
|
||||
final LoanAccountData newLoanAccount = new LoanAccountData(loanBasicDetails, convenienceDataRequired, null, null, charges,
|
||||
collateral, guarantors, productOptions, loanTermFrequencyTypeOptions, repaymentFrequencyTypeOptions,
|
||||
repaymentStrategyOptions, interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions,
|
||||
interestCalculationPeriodTypeOptions, fundOptions, chargeOptions, chargeTemplate, allowedLoanOfficers, loanPurposeOptions,
|
||||
@@ -218,10 +215,8 @@ public class LoansApiResource {
|
||||
|
||||
final LoanBasicDetailsData loanBasicDetails = this.loanReadPlatformService.retrieveLoanAccountDetails(loanId);
|
||||
|
||||
int loanRepaymentsCount = 0;
|
||||
Collection<LoanTransactionData> loanRepayments = null;
|
||||
LoanScheduleData repaymentSchedule = null;
|
||||
LoanPermissionData permissions = null;
|
||||
Collection<LoanChargeData> charges = null;
|
||||
Collection<GuarantorData> guarantors = null;
|
||||
Collection<LoanCollateralData> collateral = null;
|
||||
@@ -265,32 +260,6 @@ public class LoansApiResource {
|
||||
convenienceDataRequired = true;
|
||||
}
|
||||
|
||||
if (associationParameters.contains("permissions")) {
|
||||
|
||||
if (repaymentSchedule == null) { throw new IllegalStateException(); }
|
||||
mandatoryResponseParameters.add("permissions");
|
||||
|
||||
// FIXME - KW - Waive feature was changed to waive interest at
|
||||
// anytime so this permission checking is probably not needed -
|
||||
// look into.
|
||||
final MonetaryCurrency currency = new MonetaryCurrency(loanBasicDetails.getCurrency().code(), loanBasicDetails
|
||||
.getCurrency().decimalPlaces());
|
||||
final Money tolerance = Money.of(currency, loanBasicDetails.getInArrearsTolerance());
|
||||
|
||||
final Money totalOutstandingMoney = Money.of(currency, repaymentSchedule.totalOutstanding());
|
||||
|
||||
boolean isWaiveAllowed = totalOutstandingMoney.isGreaterThanZero()
|
||||
&& (tolerance.isGreaterThan(totalOutstandingMoney) || tolerance.isEqualTo(totalOutstandingMoney));
|
||||
|
||||
loanRepaymentsCount = retrieveNonDisbursementTransactions(loanRepayments);
|
||||
permissions = this.loanReadPlatformService.retrieveLoanPermissions(loanBasicDetails, isWaiveAllowed, loanRepaymentsCount);
|
||||
|
||||
// clear parent data which wasn't requested
|
||||
if (!associationParameters.contains("repaymentSchedule")) {
|
||||
repaymentSchedule = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (associationParameters.contains("charges")) {
|
||||
mandatoryResponseParameters.add("charges");
|
||||
charges = this.loanChargeReadPlatformService.retrieveLoanCharges(loanId);
|
||||
@@ -345,7 +314,7 @@ public class LoansApiResource {
|
||||
}
|
||||
|
||||
final LoanAccountData loanAccount = new LoanAccountData(loanBasicDetails, convenienceDataRequired, repaymentSchedule,
|
||||
loanRepayments, permissions, charges, collateral, guarantors, productOptions, loanTermFrequencyTypeOptions,
|
||||
loanRepayments, charges, collateral, guarantors, productOptions, loanTermFrequencyTypeOptions,
|
||||
repaymentFrequencyTypeOptions, repaymentStrategyOptions, interestRateFrequencyTypeOptions, amortizationTypeOptions,
|
||||
interestTypeOptions, interestCalculationPeriodTypeOptions, fundOptions, chargeOptions, chargeTemplate, allowedLoanOfficers,
|
||||
loanPurposeOptions, loanCollateralOptions);
|
||||
@@ -355,20 +324,6 @@ public class LoansApiResource {
|
||||
return this.toApiJsonSerializer.serialize(settings, loanAccount, LOAN_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
private int retrieveNonDisbursementTransactions(final Collection<LoanTransactionData> loanRepayments) {
|
||||
int loanRepaymentsCount = 0;
|
||||
if (!CollectionUtils.isEmpty(loanRepayments)) {
|
||||
for (LoanTransactionData transaction : loanRepayments) {
|
||||
if (transaction.isNotDisbursement()) {
|
||||
// use this to decide if undo disbural should permission
|
||||
// should be set to true.
|
||||
loanRepaymentsCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return loanRepaymentsCount;
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
|
||||
+6
-11
@@ -37,7 +37,7 @@ public class LoanAccountData {
|
||||
private final Long loanProductId;
|
||||
private final String loanProductName;
|
||||
private final String loanProductDescription;
|
||||
private final EnumOptionData status;
|
||||
private final LoanStatusEnumData status;
|
||||
private final Long fundId;
|
||||
private final String fundName;
|
||||
private final Long loanPurposeId;
|
||||
@@ -53,7 +53,7 @@ public class LoanAccountData {
|
||||
private final Integer numberOfRepayments;
|
||||
private final Integer repaymentEvery;
|
||||
private final EnumOptionData repaymentFrequencyType;
|
||||
private final Integer transactionProcessingStrategyId;
|
||||
private final Long transactionProcessingStrategyId;
|
||||
private final EnumOptionData amortizationType;
|
||||
private final BigDecimal interestRatePerPeriod;
|
||||
private final EnumOptionData interestRateFrequencyType;
|
||||
@@ -69,7 +69,6 @@ public class LoanAccountData {
|
||||
private final LocalDate interestChargedFromDate;
|
||||
private final LocalDate closedOnDate;
|
||||
private final LocalDate expectedMaturityDate;
|
||||
private final LocalDate lifeCycleStatusDate;
|
||||
|
||||
// associations
|
||||
private final LoanScheduleData repaymentSchedule;
|
||||
@@ -77,7 +76,6 @@ public class LoanAccountData {
|
||||
private final Collection<LoanChargeData> charges;
|
||||
private final Collection<LoanCollateralData> collateral;
|
||||
private final Collection<GuarantorData> guarantors;
|
||||
private final LoanPermissionData permissions;
|
||||
private final LoanConvenienceData convenienceData;
|
||||
|
||||
// template
|
||||
@@ -98,10 +96,9 @@ public class LoanAccountData {
|
||||
|
||||
public LoanAccountData(final LoanBasicDetailsData basicDetails, final boolean convenienceDataRequired,
|
||||
final LoanScheduleData repaymentSchedule, final Collection<LoanTransactionData> transactions,
|
||||
final LoanPermissionData permissions, final Collection<LoanChargeData> charges,
|
||||
final Collection<LoanCollateralData> collateral, final Collection<GuarantorData> guarantors,
|
||||
final Collection<LoanProductData> productOptions, final Collection<EnumOptionData> termFrequencyTypeOptions,
|
||||
final Collection<EnumOptionData> repaymentFrequencyTypeOptions,
|
||||
final Collection<LoanChargeData> charges, final Collection<LoanCollateralData> collateral,
|
||||
final Collection<GuarantorData> guarantors, final Collection<LoanProductData> productOptions,
|
||||
final Collection<EnumOptionData> termFrequencyTypeOptions, final Collection<EnumOptionData> repaymentFrequencyTypeOptions,
|
||||
final Collection<TransactionProcessingStrategyData> repaymentStrategyOptions,
|
||||
final Collection<EnumOptionData> interestRateFrequencyTypeOptions, final Collection<EnumOptionData> amortizationTypeOptions,
|
||||
final Collection<EnumOptionData> interestTypeOptions, final Collection<EnumOptionData> interestCalculationPeriodTypeOptions,
|
||||
@@ -110,7 +107,6 @@ public class LoanAccountData {
|
||||
final Collection<CodeValueData> loanCollateralOptions) {
|
||||
this.repaymentSchedule = repaymentSchedule;
|
||||
this.transactions = transactions;
|
||||
this.permissions = permissions;
|
||||
this.charges = charges;
|
||||
this.collateral = collateral;
|
||||
this.guarantors = guarantors;
|
||||
@@ -190,7 +186,7 @@ public class LoanAccountData {
|
||||
this.interestCalculationPeriodType = basicDetails.getInterestCalculationPeriodType();
|
||||
|
||||
this.status = basicDetails.getStatus();
|
||||
this.lifeCycleStatusDate = basicDetails.getLifeCycleStatusDate();
|
||||
|
||||
} else {
|
||||
this.id = null;
|
||||
this.accountNo = null;
|
||||
@@ -236,7 +232,6 @@ public class LoanAccountData {
|
||||
this.interestCalculationPeriodType = null;
|
||||
|
||||
this.status = null;
|
||||
this.lifeCycleStatusDate = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-26
@@ -36,7 +36,7 @@ public class LoanBasicDetailsData {
|
||||
private final Long loanProductId;
|
||||
private final String loanProductName;
|
||||
private final String loanProductDescription;
|
||||
private final EnumOptionData status;
|
||||
private final LoanStatusEnumData status;
|
||||
private final Long fundId;
|
||||
private final String fundName;
|
||||
private final Long loanPurposeId;
|
||||
@@ -52,7 +52,7 @@ public class LoanBasicDetailsData {
|
||||
private final Integer numberOfRepayments;
|
||||
private final Integer repaymentEvery;
|
||||
private final EnumOptionData repaymentFrequencyType;
|
||||
private final Integer transactionProcessingStrategyId;
|
||||
private final Long transactionProcessingStrategyId;
|
||||
private final EnumOptionData amortizationType;
|
||||
private final BigDecimal interestRatePerPeriod;
|
||||
private final EnumOptionData interestRateFrequencyType;
|
||||
@@ -68,7 +68,6 @@ public class LoanBasicDetailsData {
|
||||
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;
|
||||
@@ -140,14 +139,7 @@ public class LoanBasicDetailsData {
|
||||
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.transactionProcessingStrategyId = transactionStrategyId.intValue();
|
||||
} else {
|
||||
this.transactionProcessingStrategyId = null;
|
||||
}
|
||||
this.transactionProcessingStrategyId = transactionStrategyId;
|
||||
this.amortizationType = amortizationType;
|
||||
|
||||
this.interestRatePerPeriod = interestRatePerPeriod;
|
||||
@@ -165,7 +157,6 @@ public class LoanBasicDetailsData {
|
||||
this.expectedMaturityDate = null;
|
||||
this.repaymentsStartingFromDate = null;
|
||||
this.interestChargedFromDate = null;
|
||||
this.lifeCycleStatusDate = null;
|
||||
|
||||
this.charges = charges;
|
||||
this.totalDisbursementCharges = BigDecimal.ZERO;
|
||||
@@ -208,8 +199,6 @@ public class LoanBasicDetailsData {
|
||||
this.interestType = null;
|
||||
this.interestCalculationPeriodType = null;
|
||||
|
||||
this.lifeCycleStatusDate = null;
|
||||
|
||||
this.submittedOnDate = null;
|
||||
this.approvedOnDate = null;
|
||||
this.expectedDisbursementDate = expectedDisbursementDate;
|
||||
@@ -234,10 +223,9 @@ public class LoanBasicDetailsData {
|
||||
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) {
|
||||
final EnumOptionData interestCalculationPeriodType, final LoanStatusEnumData status, final Integer termFrequency,
|
||||
final EnumOptionData termPeriodFrequencyType, final Long transactionStrategyId, final Collection<LoanChargeData> charges,
|
||||
final Long loanOfficerId, String loanOfficerName, final BigDecimal totalDisbursementCharges) {
|
||||
this.id = id;
|
||||
this.accountNo = accountNo;
|
||||
this.externalId = externalId;
|
||||
@@ -277,7 +265,6 @@ public class LoanBasicDetailsData {
|
||||
this.interestType = interestType;
|
||||
this.interestCalculationPeriodType = interestCalculationPeriodType;
|
||||
this.status = status;
|
||||
this.lifeCycleStatusDate = lifeCycleStatusDate;
|
||||
this.termFrequency = termFrequency;
|
||||
this.termPeriodFrequencyType = termPeriodFrequencyType;
|
||||
this.transactionProcessingStrategyId = transactionStrategyId;
|
||||
@@ -427,7 +414,7 @@ public class LoanBasicDetailsData {
|
||||
return loanProductDescription;
|
||||
}
|
||||
|
||||
public EnumOptionData getStatus() {
|
||||
public LoanStatusEnumData getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -519,11 +506,7 @@ public class LoanBasicDetailsData {
|
||||
return interestCalculationPeriodType;
|
||||
}
|
||||
|
||||
public LocalDate getLifeCycleStatusDate() {
|
||||
return lifeCycleStatusDate;
|
||||
}
|
||||
|
||||
public Integer getTransactionStrategyId() {
|
||||
public Long getTransactionStrategyId() {
|
||||
return this.transactionProcessingStrategyId;
|
||||
}
|
||||
|
||||
@@ -556,5 +539,4 @@ public class LoanBasicDetailsData {
|
||||
|
||||
return officeId;
|
||||
}
|
||||
|
||||
}
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.portfolio.loanaccount.data;
|
||||
|
||||
/**
|
||||
* Immutable data object containing information on permissions allowed on a given loan.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class LoanPermissionData {
|
||||
|
||||
// permission for actions on loan
|
||||
private final boolean closeLoanAllowed;
|
||||
private final boolean closeLoanAsRescheduledAllowed;
|
||||
private final boolean addLoanChargeAllowed;
|
||||
private final boolean waiveAllowed;
|
||||
private final boolean makeRepaymentAllowed;
|
||||
private final boolean rejectAllowed;
|
||||
private final boolean withdrawnByApplicantAllowed;
|
||||
private final boolean undoApprovalAllowed;
|
||||
private final boolean disbursalAllowed;
|
||||
private final boolean undoDisbursalAllowed;
|
||||
private final boolean anyActionOnLoanAllowed;
|
||||
|
||||
//permissions for setting/removing guarantors for Loans
|
||||
private final boolean setGuarantorAllowed;
|
||||
private final boolean editGuarantorAllowed;
|
||||
|
||||
// status of loan
|
||||
private final boolean pendingApproval;
|
||||
private final boolean waitingForDisbursal;
|
||||
private final boolean closedObligationsMet;
|
||||
|
||||
public LoanPermissionData(
|
||||
final boolean closeLoanAllowed,
|
||||
final boolean closeLoanAsRescheduledAllowed,
|
||||
final boolean addLoanChargeAllowed,
|
||||
final boolean waiveAllowed,
|
||||
final boolean makeRepaymentAllowed,
|
||||
final boolean rejectAllowed,
|
||||
final boolean withdrawnByApplicantAllowed,
|
||||
final boolean undoApprovalAllowed,
|
||||
final boolean undoDisbursalAllowed,
|
||||
final boolean disbursalAllowed,
|
||||
final boolean setGuarantorAllowed,
|
||||
final boolean editGuarantorAllowed,
|
||||
final boolean pendingApproval,
|
||||
final boolean waitingForDisbursal,
|
||||
final boolean closedObligationsMet) {
|
||||
this.closeLoanAllowed = closeLoanAllowed;
|
||||
this.closeLoanAsRescheduledAllowed = closeLoanAsRescheduledAllowed;
|
||||
this.addLoanChargeAllowed = addLoanChargeAllowed;
|
||||
this.waiveAllowed = waiveAllowed;
|
||||
this.makeRepaymentAllowed = makeRepaymentAllowed;
|
||||
this.rejectAllowed = rejectAllowed;
|
||||
this.withdrawnByApplicantAllowed = withdrawnByApplicantAllowed;
|
||||
this.undoApprovalAllowed = undoApprovalAllowed;
|
||||
this.undoDisbursalAllowed = undoDisbursalAllowed;
|
||||
this.disbursalAllowed = disbursalAllowed;
|
||||
this.pendingApproval = pendingApproval;
|
||||
this.setGuarantorAllowed = setGuarantorAllowed;
|
||||
this.editGuarantorAllowed = editGuarantorAllowed;
|
||||
this.waitingForDisbursal = waitingForDisbursal;
|
||||
this.closedObligationsMet = closedObligationsMet;
|
||||
this.anyActionOnLoanAllowed = closeLoanAllowed || closeLoanAsRescheduledAllowed || rejectAllowed || withdrawnByApplicantAllowed || pendingApproval || undoDisbursalAllowed || makeRepaymentAllowed;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.portfolio.loanaccount.data;
|
||||
|
||||
/**
|
||||
* Immutable data object represent loan status enumerations.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class LoanStatusEnumData {
|
||||
|
||||
private final Long id;
|
||||
private final String code;
|
||||
private final String value;
|
||||
private boolean pendingApproval;
|
||||
private boolean waitingForDisbursal;
|
||||
private boolean active;
|
||||
private boolean closedObligationsMet;
|
||||
private boolean closedWrittenOff;
|
||||
private boolean closedRescheduled;
|
||||
private boolean closed;
|
||||
private boolean overpaid;
|
||||
|
||||
public LoanStatusEnumData(final Long id, final String code, final String value) {
|
||||
this.id = id;
|
||||
this.code = code;
|
||||
this.value = value;
|
||||
this.pendingApproval = Long.valueOf(100).equals(this.id);
|
||||
this.waitingForDisbursal = Long.valueOf(200).equals(this.id);
|
||||
this.active = Long.valueOf(300).equals(this.id);
|
||||
this.closedObligationsMet = Long.valueOf(600).equals(this.id);
|
||||
this.closedWrittenOff = Long.valueOf(601).equals(this.id);
|
||||
this.closedRescheduled = Long.valueOf(602).equals(this.id);
|
||||
this.closed = this.closedObligationsMet || this.closedWrittenOff || this.closedRescheduled;
|
||||
this.overpaid = Long.valueOf(700).equals(this.id);
|
||||
}
|
||||
|
||||
public Long id() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1189,7 +1189,7 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
||||
this.loanStatus = statusEnum.getValue();
|
||||
actualChanges.put("status", LoanEnumerations.status(this.loanStatus));
|
||||
|
||||
this.approvedOnDate = null;
|
||||
this.disbursedOnDate = null;
|
||||
actualChanges.put("disbursedOnDate", "");
|
||||
|
||||
updateLoanToPreDisbursalState();
|
||||
|
||||
-3
@@ -11,7 +11,6 @@ import java.util.Collection;
|
||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.DisbursementData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanBasicDetailsData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanPermissionData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanTransactionData;
|
||||
import org.mifosplatform.portfolio.loanaccount.loanschedule.data.LoanScheduleData;
|
||||
|
||||
@@ -24,8 +23,6 @@ public interface LoanReadPlatformService {
|
||||
|
||||
Collection<LoanTransactionData> retrieveLoanTransactions(Long loanId);
|
||||
|
||||
LoanPermissionData retrieveLoanPermissions(LoanBasicDetailsData loanBasicDetails, boolean isWaiverAllowed, int repaymentAndWaiveCount);
|
||||
|
||||
LoanBasicDetailsData retrieveClientAndProductDetails(Long clientId, Long productId);
|
||||
|
||||
LoanBasicDetailsData retrieveGroupAndProductDetails(Long groupId, Long productId);
|
||||
|
||||
+5
-58
@@ -29,7 +29,7 @@ import org.mifosplatform.portfolio.group.service.GroupReadPlatformService;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.DisbursementData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanBasicDetailsData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanChargeData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanPermissionData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanStatusEnumData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanTransactionData;
|
||||
import org.mifosplatform.portfolio.loanaccount.domain.Loan;
|
||||
import org.mifosplatform.portfolio.loanaccount.domain.LoanRepository;
|
||||
@@ -200,48 +200,6 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoanPermissionData retrieveLoanPermissions(final LoanBasicDetailsData loanBasicDetails, final boolean isWaiverAllowed,
|
||||
final int repaymentAndWaiveCount) {
|
||||
|
||||
final boolean pendingApproval = (loanBasicDetails.getStatus().getId().equals(100L));
|
||||
final boolean waitingForDisbursal = (loanBasicDetails.getStatus().getId().equals(200L));
|
||||
final boolean isActive = (loanBasicDetails.getStatus().getId().equals(300L));
|
||||
final boolean closedObligationsMet = (loanBasicDetails.getStatus().getId().equals(600L));
|
||||
final boolean closedWrittenOff = (loanBasicDetails.getStatus().getId().equals(602L));
|
||||
final boolean closedRescheduled = (loanBasicDetails.getStatus().getId().equals(602L));
|
||||
|
||||
final boolean closed = closedObligationsMet || closedWrittenOff || closedRescheduled;
|
||||
|
||||
final boolean isOverpaid = (loanBasicDetails.getStatus().getId().equals(700L));
|
||||
boolean addLoanChargeAllowed = true;
|
||||
boolean setGuarantorAllowed = true;
|
||||
boolean editGuarantorAllowed = true;
|
||||
if (closed || isOverpaid) {
|
||||
addLoanChargeAllowed = false;
|
||||
setGuarantorAllowed = false;
|
||||
editGuarantorAllowed = false;
|
||||
}
|
||||
|
||||
final boolean waiveAllowed = isWaiverAllowed && isActive;
|
||||
final boolean makeRepaymentAllowed = isActive;
|
||||
final boolean closeLoanAllowed = !closed && isActive;
|
||||
final boolean closeLoanAsRescheduledAllowed = !closed && !isOverpaid && isActive;
|
||||
|
||||
final boolean rejectAllowed = pendingApproval;
|
||||
final boolean withdrawnByApplicantAllowed = waitingForDisbursal || pendingApproval;
|
||||
|
||||
final boolean undoApprovalAllowed = waitingForDisbursal;
|
||||
|
||||
final boolean undoDisbursalAllowed = isActive && (repaymentAndWaiveCount == 0);
|
||||
|
||||
final boolean disbursalAllowed = waitingForDisbursal;
|
||||
|
||||
return new LoanPermissionData(closeLoanAllowed, closeLoanAsRescheduledAllowed, addLoanChargeAllowed, waiveAllowed,
|
||||
makeRepaymentAllowed, rejectAllowed, withdrawnByApplicantAllowed, undoApprovalAllowed, undoDisbursalAllowed,
|
||||
disbursalAllowed, setGuarantorAllowed, editGuarantorAllowed, pendingApproval, waitingForDisbursal, closedObligationsMet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoanBasicDetailsData retrieveClientAndProductDetails(final Long clientId, final Long productId) {
|
||||
|
||||
@@ -454,7 +412,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
final int interestRateFrequencyTypeInt = JdbcSupport.getInteger(rs, "interestRateFrequencyType");
|
||||
final EnumOptionData interestRateFrequencyType = LoanEnumerations.interestRateFrequencyType(interestRateFrequencyTypeInt);
|
||||
|
||||
final Integer transactionStrategyId = JdbcSupport.getInteger(rs, "transactionStrategyId");
|
||||
final Long transactionStrategyId = JdbcSupport.getLong(rs, "transactionStrategyId");
|
||||
|
||||
final int amortizationTypeInt = JdbcSupport.getInteger(rs, "amortizationType");
|
||||
final int interestTypeInt = JdbcSupport.getInteger(rs, "interestType");
|
||||
@@ -466,18 +424,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
.interestCalculationPeriodType(interestCalculationPeriodTypeInt);
|
||||
|
||||
final Integer lifeCycleStatusId = JdbcSupport.getInteger(rs, "lifeCycleStatusId");
|
||||
final EnumOptionData status = LoanEnumerations.status(lifeCycleStatusId);
|
||||
|
||||
LocalDate lifeCycleStatusDate = submittedOnDate;
|
||||
if (approvedOnDate != null) {
|
||||
lifeCycleStatusDate = approvedOnDate;
|
||||
}
|
||||
if (actualDisbursementDate != null) {
|
||||
lifeCycleStatusDate = actualDisbursementDate;
|
||||
}
|
||||
if (closedOnDate != null) {
|
||||
lifeCycleStatusDate = closedOnDate;
|
||||
}
|
||||
final LoanStatusEnumData status = LoanEnumerations.status(lifeCycleStatusId);
|
||||
|
||||
Collection<LoanChargeData> charges = null;
|
||||
return new LoanBasicDetailsData(id, accountNo, externalId, clientId, clientName, clientOfficeId, groupId, groupName,
|
||||
@@ -486,8 +433,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
expectedMaturityDate, expectedFirstRepaymentOnDate, interestChargedFromDate, currencyData, principal,
|
||||
inArrearsTolerance, numberOfRepayments, repaymentEvery, interestRatePerPeriod, annualInterestRate,
|
||||
repaymentFrequencyType, interestRateFrequencyType, amortizationType, interestType, interestCalculationPeriodType,
|
||||
status, lifeCycleStatusDate, termFrequency, termPeriodFrequencyType, transactionStrategyId, charges, loanOfficerId,
|
||||
loanOfficerName, totalDisbursementCharges);
|
||||
status, termFrequency, termPeriodFrequencyType, transactionStrategyId, charges, loanOfficerId, loanOfficerName,
|
||||
totalDisbursementCharges);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+278
-238
@@ -6,6 +6,7 @@
|
||||
package org.mifosplatform.portfolio.loanproduct.service;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanStatusEnumData;
|
||||
import org.mifosplatform.portfolio.loanaccount.domain.LoanStatus;
|
||||
import org.mifosplatform.portfolio.loanaccount.domain.LoanTransactionType;
|
||||
import org.mifosplatform.portfolio.loanproduct.domain.AccountingRuleType;
|
||||
@@ -16,245 +17,284 @@ import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType;
|
||||
|
||||
public class LoanEnumerations {
|
||||
|
||||
public static EnumOptionData loanTermFrequencyType(final int id) {
|
||||
return loanTermFrequencyType(PeriodFrequencyType.fromInt(id));
|
||||
}
|
||||
|
||||
public static EnumOptionData loanTermFrequencyType(final PeriodFrequencyType type) {
|
||||
final String codePrefix = "loanTermFrequency.";
|
||||
EnumOptionData optionData = null;
|
||||
switch (type) {
|
||||
case DAYS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.DAYS.getValue().longValue(), codePrefix + PeriodFrequencyType.DAYS.getCode(), "Days");
|
||||
break;
|
||||
case WEEKS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.WEEKS.getValue().longValue(), codePrefix + PeriodFrequencyType.WEEKS.getCode(), "Weeks");
|
||||
break;
|
||||
case MONTHS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.MONTHS.getValue().longValue(), codePrefix + PeriodFrequencyType.MONTHS.getCode(), "Months");
|
||||
break;
|
||||
case YEARS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.YEARS.getValue().longValue(), codePrefix + PeriodFrequencyType.YEARS.getCode(), "Years");
|
||||
break;
|
||||
default:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.INVALID.getValue().longValue(), PeriodFrequencyType.INVALID.getCode(), "Invalid");
|
||||
break;
|
||||
}
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static EnumOptionData termFrequencyType(final int id) {
|
||||
return termFrequencyType(PeriodFrequencyType.fromInt(id));
|
||||
}
|
||||
|
||||
public static EnumOptionData termFrequencyType(final PeriodFrequencyType type) {
|
||||
final String codePrefix = "termFrequency.";
|
||||
EnumOptionData optionData = null;
|
||||
switch (type) {
|
||||
case DAYS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.DAYS.getValue().longValue(), codePrefix + PeriodFrequencyType.DAYS.getCode(), "Days");
|
||||
break;
|
||||
case WEEKS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.WEEKS.getValue().longValue(), codePrefix + PeriodFrequencyType.WEEKS.getCode(), "Weeks");
|
||||
break;
|
||||
case MONTHS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.MONTHS.getValue().longValue(), codePrefix + PeriodFrequencyType.MONTHS.getCode(), "Months");
|
||||
break;
|
||||
default:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.INVALID.getValue().longValue(), PeriodFrequencyType.INVALID.getCode(), "Invalid");
|
||||
break;
|
||||
}
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static EnumOptionData repaymentFrequencyType(final int id) {
|
||||
return repaymentFrequencyType(PeriodFrequencyType.fromInt(id));
|
||||
}
|
||||
|
||||
public static EnumOptionData repaymentFrequencyType(final PeriodFrequencyType type) {
|
||||
final String codePrefix = "repaymentFrequency.";
|
||||
EnumOptionData optionData = null;
|
||||
switch (type) {
|
||||
case DAYS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.DAYS.getValue().longValue(), codePrefix + PeriodFrequencyType.DAYS.getCode(), "Days");
|
||||
break;
|
||||
case WEEKS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.WEEKS.getValue().longValue(), codePrefix + PeriodFrequencyType.WEEKS.getCode(), "Weeks");
|
||||
break;
|
||||
case MONTHS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.MONTHS.getValue().longValue(), codePrefix + PeriodFrequencyType.MONTHS.getCode(), "Months");
|
||||
break;
|
||||
default:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.INVALID.getValue().longValue(), PeriodFrequencyType.INVALID.getCode(), "Invalid");
|
||||
break;
|
||||
}
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static EnumOptionData interestRateFrequencyType(final int id) {
|
||||
return interestRateFrequencyType(PeriodFrequencyType.fromInt(id));
|
||||
}
|
||||
|
||||
public static EnumOptionData interestRateFrequencyType(final PeriodFrequencyType type) {
|
||||
final String codePrefix = "interestRateFrequency.";
|
||||
EnumOptionData optionData = null;
|
||||
switch (type) {
|
||||
case MONTHS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.MONTHS.getValue().longValue(), codePrefix + PeriodFrequencyType.MONTHS.getCode(), "Per month");
|
||||
break;
|
||||
case YEARS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.YEARS.getValue().longValue(), codePrefix + PeriodFrequencyType.YEARS.getCode(), "Per year");
|
||||
break;
|
||||
default:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.INVALID.getValue().longValue(), PeriodFrequencyType.INVALID.getCode(), "Invalid");
|
||||
break;
|
||||
}
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static EnumOptionData amortizationType(Integer id) {
|
||||
return amortizationType(AmortizationMethod.fromInt(id));
|
||||
}
|
||||
|
||||
public static EnumOptionData amortizationType(AmortizationMethod amortizationMethod) {
|
||||
EnumOptionData optionData = null;
|
||||
switch (amortizationMethod) {
|
||||
case EQUAL_INSTALLMENTS:
|
||||
optionData = new EnumOptionData(AmortizationMethod.EQUAL_INSTALLMENTS.getValue().longValue(), AmortizationMethod.EQUAL_INSTALLMENTS.getCode(), "Equal installments");
|
||||
break;
|
||||
case EQUAL_PRINCIPAL:
|
||||
optionData = new EnumOptionData(AmortizationMethod.EQUAL_PRINCIPAL.getValue().longValue(), AmortizationMethod.EQUAL_PRINCIPAL.getCode(), "Equal principle payments");
|
||||
break;
|
||||
default:
|
||||
optionData = new EnumOptionData(AmortizationMethod.INVALID.getValue().longValue(), AmortizationMethod.INVALID.getCode(), "Invalid");
|
||||
break;
|
||||
}
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static EnumOptionData interestType(Integer id) {
|
||||
return interestType(InterestMethod.fromInt(id));
|
||||
}
|
||||
|
||||
public static EnumOptionData interestType(InterestMethod type) {
|
||||
EnumOptionData optionData = null;
|
||||
switch (type) {
|
||||
case FLAT:
|
||||
optionData = new EnumOptionData(InterestMethod.FLAT.getValue().longValue(), InterestMethod.FLAT.getCode(), "Flat");
|
||||
break;
|
||||
case DECLINING_BALANCE:
|
||||
optionData = new EnumOptionData(InterestMethod.DECLINING_BALANCE.getValue().longValue(), InterestMethod.DECLINING_BALANCE.getCode(), "Declining Balance");
|
||||
break;
|
||||
default:
|
||||
optionData = new EnumOptionData(InterestMethod.INVALID.getValue().longValue(), InterestMethod.INVALID.getCode(), "Invalid");
|
||||
break;
|
||||
}
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static EnumOptionData interestCalculationPeriodType(Integer id) {
|
||||
return interestCalculationPeriodType(InterestCalculationPeriodMethod.fromInt(id));
|
||||
}
|
||||
|
||||
public static EnumOptionData interestCalculationPeriodType(InterestCalculationPeriodMethod type) {
|
||||
EnumOptionData optionData = null;
|
||||
switch (type) {
|
||||
case DAILY:
|
||||
optionData= new EnumOptionData(InterestCalculationPeriodMethod.DAILY.getValue().longValue(), InterestCalculationPeriodMethod.DAILY.getCode(), "Daily");
|
||||
break;
|
||||
case SAME_AS_REPAYMENT_PERIOD:
|
||||
optionData = new EnumOptionData(InterestCalculationPeriodMethod.SAME_AS_REPAYMENT_PERIOD.getValue().longValue(), InterestCalculationPeriodMethod.SAME_AS_REPAYMENT_PERIOD.getCode(), "Same as repayment period");
|
||||
break;
|
||||
default:
|
||||
optionData = new EnumOptionData(InterestCalculationPeriodMethod.INVALID.getValue().longValue(), InterestCalculationPeriodMethod.INVALID.getCode(), "Invalid");
|
||||
break;
|
||||
}
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static EnumOptionData transactionType(final Integer id) {
|
||||
return transactionType(LoanTransactionType.fromInt(id));
|
||||
}
|
||||
|
||||
public static EnumOptionData transactionType(final LoanTransactionType type) {
|
||||
EnumOptionData optionData = null;
|
||||
switch (type) {
|
||||
case INVALID:
|
||||
optionData = new EnumOptionData(LoanTransactionType.INVALID.getValue().longValue(), LoanTransactionType.INVALID.getCode(), "Invalid");
|
||||
break;
|
||||
case DISBURSEMENT:
|
||||
optionData= new EnumOptionData(LoanTransactionType.DISBURSEMENT.getValue().longValue(), LoanTransactionType.DISBURSEMENT.getCode(), "Dibursement");
|
||||
break;
|
||||
case REPAYMENT:
|
||||
optionData = new EnumOptionData(LoanTransactionType.REPAYMENT.getValue().longValue(), LoanTransactionType.REPAYMENT.getCode(), "Repayment");
|
||||
break;
|
||||
case REPAYMENT_AT_DISBURSEMENT:
|
||||
optionData = new EnumOptionData(LoanTransactionType.REPAYMENT_AT_DISBURSEMENT.getValue().longValue(), LoanTransactionType.REPAYMENT_AT_DISBURSEMENT.getCode(), "Repayment (at time of disbursement)");
|
||||
break;
|
||||
case CONTRA:
|
||||
optionData = new EnumOptionData(LoanTransactionType.CONTRA.getValue().longValue(), LoanTransactionType.CONTRA.getCode(), "Reversal");
|
||||
break;
|
||||
case WAIVE_INTEREST:
|
||||
optionData = new EnumOptionData(LoanTransactionType.WAIVE_INTEREST.getValue().longValue(), LoanTransactionType.WAIVE_INTEREST.getCode(), "Waive interest");
|
||||
break;
|
||||
case MARKED_FOR_RESCHEDULING:
|
||||
optionData = new EnumOptionData(LoanTransactionType.MARKED_FOR_RESCHEDULING.getValue().longValue(), LoanTransactionType.MARKED_FOR_RESCHEDULING.getCode(), "Close (as rescheduled)");
|
||||
break;
|
||||
case WRITEOFF:
|
||||
optionData = new EnumOptionData(LoanTransactionType.WRITEOFF.getValue().longValue(), LoanTransactionType.WRITEOFF.getCode(), "Close (as written-off)");
|
||||
break;
|
||||
case RECOVERY_REPAYMENT:
|
||||
optionData = new EnumOptionData(LoanTransactionType.RECOVERY_REPAYMENT.getValue().longValue(), LoanTransactionType.RECOVERY_REPAYMENT.getCode(), "Repayment (after write-off)");
|
||||
break;
|
||||
case WAIVE_CHARGES:
|
||||
optionData = new EnumOptionData(LoanTransactionType.WAIVE_CHARGES.getValue().longValue(), LoanTransactionType.WAIVE_CHARGES.getCode(), "Waive loan charges");
|
||||
break;
|
||||
}
|
||||
return optionData;
|
||||
}
|
||||
public static EnumOptionData loanTermFrequencyType(final int id) {
|
||||
return loanTermFrequencyType(PeriodFrequencyType.fromInt(id));
|
||||
}
|
||||
|
||||
public static EnumOptionData loanTermFrequencyType(final PeriodFrequencyType type) {
|
||||
final String codePrefix = "loanTermFrequency.";
|
||||
EnumOptionData optionData = null;
|
||||
switch (type) {
|
||||
case DAYS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.DAYS.getValue().longValue(), codePrefix
|
||||
+ PeriodFrequencyType.DAYS.getCode(), "Days");
|
||||
break;
|
||||
case WEEKS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.WEEKS.getValue().longValue(), codePrefix
|
||||
+ PeriodFrequencyType.WEEKS.getCode(), "Weeks");
|
||||
break;
|
||||
case MONTHS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.MONTHS.getValue().longValue(), codePrefix
|
||||
+ PeriodFrequencyType.MONTHS.getCode(), "Months");
|
||||
break;
|
||||
case YEARS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.YEARS.getValue().longValue(), codePrefix
|
||||
+ PeriodFrequencyType.YEARS.getCode(), "Years");
|
||||
break;
|
||||
default:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.INVALID.getValue().longValue(), PeriodFrequencyType.INVALID.getCode(),
|
||||
"Invalid");
|
||||
break;
|
||||
}
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static EnumOptionData termFrequencyType(final int id) {
|
||||
return termFrequencyType(PeriodFrequencyType.fromInt(id));
|
||||
}
|
||||
|
||||
public static EnumOptionData termFrequencyType(final PeriodFrequencyType type) {
|
||||
final String codePrefix = "termFrequency.";
|
||||
EnumOptionData optionData = null;
|
||||
switch (type) {
|
||||
case DAYS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.DAYS.getValue().longValue(), codePrefix
|
||||
+ PeriodFrequencyType.DAYS.getCode(), "Days");
|
||||
break;
|
||||
case WEEKS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.WEEKS.getValue().longValue(), codePrefix
|
||||
+ PeriodFrequencyType.WEEKS.getCode(), "Weeks");
|
||||
break;
|
||||
case MONTHS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.MONTHS.getValue().longValue(), codePrefix
|
||||
+ PeriodFrequencyType.MONTHS.getCode(), "Months");
|
||||
break;
|
||||
default:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.INVALID.getValue().longValue(), PeriodFrequencyType.INVALID.getCode(),
|
||||
"Invalid");
|
||||
break;
|
||||
}
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static EnumOptionData repaymentFrequencyType(final int id) {
|
||||
return repaymentFrequencyType(PeriodFrequencyType.fromInt(id));
|
||||
}
|
||||
|
||||
public static EnumOptionData repaymentFrequencyType(final PeriodFrequencyType type) {
|
||||
final String codePrefix = "repaymentFrequency.";
|
||||
EnumOptionData optionData = null;
|
||||
switch (type) {
|
||||
case DAYS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.DAYS.getValue().longValue(), codePrefix
|
||||
+ PeriodFrequencyType.DAYS.getCode(), "Days");
|
||||
break;
|
||||
case WEEKS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.WEEKS.getValue().longValue(), codePrefix
|
||||
+ PeriodFrequencyType.WEEKS.getCode(), "Weeks");
|
||||
break;
|
||||
case MONTHS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.MONTHS.getValue().longValue(), codePrefix
|
||||
+ PeriodFrequencyType.MONTHS.getCode(), "Months");
|
||||
break;
|
||||
default:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.INVALID.getValue().longValue(), PeriodFrequencyType.INVALID.getCode(),
|
||||
"Invalid");
|
||||
break;
|
||||
}
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static EnumOptionData interestRateFrequencyType(final int id) {
|
||||
return interestRateFrequencyType(PeriodFrequencyType.fromInt(id));
|
||||
}
|
||||
|
||||
public static EnumOptionData interestRateFrequencyType(final PeriodFrequencyType type) {
|
||||
final String codePrefix = "interestRateFrequency.";
|
||||
EnumOptionData optionData = null;
|
||||
switch (type) {
|
||||
case MONTHS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.MONTHS.getValue().longValue(), codePrefix
|
||||
+ PeriodFrequencyType.MONTHS.getCode(), "Per month");
|
||||
break;
|
||||
case YEARS:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.YEARS.getValue().longValue(), codePrefix
|
||||
+ PeriodFrequencyType.YEARS.getCode(), "Per year");
|
||||
break;
|
||||
default:
|
||||
optionData = new EnumOptionData(PeriodFrequencyType.INVALID.getValue().longValue(), PeriodFrequencyType.INVALID.getCode(),
|
||||
"Invalid");
|
||||
break;
|
||||
}
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static EnumOptionData amortizationType(Integer id) {
|
||||
return amortizationType(AmortizationMethod.fromInt(id));
|
||||
}
|
||||
|
||||
public static EnumOptionData amortizationType(AmortizationMethod amortizationMethod) {
|
||||
EnumOptionData optionData = null;
|
||||
switch (amortizationMethod) {
|
||||
case EQUAL_INSTALLMENTS:
|
||||
optionData = new EnumOptionData(AmortizationMethod.EQUAL_INSTALLMENTS.getValue().longValue(),
|
||||
AmortizationMethod.EQUAL_INSTALLMENTS.getCode(), "Equal installments");
|
||||
break;
|
||||
case EQUAL_PRINCIPAL:
|
||||
optionData = new EnumOptionData(AmortizationMethod.EQUAL_PRINCIPAL.getValue().longValue(),
|
||||
AmortizationMethod.EQUAL_PRINCIPAL.getCode(), "Equal principle payments");
|
||||
break;
|
||||
default:
|
||||
optionData = new EnumOptionData(AmortizationMethod.INVALID.getValue().longValue(), AmortizationMethod.INVALID.getCode(),
|
||||
"Invalid");
|
||||
break;
|
||||
}
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static EnumOptionData interestType(Integer id) {
|
||||
return interestType(InterestMethod.fromInt(id));
|
||||
}
|
||||
|
||||
public static EnumOptionData interestType(InterestMethod type) {
|
||||
EnumOptionData optionData = null;
|
||||
switch (type) {
|
||||
case FLAT:
|
||||
optionData = new EnumOptionData(InterestMethod.FLAT.getValue().longValue(), InterestMethod.FLAT.getCode(), "Flat");
|
||||
break;
|
||||
case DECLINING_BALANCE:
|
||||
optionData = new EnumOptionData(InterestMethod.DECLINING_BALANCE.getValue().longValue(),
|
||||
InterestMethod.DECLINING_BALANCE.getCode(), "Declining Balance");
|
||||
break;
|
||||
default:
|
||||
optionData = new EnumOptionData(InterestMethod.INVALID.getValue().longValue(), InterestMethod.INVALID.getCode(), "Invalid");
|
||||
break;
|
||||
}
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static EnumOptionData interestCalculationPeriodType(Integer id) {
|
||||
return interestCalculationPeriodType(InterestCalculationPeriodMethod.fromInt(id));
|
||||
}
|
||||
|
||||
public static EnumOptionData interestCalculationPeriodType(InterestCalculationPeriodMethod type) {
|
||||
EnumOptionData optionData = null;
|
||||
switch (type) {
|
||||
case DAILY:
|
||||
optionData = new EnumOptionData(InterestCalculationPeriodMethod.DAILY.getValue().longValue(),
|
||||
InterestCalculationPeriodMethod.DAILY.getCode(), "Daily");
|
||||
break;
|
||||
case SAME_AS_REPAYMENT_PERIOD:
|
||||
optionData = new EnumOptionData(InterestCalculationPeriodMethod.SAME_AS_REPAYMENT_PERIOD.getValue().longValue(),
|
||||
InterestCalculationPeriodMethod.SAME_AS_REPAYMENT_PERIOD.getCode(), "Same as repayment period");
|
||||
break;
|
||||
default:
|
||||
optionData = new EnumOptionData(InterestCalculationPeriodMethod.INVALID.getValue().longValue(),
|
||||
InterestCalculationPeriodMethod.INVALID.getCode(), "Invalid");
|
||||
break;
|
||||
}
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static EnumOptionData transactionType(final Integer id) {
|
||||
return transactionType(LoanTransactionType.fromInt(id));
|
||||
}
|
||||
|
||||
public static EnumOptionData transactionType(final LoanTransactionType type) {
|
||||
EnumOptionData optionData = null;
|
||||
switch (type) {
|
||||
case INVALID:
|
||||
optionData = new EnumOptionData(LoanTransactionType.INVALID.getValue().longValue(), LoanTransactionType.INVALID.getCode(),
|
||||
"Invalid");
|
||||
break;
|
||||
case DISBURSEMENT:
|
||||
optionData = new EnumOptionData(LoanTransactionType.DISBURSEMENT.getValue().longValue(),
|
||||
LoanTransactionType.DISBURSEMENT.getCode(), "Dibursement");
|
||||
break;
|
||||
case REPAYMENT:
|
||||
optionData = new EnumOptionData(LoanTransactionType.REPAYMENT.getValue().longValue(),
|
||||
LoanTransactionType.REPAYMENT.getCode(), "Repayment");
|
||||
break;
|
||||
case REPAYMENT_AT_DISBURSEMENT:
|
||||
optionData = new EnumOptionData(LoanTransactionType.REPAYMENT_AT_DISBURSEMENT.getValue().longValue(),
|
||||
LoanTransactionType.REPAYMENT_AT_DISBURSEMENT.getCode(), "Repayment (at time of disbursement)");
|
||||
break;
|
||||
case CONTRA:
|
||||
optionData = new EnumOptionData(LoanTransactionType.CONTRA.getValue().longValue(), LoanTransactionType.CONTRA.getCode(),
|
||||
"Reversal");
|
||||
break;
|
||||
case WAIVE_INTEREST:
|
||||
optionData = new EnumOptionData(LoanTransactionType.WAIVE_INTEREST.getValue().longValue(),
|
||||
LoanTransactionType.WAIVE_INTEREST.getCode(), "Waive interest");
|
||||
break;
|
||||
case MARKED_FOR_RESCHEDULING:
|
||||
optionData = new EnumOptionData(LoanTransactionType.MARKED_FOR_RESCHEDULING.getValue().longValue(),
|
||||
LoanTransactionType.MARKED_FOR_RESCHEDULING.getCode(), "Close (as rescheduled)");
|
||||
break;
|
||||
case WRITEOFF:
|
||||
optionData = new EnumOptionData(LoanTransactionType.WRITEOFF.getValue().longValue(),
|
||||
LoanTransactionType.WRITEOFF.getCode(), "Close (as written-off)");
|
||||
break;
|
||||
case RECOVERY_REPAYMENT:
|
||||
optionData = new EnumOptionData(LoanTransactionType.RECOVERY_REPAYMENT.getValue().longValue(),
|
||||
LoanTransactionType.RECOVERY_REPAYMENT.getCode(), "Repayment (after write-off)");
|
||||
break;
|
||||
case WAIVE_CHARGES:
|
||||
optionData = new EnumOptionData(LoanTransactionType.WAIVE_CHARGES.getValue().longValue(),
|
||||
LoanTransactionType.WAIVE_CHARGES.getCode(), "Waive loan charges");
|
||||
break;
|
||||
}
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static LoanStatusEnumData status(final Integer statusId) {
|
||||
return status(LoanStatus.fromInt(statusId));
|
||||
}
|
||||
|
||||
public static LoanStatusEnumData status(final LoanStatus status) {
|
||||
LoanStatusEnumData optionData = new LoanStatusEnumData(LoanStatus.INVALID.getValue().longValue(), LoanStatus.INVALID.getCode(),
|
||||
"Invalid");
|
||||
switch (status) {
|
||||
case INVALID:
|
||||
optionData = new LoanStatusEnumData(LoanStatus.INVALID.getValue().longValue(), LoanStatus.INVALID.getCode(), "Invalid");
|
||||
break;
|
||||
case SUBMITED_AND_PENDING_APPROVAL:
|
||||
optionData = new LoanStatusEnumData(LoanStatus.SUBMITED_AND_PENDING_APPROVAL.getValue().longValue(),
|
||||
LoanStatus.SUBMITED_AND_PENDING_APPROVAL.getCode(), "Submitted and pending approval");
|
||||
break;
|
||||
case APPROVED:
|
||||
optionData = new LoanStatusEnumData(LoanStatus.APPROVED.getValue().longValue(), LoanStatus.APPROVED.getCode(), "Approved");
|
||||
break;
|
||||
case ACTIVE:
|
||||
optionData = new LoanStatusEnumData(LoanStatus.ACTIVE.getValue().longValue(), LoanStatus.ACTIVE.getCode(), "Active");
|
||||
break;
|
||||
case REJECTED:
|
||||
optionData = new LoanStatusEnumData(LoanStatus.REJECTED.getValue().longValue(), LoanStatus.REJECTED.getCode(), "Rejected");
|
||||
break;
|
||||
case WITHDRAWN_BY_CLIENT:
|
||||
optionData = new LoanStatusEnumData(LoanStatus.WITHDRAWN_BY_CLIENT.getValue().longValue(),
|
||||
LoanStatus.WITHDRAWN_BY_CLIENT.getCode(), "Withdrawn by applicant");
|
||||
break;
|
||||
case CLOSED_OBLIGATIONS_MET:
|
||||
optionData = new LoanStatusEnumData(LoanStatus.CLOSED_OBLIGATIONS_MET.getValue().longValue(),
|
||||
LoanStatus.CLOSED_OBLIGATIONS_MET.getCode(), "Closed (obligations met)");
|
||||
break;
|
||||
case CLOSED_WRITTEN_OFF:
|
||||
optionData = new LoanStatusEnumData(LoanStatus.CLOSED_WRITTEN_OFF.getValue().longValue(),
|
||||
LoanStatus.CLOSED_WRITTEN_OFF.getCode(), "Closed (written off)");
|
||||
break;
|
||||
case CLOSED_RESCHEDULE_OUTSTANDING_AMOUNT:
|
||||
optionData = new LoanStatusEnumData(LoanStatus.CLOSED_RESCHEDULE_OUTSTANDING_AMOUNT.getValue().longValue(),
|
||||
LoanStatus.CLOSED_RESCHEDULE_OUTSTANDING_AMOUNT.getCode(), "Closed (rescheduled)");
|
||||
break;
|
||||
case OVERPAID:
|
||||
optionData = new LoanStatusEnumData(LoanStatus.OVERPAID.getValue().longValue(), LoanStatus.OVERPAID.getCode(), "Overpaid");
|
||||
break;
|
||||
}
|
||||
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static EnumOptionData status(final Integer statusId) {
|
||||
return status(LoanStatus.fromInt(statusId));
|
||||
}
|
||||
|
||||
public static EnumOptionData status(final LoanStatus status) {
|
||||
EnumOptionData optionData = new EnumOptionData(LoanStatus.INVALID.getValue().longValue(), LoanStatus.INVALID.getCode(), "Invalid");
|
||||
switch (status) {
|
||||
case INVALID:
|
||||
optionData = new EnumOptionData(LoanStatus.INVALID.getValue().longValue(), LoanStatus.INVALID.getCode(), "Invalid");
|
||||
break;
|
||||
case SUBMITED_AND_PENDING_APPROVAL:
|
||||
optionData = new EnumOptionData(LoanStatus.SUBMITED_AND_PENDING_APPROVAL.getValue().longValue(), LoanStatus.SUBMITED_AND_PENDING_APPROVAL.getCode(), "Submitted and pending approval");
|
||||
break;
|
||||
case APPROVED:
|
||||
optionData = new EnumOptionData(LoanStatus.APPROVED.getValue().longValue(), LoanStatus.APPROVED.getCode(), "Approved");
|
||||
break;
|
||||
case ACTIVE:
|
||||
optionData = new EnumOptionData(LoanStatus.ACTIVE.getValue().longValue(), LoanStatus.ACTIVE.getCode(), "Active");
|
||||
break;
|
||||
case REJECTED:
|
||||
optionData = new EnumOptionData(LoanStatus.REJECTED.getValue().longValue(), LoanStatus.REJECTED.getCode(), "Rejected");
|
||||
break;
|
||||
case WITHDRAWN_BY_CLIENT:
|
||||
optionData = new EnumOptionData(LoanStatus.WITHDRAWN_BY_CLIENT.getValue().longValue(), LoanStatus.WITHDRAWN_BY_CLIENT.getCode(), "Withdrawn by applicant");
|
||||
break;
|
||||
case CLOSED_OBLIGATIONS_MET:
|
||||
optionData = new EnumOptionData(LoanStatus.CLOSED_OBLIGATIONS_MET.getValue().longValue(), LoanStatus.CLOSED_OBLIGATIONS_MET.getCode(), "Closed (obligations met)");
|
||||
break;
|
||||
case CLOSED_WRITTEN_OFF:
|
||||
optionData = new EnumOptionData(LoanStatus.CLOSED_WRITTEN_OFF.getValue().longValue(), LoanStatus.CLOSED_WRITTEN_OFF.getCode(), "Closed (written off)");
|
||||
break;
|
||||
case CLOSED_RESCHEDULE_OUTSTANDING_AMOUNT:
|
||||
optionData = new EnumOptionData(LoanStatus.CLOSED_RESCHEDULE_OUTSTANDING_AMOUNT.getValue().longValue(), LoanStatus.CLOSED_RESCHEDULE_OUTSTANDING_AMOUNT.getCode(), "Closed (rescheduled)");
|
||||
break;
|
||||
case OVERPAID:
|
||||
optionData = new EnumOptionData(LoanStatus.OVERPAID.getValue().longValue(), LoanStatus.OVERPAID.getCode(), "Overpaid");
|
||||
break;
|
||||
}
|
||||
|
||||
return optionData;
|
||||
}
|
||||
|
||||
public static EnumOptionData accountingRuleType(final int id) {
|
||||
return accountingRuleType(AccountingRuleType.fromInt(id));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user