Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loan account term variations support for different term types #2247

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,84 +1,52 @@
<div class="container">
<h3>{{ 'labels.heading.Term Variations' | translate }}</h3>
<table mat-table [dataSource]="loanTermVariationsData" *ngIf="loanTermVariationsData.length > 0">
<ng-container matColumnDef="termType">
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Type' | translate }}</th>
<td mat-cell *matCellDef="let item">{{ item.termType.value | translate }}</td>
</ng-container>

<ng-container matColumnDef="applicableFrom">
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Added On' | translate }}</th>
<td mat-cell *matCellDef="let item">{{ item.termVariationApplicableFrom | dateFormat }}</td>
</ng-container>
<ng-container matColumnDef="value">
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Value' | translate }}</th>
<td mat-cell *matCellDef="let item">{{ item.decimalValue | formatNumber }}</td>
</ng-container>

<ng-container matColumnDef="specificToInstallment">
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Specific to Installment' | translate }}</th>
<td mat-cell *matCellDef="let item">{{ item.isSpecificToInstallment | yesNo }}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="loanDTermVariationsColumns"></tr>
<tr mat-row *matRowDef="let row; columns: loanDTermVariationsColumns"></tr>
</table>

<h3 class="m-t-20" *ngIf="interestPausesData?.length > 0">{{ 'labels.heading.Interest Pauses' | translate }}</h3>
<table mat-table class="m-t-20" [dataSource]="interestPausesData" *ngIf="interestPausesData?.length > 0">
<ng-container matColumnDef="row">
<th mat-header-cell *matHeaderCellDef>#</th>
<td mat-cell *matCellDef="let item; let idx = index">{{ idx + 1 }}</td>
</ng-container>

<ng-container matColumnDef="startDate">
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Start Date' | translate }}</th>
<td mat-cell *matCellDef="let item">{{ item.startDate | dateFormat }}</td>
</ng-container>

<ng-container matColumnDef="endDate">
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.End Date' | translate }}</th>
<td mat-cell *matCellDef="let item">{{ item.endDate | dateFormat }}</td>
</ng-container>

<ng-container matColumnDef="days">
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Days' | translate }}</th>
<td mat-cell *matCellDef="let item">{{ item.days | formatNumber }}</td>
</ng-container>

<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Actions' | translate }}</th>
<td mat-cell *matCellDef="let item">
<button
class="button"
mat-icon-button
color="primary"
matTooltip="{{ 'tooltips.Edit' | translate }}"
matTooltipPosition="right"
(click)="manageRequest(item, 'Edit')"
>
<fa-icon icon="edit" size="lg"></fa-icon>
</button>
<button
class="button"
mat-icon-button
color="warn"
matTooltip="{{ 'tooltips.Delete' | translate }}"
matTooltipPosition="left"
(click)="manageRequest(item, 'Delete')"
>
<fa-icon icon="trash" size="lg"></fa-icon>
</button>
</td>
</ng-container>

<tr mat-header-row *matHeaderRowDef="interestPausesColumns"></tr>
<tr mat-row *matRowDef="let row; columns: interestPausesColumns"></tr>
</table>

<div class="alert" [hidden]="interestPausesData?.length > 0">
<div class="message">
<i class="fa fa-exclamation-circle alert-check"></i>
{{ 'labels.text.No data found' | translate }}
</div>
<div *ngFor="let loanTermVariation of loanTermVariationsData">

<h3 class="m-t-20">{{ 'labels.heading.' + loanTermVariation.label | translate }}</h3>
<table mat-table [dataSource]="loanTermVariation.data">
<ng-container matColumnDef="row">
<th mat-header-cell *matHeaderCellDef>#</th>
<td mat-cell *matCellDef="let item; let idx = index">{{ idx + 1 }}</td>
</ng-container>

<ng-container matColumnDef="startDate">
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Start Date' | translate }}</th>
<td mat-cell *matCellDef="let item">{{ item.termVariationApplicableFrom | dateFormat }}</td>
</ng-container>

