Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Enhancement: better detection of default currency code (#6020)

shamoon1eff4b306f57
diff --git a/src-ui/src/app/components/common/input/monetary/monetary.component.spec.ts b/src-ui/src/app/components/common/input/monetary/monetary.component.spec.ts
index 0a8608a1b..4106c01ec 100644
--- a/src-ui/src/app/components/common/input/monetary/monetary.component.spec.ts
+++ b/src-ui/src/app/components/common/input/monetary/monetary.component.spec.ts
@@ -56,4 +56,10 @@ describe('MonetaryComponent', () => {
component.monetaryValue = 10.5
expect(component.value).toEqual('EUR10.50')
})
+
+ it('should set the default currency code based on LOCALE_ID', () => {
+ expect(component.defaultCurrencyCode).toEqual('USD') // default
+ component = new MonetaryComponent('pt-BR')
+ expect(component.defaultCurrencyCode).toEqual('BRL')
+ })
})
diff --git a/src-ui/src/app/components/common/input/monetary/monetary.component.ts b/src-ui/src/app/components/common/input/monetary/monetary.component.ts
index a7957b4c3..ebfd9b6bf 100644
--- a/src-ui/src/app/components/common/input/monetary/monetary.component.ts
+++ b/src-ui/src/app/components/common/input/monetary/monetary.component.ts
@@ -1,13 +1,14 @@
import {
Component,
- DEFAULT_CURRENCY_CODE,
ElementRef,
forwardRef,
Inject,
+ LOCALE_ID,
ViewChild,
} from '@angular/core'
import { NG_VALUE_ACCESSOR } from '@angular/forms'
import { AbstractInputComponent } from '../abstract-input'
+import { getLocaleCurrencyCode } from '@angular/common'
@Component({
providers: [
@@ -24,11 +25,12 @@ import { AbstractInputComponent } from '../abstract-input'
export class MonetaryComponent extends AbstractInputComponent<string> {
@ViewChild('currencyField')
currencyField: ElementRef
+ defaultCurrencyCode: string
- constructor(
- @Inject(DEFAULT_CURRENCY_CODE) public defaultCurrencyCode: string
- ) {
+ constructor(@Inject(LOCALE_ID) currentLocale: string) {
super()
+
+ this.defaultCurrencyCode = getLocaleCurrencyCode(currentLocale)
}
get currencyCode(): string {