commit for FINERACT-53 (Make the clientId URL parameter optional for 'loan details template' retrieval)

This commit is contained in:
Emmanuel Nnaa
2016-07-19 12:00:20 +02:00
parent 5ac0da03d3
commit fd3b6323a4
2 changed files with 19 additions and 6 deletions
@@ -273,12 +273,15 @@ public class LoansApiResource {
// for JLG loan both client and group details are required
if (templateType.equals("individual") || templateType.equals("jlg")) {
final LoanAccountData loanAccountClientDetails = this.loanReadPlatformService.retrieveClientDetailsTemplate(clientId);
if(clientId == null) {
newLoanAccount = newLoanAccount == null ? LoanAccountData.emptyTemplate() : newLoanAccount;
} else {
final LoanAccountData loanAccountClientDetails = this.loanReadPlatformService.retrieveClientDetailsTemplate(clientId);
officeId = loanAccountClientDetails.officeId();
newLoanAccount = newLoanAccount == null ? loanAccountClientDetails : LoanAccountData.populateClientDefaults(newLoanAccount,
loanAccountClientDetails);
officeId = loanAccountClientDetails.officeId();
newLoanAccount = newLoanAccount == null ? loanAccountClientDetails : LoanAccountData.populateClientDefaults(newLoanAccount,
loanAccountClientDetails);
}
// if it's JLG loan add group details
if (templateType.equals("jlg")) {
@@ -1557,4 +1557,14 @@ public class LoanAccountData {
return (this.repaymentFrequencyType.getId().intValue() == PeriodFrequencyType.MONTHS.getValue());
}
}
/**
* Used to produce a {@link LoanAccountData} with only collateral options for now.
*
* @return {@link LoanAccountData} object
*/
public static LoanAccountData emptyTemplate() {
final Collection<CodeValueData> loanCollateralOptions = null;
return LoanAccountData.collateralTemplate(loanCollateralOptions);
}
}