Skip to content

Commit

Permalink
feat: pricing rule in pos
Browse files Browse the repository at this point in the history
  • Loading branch information
akshayitzme committed Mar 6, 2024
1 parent 4217a50 commit 5d6ab79
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/pages/POS/POS.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -410,6 +411,7 @@ export default defineComponent({
if (existingItems.length) {
existingItems[0].quantity = (existingItems[0].quantity as number) + 1;
await this.applyPricingRule();
return;
}
Expand Down Expand Up @@ -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,
},
Expand Down

0 comments on commit 5d6ab79

Please sign in to comment.