From 744826148bb0e5fb4e49a9ed3eb610828082f19f Mon Sep 17 00:00:00 2001 From: Soni Jay Date: Wed, 4 Feb 2026 06:53:32 +0530 Subject: [PATCH] WEB-661 Fix currency multiples fields sending empty strings to API and add optional checkbox controls (#3085) --- ...posit-product-currency-step.component.html | 22 ++++-- ...posit-product-currency-step.component.scss | 4 + ...deposit-product-currency-step.component.ts | 67 +++++++++++++---- ...eposit-product-preview-step.component.html | 14 ++-- .../loan-product-currency-step.component.html | 2 +- .../loan-product-currency-step.component.scss | 4 + ...posit-product-currency-step.component.html | 33 +++++---- ...posit-product-currency-step.component.scss | 4 + ...deposit-product-currency-step.component.ts | 74 +++++++++++++++---- ...eposit-product-preview-step.component.html | 14 ++-- ...aving-product-currency-step.component.html | 35 +++++---- ...aving-product-currency-step.component.scss | 4 + .../saving-product-currency-step.component.ts | 59 ++++++++++++--- ...saving-product-preview-step.component.html | 12 +-- ...share-product-currency-step.component.html | 35 +++++---- ...share-product-currency-step.component.scss | 4 + .../share-product-currency-step.component.ts | 71 +++++++++++++----- .../share-product-preview-step.component.html | 12 +-- src/assets/translations/cs-CS.json | 4 + src/assets/translations/de-DE.json | 4 + src/assets/translations/en-US.json | 4 + src/assets/translations/es-CL.json | 4 + src/assets/translations/es-MX.json | 4 + src/assets/translations/fr-FR.json | 4 + src/assets/translations/it-IT.json | 4 + src/assets/translations/ko-KO.json | 4 + src/assets/translations/lt-LT.json | 4 + src/assets/translations/lv-LV.json | 4 + src/assets/translations/ne-NE.json | 4 + src/assets/translations/pt-PT.json | 4 + src/assets/translations/sw-SW.json | 4 + 31 files changed, 387 insertions(+), 135 deletions(-) diff --git a/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-currency-step/fixed-deposit-product-currency-step.component.html b/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-currency-step/fixed-deposit-product-currency-step.component.html index 02436e530..903f65fc5 100644 --- a/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-currency-step/fixed-deposit-product-currency-step.component.html +++ b/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-currency-step/fixed-deposit-product-currency-step.component.html @@ -32,14 +32,20 @@ - - {{ 'labels.inputs.Currency in multiples of' | translate }} - - - {{ 'labels.inputs.Currency in multiples of' | translate }} {{ 'labels.commons.is' | translate }} - {{ 'labels.commons.required' | translate }} - - + + {{ 'labels.inputs.Set the fixed deposit installment in multiples of' | translate }} + + + @if (fixedDepositProductCurrencyForm.value.setMultiples) { + + {{ 'labels.inputs.Currency in multiples of' | translate }} + + + {{ 'labels.inputs.Currency in multiples of' | translate }} {{ 'labels.commons.is' | translate }} + {{ 'labels.commons.required' | translate }} + + + }
diff --git a/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-currency-step/fixed-deposit-product-currency-step.component.scss b/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-currency-step/fixed-deposit-product-currency-step.component.scss index d59bc82ee..80a18a771 100644 --- a/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-currency-step/fixed-deposit-product-currency-step.component.scss +++ b/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-currency-step/fixed-deposit-product-currency-step.component.scss @@ -9,3 +9,7 @@ .margin-t { margin-top: 1em; } + +.checkbox-align-center { + align-items: center; +} diff --git a/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-currency-step/fixed-deposit-product-currency-step.component.ts b/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-currency-step/fixed-deposit-product-currency-step.component.ts index 9011e1891..70e456747 100644 --- a/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-currency-step/fixed-deposit-product-currency-step.component.ts +++ b/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-currency-step/fixed-deposit-product-currency-step.component.ts @@ -6,9 +6,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { Component, OnInit, Input, inject } from '@angular/core'; +import { Component, OnInit, Input, inject, DestroyRef } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { startWith } from 'rxjs/operators'; import { UntypedFormGroup, UntypedFormBuilder, Validators, ReactiveFormsModule } from '@angular/forms'; import { MatStepperPrevious, MatStepperNext } from '@angular/material/stepper'; +import { MatCheckbox } from '@angular/material/checkbox'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; @@ -20,11 +23,13 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; ...STANDALONE_SHARED_IMPORTS, MatStepperPrevious, FaIconComponent, - MatStepperNext + MatStepperNext, + MatCheckbox ] }) export class FixedDepositProductCurrencyStepComponent implements OnInit { private formBuilder = inject(UntypedFormBuilder); + private destroyRef = inject(DestroyRef); @Input() fixedDepositProductsTemplate: any; @@ -39,18 +44,14 @@ export class FixedDepositProductCurrencyStepComponent implements OnInit { ngOnInit() { this.currencyData = this.fixedDepositProductsTemplate.currencyOptions; - if (!(this.fixedDepositProductsTemplate === undefined) && this.fixedDepositProductsTemplate.id) { - this.fixedDepositProductCurrencyForm.patchValue({ - currencyCode: this.fixedDepositProductsTemplate.currency.code, - digitsAfterDecimal: this.fixedDepositProductsTemplate.currency.decimalPlaces, - inMultiplesOf: this.fixedDepositProductsTemplate.currency.inMultiplesOf - }); - } else { - this.fixedDepositProductCurrencyForm.patchValue({ - currencyCode: this.currencyData[0].code, - digitsAfterDecimal: 2 - }); - } + this.fixedDepositProductCurrencyForm.patchValue({ + currencyCode: this.fixedDepositProductsTemplate.currency?.code || this.currencyData[0].code, + digitsAfterDecimal: this.fixedDepositProductsTemplate.digitsAfterDecimal ?? '', + setMultiples: !!this.fixedDepositProductsTemplate.inMultiplesOf, + inMultiplesOf: this.fixedDepositProductsTemplate.inMultiplesOf ?? '' + }); + + this.setupConditionalValidation(); } createFixedDepositProductCurrencyForm() { @@ -61,13 +62,47 @@ export class FixedDepositProductCurrencyStepComponent implements OnInit { ], digitsAfterDecimal: [ '', - Validators.required + [ + Validators.required, + Validators.min(0) + ] ], + setMultiples: [false], inMultiplesOf: [''] }); } + setupConditionalValidation() { + const inMultiplesOfControl = this.fixedDepositProductCurrencyForm.get('inMultiplesOf'); + const setMultiplesControl = this.fixedDepositProductCurrencyForm.get('setMultiples'); + + setMultiplesControl?.valueChanges + .pipe(startWith(setMultiplesControl.value), takeUntilDestroyed(this.destroyRef)) + .subscribe((checked) => { + if (checked) { + inMultiplesOfControl?.setValidators([ + Validators.required, + Validators.min(1) + ]); + } else { + inMultiplesOfControl?.clearValidators(); + inMultiplesOfControl?.setValue(''); + } + inMultiplesOfControl?.updateValueAndValidity(); + }); + } + get fixedDepositProductCurrency() { - return this.fixedDepositProductCurrencyForm.value; + const formValue = this.fixedDepositProductCurrencyForm.value; + const result: any = { + currencyCode: formValue.currencyCode, + digitsAfterDecimal: formValue.digitsAfterDecimal + }; + + if (formValue.inMultiplesOf !== '' && formValue.inMultiplesOf !== null && formValue.inMultiplesOf !== undefined) { + result.inMultiplesOf = formValue.inMultiplesOf; + } + + return result; } } diff --git a/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-preview-step/fixed-deposit-product-preview-step.component.html b/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-preview-step/fixed-deposit-product-preview-step.component.html index 508cd1d85..ad9660e37 100644 --- a/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-preview-step/fixed-deposit-product-preview-step.component.html +++ b/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-preview-step/fixed-deposit-product-preview-step.component.html @@ -37,13 +37,17 @@
{{ 'labels.inputs.Decimal Places' | translate }}: - {{ fixedDepositProduct.digitsAfterDecimal }} + {{ + fixedDepositProduct.digitsAfterDecimal ?? fixedDepositProduct.currency?.decimalPlaces + }}
-
- {{ 'labels.inputs.Currency in multiples of' | translate }}: - {{ fixedDepositProduct.inMultiplesOf }} -
+ @if (fixedDepositProduct.inMultiplesOf) { +
+ {{ 'labels.inputs.Currency in multiples of' | translate }}: + {{ fixedDepositProduct.inMultiplesOf }} +
+ }

