Skip to content

Commit 942fb46

Browse files
Merge pull request #2569 from mariiaKraievska/WEB-261/allow-to-create-interest-refund-transaction-manually
WEB-261: Allow to create Interest Refund transaction manually
2 parents 9410438 + 6cee221 commit 942fb46

File tree

15 files changed

+135
-13
lines changed

15 files changed

+135
-13
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@
159159
<span>{{ 'labels.text.View Transaction' | translate }}</span>
160160
</button>
161161
</span>
162+
<span *ngIf="canCreateInterestRefund(transaction)">
163+
<button mat-menu-item (click)="openInterestRefundDialog(transaction)">
164+
<mat-icon><fa-icon icon="plus" size="sm"></fa-icon></mat-icon>
165+
<span>{{ 'tooltips.Create Interest Refund' | translate }}</span>
166+
</button>
167+
</span>
162168
<span *ngIf="allowUndoTransaction(transaction)">
163169
<button mat-menu-item *mifosxHasPermission="'ADJUST_LOAN'" (click)="undoTransaction(transaction, $event)">
164170
<mat-icon><fa-icon icon="undo" size="sm"></fa-icon></mat-icon>

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

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,96 @@ export class TransactionsTabComponent implements OnInit {
433433
return !(this.isReAmortize(transactionType) || this.isReAge(transactionType));
434434
}
435435

436+
canCreateInterestRefund(transaction: LoanTransaction): boolean {
437+
const type = transaction?.type?.code?.toLowerCase() || '';
438+
const isRefundType = type.includes('payoutrefund') || type.includes('merchantissuedrefund');
439+
if (!isRefundType) return false;
440+
if (transaction.manuallyReversed) return false;
441+
if (
442+
transaction.transactionRelations &&
443+
transaction.transactionRelations.some((r) => r.relationType === 'INTEREST_REFUND')
444+
)
445+
return false;
446+
return true;
447+
}
448+
449+
openInterestRefundDialog(transaction: LoanTransaction) {
450+
const loanId = this.loanId;
451+
this.loansService
452+
.getLoanTransactionActionTemplate(String(loanId), 'interest-refund', String(transaction.id))
453+
.subscribe((template: any) => {
454+
const paymentTypeField = new FormfieldBase({
455+
controlType: 'select',
456+
controlName: 'paymentTypeId',
457+
label: this.translateService.instant('labels.inputs.Payment Type'),
458+
value: template.paymentTypeId || '',
459+
required: true,
460+
order: 2
461+
});
462+
(paymentTypeField as any).options = {
463+
data: template.paymentTypeOptions || [],
464+
value: 'id',
465+
label: 'name'
466+
};
467+
const formfields: FormfieldBase[] = [
468+
new InputBase({
469+
controlName: 'amount',
470+
label: this.translateService.instant('labels.inputs.Amount'),
471+
value: template.amount,
472+
type: 'number',
473+
required: true,
474+
readonly: true,
475+
order: 1
476+
}),
477+
paymentTypeField,
478+
new InputBase({
479+
controlName: 'externalId',
480+
label: this.translateService.instant('labels.inputs.External Id'),
481+
value: '',
482+
type: 'text',
483+
required: false,
484+
order: 3
485+
}),
486+
new InputBase({
487+
controlName: 'note',
488+
label: this.translateService.instant('labels.inputs.Note'),
489+
value: '',
490+
type: 'text',
491+
required: false,
492+
order: 4
493+
})
494+
495+
];
496+
const data = {
497+
title: this.translateService.instant('labels.buttons.Create Interest Refund'),
498+
layout: { addButtonText: this.translateService.instant('labels.buttons.Create Interest Refund') },
499+
formfields: formfields
500+
};
501+
const dialogRef = this.dialog.open(FormDialogComponent, { data });
502+
dialogRef.afterClosed().subscribe((response: { data: any }) => {
503+
if (response?.data) {
504+
const { amount, transactionDate, ...rest } = response.data.value;
505+
const payload = {
506+
...rest,
507+
transactionAmount: amount,
508+
locale: this.settingsService.language.code,
509+
dateFormat: this.settingsService.dateFormat
510+
};
511+
this.loansService
512+
.executeLoansAccountTransactionsCommand(
513+
String(loanId),
514+
'interest-refund',
515+
payload,
516+
String(transaction.id)
517+
)
518+
.subscribe(() => {
519+
this.reload();
520+
});
521+
}
522+
});
523+
});
524+
}
525+
436526
private reload() {
437527
const clientId = this.route.parent.parent.snapshot.params['clientId'];
438528
const url: string = this.router.url;

src/assets/translations/cs-CS.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@
369369
"Create Group": "Vytvořit skupinu",
370370
"Create Holiday": "Vytvořte dovolenou",
371371
"Create Hook": "Vytvořte háček",
372+
"Create Interest Refund": "Vytvořit vrácení úroků",
372373
"Create Journal Entries": "Vytvářejte záznamy deníku",
373374
"Create Loan Product": "Vytvořte produkt půjčky",
374375
"Create Office": "Vytvořit Office",
@@ -3517,6 +3518,7 @@
35173518
"Yes": "Ano",
35183519
"loan product will be active and available to clients": "Datum, kdy bude úvěrový produkt aktivní a dostupný klientům. Pokud nevyplníte, bude úvěrový produkt aktivní, jakmile bude vytvořen.",
35193520
"loan product will become inactive and unavailable to clients": "Datum, kdy se úvěrový produkt stane neaktivním a nedostupným pro klienty. Pokud je prázdné, produkt zatížení se nikdy nestane neaktivním.",
3520-
"Refund transactions where interest refund will automatically be calculated": "Transakce s vrácením peněz, kde bude automaticky vypočítána refundace úroků"
3521+
"Refund transactions where interest refund will automatically be calculated": "Transakce s vrácením peněz, kde bude automaticky vypočítána refundace úroků",
3522+
"Create Interest Refund": "Vytvořit vrácení úroků"
35213523
}
35223524
}

