mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
feat(nestjs): migrate to NestJS
This commit is contained in:
62
packages/server/src/modules/Items/Item.transformer.ts
Normal file
62
packages/server/src/modules/Items/Item.transformer.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { Transformer } from '../Transformer/Transformer';
|
||||
import { Item } from './models/Item';
|
||||
// import { GetItemWarehouseTransformer } from '@/services/Warehouses/Items/GettItemWarehouseTransformer';
|
||||
|
||||
export class ItemTransformer extends Transformer {
|
||||
/**
|
||||
* Include these attributes to sale invoice object.
|
||||
* @returns {Array}
|
||||
*/
|
||||
public includeAttributes = (): string[] => {
|
||||
return [
|
||||
'typeFormatted',
|
||||
'sellPriceFormatted',
|
||||
'costPriceFormatted',
|
||||
'itemWarehouses',
|
||||
];
|
||||
};
|
||||
|
||||
/**
|
||||
* Formatted item type.
|
||||
* @param {IItem} item
|
||||
* @returns {string}
|
||||
*/
|
||||
public typeFormatted(item: Item): string {
|
||||
return this.context.i18n.t(`item.field.type.${item.type}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatted sell price.
|
||||
* @param item
|
||||
* @returns {string}
|
||||
*/
|
||||
public sellPriceFormatted(item: Item): string {
|
||||
return this.formatNumber(item.sellPrice, {
|
||||
currencyCode: this.context.organization.baseCurrency,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatted cost price.
|
||||
* @param item
|
||||
* @returns {string}
|
||||
*/
|
||||
public costPriceFormatted(item: Item): string {
|
||||
return this.formatNumber(item.costPrice, {
|
||||
currencyCode: this.context.organization.baseCurrency,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Associate the item warehouses quantity.
|
||||
* @param item
|
||||
* @returns
|
||||
*/
|
||||
// public itemWarehouses = (item) => {
|
||||
// return this.item(
|
||||
// item.itemWarehouses,
|
||||
// new GetItemWarehouseTransformer(),
|
||||
// {},
|
||||
// );
|
||||
// };
|
||||
}
|
||||
Reference in New Issue
Block a user