From ca1ba58ac847c074586c0063629982361128ce04 Mon Sep 17 00:00:00 2001 From: AbleKSaju <126228406+AbleKSaju@users.noreply.github.com> Date: Wed, 29 Jan 2025 10:15:46 +0530 Subject: [PATCH] fix: include HSN code when adding an item in POS --- src/pages/POS/POS.vue | 47 +++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/src/pages/POS/POS.vue b/src/pages/POS/POS.vue index d1322db0..79d677d4 100644 --- a/src/pages/POS/POS.vue +++ b/src/pages/POS/POS.vue @@ -528,6 +528,12 @@ export default defineComponent({ invoiceItem.item === item.name && !invoiceItem.isFreeItem ) ?? []; + const itemsHsncode = (await this.fyo.getValue( + 'Item', + item?.name as string, + 'hsnCode' + )) as number; + if (item.hasBatch) { for (const invItem of existingItems) { const itemQty = invItem.quantity ?? 0; @@ -557,6 +563,7 @@ export default defineComponent({ await this.sinvDoc.append('items', { rate: item.rate as Money, item: item.name, + hsnCode: itemsHsncode, }); return; @@ -584,32 +591,32 @@ export default defineComponent({ return; } + await this.sinvDoc.append('items', { + rate: item.rate as Money, + item: item.name, + quantity: quantity ? quantity : 1, + hsnCode: itemsHsncode, + }); + + if (this.sinvDoc.priceList) { + let itemData = this.sinvDoc.items?.filter( + (val) => val.item == item.name + ) as SalesInvoiceItem[]; + + itemData[0].rate = await getItemRateFromPriceList( + itemData[0], + this.sinvDoc.priceList + ); + } + + await this.applyPricingRule(); + await this.sinvDoc.runFormulas(); } catch (error) { return showToast({ type: 'error', message: t`${error as string}`, }); } - - await this.sinvDoc.append('items', { - rate: item.rate as Money, - item: item.name, - quantity: quantity ? quantity : 1, - }); - - if (this.sinvDoc.priceList) { - let itemData = this.sinvDoc.items?.filter( - (val) => val.item == item.name - ) as SalesInvoiceItem[]; - - itemData[0].rate = await getItemRateFromPriceList( - itemData[0], - this.sinvDoc.priceList - ); - } - - await this.applyPricingRule(); - await this.sinvDoc.runFormulas(); }, async createTransaction(shouldPrint = false, isPay = false) { try {