fix: add graphed models to item specific.

This commit is contained in:
a.bouhuolia
2021-08-23 17:04:12 +02:00
parent 0be9f591b0
commit c908dc9c61

View File

@@ -513,12 +513,10 @@ export default class ItemsService implements IItemsService {
const item = await Item.query() const item = await Item.query()
.findById(itemId) .findById(itemId)
.withGraphFetched( .withGraphFetched('sellAccount')
'costAccount', .withGraphFetched('inventoryAccount')
'sellAccount', .withGraphFetched('category')
'inventoryAccount', .withGraphFetched('costAccount');
'category'
);
if (!item) { if (!item) {
throw new ServiceError(ERRORS.NOT_FOUND); throw new ServiceError(ERRORS.NOT_FOUND);
@@ -664,7 +662,7 @@ export default class ItemsService implements IItemsService {
}); });
return { return {
...item, ...item.toObject ? item.toObject() : item,
sellPriceFormatted: formatNumber(item.sellPrice, { currencyCode }), sellPriceFormatted: formatNumber(item.sellPrice, { currencyCode }),
costPriceFormatted: formatNumber(item.costPrice, { currencyCode }), costPriceFormatted: formatNumber(item.costPrice, { currencyCode }),
}; };