mirror of
https://github.com/frappe/books.git
synced 2025-01-03 07:12:21 +00:00
chore: refactored pricing rule logic
This commit is contained in:
parent
83b8ed0c6e
commit
86b21c50e2
@ -1199,12 +1199,12 @@ export async function updatePricingRule(sinvDoc: SalesInvoice) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const appliedPricingRuleCount = sinvDoc?.items?.filter(
|
||||||
|
(val) => val.isFreeItem
|
||||||
|
).length;
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
const appliedPricingRuleCount = sinvDoc?.items?.filter(
|
|
||||||
(val) => val.isFreeItem
|
|
||||||
).length;
|
|
||||||
|
|
||||||
if (appliedPricingRuleCount !== applicablePricingRuleNames?.length) {
|
if (appliedPricingRuleCount !== applicablePricingRuleNames?.length) {
|
||||||
await sinvDoc.appendPricingRuleDetail(applicablePricingRuleNames);
|
await sinvDoc.appendPricingRuleDetail(applicablePricingRuleNames);
|
||||||
await sinvDoc.applyProductDiscount();
|
await sinvDoc.applyProductDiscount();
|
||||||
|
@ -377,15 +377,15 @@ export default defineComponent({
|
|||||||
const pricingRule =
|
const pricingRule =
|
||||||
(await this.row.parentdoc?.getPricingRule()) as ApplicablePricingRules[];
|
(await this.row.parentdoc?.getPricingRule()) as ApplicablePricingRules[];
|
||||||
|
|
||||||
let appliedPricingRuleCount: number;
|
let appliedPricingRuleCount =
|
||||||
setTimeout(async () => {
|
this.row.parentdoc?.pricingRuleDetail?.length;
|
||||||
if (appliedPricingRuleCount !== pricingRule?.length) {
|
|
||||||
appliedPricingRuleCount = pricingRule?.length;
|
|
||||||
await this.row.parentdoc?.appendPricingRuleDetail(pricingRule);
|
|
||||||
|
|
||||||
await this.row.parentdoc?.applyProductDiscount();
|
if (appliedPricingRuleCount !== pricingRule?.length) {
|
||||||
}
|
appliedPricingRuleCount = pricingRule?.length;
|
||||||
}, 1);
|
|
||||||
|
await this.row.parentdoc?.appendPricingRuleDetail(pricingRule);
|
||||||
|
await this.row.parentdoc?.applyProductDiscount();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -1085,11 +1085,11 @@ export default defineComponent({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(async () => {
|
const appliedPricingRuleCount = this.sinvDoc?.items?.filter(
|
||||||
const appliedPricingRuleCount = this.sinvDoc?.items?.filter(
|
(val) => val.isFreeItem
|
||||||
(val) => val.isFreeItem
|
).length;
|
||||||
).length;
|
|
||||||
|
|
||||||
|
setTimeout(async () => {
|
||||||
if (appliedPricingRuleCount !== hasPricingRules?.length) {
|
if (appliedPricingRuleCount !== hasPricingRules?.length) {
|
||||||
await this.sinvDoc.appendPricingRuleDetail(hasPricingRules);
|
await this.sinvDoc.appendPricingRuleDetail(hasPricingRules);
|
||||||
await this.sinvDoc.applyProductDiscount();
|
await this.sinvDoc.applyProductDiscount();
|
||||||
|
Loading…
Reference in New Issue
Block a user