mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
Enhancement: better detection of default currency code (#6020)
This commit is contained in:
parent
700af8caa2
commit
1eff4b306f
@ -56,4 +56,10 @@ describe('MonetaryComponent', () => {
|
|||||||
component.monetaryValue = 10.5
|
component.monetaryValue = 10.5
|
||||||
expect(component.value).toEqual('EUR10.50')
|
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')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
DEFAULT_CURRENCY_CODE,
|
|
||||||
ElementRef,
|
ElementRef,
|
||||||
forwardRef,
|
forwardRef,
|
||||||
Inject,
|
Inject,
|
||||||
|
LOCALE_ID,
|
||||||
ViewChild,
|
ViewChild,
|
||||||
} from '@angular/core'
|
} from '@angular/core'
|
||||||
import { NG_VALUE_ACCESSOR } from '@angular/forms'
|
import { NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||||
import { AbstractInputComponent } from '../abstract-input'
|
import { AbstractInputComponent } from '../abstract-input'
|
||||||
|
import { getLocaleCurrencyCode } from '@angular/common'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
providers: [
|
providers: [
|
||||||
@ -24,11 +25,12 @@ import { AbstractInputComponent } from '../abstract-input'
|
|||||||
export class MonetaryComponent extends AbstractInputComponent<string> {
|
export class MonetaryComponent extends AbstractInputComponent<string> {
|
||||||
@ViewChild('currencyField')
|
@ViewChild('currencyField')
|
||||||
currencyField: ElementRef
|
currencyField: ElementRef
|
||||||
|
defaultCurrencyCode: string
|
||||||
|
|
||||||
constructor(
|
constructor(@Inject(LOCALE_ID) currentLocale: string) {
|
||||||
@Inject(DEFAULT_CURRENCY_CODE) public defaultCurrencyCode: string
|
|
||||||
) {
|
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
this.defaultCurrencyCode = getLocaleCurrencyCode(currentLocale)
|
||||||
}
|
}
|
||||||
|
|
||||||
get currencyCode(): string {
|
get currencyCode(): string {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user