Skip to content

Commit 7867e59

Browse files
Merge branch 'dev' into WEB-1100-client-approval-activation-date
2 parents f0bffd4 + ae1cadc commit 7867e59

2 files changed

Lines changed: 44 additions & 32 deletions

File tree

src/app/loans/loans-view/transactions-tab/transactions-tab.component.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -434,28 +434,29 @@ export class TransactionsTabComponent extends LoanProductBaseComponent implement
434434
const locale = this.settingsService.language.code;
435435
const dateFormat = this.settingsService.dateFormat;
436436
const loanId = this.route.parent.parent.snapshot.params['loanId'];
437+
const isLoanProduct = this.loanProductService.isLoanProduct;
437438
let command = 'undo';
438439
let operationDate = this.dateUtils.parseDate(transaction.date);
439-
let payload = {};
440+
let payload: any = {};
441+
// Working capital loan undo only accepts locale/dateFormat/note/reversalExternalId;
442+
// transactionDate/transactionAmount are required only by the generic loan adjust endpoint.
443+
const undoPayload = isLoanProduct
444+
? {
445+
transactionDate: this.dateUtils.formatDate(operationDate && new Date(operationDate), dateFormat),
446+
transactionAmount: 0,
447+
dateFormat,
448+
locale
449+
}
450+
: { dateFormat, locale };
440451
if (this.isChargeOff(transaction.type)) {
441452
command = 'undo-charge-off';
442453
operationDate = this.settingsService.businessDate;
443454
payload = {};
444455
} else if (this.isWriteOff(transaction.type)) {
445456
command = 'undowriteoff';
446-
payload = {
447-
transactionDate: this.dateUtils.formatDate(operationDate && new Date(operationDate), dateFormat),
448-
transactionAmount: 0,
449-
dateFormat,
450-
locale
451-
};
457+
payload = undoPayload;
452458
} else {
453-
payload = {
454-
transactionDate: this.dateUtils.formatDate(operationDate && new Date(operationDate), dateFormat),
455-
transactionAmount: 0,
456-
dateFormat,
457-
locale
458-
};
459+
payload = undoPayload;
459460
}
460461

461462
const undoTransactionAccountDialogRef = this.dialog.open(ConfirmationDialogComponent, {

src/app/loans/loans-view/transactions/view-transaction/view-transaction.component.ts

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ export class ViewTransactionComponent extends LoanAccountActionsBaseComponent im
170170
) {
171171
this.allowUndo = false;
172172
}
173+
if (this.isWorkingCapital) {
174+
this.allowEdition = false;
175+
this.allowChargeback = false;
176+
}
173177
});
174178
this.clientId = this.route.snapshot.params['clientId'];
175179
this.loanId = this.route.snapshot.params['loanId'];
@@ -291,27 +295,34 @@ export class ViewTransactionComponent extends LoanAccountActionsBaseComponent im
291295
if (response.confirm) {
292296
const locale = this.settingsService.language.code;
293297
const dateFormat = this.settingsService.dateFormat;
294-
const data = {
295-
transactionDate: this.dateUtils.formatDate(
296-
this.transactionData.date && new Date(this.transactionData.date),
297-
dateFormat
298-
),
299-
transactionAmount: 0,
300-
dateFormat,
301-
locale
302-
};
303298
const command = this.isWriteOff(this.transactionType) ? 'undowriteoff' : 'undo';
304-
const transactionId = command === 'undowriteoff' ? null : this.transactionData.id;
305-
this.loansService
306-
.executeLoansAccountTransactionsCommand(accountId, command, data, transactionId)
307-
.subscribe(() => {
308-
this.router.navigate(['../'], {
309-
queryParams: {
310-
productType: this.loanProductService.productType.value
311-
},
312-
relativeTo: this.route
313-
});
299+
const navigateBack = () =>
300+
this.router.navigate(['../'], {
301+
queryParams: {
302+
productType: this.loanProductService.productType.value
303+
},
304+
relativeTo: this.route
314305
});
306+
if (this.isWorkingCapital) {
307+
const payload = { dateFormat, locale };
308+
this.loansService
309+
.applyWorkingCapitalLoanActionCommand(accountId, payload, command, this.transactionData.id)
310+
.subscribe(navigateBack);
311+
} else {
312+
const data = {
313+
transactionDate: this.dateUtils.formatDate(
314+
this.transactionData.date && new Date(this.transactionData.date),
315+
dateFormat
316+
),
317+
transactionAmount: 0,
318+
dateFormat,
319+
locale
320+
};
321+
const transactionId = command === 'undowriteoff' ? null : this.transactionData.id;
322+
this.loansService
323+
.executeLoansAccountTransactionsCommand(accountId, command, data, transactionId)
324+
.subscribe(navigateBack);
325+
}
315326
}
316327
});
317328
}

0 commit comments

Comments
 (0)