From 5d6ab790a868412b68714897e255a7d82ca89992 Mon Sep 17 00:00:00 2001 From: akshayitzme Date: Wed, 6 Mar 2024 15:56:14 +0530 Subject: [PATCH] feat: pricing rule in pos --- src/pages/POS/POS.vue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/pages/POS/POS.vue b/src/pages/POS/POS.vue index fc03e6d5e..64ab4ccb1 100644 --- a/src/pages/POS/POS.vue +++ b/src/pages/POS/POS.vue @@ -212,6 +212,7 @@ import { validateSinv, } from 'src/utils/pos'; import Barcode from 'src/components/Controls/Barcode.vue'; +import { getPricingRule } from 'models/helpers'; export default defineComponent({ name: 'POS', @@ -359,7 +360,7 @@ export default defineComponent({ async addItem(item: POSItem | Item | undefined) { // eslint-disable-next-line @typescript-eslint/no-floating-promises - this.sinvDoc.runFormulas(); + await this.sinvDoc.runFormulas(); if (!item) { return; @@ -410,6 +411,7 @@ export default defineComponent({ if (existingItems.length) { existingItems[0].quantity = (existingItems[0].quantity as number) + 1; + await this.applyPricingRule(); return; } @@ -557,6 +559,17 @@ export default defineComponent({ validateSinv(this.sinvDoc as SalesInvoice, this.itemQtyMap); await validateShipment(this.itemSerialNumbers); }, + async applyPricingRule() { + const hasPricingRules = await getPricingRule( + this.sinvDoc as SalesInvoice + ); + if (!hasPricingRules) { + return; + } + + await this.sinvDoc.appendPricingRuleDetail(hasPricingRules); + await this.sinvDoc.applyProductDiscount(); + }, getItem, },