<ng-container matColumnDef="endDate">
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.End Date' | translate }}</th>
<td mat-cell *matCellDef="let item">{{ item.dateValue | dateFormat }}</td>
</ng-container>

<ng-container matColumnDef="value">
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Value' | translate }}</th>
<td mat-cell *matCellDef="let item">{{ item.decimalValue | formatNumber }}</td>
</ng-container>

<ng-container matColumnDef="days">
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Days' | translate }}</th>
<td mat-cell *matCellDef="let item">{{ item.days | formatNumber }}</td>
</ng-container>

<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Actions' | translate }}</th>
<td mat-cell *matCellDef="let item">
<span *ngIf="allowActions(item.termType.value)">
<button class="button" mat-icon-button color="primary" matTooltip="{{ 'tooltips.Edit' | translate }}"
matTooltipPosition="right" (click)="manageRequest(item, 'Edit')">
<fa-icon icon="edit" size="lg"></fa-icon>
</button>
<button class="button" mat-icon-button color="warn" matTooltip="{{ 'tooltips.Delete' | translate }}"
matTooltipPosition="left" (click)="manageRequest(item, 'Delete')">
<fa-icon icon="trash" size="lg"></fa-icon>
</button>
</span>
</td>
</ng-container>

<tr mat-header-row *matHeaderRowDef="loanDTermVariationsColumns"></tr>
<tr mat-row *matRowDef="let row; columns: loanDTermVariationsColumns"></tr>
</table>
</div>
</div>

