feat: create group loan aplication functionality added (#1460)

* feat: create group loan aplication functionality added

* lint fixes

* lint fix
This commit is contained in:
Ramveer
2022-07-15 19:22:34 +05:30
committed by GitHub
parent dd4e31e56d
commit 4a40b5eca7
5 changed files with 23 additions and 14 deletions
@@ -72,7 +72,7 @@
<span *ngIf="groupViewData.clientMembers">
<button mat-menu-item *mifosxHasPermission="'CREATE_LOAN'">Bulk JLG Loan Application</button></span>
<button mat-menu-item *mifosxHasPermission="'CREATE_SAVINGSACCOUNT'" [routerLink]="['savings-accounts', 'create']">Group Saving Application</button>
<button mat-menu-item *mifosxHasPermission="'CREATE_LOAN'">Group Loan Application</button>
<button mat-menu-item *mifosxHasPermission="'CREATE_LOAN'" [routerLink]="['loans-accounts', 'create']">Group Loan Application</button>
</mat-menu>
<button mat-raised-button [matMenuTriggerFor]="More">More</button>
@@ -23,7 +23,8 @@ export class LoansAccountTemplateResolver implements Resolve<Object> {
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const clientId = route.parent.parent.paramMap.get('clientId');
return this.loansService.getLoansAccountTemplateResource(clientId);
const entityId = route.parent.parent.paramMap.get('clientId') || route.parent.parent.paramMap.get('groupId');
const isGroup = (route.parent.parent.paramMap.get('groupId')) ? true : false;
return this.loansService.getLoansAccountTemplateResource(entityId, isGroup);
}
}
@@ -67,9 +67,10 @@ export class CreateLoansAccountComponent implements OnInit {
this.loansService.getLoansCollateralTemplateResource(this.loansAccountProductTemplate.loanProductId).subscribe((response: any) => {
this.collateralOptions = response.loanCollateralOptions;
});
const clientId = this.loansAccountTemplate.clientId;
const entityId = (this.loansAccountTemplate.clientId) ? this.loansAccountTemplate.clientId : this.loansAccountTemplate.group.id;
const isGroup = (this.loansAccountTemplate.clientId) ? false : true;
const productId = this.loansAccountProductTemplate.loanProductId;
this.loansService.getLoansAccountTemplateResource(clientId, productId).subscribe((response: any) => {
this.loansService.getLoansAccountTemplateResource(entityId, isGroup, productId).subscribe((response: any) => {
this.multiDisburseLoan = response.multiDisburseLoan;
});
}
@@ -107,10 +108,8 @@ export class CreateLoansAccountComponent implements OnInit {
submit() {
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const loanType = 'individual';
const loansAccountData = {
...this.loansAccount,
clientId: this.loansAccountTemplate.clientId,
charges: this.loansAccount.charges.map((charge: any) => ({
chargeId: charge.id,
amount: charge.amount,
@@ -131,8 +130,14 @@ export class CreateLoansAccountComponent implements OnInit {
expectedDisbursementDate: this.dateUtils.formatDate(this.loansAccount.expectedDisbursementDate, dateFormat),
dateFormat,
locale,
loanType
};
if (this.loansAccountTemplate.clientId) {
loansAccountData.clientId = this.loansAccountTemplate.clientId;
loansAccountData.loanType = 'individual';
} else {
loansAccountData.groupId = this.loansAccountTemplate.group.id;
loansAccountData.loanType = 'group';
}
if (loansAccountData.syncRepaymentsWithMeeting) {
loansAccountData.calendarId = this.loansAccountProductTemplate.calendarOptions[0].id;
@@ -88,9 +88,10 @@ export class LoansAccountDetailsStepComponent implements OnInit {
* Fetches loans account product template on productId value changes
*/
buildDependencies() {
const clientId = this.loansAccountTemplate.clientId;
const entityId = (this.loansAccountTemplate.clientId) ? this.loansAccountTemplate.clientId : this.loansAccountTemplate.group.id;
const isGroup = (this.loansAccountTemplate.clientId) ? false : true;
this.loansAccountDetailsForm.get('productId').valueChanges.subscribe((productId: string) => {
this.loansService.getLoansAccountTemplateResource(clientId, productId).subscribe((response: any) => {
this.loansService.getLoansAccountTemplateResource(entityId, isGroup, productId).subscribe((response: any) => {
this.loansAccountProductTemplate.emit(response);
this.loanOfficerOptions = response.loanOfficerOptions;
this.loanPurposeOptions = response.loanPurposeOptions;
+6 -4
View File
@@ -268,12 +268,14 @@ export class LoansService {
* @param {any} clientId Client ID
* @param {any} productId Product ID
*/
getLoansAccountTemplateResource(clientId: any, productId?: any): Observable<any> {
getLoansAccountTemplateResource(entityId: any, isGroup: boolean, productId?: any): Observable<any> {
let httpParams = new HttpParams().set('activeOnly', 'true')
.set('clientId', clientId)
.set('staffInSelectedOfficeOnly', 'true')
.set('templateType', 'individual');
.set('staffInSelectedOfficeOnly', 'true');
httpParams = productId ? httpParams.set('productId', productId) : httpParams;
httpParams = isGroup ? httpParams.set('groupId', entityId)
.set('templateType', 'group') :
httpParams.set('clientId', entityId)
.set('templateType', 'individual');
return this.http.get('/loans/template', { params: httpParams });
}