{{ 'labels.heading.Terms' | translate }}

diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-currency-step/loan-product-currency-step.component.html b/src/app/products/loan-products/loan-product-stepper/loan-product-currency-step/loan-product-currency-step.component.html index 2e75dfabc..94eb3b703 100644 --- a/src/app/products/loan-products/loan-product-stepper/loan-product-currency-step/loan-product-currency-step.component.html +++ b/src/app/products/loan-products/loan-product-stepper/loan-product-currency-step/loan-product-currency-step.component.html @@ -47,7 +47,7 @@ - + {{ 'labels.inputs.Set the multiples of the loan and its installment' | translate }} diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-currency-step/loan-product-currency-step.component.scss b/src/app/products/loan-products/loan-product-stepper/loan-product-currency-step/loan-product-currency-step.component.scss index d59bc82ee..a6734cf04 100644 --- a/src/app/products/loan-products/loan-product-stepper/loan-product-currency-step/loan-product-currency-step.component.scss +++ b/src/app/products/loan-products/loan-product-stepper/loan-product-currency-step/loan-product-currency-step.component.scss @@ -9,3 +9,7 @@ .margin-t { margin-top: 1em; } + +.align-center { + align-items: center; +} diff --git a/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-currency-step/recurring-deposit-product-currency-step.component.html b/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-currency-step/recurring-deposit-product-currency-step.component.html index 6932281dc..a9e852cc9 100644 --- a/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-currency-step/recurring-deposit-product-currency-step.component.html +++ b/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-currency-step/recurring-deposit-product-currency-step.component.html @@ -42,19 +42,26 @@ - - {{ 'labels.inputs.Currency in multiples of' | translate }} - - - {{ 'labels.inputs.Currency in multiples of' | translate }} {{ 'labels.commons.is' | translate }} - {{ 'labels.commons.required' | translate }} - - + + {{ 'labels.inputs.Set the recurring deposit installment in multiples of' | translate }} + + + @if (recurringDepositProductCurrencyForm.value.setMultiples) { + + {{ 'labels.inputs.Currency in multiples of' | translate }} + + + {{ 'labels.inputs.Currency in multiples of' | translate }} {{ 'labels.commons.is' | translate }} + {{ 'labels.commons.required' | translate }} + + + }
diff --git a/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-currency-step/recurring-deposit-product-currency-step.component.scss b/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-currency-step/recurring-deposit-product-currency-step.component.scss index d59bc82ee..6abf30d93 100644 --- a/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-currency-step/recurring-deposit-product-currency-step.component.scss +++ b/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-currency-step/recurring-deposit-product-currency-step.component.scss @@ -9,3 +9,7 @@ .margin-t { margin-top: 1em; } + +.align-items-center { + align-items: center; +} diff --git a/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-currency-step/recurring-deposit-product-currency-step.component.ts b/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-currency-step/recurring-deposit-product-currency-step.component.ts index 4e744f830..a8abe7e14 100644 --- a/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-currency-step/recurring-deposit-product-currency-step.component.ts +++ b/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-currency-step/recurring-deposit-product-currency-step.component.ts @@ -6,12 +6,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { Component, OnInit, Input, inject } from '@angular/core'; +import { Component, OnInit, Input, inject, DestroyRef } from '@angular/core'; import { UntypedFormGroup, UntypedFormBuilder, Validators, ReactiveFormsModule } from '@angular/forms'; import { MatTooltip } from '@angular/material/tooltip'; import { MatStepperPrevious, MatStepperNext } from '@angular/material/stepper'; +import { MatCheckbox } from '@angular/material/checkbox'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; @Component({ selector: 'mifosx-recurring-deposit-product-currency-step', @@ -22,11 +24,13 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; MatTooltip, MatStepperPrevious, FaIconComponent, - MatStepperNext + MatStepperNext, + MatCheckbox ] }) export class RecurringDepositProductCurrencyStepComponent implements OnInit { private formBuilder = inject(UntypedFormBuilder); + private destroyRef = inject(DestroyRef); @Input() recurringDepositProductsTemplate: any; @@ -40,17 +44,25 @@ export class RecurringDepositProductCurrencyStepComponent implements OnInit { ngOnInit() { this.currencyData = this.recurringDepositProductsTemplate.currencyOptions; - if (!(this.recurringDepositProductsTemplate === undefined) && this.recurringDepositProductsTemplate.id) { - this.recurringDepositProductCurrencyForm.patchValue({ - currencyCode: this.recurringDepositProductsTemplate.currency.code, - digitsAfterDecimal: this.recurringDepositProductsTemplate.currency.decimalPlaces, - inMultiplesOf: this.recurringDepositProductsTemplate.currency.inMultiplesOf - }); - } else { - this.recurringDepositProductCurrencyForm.patchValue({ - currencyCode: this.currencyData[0].code, - digitsAfterDecimal: 2 - }); + + this.recurringDepositProductCurrencyForm.patchValue({ + currencyCode: this.recurringDepositProductsTemplate.currency?.code || this.currencyData[0].code, + digitsAfterDecimal: this.recurringDepositProductsTemplate.digitsAfterDecimal ?? '', + setMultiples: !!this.recurringDepositProductsTemplate.inMultiplesOf, + inMultiplesOf: this.recurringDepositProductsTemplate.inMultiplesOf ?? '' + }); + + this.setupConditionalValidation(); + + // Apply initial validators based on the patched setMultiples value + const inMultiplesOfControl = this.recurringDepositProductCurrencyForm.get('inMultiplesOf'); + const setMultiplesControl = this.recurringDepositProductCurrencyForm.get('setMultiples'); + if (setMultiplesControl?.value) { + inMultiplesOfControl?.setValidators([ + Validators.required, + Validators.min(1) + ]); + inMultiplesOfControl?.updateValueAndValidity(); } } @@ -62,13 +74,45 @@ export class RecurringDepositProductCurrencyStepComponent implements OnInit { ], digitsAfterDecimal: [ '', - Validators.required + [ + Validators.required, + Validators.min(0) + ] ], + setMultiples: [false], inMultiplesOf: [''] }); } + setupConditionalValidation() { + const inMultiplesOfControl = this.recurringDepositProductCurrencyForm.get('inMultiplesOf'); + const setMultiplesControl = this.recurringDepositProductCurrencyForm.get('setMultiples'); + + setMultiplesControl?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((checked) => { + if (checked) { + inMultiplesOfControl?.setValidators([ + Validators.required, + Validators.min(1) + ]); + } else { + inMultiplesOfControl?.clearValidators(); + inMultiplesOfControl?.setValue(''); + } + inMultiplesOfControl?.updateValueAndValidity(); + }); + } + get recurringDepositProductCurrency() { - return this.recurringDepositProductCurrencyForm.value; + const formValue = this.recurringDepositProductCurrencyForm.value; + const result: any = { + currencyCode: formValue.currencyCode, + digitsAfterDecimal: formValue.digitsAfterDecimal + }; + + if (formValue.inMultiplesOf !== '' && formValue.inMultiplesOf !== null && formValue.inMultiplesOf !== undefined) { + result.inMultiplesOf = formValue.inMultiplesOf; + } + + return result; } } diff --git a/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-preview-step/recurring-deposit-product-preview-step.component.html b/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-preview-step/recurring-deposit-product-preview-step.component.html index 2d79576cf..ec171ab73 100644 --- a/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-preview-step/recurring-deposit-product-preview-step.component.html +++ b/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-preview-step/recurring-deposit-product-preview-step.component.html @@ -37,13 +37,17 @@
{{ 'labels.inputs.Decimal Places' | translate }}: - {{ recurringDepositProduct.digitsAfterDecimal }} + {{ + recurringDepositProduct.digitsAfterDecimal ?? recurringDepositProduct.currency?.decimalPlaces + }}
-
- {{ 'labels.inputs.Currency in multiples of' | translate }}: - {{ recurringDepositProduct.inMultiplesOf }} -
+ @if (recurringDepositProduct.inMultiplesOf) { +
+ {{ 'labels.inputs.Currency in multiples of' | translate }}: + {{ recurringDepositProduct.inMultiplesOf }} +
+ }

{{ 'labels.heading.Terms' | translate }}

diff --git a/src/app/products/saving-products/saving-product-stepper/saving-product-currency-step/saving-product-currency-step.component.html b/src/app/products/saving-products/saving-product-stepper/saving-product-currency-step/saving-product-currency-step.component.html index c6fad846f..c0d376ad8 100644 --- a/src/app/products/saving-products/saving-product-stepper/saving-product-currency-step/saving-product-currency-step.component.html +++ b/src/app/products/saving-products/saving-product-stepper/saving-product-currency-step/saving-product-currency-step.component.html @@ -43,21 +43,26 @@ - - {{ 'labels.inputs.Currency in multiples of' | translate }} - - - {{ 'labels.inputs.Currency in multiples of' | translate }} {{ 'labels.commons.is' | translate }} - {{ 'labels.commons.required' | translate }} - - + + {{ 'labels.inputs.Set the saving installment in multiples of' | translate }} + + + @if (savingProductCurrencyForm.value.setMultiples) { + + {{ 'labels.inputs.Currency in multiples of' | translate }} + + + {{ 'labels.inputs.Currency in multiples of' | translate }} {{ 'labels.commons.is' | translate }} + {{ 'labels.commons.required' | translate }} + + + }
diff --git a/src/app/products/saving-products/saving-product-stepper/saving-product-currency-step/saving-product-currency-step.component.scss b/src/app/products/saving-products/saving-product-stepper/saving-product-currency-step/saving-product-currency-step.component.scss index d59bc82ee..80a18a771 100644 --- a/src/app/products/saving-products/saving-product-stepper/saving-product-currency-step/saving-product-currency-step.component.scss +++ b/src/app/products/saving-products/saving-product-stepper/saving-product-currency-step/saving-product-currency-step.component.scss @@ -9,3 +9,7 @@ .margin-t { margin-top: 1em; } + +.checkbox-align-center { + align-items: center; +} diff --git a/src/app/products/saving-products/saving-product-stepper/saving-product-currency-step/saving-product-currency-step.component.ts b/src/app/products/saving-products/saving-product-stepper/saving-product-currency-step/saving-product-currency-step.component.ts index 885ac9600..699765a37 100644 --- a/src/app/products/saving-products/saving-product-stepper/saving-product-currency-step/saving-product-currency-step.component.ts +++ b/src/app/products/saving-products/saving-product-stepper/saving-product-currency-step/saving-product-currency-step.component.ts @@ -6,10 +6,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { Component, OnInit, Input, inject } from '@angular/core'; +import { Component, OnInit, Input, inject, DestroyRef } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { UntypedFormGroup, UntypedFormBuilder, Validators, ReactiveFormsModule } from '@angular/forms'; import { MatTooltip } from '@angular/material/tooltip'; import { MatStepperPrevious, MatStepperNext } from '@angular/material/stepper'; +import { MatCheckbox } from '@angular/material/checkbox'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; @@ -22,11 +24,13 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; MatTooltip, MatStepperPrevious, FaIconComponent, - MatStepperNext + MatStepperNext, + MatCheckbox ] }) export class SavingProductCurrencyStepComponent implements OnInit { private formBuilder = inject(UntypedFormBuilder); + private destroyRef = inject(DestroyRef); @Input() savingProductsTemplate: any; @@ -43,11 +47,12 @@ export class SavingProductCurrencyStepComponent implements OnInit { this.savingProductCurrencyForm.patchValue({ currencyCode: this.savingProductsTemplate.currency.code || this.currencyData[0].code, - digitsAfterDecimal: this.savingProductsTemplate.currency.code - ? this.savingProductsTemplate.currency.decimalPlaces - : 2, - inMultiplesOf: this.savingProductsTemplate.currency.inMultiplesOf || '' + digitsAfterDecimal: this.savingProductsTemplate.digitsAfterDecimal ?? '', + setMultiples: !!this.savingProductsTemplate.inMultiplesOf, + inMultiplesOf: this.savingProductsTemplate.inMultiplesOf ?? '' }); + + this.setupConditionalValidation(); } createSavingProductCurrencyForm() { @@ -63,17 +68,47 @@ export class SavingProductCurrencyStepComponent implements OnInit { Validators.min(0) ] ], - inMultiplesOf: [ - '', - [ + setMultiples: [false], + inMultiplesOf: [''] + }); + } + + setupConditionalValidation() { + const inMultiplesOfControl = this.savingProductCurrencyForm.get('inMultiplesOf'); + const setMultiplesControl = this.savingProductCurrencyForm.get('setMultiples'); + if (setMultiplesControl?.value) { + inMultiplesOfControl?.setValidators([ + Validators.required, + Validators.min(1) + ]); + inMultiplesOfControl?.updateValueAndValidity(); + } + + setMultiplesControl?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((checked) => { + if (checked) { + inMultiplesOfControl?.setValidators([ Validators.required, Validators.min(1) - ] - ] + ]); + } else { + inMultiplesOfControl?.clearValidators(); + inMultiplesOfControl?.setValue(''); + } + inMultiplesOfControl?.updateValueAndValidity(); }); } get savingProductCurrency() { - return this.savingProductCurrencyForm.value; + const formValue = this.savingProductCurrencyForm.value; + const result: any = { + currencyCode: formValue.currencyCode, + digitsAfterDecimal: formValue.digitsAfterDecimal + }; + + if (formValue.inMultiplesOf !== '' && formValue.inMultiplesOf !== null && formValue.inMultiplesOf !== undefined) { + result.inMultiplesOf = formValue.inMultiplesOf; + } + + return result; } } diff --git a/src/app/products/saving-products/saving-product-stepper/saving-product-preview-step/saving-product-preview-step.component.html b/src/app/products/saving-products/saving-product-stepper/saving-product-preview-step/saving-product-preview-step.component.html index 560359503..150e129e1 100644 --- a/src/app/products/saving-products/saving-product-stepper/saving-product-preview-step/saving-product-preview-step.component.html +++ b/src/app/products/saving-products/saving-product-stepper/saving-product-preview-step/saving-product-preview-step.component.html @@ -37,13 +37,15 @@
{{ 'labels.inputs.Decimal Places' | translate }}: - {{ savingProduct.digitsAfterDecimal }} + {{ savingProduct.digitsAfterDecimal ?? savingProduct.currency?.decimalPlaces }}
-
- {{ 'labels.inputs.Currency in multiples of' | translate }}: - {{ savingProduct.inMultiplesOf }} -
+ @if (savingProduct.inMultiplesOf) { +
+ {{ 'labels.inputs.Currency in multiples of' | translate }}: + {{ savingProduct.inMultiplesOf }} +
+ }