</div>
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,26 @@ export class LoanTermVariationsTabComponent {
/** Loan Term Variation Data */
loanTermVariationsData: any[] = [];
loanDTermVariationsColumns: string[] = [
'termType',
'applicableFrom',
'value',
'specificToInstallment'
];
/** Interest Pauses Data */
interestPausesData: any[] = [];
interestPausesColumns: string[] = [
'row',
'startDate',
'endDate',
'days',
'actions'
];

emiAmountData: any[] = [];
interestRateData: any[] = [];
dueDateData: any[] = [];
deleteInstallmentData: any[] = [];
insertInstallmentData: any[] = [];
principalAmountData: any[] = [];
graceOnInterestData: any[] = [];
graceOnPrincipalData: any[] = [];
extendRepaymentPeriodData: any[] = [];
interestRateFromInstallmentData: any[] = [];
interestPausesData: any[] = [];
invalidData: any[] = [];

loanId: number;
clientId: AnyKindOfDictionary;

Expand All @@ -47,14 +52,117 @@ export class LoanTermVariationsTabComponent {
) {
this.interestPausesData = [];
this.clientId = this.route.parent.parent.snapshot.paramMap.get('clientId');
this.route.data.subscribe((data: { loanDetailsData: any; interestPausesData: any }) => {
this.route.data.subscribe((data: { loanDetailsData: any; }) => {
this.loanId = data.loanDetailsData.id;
this.loanTermVariationsData = data.loanDetailsData.loanTermVariations;
this.interestPausesData = [];
data.interestPausesData?.forEach((item: any) => {
item.days = dates.calculateDiff(new Date(item.startDate), new Date(item.endDate));
this.interestPausesData.push(item);
this.loanTermVariationsData = [];
data.loanDetailsData.loanTermVariations?.forEach((item: any) => {
item.days = dates.calculateDiff(new Date(item.termVariationApplicableFrom), new Date(item.dateValue)) + 1;
switch (item.termType.value) {
case 'emiAmount':
this.emiAmountData.push(item);
break;
case 'interestRate':
this.interestRateData.push(item);
break;
case 'deleteInstallment':
this.deleteInstallmentData.push(item);
break;
case 'dueDate':
this.dueDateData.push(item);
break;
case 'insertInstallment':
this.insertInstallmentData.push(item);
break;
case 'principalAmount':
this.principalAmountData.push(item);
break;
case 'graceOnInterest':
this.graceOnInterestData.push(item);
break;
case 'graceOnPrincipal':
this.graceOnPrincipalData.push(item);
break;
case 'extendRepaymentPeriod':
this.extendRepaymentPeriodData.push(item);
break;
case 'interestRateForInstallment':
this.interestRateFromInstallmentData.push(item);
break;
case 'interestPause':
this.interestPausesData.push(item);
break;
default:
this.invalidData.push(item);
break;
}
});

if (this.deleteInstallmentData.length > 0) {
this.loanTermVariationsData.push({
"label": "Delete Installment",
"data": this.deleteInstallmentData
});
}
if (this.dueDateData.length > 0) {
this.loanTermVariationsData.push({
"label": "Due Date",
"data": this.dueDateData
});
}
if (this.emiAmountData.length > 0) {
this.loanTermVariationsData.push({
"label": "EMI Amount",
"data": this.emiAmountData
});
}
if (this.extendRepaymentPeriodData.length > 0) {
this.loanTermVariationsData.push({
"label": "Extend Repayment Period",
"data": this.extendRepaymentPeriodData
});
}
if (this.graceOnInterestData.length > 0) {
this.loanTermVariationsData.push({
"label": "Grace On Interest",
"data": this.graceOnInterestData
});
}
if (this.graceOnPrincipalData.length > 0) {
this.loanTermVariationsData.push({
"label": "Grace On Principal",
"data": this.graceOnPrincipalData
});
}
if (this.insertInstallmentData.length > 0) {
this.loanTermVariationsData.push({
"label": "Insert Installment",
"data": this.insertInstallmentData
});
}
if (this.interestPausesData.length > 0) {
this.loanTermVariationsData.push({
"label": "Interest Pauses",
"data": this.interestPausesData
});
}
if (this.interestRateData.length > 0) {
this.loanTermVariationsData.push({
"label": "Interest Rate",
"data": this.interestRateData
});
}
if (this.interestRateFromInstallmentData.length > 0) {
this.loanTermVariationsData.push({
"label": "Interest Rate From Installment",
"data": this.interestRateFromInstallmentData
});
}
if (this.principalAmountData.length > 0) {
this.loanTermVariationsData.push({
"label": "Principal Amount",
"data": this.principalAmountData
});
}
});
}

Expand Down Expand Up @@ -131,4 +239,8 @@ export class LoanTermVariationsTabComponent {
.navigateByUrl(`/clients/${this.clientId}/loans-accounts`, { skipLocationChange: true })
.then(() => this.router.navigate([url]));
}

allowActions(termType: string): boolean {
return (termType === 'interestPause')
}
}
12 changes: 11 additions & 1 deletion src/assets/translations/cs-CS.json
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,17 @@
"You have created": "Vytvořili jste",
"You can drag and drop the rows to set a Payment Allocations order": "Řádky můžete přetáhnout a nastavit tak příkaz přidělení plateb",
"successfully select option": "úspěšně. Chcete-li pokračovat dále, vyberte si z níže uvedených možností.",
"Map Charge-off reasons to Expense accounts": "Mapujte důvody pro zúčtování na výdajové účty"
"Map Charge-off reasons to Expense accounts": "Mapujte důvody pro zúčtování na výdajové účty",
"Interest Rate From Installment": "Úroková sazba ze splátky",
"Due Date": "Datum splatnosti",
"Delete Installment": "Smazat splátku",
"EMI Amount": "Částka EMI",
"Extend Repayment Period": "Prodloužit dobu splácení",
"Grace On Interest": "Grace On Interest",
"Grace On Principal": "Grace na ředitelce",
"Insert Installment": "Vložit splátku",
"Interest Rate": "Úroková sazba",
"Principal Amount": "Částka jistiny"
},
"inputs": {
"accounting": {
Expand Down
12 changes: 11 additions & 1 deletion src/assets/translations/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,17 @@
"You have created": "Du hast erstellt",
"You can drag and drop the rows to set a Payment Allocations order": "Sie können die Zeilen per Drag-and-Drop verschieben, um eine Zahlungszuordnungsreihenfolge festzulegen",
"successfully select option": "erfolgreich. Bitte wählen Sie eine der folgenden Optionen aus, um fortzufahren.",
"Map Charge-off reasons to Expense accounts": "Abschreibungsgründe Aufwandskonten zuordnen"
"Map Charge-off reasons to Expense accounts": "Abschreibungsgründe Aufwandskonten zuordnen",
"Interest Rate From Installment": "Zinssatz ab Ratenzahlung",
"Due Date": "Fälligkeitsdatum",
"Delete Installment": "Rate löschen",
"EMI Amount": "EMI-Betrag",
"Extend Repayment Period": "Verlängern Sie die Rückzahlungsfrist",
"Grace On Interest": "Gnade auf Zinsen",
"Grace On Principal": "Grace On Principal",
"Insert Installment": "Ratenzahlung einfügen",
"Interest Rate": "Zinssatz",
"Principal Amount": "Hauptbetrag"
},
"inputs": {
"accounting": {
Expand Down
12 changes: 11 additions & 1 deletion src/assets/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,17 @@
"You have created": "You have created",
"You can drag and drop the rows to set a Payment Allocations order": "You can drag and drop the rows to set a Payment Allocations order",
"successfully select option": "successfully. Please select from the options below to proceed further.",
"Map Charge-off reasons to Expense accounts": "Map Charge-off reasons to Expense accounts"
"Map Charge-off reasons to Expense accounts": "Map Charge-off reasons to Expense accounts",
"Interest Rate From Installment": "Interest Rate From Installment",
"Due Date": "Due Date",
"Delete Installment": "Delete Installment",
"EMI Amount": "EMI Amount",
"Extend Repayment Period": "Extend Repayment Period",
"Grace On Interest": "Grace On Interest",
"Grace On Principal": "Grace On Principal",
"Insert Installment": "Insert Installment",
"Interest Rate": "Interest Rate",
"Principal Amount": "Principal Amount"
},
"inputs": {
"accounting": {
Expand Down
12 changes: 11 additions & 1 deletion src/assets/translations/es-MX.json
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,17 @@
"You have created": "tu has creado",
"You can drag and drop the rows to set a Payment Allocations order": "Puede arrastrar y soltar las filas para establecer un orden de asignaciones de pago",
"successfully select option": "exitosamente. Seleccione una de las opciones siguientes para continuar.",
"Map Charge-off reasons to Expense accounts": "Asignar motivos de cancelación a cuentas de gastos"
"Map Charge-off reasons to Expense accounts": "Asignar motivos de cancelación a cuentas de gastos",
"Interest Rate From Installment": "Tasa de interés a plazos",
"Due Date": "Fecha de vencimiento",
"Delete Installment": "Eliminar cuota",
"EMI Amount": "Monto de Cuota",
"Extend Repayment Period": "Ampliar el período de pago",
"Grace On Interest": "Gracia por interés",
"Grace On Principal": "Gracia al director",
"Insert Installment": "Insertar cuota",
"Interest Rate": "Tasa de interés",
"Principal Amount": "Monto principal"
},
"inputs": {
"accounting": {
Expand Down
12 changes: 11 additions & 1 deletion src/assets/translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,17 @@
"You have created": "Vous avez créé",
"You can drag and drop the rows to set a Payment Allocations order": "Vous pouvez faire glisser et déposer les lignes pour définir un ordre de répartition des paiements",
"successfully select option": "avec succès. Veuillez sélectionner parmi les options ci-dessous pour continuer.",
"Map Charge-off reasons to Expense accounts": "Cartographier les motifs de radiation sur les comptes de dépenses"
"Map Charge-off reasons to Expense accounts": "Cartographier les motifs de radiation sur les comptes de dépenses",
"Interest Rate From Installment": "Taux d'intérêt à partir du versement",
"Due Date": "Date d'échéance",
"Delete Installment": "Supprimer le versement",
"EMI Amount": "Montant EMI",
"Extend Repayment Period": "Prolonger la période de remboursement",
"Grace On Interest": "Grâce sur les intérêts",
"Grace On Principal": "Grace sur le principal",
"Insert Installment": "Insérer un versement",
"Interest Rate": "Taux d'intérêt",
"Principal Amount": "Montant principal"
},
"inputs": {
"accounting": {
Expand Down
Loading
Loading