fix(server): add formatted values to responses transformers

This commit is contained in:
Ahmed Bouhuolia
2023-12-04 08:21:06 +02:00
parent 0f39cfb3af
commit fb70c94465
12 changed files with 189 additions and 13 deletions

View File

@@ -1,6 +1,7 @@
import { Transformer } from '@/lib/Transformer/Transformer';
import { formatNumber } from 'utils';
import { SaleInvoiceTaxEntryTransformer } from './SaleInvoiceTaxEntryTransformer';
import { ItemEntryTransformer } from './ItemEntryTransformer';
export class SaleInvoiceTransformer extends Transformer {
/**
@@ -23,6 +24,7 @@ export class SaleInvoiceTransformer extends Transformer {
'totalFormatted',
'totalLocalFormatted',
'taxes',
'entries',
];
};
@@ -95,6 +97,7 @@ export class SaleInvoiceTransformer extends Transformer {
protected subtotalFormatted = (invoice): string => {
return formatNumber(invoice.subtotal, {
currencyCode: this.context.organization.baseCurrency,
money: false,
});
};
@@ -176,4 +179,15 @@ export class SaleInvoiceTransformer extends Transformer {
currencyCode: invoice.currencyCode,
});
};
/**
* Retrieves the entries of the sale invoice.
* @param {ISaleInvoice} invoice
* @returns {}
*/
protected entries = (invoice) => {
return this.item(invoice.entries, new ItemEntryTransformer(), {
currencyCode: invoice.currencyCode,
});
};
}