src/assets/translations/de-DE.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@
369369
"Create Group": "Gruppe erstellen",
370370
"Create Holiday": "Urlaub erstellen",
371371
"Create Hook": "Hook erstellen",
372+
"Create Interest Refund": "Zinsrückerstattung erstellen",
372373
"Create Journal Entries": "Erstellen Sie Journaleinträge",
373374
"Create Loan Product": "Darlehensprodukt erstellen",
374375
"Create Office": "Büro erstellen",
@@ -3516,6 +3517,7 @@
35163517
"Yes": "Ja",
35173518
"loan product will be active and available to clients": "Das Datum, an dem das Kreditprodukt aktiv und für Kunden verfügbar sein wird. Wenn das Feld leer ist, ist das Kreditprodukt aktiv, sobald es erstellt wird.",
35183519
"loan product will become inactive and unavailable to clients": "Das Datum, an dem das Kreditprodukt inaktiv wird und für Kunden nicht mehr verfügbar ist. Wenn es leer ist, wird das Ladeprodukt niemals inaktiv.",
3519-
"Refund transactions where interest refund will automatically be calculated": "Rückerstattungstransaktionen, bei denen die Zinsrückerstattung automatisch berechnet wird"
3520+
"Refund transactions where interest refund will automatically be calculated": "Rückerstattungstransaktionen, bei denen die Zinsrückerstattung automatisch berechnet wird",
3521+
"Create Interest Refund": "Zinsrückerstattung erstellen"
35203522
}
35213523
}

src/assets/translations/en-US.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@
370370
"Create Group": "Create Group",
371371
"Create Holiday": "Create Holiday",
372372
"Create Hook": "Create Hook",
373+
"Create Interest Refund": "Create Interest Refund",
373374
"Create Journal Entries": "Create Journal Entries",
374375
"Create Loan Product": "Create Loan Product",
375376
"Create Office": "Create Office",
@@ -3622,6 +3623,7 @@
36223623
"Yes": "Yes",
36233624
"loan product will be active and available to clients": "The date that the loan product will be active and available to clients. If blank, the loan product will be active as soon as it is created.",
36243625
"loan product will become inactive and unavailable to clients": "The date that the loan product will become inactive and unavailable to clients. If blank, the load product will never become inactive.",
3625-
"Refund transactions where interest refund will automatically be calculated": "Refund transactions where interest refund will automatically be calculated"
3626+
"Refund transactions where interest refund will automatically be calculated": "Refund transactions where interest refund will automatically be calculated",
3627+
"Create Interest Refund": "Create Interest Refund"
36263628
}
36273629
}

src/assets/translations/es-CL.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@
369369
"Create Group": "Crea un Grupo",
370370
"Create Holiday": "Crear Festivo",
371371
"Create Hook": "Crear gancho",
372+
"Create Interest Refund": "Crear reembolso de intereses",
372373
"Create Journal Entries": "Crear entradas de diario",
373374
"Create Loan Product": "Crear producto de Crédito",
374375
"Create Office": "Crear Oficina",
@@ -3517,6 +3518,7 @@
35173518
"Yes": "",
35183519
"loan product will be active and available to clients": "La fecha en que el producto de Crédito estará activo y disponible para los clientes. Si está en blanco, el producto de Crédito estará activo tan pronto como se cree.",
35193520
"loan product will become inactive and unavailable to clients": "La fecha en que el producto de Crédito quedará inactivo y no estará disponible para los clientes. Si está en blanco, el producto de carga nunca quedará inactivo.",
3520-
"Refund transactions where interest refund will automatically be calculated": "Transacciones de reembolso en las que el reembolso de intereses se calculará automáticamente"
3521+
"Refund transactions where interest refund will automatically be calculated": "Transacciones de reembolso en las que el reembolso de intereses se calculará automáticamente",
3522+
"Create Interest Refund": "Crear reembolso de intereses"
35213523
}
35223524
}

