diff --git a/README.md b/README.md index 0f6c64fe..7ed78e16 100644 --- a/README.md +++ b/README.md @@ -128,19 +128,19 @@ If you want to contribute code then you can fork this repo, make changes and rai ## Translation Contributors -| Language | Contributors | -| ------------------ | ---------------------------------------------------------------------------------- | -| French | [DeepL](https://www.deepl.com/), [mael-chouteau](https://github.com/mael-chouteau) | -| German | [DeepL](https://www.deepl.com/), [barredterra](https://github.com/barredterra) | -| Portuguese | [DeepL](https://www.deepl.com/) | -| Arabic | [taha2002](https://github.com/taha2002) | -| Catalan | Dídac E. Jiménez | -| Dutch | [FastAct](https://github.com/FastAct) | -| Spanish | [talmax1124](https://github.com/talmax1124) | -| Gujarati | [dhruvilxcode](https://github.com/dhruvilxcode) | -| Korean | [Isaac-Kwon](https://github.com/Isaac-Kwon) | -| Simplified Chinese | [wcxu21](https://github.com/wcxu21) | -| Swedish | [papplo](https://github.com/papplo) | +| Language | Contributors | +| ------------------ | ------------------------------------------------------------------------------------------------ | +| French | [DeepL](https://www.deepl.com/), [mael-chouteau](https://github.com/mael-chouteau) | +| German | [DeepL](https://www.deepl.com/), [barredterra](https://github.com/barredterra) | +| Portuguese | [DeepL](https://www.deepl.com/) | +| Arabic | [taha2002](https://github.com/taha2002) | +| Catalan | Dídac E. Jiménez | +| Dutch | [FastAct](https://github.com/FastAct) | +| Spanish | [talmax1124](https://github.com/talmax1124) | +| Gujarati | [dhruvilxcode](https://github.com/dhruvilxcode), [4silvertooth](https://github.com/4silvertooth) | +| Korean | [Isaac-Kwon](https://github.com/Isaac-Kwon) | +| Simplified Chinese | [wcxu21](https://github.com/wcxu21) | +| Swedish | [papplo](https://github.com/papplo) | ## License diff --git a/fyo/core/converter.ts b/fyo/core/converter.ts index 07521dae..7a3c2d55 100644 --- a/fyo/core/converter.ts +++ b/fyo/core/converter.ts @@ -295,7 +295,7 @@ function toDocAttachment(value: RawValue, field: Field): null | Attachment { function toRawCurrency(value: DocValue, fyo: Fyo, field: Field): string { if (isPesa(value)) { - return (value as Money).store; + return value.store; } if (getIsNullOrUndef(value)) { diff --git a/fyo/model/doc.ts b/fyo/model/doc.ts index d05f8628..8ca10616 100644 --- a/fyo/model/doc.ts +++ b/fyo/model/doc.ts @@ -543,7 +543,7 @@ export class Doc extends Observable { } if (isPesa(value)) { - value = (value as Money).copy(); + value = value.copy(); } if (value === null && this.schema.isSingle) { @@ -966,7 +966,8 @@ export class Doc extends Observable { throw err; } } - return value as Money; + + return value; }) .reduce((a, b) => a.add(b), this.fyo.pesa(0)); diff --git a/fyo/model/helpers.ts b/fyo/model/helpers.ts index 5670683e..006515ef 100644 --- a/fyo/model/helpers.ts +++ b/fyo/model/helpers.ts @@ -17,7 +17,7 @@ export function areDocValuesEqual( if (isPesa(dvOne)) { try { - return (dvOne as Money).eq(dvTwo as string | number); + return dvOne.eq(dvTwo as string | number); } catch { return false; } @@ -134,7 +134,7 @@ function shouldApplyFormulaPreSync( export function isDocValueTruthy(docValue: DocValue | Doc[]) { if (isPesa(docValue)) { - return !(docValue as Money).isZero(); + return !docValue.isZero(); } if (Array.isArray(docValue)) { diff --git a/fyo/utils/index.ts b/fyo/utils/index.ts index 4f2be722..c35bbff9 100644 --- a/fyo/utils/index.ts +++ b/fyo/utils/index.ts @@ -36,7 +36,7 @@ export function getDuplicates(array: unknown[]) { return duplicates; } -export function isPesa(value: unknown): boolean { +export function isPesa(value: unknown): value is Money { return value instanceof Money; } diff --git a/src/utils/index.ts b/src/utils/index.ts index 28054f32..8a373551 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -7,7 +7,7 @@ import { isPesa } from 'fyo/utils'; import { BaseError, DuplicateEntryError, - LinkValidationError + LinkValidationError, } from 'fyo/utils/errors'; import { Money } from 'pesa'; import { Field, FieldType, FieldTypeEnum } from 'schemas/types'; @@ -85,7 +85,7 @@ export function convertPesaValuesToFloat(obj: Record) { return; } - obj[key] = (value as Money).float; + obj[key] = value.float; }); } diff --git a/utils/index.ts b/utils/index.ts index ce31f9e4..8926657b 100644 --- a/utils/index.ts +++ b/utils/index.ts @@ -83,7 +83,7 @@ export function getListFromMap(map: Record): T[] { return Object.keys(map).map((n) => map[n]); } -export function getIsNullOrUndef(value: unknown): boolean { +export function getIsNullOrUndef(value: unknown): value is null | undefined { return value === null || value === undefined; }