mirror of
https://github.com/frappe/books.git
synced 2024-11-09 23:30:56 +00:00
feat: pricing rule in pos
This commit is contained in:
parent
a455aeb3ce
commit
427b8260e0
@ -217,6 +217,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',
|
||||
@ -364,7 +365,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;
|
||||
@ -415,6 +416,7 @@ export default defineComponent({
|
||||
|
||||
if (existingItems.length) {
|
||||
existingItems[0].quantity = (existingItems[0].quantity as number) + 1;
|
||||
await this.applyPricingRule();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -562,6 +564,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,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user