mirror of
https://github.com/openMF/web-app.git
synced 2026-02-06 14:11:48 +00:00
WEB-632-loan-product-default-empty-multiples-fields (#3084)
This commit is contained in:
parent
83a5a9e2b0
commit
58adc0a7d8
@ -61,16 +61,20 @@
|
||||
</div>
|
||||
<div class="flex-fill layout-row">
|
||||
<span class="flex-40">{{ 'labels.inputs.Decimal Places' | translate }}:</span>
|
||||
<span class="flex-60">{{ loanProduct.currency.decimalPlaces }}</span>
|
||||
</div>
|
||||
<div class="flex-fill layout-row">
|
||||
<span class="flex-40">{{ 'labels.inputs.Currency in multiples of' | translate }}:</span>
|
||||
<span class="flex-60">{{ loanProduct.currency.inMultiplesOf }}</span>
|
||||
</div>
|
||||
<div class="flex-fill layout-row">
|
||||
<span class="flex-40">{{ 'labels.inputs.Installment in multiples of' | translate }}:</span>
|
||||
<span class="flex-60">{{ loanProduct.installmentAmountInMultiplesOf }}</span>
|
||||
<span class="flex-60">{{ loanProduct.digitsAfterDecimal ?? loanProduct.currency.decimalPlaces }}</span>
|
||||
</div>
|
||||
@if (loanProduct.inMultiplesOf || loanProduct.currency?.inMultiplesOf) {
|
||||
<div class="flex-fill layout-row">
|
||||
<span class="flex-40">{{ 'labels.inputs.Currency in multiples of' | translate }}:</span>
|
||||
<span class="flex-60">{{ loanProduct.inMultiplesOf ?? loanProduct.currency.inMultiplesOf }}</span>
|
||||
</div>
|
||||
}
|
||||
@if (loanProduct.installmentAmountInMultiplesOf) {
|
||||
<div class="flex-fill layout-row">
|
||||
<span class="flex-40">{{ 'labels.inputs.Installment in multiples of' | translate }}:</span>
|
||||
<span class="flex-60">{{ loanProduct.installmentAmountInMultiplesOf }}</span>
|
||||
</div>
|
||||
}
|
||||
<h3 class="mat-h3 flex-fill">{{ 'labels.heading.Terms' | translate }}</h3>
|
||||
<mat-divider [inset]="true"></mat-divider>
|
||||
<div class="flex-fill layout-row">
|
||||
|
||||
@ -47,38 +47,44 @@
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field class="flex-48">
|
||||
<mat-label>{{ 'labels.inputs.Currency in multiples of' | translate }}</mat-label>
|
||||
<input
|
||||
type="number"
|
||||
min="1"
|
||||
matInput
|
||||
matTooltip="{{ 'tooltips.Enter multiples of currency value' | translate }}"
|
||||
formControlName="inMultiplesOf"
|
||||
required
|
||||
/>
|
||||
<mat-error *ngIf="loanProductCurrencyForm.get('inMultiplesOf')?.hasError('required')">
|
||||
{{ 'labels.inputs.Currency in multiples of' | translate }} {{ 'labels.commons.is' | translate }}
|
||||
<strong>{{ 'labels.commons.required' | translate }}</strong>
|
||||
</mat-error>
|
||||
<mat-error *ngIf="loanProductCurrencyForm.get('inMultiplesOf')?.hasError('min')">
|
||||
{{ 'labels.inputs.Currency in multiples of' | translate }}
|
||||
{{ 'labels.commons.Minimum Value must be' | translate }} <strong>1</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-checkbox labelPosition="before" formControlName="setMultiples" class="flex-98 margin-t">
|
||||
{{ 'labels.inputs.Set the multiples of the loan and its installment' | translate }}
|
||||
</mat-checkbox>
|
||||
|
||||
<mat-form-field class="flex-48">
|
||||
<mat-label>{{ 'labels.inputs.Installment in multiples of' | translate }}</mat-label>
|
||||
<input type="number" min="1" matInput formControlName="installmentAmountInMultiplesOf" required />
|
||||
<mat-error *ngIf="loanProductCurrencyForm.get('installmentAmountInMultiplesOf')?.hasError('required')">
|
||||
{{ 'labels.inputs.Installment in multiples of' | translate }} {{ 'labels.commons.is' | translate }}
|
||||
<strong>{{ 'labels.commons.required' | translate }}</strong>
|
||||
</mat-error>
|
||||
<mat-error *ngIf="loanProductCurrencyForm.get('installmentAmountInMultiplesOf')?.hasError('min')">
|
||||
{{ 'labels.inputs.Installment in multiples of' | translate }}
|
||||
{{ 'labels.commons.Minimum Value must be' | translate }} <strong>1</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
@if (loanProductCurrencyForm.value.setMultiples) {
|
||||
<mat-form-field class="flex-48">
|
||||
<mat-label>{{ 'labels.inputs.Currency in multiples of' | translate }}</mat-label>
|
||||
<input
|
||||
type="number"
|
||||
min="1"
|
||||
matInput
|
||||
matTooltip="{{ 'tooltips.Enter multiples of currency value' | translate }}"
|
||||
formControlName="inMultiplesOf"
|
||||
required
|
||||
/>
|
||||
<mat-error *ngIf="loanProductCurrencyForm.get('inMultiplesOf')?.hasError('required')">
|
||||
{{ 'labels.inputs.Currency in multiples of' | translate }} {{ 'labels.commons.is' | translate }}
|
||||
<strong>{{ 'labels.commons.required' | translate }}</strong>
|
||||
</mat-error>
|
||||
<mat-error *ngIf="loanProductCurrencyForm.get('inMultiplesOf')?.hasError('min')">
|
||||
{{ 'labels.inputs.Currency in multiples of' | translate }}
|
||||
{{ 'labels.commons.Minimum Value must be' | translate }} <strong>1</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field class="flex-48">
|
||||
<mat-label>{{ 'labels.inputs.Installment in multiples of' | translate }}</mat-label>
|
||||
<input type="number" min="1" matInput formControlName="installmentAmountInMultiplesOf" required />
|
||||
<mat-error *ngIf="loanProductCurrencyForm.get('installmentAmountInMultiplesOf')?.hasError('required')">
|
||||
{{ 'labels.inputs.Installment in multiples of' | translate }} {{ 'labels.commons.is' | translate }}
|
||||
<strong>{{ 'labels.commons.required' | translate }}</strong>
|
||||
</mat-error>
|
||||
<mat-error *ngIf="loanProductCurrencyForm.get('installmentAmountInMultiplesOf')?.hasError('min')">
|
||||
{{ 'labels.inputs.Installment in multiples of' | translate }}
|
||||
{{ 'labels.commons.Minimum Value must be' | translate }} <strong>1</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="layout-row align-center gap-2percent margin-t responsive-column">
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
import { Component, OnInit, Input, inject } from '@angular/core';
|
||||
import { UntypedFormGroup, UntypedFormBuilder, Validators, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatTooltip } from '@angular/material/tooltip';
|
||||
import { MatCheckbox } from '@angular/material/checkbox';
|
||||
import { MatStepperPrevious, MatStepperNext } from '@angular/material/stepper';
|
||||
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
|
||||
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
||||
@ -20,6 +21,7 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
||||
imports: [
|
||||
...STANDALONE_SHARED_IMPORTS,
|
||||
MatTooltip,
|
||||
MatCheckbox,
|
||||
MatStepperPrevious,
|
||||
FaIconComponent,
|
||||
MatStepperNext
|
||||
@ -48,6 +50,11 @@ export class LoanProductCurrencyStepComponent implements OnInit {
|
||||
this.loanProductsTemplate.currency.decimalPlaces === null
|
||||
? ''
|
||||
: this.loanProductsTemplate.currency.decimalPlaces,
|
||||
setMultiples: !!(
|
||||
(this.loanProductsTemplate.currency.inMultiplesOf && this.loanProductsTemplate.currency.inMultiplesOf !== 0) ||
|
||||
(this.loanProductsTemplate.installmentAmountInMultiplesOf &&
|
||||
this.loanProductsTemplate.installmentAmountInMultiplesOf !== 0)
|
||||
),
|
||||
inMultiplesOf:
|
||||
this.loanProductsTemplate.currency.inMultiplesOf === 0 ||
|
||||
this.loanProductsTemplate.currency.inMultiplesOf === undefined ||
|
||||
@ -61,6 +68,50 @@ export class LoanProductCurrencyStepComponent implements OnInit {
|
||||
? ''
|
||||
: this.loanProductsTemplate.installmentAmountInMultiplesOf
|
||||
});
|
||||
|
||||
this.setupConditionalValidation();
|
||||
}
|
||||
|
||||
setupConditionalValidation() {
|
||||
this.loanProductCurrencyForm.get('setMultiples')?.valueChanges.subscribe((setMultiples: boolean) => {
|
||||
const inMultiplesOfControl = this.loanProductCurrencyForm.get('inMultiplesOf');
|
||||
const installmentControl = this.loanProductCurrencyForm.get('installmentAmountInMultiplesOf');
|
||||
|
||||
if (setMultiples) {
|
||||
inMultiplesOfControl?.setValidators([
|
||||
Validators.required,
|
||||
Validators.min(1)
|
||||
]);
|
||||
installmentControl?.setValidators([
|
||||
Validators.required,
|
||||
Validators.min(1)
|
||||
]);
|
||||
} else {
|
||||
inMultiplesOfControl?.clearValidators();
|
||||
installmentControl?.clearValidators();
|
||||
inMultiplesOfControl?.setValue('');
|
||||
installmentControl?.setValue('');
|
||||
}
|
||||
|
||||
inMultiplesOfControl?.updateValueAndValidity();
|
||||
installmentControl?.updateValueAndValidity();
|
||||
});
|
||||
|
||||
const initialSetMultiples = this.loanProductCurrencyForm.get('setMultiples')?.value;
|
||||
if (initialSetMultiples) {
|
||||
const inMultiplesOfControl = this.loanProductCurrencyForm.get('inMultiplesOf');
|
||||
const installmentControl = this.loanProductCurrencyForm.get('installmentAmountInMultiplesOf');
|
||||
inMultiplesOfControl?.setValidators([
|
||||
Validators.required,
|
||||
Validators.min(1)
|
||||
]);
|
||||
installmentControl?.setValidators([
|
||||
Validators.required,
|
||||
Validators.min(1)
|
||||
]);
|
||||
inMultiplesOfControl?.updateValueAndValidity();
|
||||
installmentControl?.updateValueAndValidity();
|
||||
}
|
||||
}
|
||||
|
||||
createLoanProductCurrencyForm() {
|
||||
@ -76,24 +127,33 @@ export class LoanProductCurrencyStepComponent implements OnInit {
|
||||
Validators.min(0)
|
||||
]
|
||||
],
|
||||
inMultiplesOf: [
|
||||
'',
|
||||
[
|
||||
Validators.required,
|
||||
Validators.min(1)
|
||||
]
|
||||
],
|
||||
installmentAmountInMultiplesOf: [
|
||||
'',
|
||||
[
|
||||
Validators.required,
|
||||
Validators.min(1)
|
||||
]
|
||||
]
|
||||
setMultiples: [false],
|
||||
inMultiplesOf: [''],
|
||||
installmentAmountInMultiplesOf: ['']
|
||||
});
|
||||
}
|
||||
|
||||
get loanProductCurrency() {
|
||||
return this.loanProductCurrencyForm.value;
|
||||
const formValue = this.loanProductCurrencyForm.value;
|
||||
const result: any = {
|
||||
currencyCode: formValue.currencyCode,
|
||||
digitsAfterDecimal: formValue.digitsAfterDecimal
|
||||
};
|
||||
|
||||
if (formValue.setMultiples) {
|
||||
if (formValue.inMultiplesOf !== '' && formValue.inMultiplesOf !== null && formValue.inMultiplesOf !== undefined) {
|
||||
result.inMultiplesOf = formValue.inMultiplesOf;
|
||||
}
|
||||
|
||||
if (
|
||||
formValue.installmentAmountInMultiplesOf !== '' &&
|
||||
formValue.installmentAmountInMultiplesOf !== null &&
|
||||
formValue.installmentAmountInMultiplesOf !== undefined
|
||||
) {
|
||||
result.installmentAmountInMultiplesOf = formValue.installmentAmountInMultiplesOf;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1578,6 +1578,7 @@
|
||||
"Currency Multiple": "Násobek měn",
|
||||
"Currency Name": "Název měny",
|
||||
"Currency in multiples of": "Měna v násobcích",
|
||||
"Set the multiples of the loan and its installment": "Nastavit násobky půjčky a její splátky",
|
||||
"Current Balance": "Aktuální zůstatek",
|
||||
"Current Balances": "Aktuální zůstatky",
|
||||
"Current Business Date": "Aktuální obchodní datum",
|
||||
|
||||
@ -1580,6 +1580,7 @@
|
||||
"Currency Multiple": "Währungsmultiplikator",
|
||||
"Currency Name": "Währungsname",
|
||||
"Currency in multiples of": "Währung in Vielfachen von",
|
||||
"Set the multiples of the loan and its installment": "Die Vielfachen des Darlehens und seiner Rate festlegen",
|
||||
"Current Balance": "Aktueller Kontostand",
|
||||
"Current Balances": "Aktuelle Guthaben",
|
||||
"Current Business Date": "Aktuelles Geschäftsdatum",
|
||||
|
||||
@ -1584,6 +1584,7 @@
|
||||
"Currency Multiple": "Currency Multiple",
|
||||
"Currency Name": "Currency Name",
|
||||
"Currency in multiples of": "Currency in multiples of",
|
||||
"Set the multiples of the loan and its installment": "Set the multiples of the loan and its installment",
|
||||
"Current Balance": "Current Balance",
|
||||
"Current Balances": "Current Balances",
|
||||
"Current Business Date": "Current Business Date",
|
||||
|
||||
@ -1580,6 +1580,7 @@
|
||||
"Currency Multiple": "Moneda múltiple",
|
||||
"Currency Name": "Nombre de la moneda",
|
||||
"Currency in multiples of": "Moneda en múltiplos de",
|
||||
"Set the multiples of the loan and its installment": "Establecer los múltiplos del préstamo y su cuota",
|
||||
"Current Balance": "Saldo actual",
|
||||
"Current Balances": "Saldos actuales",
|
||||
"Current Business Date": "Fecha del sistema actual",
|
||||
|
||||
@ -1579,6 +1579,7 @@
|
||||
"Currency Multiple": "Moneda múltiple",
|
||||
"Currency Name": "Nombre de la moneda",
|
||||
"Currency in multiples of": "Moneda en múltiplos de",
|
||||
"Set the multiples of the loan and its installment": "Establecer los múltiplos del crédito y su cuota",
|
||||
"Current Balance": "Saldo actual",
|
||||
"Current Balances": "Saldos actuales",
|
||||
"Current Business Date": "Fecha del sistema actual",
|
||||
|
||||
@ -1580,6 +1580,7 @@
|
||||
"Currency Multiple": "Devise multiple",
|
||||
"Currency Name": "Nom de la devise",
|
||||
"Currency in multiples of": "Monnaie en multiples de",
|
||||
"Set the multiples of the loan and its installment": "Définir les multiples du prêt et de son versement",
|
||||
"Current Balance": "Solde actuel",
|
||||
"Current Balances": "Soldes courants",
|
||||
"Current Business Date": "Date d'ouverture actuelle",
|
||||
|
||||
@ -1579,6 +1579,7 @@
|
||||
"Currency Multiple": "Valuta multipla",
|
||||
"Currency Name": "Nome della valuta",
|
||||
"Currency in multiples of": "Valuta in multipli di",
|
||||
"Set the multiples of the loan and its installment": "Imposta i multipli del prestito e della sua rata",
|
||||
"Current Balance": "Bilancio corrente",
|
||||
"Current Balances": "Saldi correnti",
|
||||
"Current Business Date": "Data lavorativa corrente",
|
||||
|
||||
@ -1581,6 +1581,7 @@
|
||||
"Currency Multiple": "통화 배수",
|
||||
"Currency Name": "통화 이름",
|
||||
"Currency in multiples of": "통화의 배수",
|
||||
"Set the multiples of the loan and its installment": "대출 및 할부금의 배수 설정",
|
||||
"Current Balance": "현재의 균형",
|
||||
"Current Balances": "현재 잔액",
|
||||
"Current Business Date": "현재 영업일",
|
||||
|
||||
@ -1578,6 +1578,7 @@
|
||||
"Currency Multiple": "Keli valiuta",
|
||||
"Currency Name": "Valiutos pavadinimas",
|
||||
"Currency in multiples of": "Valiuta kartotiniais",
|
||||
"Set the multiples of the loan and its installment": "Nustatyti paskolos ir jos įmokos kartotinius",
|
||||
"Current Balance": "Dabartinis balansas",
|
||||
"Current Balances": "Dabartiniai likučiai",
|
||||
"Current Business Date": "Dabartinė verslo data",
|
||||
|
||||
@ -1580,6 +1580,7 @@
|
||||
"Currency Multiple": "Valūta vairākas",
|
||||
"Currency Name": "Valūtas nosaukums",
|
||||
"Currency in multiples of": "Valūta daudzkārtnēs",
|
||||
"Set the multiples of the loan and its installment": "Iestatīt aizdevuma un tā maksājuma daudzkārtņus",
|
||||
"Current Balance": "Pašreizējā bilance",
|
||||
"Current Balances": "Pašreizējie atlikumi",
|
||||
"Current Business Date": "Pašreizējais darba datums",
|
||||
|
||||
@ -1578,6 +1578,7 @@
|
||||
"Currency Multiple": "मुद्रा बहु",
|
||||
"Currency Name": "मुद्रा नाम",
|
||||
"Currency in multiples of": "को गुणनमा मुद्रा",
|
||||
"Set the multiples of the loan and its installment": "ऋण र यसको किस्ताको गुणन सेट गर्नुहोस्",
|
||||
"Current Balance": "हालको मौज्दात",
|
||||
"Current Balances": "हालको ब्यालेन्स",
|
||||
"Current Business Date": "हालको व्यापार मिति",
|
||||
|
||||
@ -1579,6 +1579,7 @@
|
||||
"Currency Multiple": "Múltipla Moeda",
|
||||
"Currency Name": "Nome da moeda",
|
||||
"Currency in multiples of": "Moeda em múltiplos de",
|
||||
"Set the multiples of the loan and its installment": "Definir os múltiplos do empréstimo e sua prestação",
|
||||
"Current Balance": "Saldo Atual",
|
||||
"Current Balances": "Saldos Atuais",
|
||||
"Current Business Date": "Data comercial atual",
|
||||
|
||||
@ -1576,6 +1576,7 @@
|
||||
"Currency Multiple": "Sarafu Nyingi",
|
||||
"Currency Name": "Jina la Sarafu",
|
||||
"Currency in multiples of": "Sarafu katika mafungu ya",
|
||||
"Set the multiples of the loan and its installment": "Weka mafungu ya mkopo na awamu yake",
|
||||
"Current Balance": "Salio la Sasa",
|
||||
"Current Balances": "Mizani ya Sasa",
|
||||
"Current Business Date": "Tarehe ya Biashara ya Sasa",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user