mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-17 10:13:56 -05:00
Fix: allow 0 in monetary field (#6658)
This commit is contained in:
parent
9b3a29cddd
commit
22c8d8ef2a
src-ui/src/app/components/common/input/monetary
@ -74,4 +74,13 @@ describe('MonetaryComponent', () => {
|
|||||||
expect(component.currency).toEqual('USD')
|
expect(component.currency).toEqual('USD')
|
||||||
expect(component.monetaryValue).toEqual('')
|
expect(component.monetaryValue).toEqual('')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should handle zero values', () => {
|
||||||
|
component.writeValue('USD0.00')
|
||||||
|
expect(component.currency).toEqual('USD')
|
||||||
|
expect(component.monetaryValue).toEqual('0.00')
|
||||||
|
component.monetaryValue = '0'
|
||||||
|
component.monetaryValueChange()
|
||||||
|
expect(component.value).toEqual('USD0.00')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -22,8 +22,9 @@ export class MonetaryComponent extends AbstractInputComponent<string> {
|
|||||||
public get monetaryValue(): string {
|
public get monetaryValue(): string {
|
||||||
return this._monetaryValue
|
return this._monetaryValue
|
||||||
}
|
}
|
||||||
public set monetaryValue(value: string) {
|
public set monetaryValue(value: any) {
|
||||||
if (value) this._monetaryValue = value
|
if (value || value?.toString() === '0')
|
||||||
|
this._monetaryValue = value.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultCurrencyCode: string
|
defaultCurrencyCode: string
|
||||||
@ -44,6 +45,9 @@ export class MonetaryComponent extends AbstractInputComponent<string> {
|
|||||||
|
|
||||||
public monetaryValueChange(fixed: boolean = false): void {
|
public monetaryValueChange(fixed: boolean = false): void {
|
||||||
this.monetaryValue = this.parseMonetaryValue(this.monetaryValue, fixed)
|
this.monetaryValue = this.parseMonetaryValue(this.monetaryValue, fixed)
|
||||||
|
if (this.monetaryValue === '0') {
|
||||||
|
this.monetaryValue = '0.00'
|
||||||
|
}
|
||||||
this.onChange(this.currency + this.monetaryValue)
|
this.onChange(this.currency + this.monetaryValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user