From 68ab5b1c16bcaa65d284f5e27f3c02e5e57c5d32 Mon Sep 17 00:00:00 2001 From: Tomek Hanaj <12088991+tomaszhanaj@users.noreply.github.com> Date: Wed, 10 Dec 2025 15:01:22 +0100 Subject: [PATCH] AAE-39923 Placholeder is formatted according to the enableFractions (#11441) * [AAE-39923] placholeder is formatted according to the enableFractions property * [AAE-39923] unit tests for placeholder decimal part --- .../widgets/amount/amount.widget.spec.ts | 39 +++++++++++++++++++ .../widgets/amount/amount.widget.ts | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/lib/core/src/lib/form/components/widgets/amount/amount.widget.spec.ts b/lib/core/src/lib/form/components/widgets/amount/amount.widget.spec.ts index 1fc56dcd70..b4c20e00a9 100644 --- a/lib/core/src/lib/form/components/widgets/amount/amount.widget.spec.ts +++ b/lib/core/src/lib/form/components/widgets/amount/amount.widget.spec.ts @@ -890,6 +890,45 @@ describe('AmountWidgetComponent - rendering', () => { const expectedValue = '5.000,00 €'.replace(' ', '\u00A0'); expect(widget.placeholder).toBe(expectedValue); }); + + it('should format numeric placeholder with decimal digits', () => { + widget.field.placeholder = '1234.11'; + widget.currency = 'USD'; + widget.currencyDisplay = 'symbol'; + widget.decimalProperty = widget.showDecimalDigits; + + widget.enableDisplayBasedOnLocale = true; + widget.locale = 'de-DE'; + + const expected = '1.234,11 $'.replace(' ', '\u00A0'); + expect(widget.placeholder).toBe(expected); + }); + + it('should format numeric placeholder without decimal digits', () => { + widget.field.placeholder = '1234.11'; + widget.currency = 'USD'; + widget.currencyDisplay = 'symbol'; + widget.decimalProperty = widget.notShowDecimalDigits; + + widget.enableDisplayBasedOnLocale = true; + widget.locale = 'de-DE'; + + const expected = '1.234 $'.replace(' ', '\u00A0'); + expect(widget.placeholder).toBe(expected); + }); + + it('should format numeric placeholder without decimal digits and rounding', () => { + widget.field.placeholder = '1234.55'; + widget.currency = 'USD'; + widget.currencyDisplay = 'symbol'; + widget.decimalProperty = widget.notShowDecimalDigits; + + widget.enableDisplayBasedOnLocale = true; + widget.locale = 'de-DE'; + + const expected = '1.235 $'.replace(' ', '\u00A0'); + expect(widget.placeholder).toBe(expected); + }); }); describe('checkIfEmptyStringOrOnlySpaces', () => { diff --git a/lib/core/src/lib/form/components/widgets/amount/amount.widget.ts b/lib/core/src/lib/form/components/widgets/amount/amount.widget.ts index c5a4b20974..6ebb0f5901 100644 --- a/lib/core/src/lib/form/components/widgets/amount/amount.widget.ts +++ b/lib/core/src/lib/form/components/widgets/amount/amount.widget.ts @@ -83,7 +83,7 @@ export class AmountWidgetComponent extends WidgetComponent implements OnInit { if (isNaN(stringConvertedToNumber)) { return this.field.placeholder; } - return this.currencyPipe.transform(this.field.placeholder, this.currency, this.currencyDisplay, this.showDecimalDigits, this.locale); + return this.currencyPipe.transform(this.field.placeholder, this.currency, this.currencyDisplay, this.decimalProperty, this.locale); } constructor(