{{ 'labels.inputs.Terms' | translate }}

diff --git a/src/app/products/share-products/share-product-stepper/share-product-currency-step/share-product-currency-step.component.html b/src/app/products/share-products/share-product-stepper/share-product-currency-step/share-product-currency-step.component.html index e7e659338..afd71fd4f 100644 --- a/src/app/products/share-products/share-product-stepper/share-product-currency-step/share-product-currency-step.component.html +++ b/src/app/products/share-products/share-product-stepper/share-product-currency-step/share-product-currency-step.component.html @@ -43,21 +43,26 @@ - - {{ 'labels.inputs.Currency in multiples of' | translate }} - - - {{ 'labels.inputs.Currency in multiples of' | translate }} {{ 'labels.commons.is' | translate }} - {{ 'labels.commons.required' | translate }} - - + + {{ 'labels.inputs.Set the share installment in multiples of' | translate }} + + + @if (shareProductCurrencyForm.value.setMultiples) { + + {{ 'labels.inputs.Currency in multiples of' | translate }} + + + {{ 'labels.inputs.Currency in multiples of' | translate }} {{ 'labels.commons.is' | translate }} + {{ 'labels.commons.required' | translate }} + + + }
diff --git a/src/app/products/share-products/share-product-stepper/share-product-currency-step/share-product-currency-step.component.scss b/src/app/products/share-products/share-product-stepper/share-product-currency-step/share-product-currency-step.component.scss index d59bc82ee..6abf30d93 100644 --- a/src/app/products/share-products/share-product-stepper/share-product-currency-step/share-product-currency-step.component.scss +++ b/src/app/products/share-products/share-product-stepper/share-product-currency-step/share-product-currency-step.component.scss @@ -9,3 +9,7 @@ .margin-t { margin-top: 1em; } + +.align-items-center { + align-items: center; +} diff --git a/src/app/products/share-products/share-product-stepper/share-product-currency-step/share-product-currency-step.component.ts b/src/app/products/share-products/share-product-stepper/share-product-currency-step/share-product-currency-step.component.ts index 21c82d35e..f2f08980e 100644 --- a/src/app/products/share-products/share-product-stepper/share-product-currency-step/share-product-currency-step.component.ts +++ b/src/app/products/share-products/share-product-stepper/share-product-currency-step/share-product-currency-step.component.ts @@ -6,10 +6,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { Component, OnInit, Input, inject } from '@angular/core'; +import { Component, OnInit, Input, inject, DestroyRef } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { UntypedFormGroup, UntypedFormBuilder, Validators, ReactiveFormsModule } from '@angular/forms'; import { MatTooltip } from '@angular/material/tooltip'; import { MatStepperPrevious, MatStepperNext } from '@angular/material/stepper'; +import { MatCheckbox } from '@angular/material/checkbox'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; @@ -22,11 +24,13 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; MatTooltip, MatStepperPrevious, FaIconComponent, - MatStepperNext + MatStepperNext, + MatCheckbox ] }) export class ShareProductCurrencyStepComponent implements OnInit { private formBuilder = inject(UntypedFormBuilder); + private destroyRef = inject(DestroyRef); @Input() shareProductsTemplate: any; @@ -41,18 +45,14 @@ export class ShareProductCurrencyStepComponent implements OnInit { ngOnInit() { this.currencyData = this.shareProductsTemplate.currencyOptions; - if (this.shareProductsTemplate.currency) { - this.shareProductCurrencyForm.patchValue({ - currencyCode: this.shareProductsTemplate.currency.code, - digitsAfterDecimal: this.shareProductsTemplate.currency.decimalPlaces, - inMultiplesOf: this.shareProductsTemplate.currency.inMultiplesOf - }); - } else { - this.shareProductCurrencyForm.patchValue({ - currencyCode: this.currencyData[0].code, - digitsAfterDecimal: 2 - }); - } + this.shareProductCurrencyForm.patchValue({ + currencyCode: this.shareProductsTemplate.currency?.code || this.currencyData[0].code, + digitsAfterDecimal: this.shareProductsTemplate.digitsAfterDecimal ?? '', + setMultiples: !!this.shareProductsTemplate.inMultiplesOf, + inMultiplesOf: this.shareProductsTemplate.inMultiplesOf ?? '' + }); + + this.setupConditionalValidation(); } createShareProductCurrencyForm() { @@ -68,17 +68,48 @@ export class ShareProductCurrencyStepComponent implements OnInit { Validators.min(0) ] ], - inMultiplesOf: [ - '', - [ + setMultiples: [false], + inMultiplesOf: [''] + }); + } + + setupConditionalValidation() { + const inMultiplesOfControl = this.shareProductCurrencyForm.get('inMultiplesOf'); + const setMultiplesControl = this.shareProductCurrencyForm.get('setMultiples'); + + const applyInMultiplesValidators = (checked: boolean) => { + if (checked) { + inMultiplesOfControl?.setValidators([ Validators.required, Validators.min(1) - ] - ] + ]); + } else { + inMultiplesOfControl?.clearValidators(); + inMultiplesOfControl?.setValue(''); + } + inMultiplesOfControl?.updateValueAndValidity(); + }; + + // Apply validators based on initial value + applyInMultiplesValidators(setMultiplesControl?.value); + + // Listen for changes + setMultiplesControl?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((checked) => { + applyInMultiplesValidators(checked); }); } get shareProductCurrency() { - return this.shareProductCurrencyForm.value; + const formValue = this.shareProductCurrencyForm.value; + const result: any = { + currencyCode: formValue.currencyCode, + digitsAfterDecimal: formValue.digitsAfterDecimal + }; + + if (formValue.inMultiplesOf !== '' && formValue.inMultiplesOf !== null && formValue.inMultiplesOf !== undefined) { + result.inMultiplesOf = formValue.inMultiplesOf; + } + + return result; } } diff --git a/src/app/products/share-products/share-product-stepper/share-product-preview-step/share-product-preview-step.component.html b/src/app/products/share-products/share-product-stepper/share-product-preview-step/share-product-preview-step.component.html index 7be146780..5517f3556 100644 --- a/src/app/products/share-products/share-product-stepper/share-product-preview-step/share-product-preview-step.component.html +++ b/src/app/products/share-products/share-product-stepper/share-product-preview-step/share-product-preview-step.component.html @@ -37,13 +37,15 @@
{{ 'labels.inputs.Decimal Places' | translate }}: - {{ shareProduct.digitsAfterDecimal }} + {{ shareProduct.digitsAfterDecimal ?? shareProduct.currency?.decimalPlaces }}
-
- {{ 'labels.inputs.Currency in multiples of' | translate }}: - {{ shareProduct.inMultiplesOf }} -
+ @if (shareProduct.inMultiplesOf) { +
+ {{ 'labels.inputs.Currency in multiples of' | translate }}: + {{ shareProduct.inMultiplesOf }} +
+ }

