diff --git a/src/components/POS/SelectedItemRow.vue b/src/components/POS/SelectedItemRow.vue index 84833ea8..45fde7f2 100644 --- a/src/components/POS/SelectedItemRow.vue +++ b/src/components/POS/SelectedItemRow.vue @@ -69,7 +69,7 @@ @@ -273,7 +273,7 @@ export default defineComponent({ props: { row: { type: SalesInvoiceItem, required: true }, }, - emits: ['removeItem', 'runSinvFormulas', 'setItemSerialNumbers'], + emits: ['runSinvFormulas', 'setItemSerialNumbers', 'addItem'], setup() { return { isDiscountingEnabled: inject('isDiscountingEnabled') as boolean, @@ -362,6 +362,28 @@ export default defineComponent({ this.row._applyFormula('transferQuantity'); this.$emit('runSinvFormulas'); }, + removeAddedItem(row: SalesInvoiceItem) { + this.row.parentdoc?.remove('items', row?.idx as number); + + if (!row.isFreeItem) { + this.updatePricingRuleItem(); + } + }, + async updatePricingRuleItem() { + const pricingRule = await this.row.parentdoc?.getPricingRule() as ApplicablePricingRules[]; + + setTimeout(() => { + const appliedPricingRuleCount = this.row.parentdoc?.items?.filter( + (val) => val.isFreeItem + ).length; + + if (appliedPricingRuleCount !== pricingRule?.length) { + this.row.parentdoc?.appendPricingRuleDetail(pricingRule); + + this.row.parentdoc?.applyProductDiscount(); + } + }, 1); + }, }, }); diff --git a/src/components/POS/SelectedItemTable.vue b/src/components/POS/SelectedItemTable.vue index 9c7ab31f..6822adfc 100644 --- a/src/components/POS/SelectedItemTable.vue +++ b/src/components/POS/SelectedItemTable.vue @@ -37,7 +37,6 @@ > @@ -138,9 +137,6 @@ export default defineComponent({ }, }, methods: { - removeItem(idx: number) { - this.sinvDoc.remove('items', idx); - }, async runSinvFormulas() { await this.sinvDoc.runFormulas(); },