diff --git a/src/app/shared/localized-currency-pipe/localized-currency.pipe.ts b/src/app/shared/localized-currency-pipe/localized-currency.pipe.ts index ba5b213e6c..9a12d4a24e 100644 --- a/src/app/shared/localized-currency-pipe/localized-currency.pipe.ts +++ b/src/app/shared/localized-currency-pipe/localized-currency.pipe.ts @@ -16,7 +16,7 @@ export const LOCALIZED_CURRENCY = { }) export class LocalizedCurrencyPipe implements PipeTransform, OnDestroy { private lang: string; - private destroy$: Subject = new Subject(); + private destroy$: Subject = new Subject(); constructor(translate: TranslateService, localStorageService: LocalStorageService) { this.lang = localStorageService.getCurrentLanguage() || translate.defaultLang; @@ -25,12 +25,17 @@ export class LocalizedCurrencyPipe implements PipeTransform, OnDestroy { }); } - transform(value: any): any { - return `${value} ${LOCALIZED_CURRENCY[this.lang]}`; + transform(value: number | string | null, fixedDigits: boolean = false): string | null { + if (value == null || isNaN(Number(value))) { + return null; + } + + const formattedValue = fixedDigits ? Number(value).toFixed(2) : Math.round(Number(value) * 100) / 100; + return `${formattedValue} ${LOCALIZED_CURRENCY[this.lang]}`; } ngOnDestroy() { - this.destroy$.next(true); - this.destroy$.unsubscribe(); + this.destroy$.next(); + this.destroy$.complete(); } } diff --git a/src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.html b/src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.html index 35cbdb748d..6c89c27fd1 100644 --- a/src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.html +++ b/src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.html @@ -31,7 +31,7 @@
{{ 'order-details.title-without-
  • {{ bag.capacity | volume }} - {{ bag.price | localizedCurrency }} + {{ bag.price | localizedCurrency: true }}
    - {{ getBagQuantity(bag.id) * bag.price | localizedCurrency }} + {{ getBagQuantity(bag.id) * bag.price | localizedCurrency: true }}
  • @@ -66,7 +66,7 @@
    {{ 'order-details.title-without-

    {{ 'order-details.order-amount' | translate }} - {{ orderSum | localizedCurrency }} + {{ orderSum | localizedCurrency: true }}

    @@ -84,7 +84,7 @@

    {{ 'order-details.title-without-

    {{ 'order-details.amount-due' | translate }} - {{ finalSum | localizedCurrency }} + {{ finalSum | localizedCurrency: true }}