{{ 'labels.heading.Terms' | translate }}

diff --git a/src/assets/translations/cs-CS.json b/src/assets/translations/cs-CS.json index 54936ef61..e877bc51e 100644 --- a/src/assets/translations/cs-CS.json +++ b/src/assets/translations/cs-CS.json @@ -1579,6 +1579,10 @@ "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", + "Set the saving installment in multiples of": "Nastavit splátku úspor v násobcích", + "Set the share installment in multiples of": "Nastavit splátku akcií v násobcích", + "Set the fixed deposit installment in multiples of": "Nastavit splátku pevného vkladu v násobcích", + "Set the recurring deposit installment in multiples of": "Nastavit splátku opakovaného vkladu v násobcích", "Current Balance": "Aktuální zůstatek", "Current Balances": "Aktuální zůstatky", "Current Business Date": "Aktuální obchodní datum", diff --git a/src/assets/translations/de-DE.json b/src/assets/translations/de-DE.json index a3505b7e7..ee82ead8d 100644 --- a/src/assets/translations/de-DE.json +++ b/src/assets/translations/de-DE.json @@ -1581,6 +1581,10 @@ "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", + "Set the saving installment in multiples of": "Die Sparrate in Vielfachen festlegen", + "Set the share installment in multiples of": "Die Aktienrate in Vielfachen festlegen", + "Set the fixed deposit installment in multiples of": "Die Festgeldrate in Vielfachen festlegen", + "Set the recurring deposit installment in multiples of": "Die wiederkehrende Einlage in Vielfachen festlegen", "Current Balance": "Aktueller Kontostand", "Current Balances": "Aktuelle Guthaben", "Current Business Date": "Aktuelles Geschäftsdatum", diff --git a/src/assets/translations/en-US.json b/src/assets/translations/en-US.json index b993d69d0..1b49b1078 100644 --- a/src/assets/translations/en-US.json +++ b/src/assets/translations/en-US.json @@ -1585,6 +1585,10 @@ "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", + "Set the saving installment in multiples of": "Set the saving installment in multiples", + "Set the share installment in multiples of": "Set the share installment in multiples", + "Set the fixed deposit installment in multiples of": "Set the fixed deposit installment in multiples", + "Set the recurring deposit installment in multiples of": "Set the recurring deposit installment in multiples", "Current Balance": "Current Balance", "Current Balances": "Current Balances", "Current Business Date": "Current Business Date", diff --git a/src/assets/translations/es-CL.json b/src/assets/translations/es-CL.json index 6eb3bd932..be5f3777a 100644 --- a/src/assets/translations/es-CL.json +++ b/src/assets/translations/es-CL.json @@ -1581,6 +1581,10 @@ "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", + "Set the saving installment in multiples of": "Establecer la cuota de ahorro en múltiplos de", + "Set the share installment in multiples of": "Establecer la cuota de acciones en múltiplos de", + "Set the fixed deposit installment in multiples of": "Establecer la cuota de depósito fijo en múltiplos de", + "Set the recurring deposit installment in multiples of": "Establecer la cuota de depósito recurrente en múltiplos de", "Current Balance": "Saldo actual", "Current Balances": "Saldos actuales", "Current Business Date": "Fecha del sistema actual", diff --git a/src/assets/translations/es-MX.json b/src/assets/translations/es-MX.json index f13cace8f..db6b896e1 100644 --- a/src/assets/translations/es-MX.json +++ b/src/assets/translations/es-MX.json @@ -1580,6 +1580,10 @@ "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", + "Set the saving installment in multiples of": "Establecer la cuota de ahorro en múltiplos de", + "Set the share installment in multiples of": "Establecer la cuota de acciones en múltiplos de", + "Set the fixed deposit installment in multiples of": "Establecer la cuota de depósito fijo en múltiplos de", + "Set the recurring deposit installment in multiples of": "Establecer la cuota de depósito recurrente en múltiplos de", "Current Balance": "Saldo actual", "Current Balances": "Saldos actuales", "Current Business Date": "Fecha del sistema actual", diff --git a/src/assets/translations/fr-FR.json b/src/assets/translations/fr-FR.json index e71e790cb..b7ae41d5b 100644 --- a/src/assets/translations/fr-FR.json +++ b/src/assets/translations/fr-FR.json @@ -1581,6 +1581,10 @@ "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", + "Set the saving installment in multiples of": "Définir le versement d'épargne en multiples de", + "Set the share installment in multiples of": "Définir le versement d'actions en multiples de", + "Set the fixed deposit installment in multiples of": "Définir le versement de dépôt fixe en multiples de", + "Set the recurring deposit installment in multiples of": "Définir le versement de dépôt récurrent en multiples de", "Current Balance": "Solde actuel", "Current Balances": "Soldes courants", "Current Business Date": "Date d'ouverture actuelle", diff --git a/src/assets/translations/it-IT.json b/src/assets/translations/it-IT.json index e688402d8..78ef022d8 100644 --- a/src/assets/translations/it-IT.json +++ b/src/assets/translations/it-IT.json @@ -1580,6 +1580,10 @@ "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", + "Set the saving installment in multiples of": "Imposta la rata di risparmio in multipli di", + "Set the share installment in multiples of": "Imposta la rata delle azioni in multipli di", + "Set the fixed deposit installment in multiples of": "Imposta la rata del deposito fisso in multipli di", + "Set the recurring deposit installment in multiples of": "Imposta la rata del deposito ricorrente in multipli di", "Current Balance": "Bilancio corrente", "Current Balances": "Saldi correnti", "Current Business Date": "Data lavorativa corrente", diff --git a/src/assets/translations/ko-KO.json b/src/assets/translations/ko-KO.json index 633fe14d0..864f17fd3 100644 --- a/src/assets/translations/ko-KO.json +++ b/src/assets/translations/ko-KO.json @@ -1582,6 +1582,10 @@ "Currency Name": "통화 이름", "Currency in multiples of": "통화의 배수", "Set the multiples of the loan and its installment": "대출 및 할부금의 배수 설정", + "Set the saving installment in multiples of": "저축 할부금을 배수로 설정", + "Set the share installment in multiples of": "주식 할부금을 배수로 설정", + "Set the fixed deposit installment in multiples of": "정기 예금 할부금을 배수로 설정", + "Set the recurring deposit installment in multiples of": "반복 예금 할부금을 배수로 설정", "Current Balance": "현재의 균형", "Current Balances": "현재 잔액", "Current Business Date": "현재 영업일", diff --git a/src/assets/translations/lt-LT.json b/src/assets/translations/lt-LT.json index 32d7cda86..e512f5bce 100644 --- a/src/assets/translations/lt-LT.json +++ b/src/assets/translations/lt-LT.json @@ -1579,6 +1579,10 @@ "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", + "Set the saving installment in multiples of": "Nustatyti taupymo įmoką kartotiniais", + "Set the share installment in multiples of": "Nustatyti akcijų įmoką kartotiniais", + "Set the fixed deposit installment in multiples of": "Nustatyti terminuoto indėlio įmoką kartotiniais", + "Set the recurring deposit installment in multiples of": "Nustatyti pasikartojantį indėlį kartotiniais", "Current Balance": "Dabartinis balansas", "Current Balances": "Dabartiniai likučiai", "Current Business Date": "Dabartinė verslo data", diff --git a/src/assets/translations/lv-LV.json b/src/assets/translations/lv-LV.json index 074e2cf35..2d1290820 100644 --- a/src/assets/translations/lv-LV.json +++ b/src/assets/translations/lv-LV.json @@ -1581,6 +1581,10 @@ "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", + "Set the saving installment in multiples of": "Iestatīt ietaupījuma maksājumu daudzkārtņos", + "Set the share installment in multiples of": "Iestatīt akciju maksājumu daudzkārtņos", + "Set the fixed deposit installment in multiples of": "Iestatīt termiņnoguldījuma maksājumu daudzkārtņos", + "Set the recurring deposit installment in multiples of": "Iestatīt atkārtotā depozīta maksājumu daudzkārtņos", "Current Balance": "Pašreizējā bilance", "Current Balances": "Pašreizējie atlikumi", "Current Business Date": "Pašreizējais darba datums", diff --git a/src/assets/translations/ne-NE.json b/src/assets/translations/ne-NE.json index 5f8fe93f7..2bd7cd1fd 100644 --- a/src/assets/translations/ne-NE.json +++ b/src/assets/translations/ne-NE.json @@ -1579,6 +1579,10 @@ "Currency Name": "मुद्रा नाम", "Currency in multiples of": "को गुणनमा मुद्रा", "Set the multiples of the loan and its installment": "ऋण र यसको किस्ताको गुणन सेट गर्नुहोस्", + "Set the saving installment in multiples of": "बचत किस्ता गुणनमा सेट गर्नुहोस्", + "Set the share installment in multiples of": "शेयर किस्ता गुणनमा सेट गर्नुहोस्", + "Set the fixed deposit installment in multiples of": "निश्चित निक्षेप किस्ता गुणनमा सेट गर्नुहोस्", + "Set the recurring deposit installment in multiples of": "आवर्ती निक्षेप किस्ता गुणनमा सेट गर्नुहोस्", "Current Balance": "हालको मौज्दात", "Current Balances": "हालको ब्यालेन्स", "Current Business Date": "हालको व्यापार मिति", diff --git a/src/assets/translations/pt-PT.json b/src/assets/translations/pt-PT.json index a646678c2..18b396aa8 100644 --- a/src/assets/translations/pt-PT.json +++ b/src/assets/translations/pt-PT.json @@ -1580,6 +1580,10 @@ "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", + "Set the saving installment in multiples of": "Definir a prestação de poupança em múltiplos de", + "Set the share installment in multiples of": "Definir a prestação de ações em múltiplos de", + "Set the fixed deposit installment in multiples of": "Definir a prestação de depósito fixo em múltiplos de", + "Set the recurring deposit installment in multiples of": "Definir a prestação de depósito recorrente em múltiplos de", "Current Balance": "Saldo Atual", "Current Balances": "Saldos Atuais", "Current Business Date": "Data comercial atual", diff --git a/src/assets/translations/sw-SW.json b/src/assets/translations/sw-SW.json index 37baf6faa..b75be1b2b 100644 --- a/src/assets/translations/sw-SW.json +++ b/src/assets/translations/sw-SW.json @@ -1577,6 +1577,10 @@ "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", + "Set the saving installment in multiples of": "Weka awamu ya akiba katika mafungu ya", + "Set the share installment in multiples of": "Weka awamu ya hisa katika mafungu ya", + "Set the fixed deposit installment in multiples of": "Weka awamu ya amana isiyobadilika katika mafungu ya", + "Set the recurring deposit installment in multiples of": "Weka awamu ya amana inayorudiwa katika mafungu ya", "Current Balance": "Salio la Sasa", "Current Balances": "Mizani ya Sasa", "Current Business Date": "Tarehe ya Biashara ya Sasa",