From d84a531c96c4534e14ba12631b59625482510edb Mon Sep 17 00:00:00 2001 From: zaqoutabed Date: Wed, 7 Jun 2023 01:38:48 +0300 Subject: [PATCH] fix: getItemPrice logic --- models/helpers.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/models/helpers.ts b/models/helpers.ts index cf6d4082..00b297d9 100644 --- a/models/helpers.ts +++ b/models/helpers.ts @@ -363,18 +363,21 @@ export async function getItemPrice( return; } - const isUomDependent = await doc.fyo.getValue( + const { isUomDependent, enabled, buying, selling } = await doc.fyo.doc.getDoc( ModelNameEnum.PriceList, doc.priceList, - 'isUomDependent' ); + if(!enabled || doc.isSales && !selling || !doc.isSales && !buying){ + return + } + const itemPriceQuery = Object.values( await doc.fyo.db.getAll(ModelNameEnum.ItemPrice, { filters: { enabled: true, item: doc.item, - ...(doc.isSales ? { selling: true } : { buying: true }), + // ...(doc.isSales ? { selling: true } : { buying: true }), ...(doc.batch ? { batch: doc.batch as string } : { batch: null }), }, fields: ['name', 'unit', 'party', 'batch', 'validFrom', 'validUpto'],