Merge remote-tracking branch 'nayan/MIFOSX-269'
This commit is contained in:
@@ -42,6 +42,27 @@ public class GroupData {
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final Collection<GroupLookup> childGroups;
|
private final Collection<GroupLookup> childGroups;
|
||||||
|
|
||||||
|
public GroupData(Long id, String name, String externalId, Long officeId, Long staffId, Long parentId, String hierarchy) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.externalId = externalId;
|
||||||
|
this.officeId = officeId;
|
||||||
|
this.staffId = staffId;
|
||||||
|
this.parentId = parentId;
|
||||||
|
this.hierarchy = hierarchy;
|
||||||
|
this.officeName = null;
|
||||||
|
this.parentName = null;
|
||||||
|
this.staffName = null;
|
||||||
|
this.groupSummaryData = null;
|
||||||
|
this.groupLevelData = null;
|
||||||
|
this.clientMembers = null;
|
||||||
|
this.allowedClients = null;
|
||||||
|
this.allowedOffices = null;
|
||||||
|
this.allowedParentGroups = null;
|
||||||
|
this.allowedStaffs = null;
|
||||||
|
this.childGroups = null;
|
||||||
|
}
|
||||||
|
|
||||||
public GroupData(final Long id, final Long officeId, final String officeName, final String name, final String externalId,
|
public GroupData(final Long id, final Long officeId, final String officeName, final String name, final String externalId,
|
||||||
final Long parentId, final String parentName, final Long staffId, final String staffName, final String hierarchy) {
|
final Long parentId, final String parentName, final Long staffId, final String staffName, final String hierarchy) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|||||||
+32
-15
@@ -61,6 +61,8 @@ import org.mifosplatform.portfolio.loanaccount.service.LoanChargeReadPlatformSer
|
|||||||
import org.mifosplatform.portfolio.loanaccount.service.LoanReadPlatformService;
|
import org.mifosplatform.portfolio.loanaccount.service.LoanReadPlatformService;
|
||||||
import org.mifosplatform.portfolio.loanproduct.data.LoanProductData;
|
import org.mifosplatform.portfolio.loanproduct.data.LoanProductData;
|
||||||
import org.mifosplatform.portfolio.loanproduct.data.TransactionProcessingStrategyData;
|
import org.mifosplatform.portfolio.loanproduct.data.TransactionProcessingStrategyData;
|
||||||
|
import org.mifosplatform.portfolio.loanproduct.domain.LendingStrategy;
|
||||||
|
import org.mifosplatform.portfolio.loanproduct.exception.InvalidLendingStrategy;
|
||||||
import org.mifosplatform.portfolio.loanproduct.service.LoanDropdownReadPlatformService;
|
import org.mifosplatform.portfolio.loanproduct.service.LoanDropdownReadPlatformService;
|
||||||
import org.mifosplatform.portfolio.loanproduct.service.LoanProductReadPlatformService;
|
import org.mifosplatform.portfolio.loanproduct.service.LoanProductReadPlatformService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -76,16 +78,16 @@ import com.google.gson.JsonElement;
|
|||||||
public class LoansApiResource {
|
public class LoansApiResource {
|
||||||
|
|
||||||
private final Set<String> LOAN_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "accountNo", "status", "externalId",
|
private final Set<String> LOAN_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "accountNo", "status", "externalId",
|
||||||
"clientId", "groupId", "clientName", "groupName", "loanProductId", "loanProductName", "loanProductDescription", "fundId",
|
"clientId", "group", "loanProductId", "loanProductName", "loanProductDescription", "fundId", "fundName", "loanPurposeId",
|
||||||
"fundName", "loanPurposeId", "loanPurposeName", "loanOfficerId", "loanOfficerName", "currency", "principal",
|
"loanPurposeName", "loanOfficerId", "loanOfficerName", "currency", "principal", "inArrearsTolerance", "termFrequency",
|
||||||
"inArrearsTolerance", "termFrequency", "termPeriodFrequencyType", "numberOfRepayments", "repaymentEvery",
|
"termPeriodFrequencyType", "numberOfRepayments", "repaymentEvery", "interestRatePerPeriod", "annualInterestRate",
|
||||||
"interestRatePerPeriod", "annualInterestRate", "repaymentFrequencyType", "transactionProcessingStrategyId",
|
"repaymentFrequencyType", "transactionProcessingStrategyId", "interestRateFrequencyType", "amortizationType", "interestType",
|
||||||
"interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType",
|
"interestCalculationPeriodType", "expectedFirstRepaymentOnDate", "interestChargedFromDate", "timeline",
|
||||||
"expectedFirstRepaymentOnDate", "interestChargedFromDate", "timeline", "totalFeeChargesAtDisbursement", "summary",
|
"totalFeeChargesAtDisbursement", "summary", "repaymentSchedule", "transactions", "charges", "collateral", "guarantors",
|
||||||
"repaymentSchedule", "transactions", "charges", "collateral", "guarantors", "productOptions", "amortizationTypeOptions",
|
"productOptions", "amortizationTypeOptions", "interestTypeOptions", "interestCalculationPeriodTypeOptions",
|
||||||
"interestTypeOptions", "interestCalculationPeriodTypeOptions", "repaymentFrequencyTypeOptions", "termFrequencyTypeOptions",
|
"repaymentFrequencyTypeOptions", "termFrequencyTypeOptions", "interestRateFrequencyTypeOptions", "fundOptions",
|
||||||
"interestRateFrequencyTypeOptions", "fundOptions", "repaymentStrategyOptions", "chargeOptions", "loanOfficerOptions",
|
"repaymentStrategyOptions", "chargeOptions", "loanOfficerOptions", "loanPurposeOptions", "loanCollateralOptions",
|
||||||
"loanPurposeOptions", "loanCollateralOptions", "chargeTemplate"));
|
"chargeTemplate"));
|
||||||
|
|
||||||
private final String resourceNameForPermissions = "LOAN";
|
private final String resourceNameForPermissions = "LOAN";
|
||||||
|
|
||||||
@@ -147,7 +149,7 @@ public class LoansApiResource {
|
|||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String template(@QueryParam("clientId") final Long clientId, @QueryParam("groupId") final Long groupId,
|
public String template(@QueryParam("clientId") final Long clientId, @QueryParam("groupId") final Long groupId,
|
||||||
@QueryParam("productId") final Long productId, @Context final UriInfo uriInfo) {
|
@QueryParam("productId") final Long productId, @QueryParam("lendingStrategy") final Integer lendingStrategy, @Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||||
|
|
||||||
@@ -198,6 +200,7 @@ public class LoansApiResource {
|
|||||||
final LoanAccountData loanBasicDetails = this.loanReadPlatformService.retrieveTemplateWithClientAndProductDetails(clientId,
|
final LoanAccountData loanBasicDetails = this.loanReadPlatformService.retrieveTemplateWithClientAndProductDetails(clientId,
|
||||||
productId);
|
productId);
|
||||||
final Collection<LoanChargeData> charges = loanBasicDetails.charges();
|
final Collection<LoanChargeData> charges = loanBasicDetails.charges();
|
||||||
|
|
||||||
if (productId != null) {
|
if (productId != null) {
|
||||||
final Long officeId = loanBasicDetails.officeId();
|
final Long officeId = loanBasicDetails.officeId();
|
||||||
allowedLoanOfficers = this.staffReadPlatformService.retrieveAllLoanOfficersByOffice(officeId);
|
allowedLoanOfficers = this.staffReadPlatformService.retrieveAllLoanOfficersByOffice(officeId);
|
||||||
@@ -209,9 +212,22 @@ public class LoansApiResource {
|
|||||||
interestCalculationPeriodTypeOptions, fundOptions, chargeOptions, chargeTemplate, allowedLoanOfficers,
|
interestCalculationPeriodTypeOptions, fundOptions, chargeOptions, chargeTemplate, allowedLoanOfficers,
|
||||||
loanPurposeOptions, loanCollateralOptions);
|
loanPurposeOptions, loanCollateralOptions);
|
||||||
|
|
||||||
} else if (groupId != null) {
|
} else if (groupId != null ) {
|
||||||
final LoanAccountData loanBasicDetails = this.loanReadPlatformService.retrieveTemplateWithGroupAndProductDetails(groupId,
|
|
||||||
productId);
|
LoanAccountData loanBasicDetails = null;
|
||||||
|
|
||||||
|
if (LendingStrategy.JOINT_LIABILITY_LOAN.getId().equals(lendingStrategy)){
|
||||||
|
loanBasicDetails = this.loanReadPlatformService.retrieveTemplateWithCompleteGroupAndProductDetails(groupId,
|
||||||
|
productId);
|
||||||
|
}
|
||||||
|
else if( LendingStrategy.GROUP_LOAN.getId().equals(lendingStrategy)){
|
||||||
|
loanBasicDetails = this.loanReadPlatformService.retrieveTemplateWithGroupAndProductDetails(groupId,
|
||||||
|
productId);
|
||||||
|
}else{
|
||||||
|
throw new InvalidLendingStrategy(lendingStrategy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
final Collection<LoanChargeData> charges = loanBasicDetails.charges();
|
final Collection<LoanChargeData> charges = loanBasicDetails.charges();
|
||||||
if (productId != null) {
|
if (productId != null) {
|
||||||
final Long officeId = loanBasicDetails.officeId();
|
final Long officeId = loanBasicDetails.officeId();
|
||||||
@@ -223,7 +239,8 @@ public class LoansApiResource {
|
|||||||
repaymentStrategyOptions, interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions,
|
repaymentStrategyOptions, interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions,
|
||||||
interestCalculationPeriodTypeOptions, fundOptions, chargeOptions, chargeTemplate, allowedLoanOfficers,
|
interestCalculationPeriodTypeOptions, fundOptions, chargeOptions, chargeTemplate, allowedLoanOfficers,
|
||||||
loanPurposeOptions, loanCollateralOptions);
|
loanPurposeOptions, loanCollateralOptions);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
newLoanAccount = LoanAccountData.collateralTemplate(loanCollateralOptions);
|
newLoanAccount = LoanAccountData.collateralTemplate(loanCollateralOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+20
-34
@@ -19,6 +19,7 @@ import org.mifosplatform.organisation.staff.data.StaffData;
|
|||||||
import org.mifosplatform.portfolio.charge.data.ChargeData;
|
import org.mifosplatform.portfolio.charge.data.ChargeData;
|
||||||
import org.mifosplatform.portfolio.collateral.data.CollateralData;
|
import org.mifosplatform.portfolio.collateral.data.CollateralData;
|
||||||
import org.mifosplatform.portfolio.fund.data.FundData;
|
import org.mifosplatform.portfolio.fund.data.FundData;
|
||||||
|
import org.mifosplatform.portfolio.group.data.GroupData;
|
||||||
import org.mifosplatform.portfolio.loanaccount.guarantor.data.GuarantorData;
|
import org.mifosplatform.portfolio.loanaccount.guarantor.data.GuarantorData;
|
||||||
import org.mifosplatform.portfolio.loanaccount.loanschedule.data.LoanScheduleData;
|
import org.mifosplatform.portfolio.loanaccount.loanschedule.data.LoanScheduleData;
|
||||||
import org.mifosplatform.portfolio.loanproduct.data.LoanProductData;
|
import org.mifosplatform.portfolio.loanproduct.data.LoanProductData;
|
||||||
@@ -45,9 +46,7 @@ public class LoanAccountData {
|
|||||||
private final Long clientId;
|
private final Long clientId;
|
||||||
private final String clientName;
|
private final String clientName;
|
||||||
private final Long clientOfficeId;
|
private final Long clientOfficeId;
|
||||||
private final Long groupId;
|
private final GroupData group;
|
||||||
private final String groupName;
|
|
||||||
private final Long groupOfficeId;
|
|
||||||
private final Long loanProductId;
|
private final Long loanProductId;
|
||||||
private final String loanProductName;
|
private final String loanProductName;
|
||||||
private final String loanProductDescription;
|
private final String loanProductDescription;
|
||||||
@@ -122,9 +121,7 @@ public class LoanAccountData {
|
|||||||
final Long clientId = null;
|
final Long clientId = null;
|
||||||
final String clientName = null;
|
final String clientName = null;
|
||||||
final Long clientOfficeId = null;
|
final Long clientOfficeId = null;
|
||||||
final Long groupId = null;
|
final GroupData group = null;
|
||||||
final String groupName = null;
|
|
||||||
final Long groupOfficeId = null;
|
|
||||||
final Long loanProductId = null;
|
final Long loanProductId = null;
|
||||||
final String loanProductName = null;
|
final String loanProductName = null;
|
||||||
final String loanProductDescription = null;
|
final String loanProductDescription = null;
|
||||||
@@ -174,8 +171,8 @@ public class LoanAccountData {
|
|||||||
final Collection<StaffData> loanOfficerOptions = null;
|
final Collection<StaffData> loanOfficerOptions = null;
|
||||||
final Collection<CodeValueData> loanPurposeOptions = null;
|
final Collection<CodeValueData> loanPurposeOptions = null;
|
||||||
|
|
||||||
return new LoanAccountData(id, accountNo, status, externalId, clientId, clientName, clientOfficeId, groupId, groupName,
|
return new LoanAccountData(id, accountNo, status, externalId, clientId, clientName, clientOfficeId, group,
|
||||||
groupOfficeId, loanProductId, loanProductName, loanProductDescription, fundId, fundName, loanPurposeId, loanPurposeName,
|
loanProductId, loanProductName, loanProductDescription, fundId, fundName, loanPurposeId, loanPurposeName,
|
||||||
loanOfficerId, loanOfficerName, currencyData, principal, inArrearsTolerance, termFrequency, termPeriodFrequencyType,
|
loanOfficerId, loanOfficerName, currencyData, principal, inArrearsTolerance, termFrequency, termPeriodFrequencyType,
|
||||||
numberOfRepayments, repaymentEvery, repaymentFrequencyType, transactionProcessingStrategyId, amortizationType,
|
numberOfRepayments, repaymentEvery, repaymentFrequencyType, transactionProcessingStrategyId, amortizationType,
|
||||||
interestRatePerPeriod, interestRateFrequencyType, annualInterestRate, interestType, interestCalculationPeriodType,
|
interestRatePerPeriod, interestRateFrequencyType, annualInterestRate, interestType, interestCalculationPeriodType,
|
||||||
@@ -196,9 +193,8 @@ public class LoanAccountData {
|
|||||||
final String accountNo = null;
|
final String accountNo = null;
|
||||||
final LoanStatusEnumData status = null;
|
final LoanStatusEnumData status = null;
|
||||||
final String externalId = null;
|
final String externalId = null;
|
||||||
final Long groupId = null;
|
final GroupData group = null;
|
||||||
final String groupName = null;
|
final String groupName = null;
|
||||||
final Long groupOfficeId = null;
|
|
||||||
final Long loanProductId = null;
|
final Long loanProductId = null;
|
||||||
final String loanProductName = null;
|
final String loanProductName = null;
|
||||||
final String loanProductDescription = null;
|
final String loanProductDescription = null;
|
||||||
@@ -249,8 +245,8 @@ public class LoanAccountData {
|
|||||||
final Collection<CodeValueData> loanPurposeOptions = null;
|
final Collection<CodeValueData> loanPurposeOptions = null;
|
||||||
final Collection<CodeValueData> loanCollateralOptions = null;
|
final Collection<CodeValueData> loanCollateralOptions = null;
|
||||||
|
|
||||||
return new LoanAccountData(id, accountNo, status, externalId, clientId, clientName, clientOfficeId, groupId, groupName,
|
return new LoanAccountData(id, accountNo, status, externalId, clientId, clientName, clientOfficeId, group,
|
||||||
groupOfficeId, loanProductId, loanProductName, loanProductDescription, fundId, fundName, loanPurposeId, loanPurposeName,
|
loanProductId, loanProductName, loanProductDescription, fundId, fundName, loanPurposeId, loanPurposeName,
|
||||||
loanOfficerId, loanOfficerName, currencyData, principal, inArrearsTolerance, termFrequency, termPeriodFrequencyType,
|
loanOfficerId, loanOfficerName, currencyData, principal, inArrearsTolerance, termFrequency, termPeriodFrequencyType,
|
||||||
numberOfRepayments, repaymentEvery, repaymentFrequencyType, transactionProcessingStrategyId, amortizationType,
|
numberOfRepayments, repaymentEvery, repaymentFrequencyType, transactionProcessingStrategyId, amortizationType,
|
||||||
interestRatePerPeriod, interestRateFrequencyType, annualInterestRate, interestType, interestCalculationPeriodType,
|
interestRatePerPeriod, interestRateFrequencyType, annualInterestRate, interestType, interestCalculationPeriodType,
|
||||||
@@ -265,7 +261,7 @@ public class LoanAccountData {
|
|||||||
* Used to produce a {@link LoanAccountData} with only group information
|
* Used to produce a {@link LoanAccountData} with only group information
|
||||||
* defaulted.
|
* defaulted.
|
||||||
*/
|
*/
|
||||||
public static LoanAccountData groupDefaults(final Long groupId, final String groupName, final Long groupOfficeId,
|
public static LoanAccountData groupDefaults(final GroupData group,
|
||||||
final LocalDate expectedDisbursementDate) {
|
final LocalDate expectedDisbursementDate) {
|
||||||
|
|
||||||
final Long id = null;
|
final Long id = null;
|
||||||
@@ -325,8 +321,8 @@ public class LoanAccountData {
|
|||||||
final Collection<CodeValueData> loanPurposeOptions = null;
|
final Collection<CodeValueData> loanPurposeOptions = null;
|
||||||
final Collection<CodeValueData> loanCollateralOptions = null;
|
final Collection<CodeValueData> loanCollateralOptions = null;
|
||||||
|
|
||||||
return new LoanAccountData(id, accountNo, status, externalId, clientId, clientName, clientOfficeId, groupId, groupName,
|
return new LoanAccountData(id, accountNo, status, externalId, clientId, clientName, clientOfficeId, group,
|
||||||
groupOfficeId, loanProductId, loanProductName, loanProductDescription, fundId, fundName, loanPurposeId, loanPurposeName,
|
loanProductId, loanProductName, loanProductDescription, fundId, fundName, loanPurposeId, loanPurposeName,
|
||||||
loanOfficerId, loanOfficerName, currencyData, principal, inArrearsTolerance, termFrequency, termPeriodFrequencyType,
|
loanOfficerId, loanOfficerName, currencyData, principal, inArrearsTolerance, termFrequency, termPeriodFrequencyType,
|
||||||
numberOfRepayments, repaymentEvery, repaymentFrequencyType, transactionProcessingStrategyId, amortizationType,
|
numberOfRepayments, repaymentEvery, repaymentFrequencyType, transactionProcessingStrategyId, amortizationType,
|
||||||
interestRatePerPeriod, interestRateFrequencyType, annualInterestRate, interestType, interestCalculationPeriodType,
|
interestRatePerPeriod, interestRateFrequencyType, annualInterestRate, interestType, interestCalculationPeriodType,
|
||||||
@@ -367,7 +363,7 @@ public class LoanAccountData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new LoanAccountData(acc.id, acc.accountNo, acc.status, acc.externalId, acc.clientId, acc.clientName, acc.clientOfficeId,
|
return new LoanAccountData(acc.id, acc.accountNo, acc.status, acc.externalId, acc.clientId, acc.clientName, acc.clientOfficeId,
|
||||||
acc.groupId, acc.groupName, acc.groupOfficeId, product.getId(), product.getName(), product.getDescription(),
|
acc.group, product.getId(), product.getName(), product.getDescription(),
|
||||||
product.getFundId(), product.getFundName(), acc.loanPurposeId, acc.loanPurposeName, acc.loanOfficerId, acc.loanOfficerName,
|
product.getFundId(), product.getFundName(), acc.loanPurposeId, acc.loanPurposeName, acc.loanOfficerId, acc.loanOfficerName,
|
||||||
product.getCurrency(), product.getPrincipal(), product.getInArrearsTolerance(), termFrequency, termPeriodFrequencyType,
|
product.getCurrency(), product.getPrincipal(), product.getInArrearsTolerance(), termFrequency, termPeriodFrequencyType,
|
||||||
product.getNumberOfRepayments(), product.getRepaymentEvery(), product.getRepaymentFrequencyType(),
|
product.getNumberOfRepayments(), product.getRepaymentEvery(), product.getRepaymentFrequencyType(),
|
||||||
@@ -385,8 +381,8 @@ public class LoanAccountData {
|
|||||||
* query.
|
* query.
|
||||||
*/
|
*/
|
||||||
public static LoanAccountData basicLoanDetails(final Long id, final String accountNo, final LoanStatusEnumData status,
|
public static LoanAccountData basicLoanDetails(final Long id, final String accountNo, final LoanStatusEnumData status,
|
||||||
final String externalId, final Long clientId, final String clientName, final Long clientOfficeId, final Long groupId,
|
final String externalId, final Long clientId, final String clientName, final Long clientOfficeId, final GroupData group,
|
||||||
final String groupName, final Long groupOfficeId, final Long loanProductId, final String loanProductName,
|
final Long loanProductId, final String loanProductName,
|
||||||
final String loanProductDescription, final Long fundId, final String fundName, final Long loanPurposeId,
|
final String loanProductDescription, final Long fundId, final String fundName, final Long loanPurposeId,
|
||||||
final String loanPurposeName, final Long loanOfficerId, final String loanOfficerName, final CurrencyData currencyData,
|
final String loanPurposeName, final Long loanOfficerId, final String loanOfficerName, final CurrencyData currencyData,
|
||||||
final BigDecimal principal, final BigDecimal inArrearsTolerance, final Integer termFrequency,
|
final BigDecimal principal, final BigDecimal inArrearsTolerance, final Integer termFrequency,
|
||||||
@@ -418,8 +414,8 @@ public class LoanAccountData {
|
|||||||
final Collection<CodeValueData> loanPurposeOptions = null;
|
final Collection<CodeValueData> loanPurposeOptions = null;
|
||||||
final Collection<CodeValueData> loanCollateralOptions = null;
|
final Collection<CodeValueData> loanCollateralOptions = null;
|
||||||
|
|
||||||
return new LoanAccountData(id, accountNo, status, externalId, clientId, clientName, clientOfficeId, groupId, groupName,
|
return new LoanAccountData(id, accountNo, status, externalId, clientId, clientName, clientOfficeId, group,
|
||||||
groupOfficeId, loanProductId, loanProductName, loanProductDescription, fundId, fundName, loanPurposeId, loanPurposeName,
|
loanProductId, loanProductName, loanProductDescription, fundId, fundName, loanPurposeId, loanPurposeName,
|
||||||
loanOfficerId, loanOfficerName, currencyData, principal, inArrearsTolerance, termFrequency, termPeriodFrequencyType,
|
loanOfficerId, loanOfficerName, currencyData, principal, inArrearsTolerance, termFrequency, termPeriodFrequencyType,
|
||||||
numberOfRepayments, repaymentEvery, repaymentFrequencyType, transactionStrategyId, amortizationType, interestRatePerPeriod,
|
numberOfRepayments, repaymentEvery, repaymentFrequencyType, transactionStrategyId, amortizationType, interestRatePerPeriod,
|
||||||
interestRateFrequencyType, annualInterestRate, interestType, interestCalculationPeriodType, expectedFirstRepaymentOnDate,
|
interestRateFrequencyType, annualInterestRate, interestType, interestCalculationPeriodType, expectedFirstRepaymentOnDate,
|
||||||
@@ -446,7 +442,7 @@ public class LoanAccountData {
|
|||||||
final Collection<StaffData> loanOfficerOptions, final Collection<CodeValueData> loanPurposeOptions,
|
final Collection<StaffData> loanOfficerOptions, final Collection<CodeValueData> loanPurposeOptions,
|
||||||
final Collection<CodeValueData> loanCollateralOptions) {
|
final Collection<CodeValueData> loanCollateralOptions) {
|
||||||
return new LoanAccountData(acc.id, acc.accountNo, acc.status, acc.externalId, acc.clientId, acc.clientName, acc.clientOfficeId,
|
return new LoanAccountData(acc.id, acc.accountNo, acc.status, acc.externalId, acc.clientId, acc.clientName, acc.clientOfficeId,
|
||||||
acc.groupId, acc.groupName, acc.groupOfficeId, acc.loanProductId, acc.loanProductName, acc.loanProductDescription,
|
acc.group, acc.loanProductId, acc.loanProductName, acc.loanProductDescription,
|
||||||
acc.fundId, acc.fundName, acc.loanPurposeId, acc.loanPurposeName, acc.loanOfficerId, acc.loanOfficerName, acc.currency,
|
acc.fundId, acc.fundName, acc.loanPurposeId, acc.loanPurposeName, acc.loanOfficerId, acc.loanOfficerName, acc.currency,
|
||||||
acc.principal, acc.inArrearsTolerance, acc.termFrequency, acc.termPeriodFrequencyType, acc.numberOfRepayments,
|
acc.principal, acc.inArrearsTolerance, acc.termFrequency, acc.termPeriodFrequencyType, acc.numberOfRepayments,
|
||||||
acc.repaymentEvery, acc.repaymentFrequencyType, acc.transactionProcessingStrategyId, acc.amortizationType,
|
acc.repaymentEvery, acc.repaymentFrequencyType, acc.transactionProcessingStrategyId, acc.amortizationType,
|
||||||
@@ -466,9 +462,7 @@ public class LoanAccountData {
|
|||||||
final Long clientId,
|
final Long clientId,
|
||||||
final String clientName,
|
final String clientName,
|
||||||
final Long clientOfficeId, //
|
final Long clientOfficeId, //
|
||||||
final Long groupId,
|
final GroupData group,
|
||||||
final String groupName,
|
|
||||||
final Long groupOfficeId, //
|
|
||||||
final Long loanProductId,
|
final Long loanProductId,
|
||||||
final String loanProductName,
|
final String loanProductName,
|
||||||
final String loanProductDescription, //
|
final String loanProductDescription, //
|
||||||
@@ -508,9 +502,7 @@ public class LoanAccountData {
|
|||||||
this.clientId = clientId;
|
this.clientId = clientId;
|
||||||
this.clientName = clientName;
|
this.clientName = clientName;
|
||||||
this.clientOfficeId = clientOfficeId;
|
this.clientOfficeId = clientOfficeId;
|
||||||
this.groupId = groupId;
|
this.group = group;
|
||||||
this.groupName = groupName;
|
|
||||||
this.groupOfficeId = groupOfficeId;
|
|
||||||
this.loanProductId = loanProductId;
|
this.loanProductId = loanProductId;
|
||||||
this.loanProductName = loanProductName;
|
this.loanProductName = loanProductName;
|
||||||
this.loanProductDescription = loanProductDescription;
|
this.loanProductDescription = loanProductDescription;
|
||||||
@@ -602,13 +594,7 @@ public class LoanAccountData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Long officeId() {
|
public Long officeId() {
|
||||||
Long officeId = this.clientOfficeId;
|
return this.clientOfficeId;
|
||||||
|
|
||||||
if (officeId == null) {
|
|
||||||
officeId = this.groupOfficeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
return officeId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long loanOfficerId() {
|
public Long loanOfficerId() {
|
||||||
|
|||||||
+2
@@ -31,4 +31,6 @@ public interface LoanReadPlatformService {
|
|||||||
LoanTransactionData retrieveLoanTransaction(Long loanId, Long transactionId);
|
LoanTransactionData retrieveLoanTransaction(Long loanId, Long transactionId);
|
||||||
|
|
||||||
LoanTransactionData retrieveNewClosureDetails();
|
LoanTransactionData retrieveNewClosureDetails();
|
||||||
|
|
||||||
|
LoanAccountData retrieveTemplateWithCompleteGroupAndProductDetails(Long groupId, Long productId);
|
||||||
}
|
}
|
||||||
+35
-7
@@ -158,10 +158,9 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
|||||||
|
|
||||||
context.authenticatedUser();
|
context.authenticatedUser();
|
||||||
|
|
||||||
final GroupData groupAccount = this.groupReadPlatformService.retrieveGroup(groupId);
|
final GroupData groupAccount = this.groupReadPlatformService.retrieveGroupDetails(groupId , false);
|
||||||
final LocalDate expectedDisbursementDate = DateUtils.getLocalDateOfTenant();
|
final LocalDate expectedDisbursementDate = DateUtils.getLocalDateOfTenant();
|
||||||
LoanAccountData loanDetails = LoanAccountData.groupDefaults(groupAccount.getId(), groupAccount.getName(),
|
LoanAccountData loanDetails = LoanAccountData.groupDefaults(groupAccount, expectedDisbursementDate);
|
||||||
groupAccount.getOfficeId(), expectedDisbursementDate);
|
|
||||||
|
|
||||||
if (productId != null) {
|
if (productId != null) {
|
||||||
LoanProductData selectedProduct = this.loanProductReadPlatformService.retrieveLoanProduct(productId);
|
LoanProductData selectedProduct = this.loanProductReadPlatformService.retrieveLoanProduct(productId);
|
||||||
@@ -170,7 +169,25 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
|||||||
|
|
||||||
return loanDetails;
|
return loanDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LoanAccountData retrieveTemplateWithCompleteGroupAndProductDetails(Long groupId, Long productId){
|
||||||
|
|
||||||
|
context.authenticatedUser();
|
||||||
|
|
||||||
|
final GroupData groupAccount = this.groupReadPlatformService.retrieveGroup(groupId);
|
||||||
|
final LocalDate expectedDisbursementDate = DateUtils.getLocalDateOfTenant();
|
||||||
|
LoanAccountData loanDetails = LoanAccountData.groupDefaults(groupAccount, expectedDisbursementDate);
|
||||||
|
|
||||||
|
if (productId != null) {
|
||||||
|
LoanProductData selectedProduct = this.loanProductReadPlatformService.retrieveLoanProduct(productId);
|
||||||
|
loanDetails = LoanAccountData.populateLoanProductDefaults(loanDetails, selectedProduct);
|
||||||
|
}
|
||||||
|
|
||||||
|
return loanDetails;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoanTransactionData retrieveLoanTransactionTemplate(final Long loanId) {
|
public LoanTransactionData retrieveLoanTransactionTemplate(final Long loanId) {
|
||||||
|
|
||||||
@@ -263,7 +280,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
|||||||
+ " l.loanpurpose_cv_id as loanPurposeId, cv.code_value as loanPurposeName,"
|
+ " l.loanpurpose_cv_id as loanPurposeId, cv.code_value as loanPurposeName,"
|
||||||
+ " lp.id as loanProductId, lp.name as loanProductName, lp.description as loanProductDescription,"
|
+ " lp.id as loanProductId, lp.name as loanProductName, lp.description as loanProductDescription,"
|
||||||
+ " c.id as clientId, c.display_name as clientName, c.office_id as clientOfficeId,"
|
+ " c.id as clientId, c.display_name as clientName, c.office_id as clientOfficeId,"
|
||||||
+ " g.id as groupId, g.name as groupName, g.office_id as groupOfficeId,"
|
+ " g.id as groupId, g.name as groupName, g.office_id as groupOfficeId, g.staff_id As groupStaffId , g.parent_id as groupParentId , g.hierarchy As groupHierarchy , g.external_id As groupExternalId , "
|
||||||
+ " l.submittedon_date as submittedOnDate, sbu.username as submittedByUsername, sbu.firstname as submittedByFirstname, sbu.lastname as submittedByLastname,"
|
+ " l.submittedon_date as submittedOnDate, sbu.username as submittedByUsername, sbu.firstname as submittedByFirstname, sbu.lastname as submittedByLastname,"
|
||||||
+ " l.rejectedon_date as rejectedOnDate, rbu.username as rejectedByUsername, rbu.firstname as rejectedByFirstname, rbu.lastname as rejectedByLastname,"
|
+ " l.rejectedon_date as rejectedOnDate, rbu.username as rejectedByUsername, rbu.firstname as rejectedByFirstname, rbu.lastname as rejectedByLastname,"
|
||||||
+ " l.withdrawnon_date as withdrawnOnDate, wbu.username as withdrawnByUsername, wbu.firstname as withdrawnByFirstname, wbu.lastname as withdrawnByLastname,"
|
+ " l.withdrawnon_date as withdrawnOnDate, wbu.username as withdrawnByUsername, wbu.firstname as withdrawnByFirstname, wbu.lastname as withdrawnByLastname,"
|
||||||
@@ -349,8 +366,12 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
|||||||
final String clientName = rs.getString("clientName");
|
final String clientName = rs.getString("clientName");
|
||||||
|
|
||||||
final Long groupId = JdbcSupport.getLong(rs, "groupId");
|
final Long groupId = JdbcSupport.getLong(rs, "groupId");
|
||||||
final Long groupOfficeId = JdbcSupport.getLong(rs, "groupOfficeId");
|
|
||||||
final String groupName = rs.getString("groupName");
|
final String groupName = rs.getString("groupName");
|
||||||
|
final String groupExternalId = rs.getString("groupExternalId");
|
||||||
|
final Long groupOfficeId = JdbcSupport.getLong(rs, "groupOfficeId");
|
||||||
|
final Long groupStaffId = JdbcSupport.getLong(rs, "groupStaffId");
|
||||||
|
final Long groupParentId = JdbcSupport.getLong(rs, "groupParentId");
|
||||||
|
final String groupHierarchy = rs.getString("groupHierarchy");
|
||||||
|
|
||||||
final Long fundId = JdbcSupport.getLong(rs, "fundId");
|
final Long fundId = JdbcSupport.getLong(rs, "fundId");
|
||||||
final String fundName = rs.getString("fundName");
|
final String fundName = rs.getString("fundName");
|
||||||
@@ -494,8 +515,15 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
|||||||
totalWaived, totalWrittenOff, totalOutstanding, totalOverdue, overdueSinceDate);
|
totalWaived, totalWrittenOff, totalOutstanding, totalOverdue, overdueSinceDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
return LoanAccountData.basicLoanDetails(id, accountNo, status, externalId, clientId, clientName, clientOfficeId, groupId,
|
GroupData groupData = null;
|
||||||
groupName, groupOfficeId, loanProductId, loanProductName, loanProductDescription, fundId, fundName, loanPurposeId,
|
|
||||||
|
if(groupId != null){
|
||||||
|
|
||||||
|
groupData = new GroupData(groupId, groupName, groupExternalId, groupOfficeId, groupStaffId, groupParentId, groupHierarchy);
|
||||||
|
}
|
||||||
|
|
||||||
|
return LoanAccountData.basicLoanDetails(id, accountNo, status, externalId, clientId, clientName, clientOfficeId, groupData,
|
||||||
|
loanProductId, loanProductName, loanProductDescription, fundId, fundName, loanPurposeId,
|
||||||
loanPurposeName, loanOfficerId, loanOfficerName, currencyData, principal, inArrearsTolerance, termFrequency,
|
loanPurposeName, loanOfficerId, loanOfficerName, currencyData, principal, inArrearsTolerance, termFrequency,
|
||||||
termPeriodFrequencyType, numberOfRepayments, repaymentEvery, repaymentFrequencyType, transactionStrategyId,
|
termPeriodFrequencyType, numberOfRepayments, repaymentEvery, repaymentFrequencyType, transactionStrategyId,
|
||||||
amortizationType, interestRatePerPeriod, interestRateFrequencyType, annualInterestRate, interestType,
|
amortizationType, interestRatePerPeriod, interestRateFrequencyType, annualInterestRate, interestType,
|
||||||
|
|||||||
+84
@@ -0,0 +1,84 @@
|
|||||||
|
package org.mifosplatform.portfolio.loanproduct.domain;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* INDIVIDUAL_LOAN: Individual loans are applicable only to clients.
|
||||||
|
* GROUP_LOAN: * Group loans are applicable only to groups. And tracked only at
|
||||||
|
* group level.
|
||||||
|
* JOINT_LIABILITY_LOAN: Joint liability loans are applicable only
|
||||||
|
* to clients within a group.
|
||||||
|
* LINKED_LOAN: Loan is given to group, then later loan amount is split into individual loans. Loan is tracked at both
|
||||||
|
* individual and group level
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum LendingStrategy {
|
||||||
|
|
||||||
|
INDIVIDUAL_LOAN(100, "lendingStrategy.individaulLoan", "individaulLoan"), //
|
||||||
|
GROUP_LOAN(200, "lendingStrategy.groupLoan", "groupLoan"), //
|
||||||
|
JOINT_LIABILITY_LOAN(300, "lendingStrategy.joinLiabilityLoan", "joinLiabilityLoan"), //
|
||||||
|
LINKED_LOAN(400, "lendingStrategy.linkedLoan", "linkedLoan"), //
|
||||||
|
INVALID(900, "lendingStrategy.invalid", "invalid");
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
private String code;
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
LendingStrategy(final Integer id, final String code, final String value) {
|
||||||
|
this.id = id;
|
||||||
|
this.code = code;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Map<Integer, LendingStrategy> intToEnumMap = new HashMap<Integer, LendingStrategy>();
|
||||||
|
private static int minValue;
|
||||||
|
private static int maxValue;
|
||||||
|
static {
|
||||||
|
int i = 0;
|
||||||
|
for (final LendingStrategy type : LendingStrategy.values()) {
|
||||||
|
if (i == 0) {
|
||||||
|
minValue = type.id;
|
||||||
|
}
|
||||||
|
intToEnumMap.put(type.id, type);
|
||||||
|
if (minValue >= type.id) {
|
||||||
|
minValue = type.id;
|
||||||
|
}
|
||||||
|
if (maxValue < type.id) {
|
||||||
|
maxValue = type.id;
|
||||||
|
}
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LendingStrategy fromInt(final int i) {
|
||||||
|
final LendingStrategy type = intToEnumMap.get(Integer.valueOf(i));
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getMinValue() {
|
||||||
|
return minValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getMaxValue() {
|
||||||
|
return maxValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return this.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
/**
|
||||||
|
* 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.loanproduct.exception;
|
||||||
|
|
||||||
|
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link AbstractPlatformDomainRuleException} thrown when lending strategy mismatch
|
||||||
|
* occurs
|
||||||
|
*/
|
||||||
|
public class InvalidLendingStrategy extends AbstractPlatformDomainRuleException {
|
||||||
|
public InvalidLendingStrategy(final Integer strategyId ) {
|
||||||
|
super("error.msg.unsupported.lending.strategy", "Stratagy code ["+ strategyId + "] passed is not valid.");
|
||||||
|
}
|
||||||
|
}
|
||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
/**
|
||||||
|
* 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.loanproduct.service;
|
||||||
|
|
||||||
|
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||||
|
import org.mifosplatform.portfolio.loanproduct.domain.LendingStrategy;
|
||||||
|
|
||||||
|
public class LendingStrategyEnumerations {
|
||||||
|
|
||||||
|
public static EnumOptionData lendingStrategy(final Integer id) {
|
||||||
|
return lendingStrategy(LendingStrategy.fromInt(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EnumOptionData lendingStrategy(final LendingStrategy type) {
|
||||||
|
EnumOptionData optionData = null;
|
||||||
|
switch (type) {
|
||||||
|
case INDIVIDUAL_LOAN:
|
||||||
|
optionData = new EnumOptionData(type.getId().longValue(), type.getCode(), "Individual loan");
|
||||||
|
break;
|
||||||
|
case GROUP_LOAN:
|
||||||
|
optionData = new EnumOptionData(type.getId().longValue(), type.getCode(), "Group loan");
|
||||||
|
break;
|
||||||
|
case JOINT_LIABILITY_LOAN:
|
||||||
|
optionData = new EnumOptionData(type.getId().longValue(), type.getCode(), "Joint liability loan");
|
||||||
|
break;
|
||||||
|
case LINKED_LOAN:
|
||||||
|
optionData = new EnumOptionData(type.getId().longValue(), type.getCode(), "Linked loan");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
optionData = new EnumOptionData(LendingStrategy.INVALID.getId().longValue(), LendingStrategy.INVALID.getCode() , "Invalid");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return optionData;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user