From c908dc9c613e9377c0a804fcbd6ae124fc41adf6 Mon Sep 17 00:00:00 2001 From: "a.bouhuolia" Date: Mon, 23 Aug 2021 17:04:12 +0200 Subject: [PATCH] fix: add graphed models to item specific. --- server/src/services/Items/ItemsService.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/server/src/services/Items/ItemsService.ts b/server/src/services/Items/ItemsService.ts index 86aa4894c..b65f88a6f 100644 --- a/server/src/services/Items/ItemsService.ts +++ b/server/src/services/Items/ItemsService.ts @@ -513,12 +513,10 @@ export default class ItemsService implements IItemsService { const item = await Item.query() .findById(itemId) - .withGraphFetched( - 'costAccount', - 'sellAccount', - 'inventoryAccount', - 'category' - ); + .withGraphFetched('sellAccount') + .withGraphFetched('inventoryAccount') + .withGraphFetched('category') + .withGraphFetched('costAccount'); if (!item) { throw new ServiceError(ERRORS.NOT_FOUND); @@ -664,7 +662,7 @@ export default class ItemsService implements IItemsService { }); return { - ...item, + ...item.toObject ? item.toObject() : item, sellPriceFormatted: formatNumber(item.sellPrice, { currencyCode }), costPriceFormatted: formatNumber(item.costPrice, { currencyCode }), };