src/assets/translations/es-MX.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@
369369
"Create Group": "Crea un Grupo",
370370
"Create Holiday": "Crear Festivo",
371371
"Create Hook": "Crear gancho",
372+
"Create Interest Refund": "Crear reembolso de intereses",
372373
"Create Journal Entries": "Crear entradas de diario",
373374
"Create Loan Product": "Crear producto de Crédito",
374375
"Create Office": "Crear Oficina",
@@ -3517,6 +3518,7 @@
35173518
"Yes": "",
35183519
"loan product will be active and available to clients": "La fecha en que el producto de Crédito estará activo y disponible para los clientes. Si está en blanco, el producto de Crédito estará activo tan pronto como se cree.",
35193520
"loan product will become inactive and unavailable to clients": "La fecha en que el producto de Crédito quedará inactivo y no estará disponible para los clientes. Si está en blanco, el producto de carga nunca quedará inactivo.",
3520-
"Refund transactions where interest refund will automatically be calculated": "Transacciones de reembolso en las que el reembolso de intereses se calculará automáticamente"
3521+
"Refund transactions where interest refund will automatically be calculated": "Transacciones de reembolso en las que el reembolso de intereses se calculará automáticamente",
3522+
"Create Interest Refund": "Crear reembolso de intereses"
35213523
}
35223524
}

src/assets/translations/fr-FR.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@
369369
"Create Group": "Créer un groupe",
370370
"Create Holiday": "Créer des vacances",
371371
"Create Hook": "Créer un crochet",
372+
"Create Interest Refund": "Créer un remboursement d’intérêts",
372373
"Create Journal Entries": "Créer des entrées de journal",
373374
"Create Loan Product": "Créer un produit de prêt",
374375
"Create Office": "Créer un bureau",
@@ -3516,6 +3517,7 @@
35163517
"Yes": "Oui",
35173518
"loan product will be active and available to clients": "La date à laquelle le produit de prêt sera actif et disponible pour les clients. Si ce champ est vide, le produit de prêt sera actif dès sa création.",
35183519
"loan product will become inactive and unavailable to clients": "Date à laquelle le produit de prêt deviendra inactif et indisponible pour les clients. S'il est vide, le produit chargé ne deviendra jamais inactif.",
3519-
"Refund transactions where interest refund will automatically be calculated": "Opérations de remboursement pour lesquelles le remboursement des intérêts sera automatiquement calculé"
3520+
"Refund transactions where interest refund will automatically be calculated": "Opérations de remboursement pour lesquelles le remboursement des intérêts sera automatiquement calculé",
3521+
"Create Interest Refund": "Créer un remboursement d’intérêts"
35203522
}
35213523
}

src/assets/translations/it-IT.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@
369369
"Create Group": "Creare un gruppo",
370370
"Create Holiday": "Crea vacanza",
371371
"Create Hook": "Crea gancio",
372+
"Create Interest Refund": "Crea rimborso interessi",
372373
"Create Journal Entries": "Crea voci di diario",
373374
"Create Loan Product": "Crea prodotto di prestito",
374375
"Create Office": "Crea ufficio",
@@ -3517,6 +3518,7 @@
35173518
"Yes": "",
35183519
"loan product will be active and available to clients": "La data in cui il prodotto di prestito sarà attivo e disponibile per i clienti. Se vuoto, il prodotto di prestito sarà attivo non appena verrà creato.",
35193520
"loan product will become inactive and unavailable to clients": "La data in cui il prodotto di prestito diventerà inattivo e non disponibile per i clienti. Se vuoto, il prodotto caricato non diventerà mai inattivo.",
3520-
"Refund transactions where interest refund will automatically be calculated": "Transazioni di rimborso in cui il rimborso degli interessi verrà calcolato automaticamente"
3521+
"Refund transactions where interest refund will automatically be calculated": "Transazioni di rimborso in cui il rimborso degli interessi verrà calcolato automaticamente",
3522+
"Create Interest Refund": "Crea rimborso interessi"
35213523
}
35223524
}

src/assets/translations/ko-KO.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@
369369
"Create Group": "그룹 만들기",
370370
"Create Holiday": "공휴일 만들기",
371371
"Create Hook": "후크 생성",
372+
"Create Interest Refund": "이자 환불 생성",
372373
"Create Journal Entries": "분개 항목 만들기",
373374
"Create Loan Product": "대출상품 생성",
374375
"Create Office": "사무실 만들기",
@@ -3517,6 +3518,7 @@
35173518
"Yes": "",
35183519
"loan product will be active and available to clients": "대출 상품이 활성화되어 고객에게 제공되는 날짜입니다. 비어 있으면 대출 상품이 생성되자마자 활성화됩니다.",
35193520
"loan product will become inactive and unavailable to clients": "대출 상품이 비활성화되어 고객이 사용할 수 없게 되는 날짜입니다. 비어 있으면 로드 제품이 비활성화되지 않습니다.",
3520-
"Refund transactions where interest refund will automatically be calculated": "이자 환불이 자동으로 계산되는 환불 거래"
3521+
"Refund transactions where interest refund will automatically be calculated": "이자 환불이 자동으로 계산되는 환불 거래",
3522+
"Create Interest Refund": "이자 환불 생성"
35213523
}
35223524
}

0 commit comments

Comments
 (0)