Skip to content

Commit d20c930

Browse files
committed
WEB-95 Fix problems with GLIM application: saved total ,Moratorium, Overdue Charges
1 parent c271ad8 commit d20c930

File tree

6 files changed

+146
-57
lines changed

6 files changed

+146
-57
lines changed

src/app/loans/glim-account/create-glim-account/create-glim-account.component.ts

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -175,37 +175,36 @@ export class CreateGlimAccountComponent {
175175
};
176176
}
177177

178-
setData(client: any, totalLoan: number): any {
178+
setData(client: any, totalLoan: number, isParent?: boolean): any {
179179
const locale = this.settingsService.language.code;
180180
const dateFormat = this.settingsService.dateFormat;
181181
// const monthDayFormat = 'dd MMMM';
182-
const data = {
182+
const data: any = {
183183
...this.loansAccount,
184184
charges: this.loansAccount.charges.map((charge: any) => ({
185185
chargeId: charge.id,
186186
amount: charge.amount
187187
})),
188188
clientId: client.id,
189-
totalLoan: totalLoan,
190189
loanType: 'glim',
191190
amortizationType: 1,
192-
isParentAccount: true,
193191
principal: client.principal,
194192
syncDisbursementWithMeeting: false,
195193
expectedDisbursementDate: this.dateUtils.formatDate(this.loansAccount.expectedDisbursementDate, dateFormat),
196194
submittedOnDate: this.dateUtils.formatDate(this.loansAccount.submittedOnDate, dateFormat),
197-
dateFormat,
198-
// monthDayFormat,
199-
locale
195+
dateFormat: dateFormat,
196+
locale: locale,
197+
groupId: this.loansAccountTemplate.group.id
200198
};
201-
data.groupId = this.loansAccountTemplate.group.id;
202-
199+
if (isParent) {
200+
data.totalLoan = totalLoan;
201+
data.isParentAccount = true;
202+
}
203203
delete data.principalAmount;
204204
// TODO: 2025-03-17: Apparently (?!) unsupported for GLIM
205205
delete data.allowPartialPeriodInterestCalculation;
206206
delete data.multiDisburseLoan;
207207
delete data.isFloatingInterestRate;
208-
209208
return JSON.stringify(data);
210209
}
211210

@@ -214,12 +213,22 @@ export class CreateGlimAccountComponent {
214213
const requestData = [];
215214
const memberSelected = this.selectedMembers.selectedMembers;
216215
const totalLoan = this.totalLoanAmount();
216+
requestData.push({
217+
requestId: '0',
218+
method: 'POST',
219+
relativeUrl: 'loans',
220+
body: this.setData(
221+
{ id: this.loansAccountTemplate.group.id, principal: totalLoan, isParentAccount: true },
222+
totalLoan,
223+
true
224+
)
225+
});
217226
for (let index = 0; index < memberSelected.length; index++) {
218227
requestData.push({
219-
requestId: index.toString(),
228+
requestId: (index + 1).toString(),
220229
method: 'POST',
221230
relativeUrl: 'loans',
222-
body: this.setData(memberSelected[index], totalLoan)
231+
body: this.setData(memberSelected[index], totalLoan, false)
223232
});
224233
}
225234
return requestData;
@@ -234,27 +243,6 @@ export class CreateGlimAccountComponent {
234243
return total;
235244
}
236245

237-
/**
238-
* Creates a new GLIM account.
239-
*/
240-
submit() {
241-
const data = this.buildRequestData();
242-
this.loansService.createGlimAccount(data).subscribe((response: any) => {
243-
const body = JSON.parse(response[0].body);
244-
if (body.glimId) {
245-
this.router.navigate(
246-
[
247-
'../',
248-
body.glimId
249-
],
250-
{ relativeTo: this.route }
251-
);
252-
} else {
253-
this.notify(body, data);
254-
}
255-
});
256-
}
257-
258246
notify(body: any, data: any) {
259247
let message = body.defaultUserMessage + ' ';
260248
while (body.errors?.length > 0) message += body.errors.pop().developerMessage + ' ';

src/app/loans/loans-account-stepper/loans-account-charges-step/loans-account-charges-step.component.html

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@
3939
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Amount' | translate }}</th>
4040
<td mat-cell *matCellDef="let charge">
4141
{{ charge.amount }}
42-
<button mat-icon-button color="primary" (click)="editChargeAmount(charge)">
42+
<button
43+
mat-icon-button
44+
color="primary"
45+
(click)="editChargeAmount(charge)"
46+
type="button"
47+
aria-label="Edit charge amount"
48+
>
4349
<fa-icon icon="pen"></fa-icon>
4450
</button>
4551
</td>
@@ -84,6 +90,8 @@
8490
charge.chargeTimeType.value === 'Specified due date'
8591
"
8692
(click)="editChargeDate(charge)"
93+
type="button"
94+
aria-label="Edit charge date"
8795
>
8896
<fa-icon icon="pen"></fa-icon>
8997
</button>
@@ -93,7 +101,7 @@
93101
<ng-container matColumnDef="action">
94102
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Actions' | translate }}</th>
95103
<td mat-cell *matCellDef="let charge">
96-
<button mat-icon-button color="warn" (click)="deleteCharge(charge)">
104+
<button mat-icon-button color="warn" (click)="deleteCharge(charge)" type="button" aria-label="Delete charge">
97105
<fa-icon icon="trash"></fa-icon>
98106
</button>
99107
</td>
@@ -120,7 +128,18 @@ <h4 class="mat-h4 flex-98">{{ 'labels.heading.Overdue Charges' | translate }}</h
120128

121129
<ng-container matColumnDef="amount">
122130
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Amount' | translate }}</th>
123-
<td mat-cell *matCellDef="let charge">{{ charge.amount | formatNumber }}</td>
131+
<td mat-cell *matCellDef="let charge">
132+
{{ charge.amount | formatNumber }}
133+
<button
134+
mat-icon-button
135+
color="primary"
136+
(click)="editOverdueChargeAmount(charge)"
137+
type="button"
138+
aria-label="Edit overdue charge amount"
139+
>
140+
<fa-icon icon="pen"></fa-icon>
141+
</button>
142+
</td>
124143
</ng-container>
125144

126145
<ng-container matColumnDef="collectedon">
@@ -134,15 +153,15 @@ <h4 class="mat-h4 flex-98">{{ 'labels.heading.Overdue Charges' | translate }}</h
134153
</div>
135154

136155
<div class="layout-row responsive-column align-center gap-2px margin-t">
137-
<button mat-raised-button matStepperPrevious>
156+
<button mat-raised-button matStepperPrevious type="button">
138157
<fa-icon icon="arrow-left" class="m-r-10"></fa-icon>
139158
{{ 'labels.buttons.Previous' | translate }}
140159
</button>
141-
<button mat-raised-button matStepperNext>
160+
<button mat-raised-button matStepperNext type="button">
142161
{{ 'labels.buttons.Next' | translate }}
143162
<fa-icon icon="arrow-right" class="m-l-10"></fa-icon>
144163
</button>
145-
<button mat-raised-button *ngIf="loanId" [routerLink]="['../', 'general']">
164+
<button mat-raised-button *ngIf="loanId" [routerLink]="['../', 'general']" type="button">
146165
{{ 'labels.buttons.Cancel' | translate }}
147166
</button>
148167
</div>

src/app/loans/loans-account-stepper/loans-account-charges-step/loans-account-charges-step.component.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,33 @@ export class LoansAccountChargesStepComponent implements OnInit, OnChanges {
303303
});
304304
}
305305

306+
editOverdueChargeAmount(charge: any) {
307+
const formfields: FormfieldBase[] = [
308+
new InputBase({
309+
controlName: 'amount',
310+
label: 'Amount',
311+
value: charge.amount,
312+
type: 'number',
313+
required: false
314+
})
315+
316+
];
317+
const data = {
318+
title: 'Edit Overdue Charge Amount',
319+
layout: { addButtonText: 'Confirm' },
320+
formfields: formfields
321+
};
322+
const editNoteDialogRef = this.dialog.open(FormDialogComponent, { data });
323+
editNoteDialogRef.afterClosed().subscribe((response: any) => {
324+
if (response.data) {
325+
const newCharge = { ...charge, amount: response.data.value.amount };
326+
this.overDueChargesDataSource.splice(this.overDueChargesDataSource.indexOf(charge), 1, newCharge);
327+
this.overDueChargesDataSource = this.overDueChargesDataSource.concat([]);
328+
}
329+
});
330+
this.pristine = false;
331+
}
332+
306333
get isValid() {
307334
return true;
308335
// !this.activeClientMembers ||

0 commit comments

Comments
 (0)