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;
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
(async () => {
|
||||
const appliedPricingRuleCount = sinvDoc?.items?.filter(
|
||||
(val) => val.isFreeItem
|
||||
).length;
|
||||
|
||||
setTimeout(() => {
|
||||
(async () => {
|
||||
if (appliedPricingRuleCount !== applicablePricingRuleNames?.length) {
|
||||
await sinvDoc.appendPricingRuleDetail(applicablePricingRuleNames);
|
||||
await sinvDoc.applyProductDiscount();
|
||||
|
@ -377,15 +377,15 @@ export default defineComponent({
|
||||
const pricingRule =
|
||||
(await this.row.parentdoc?.getPricingRule()) as ApplicablePricingRules[];
|
||||
|
||||
let appliedPricingRuleCount: number;
|
||||
setTimeout(async () => {
|
||||
let appliedPricingRuleCount =
|
||||
this.row.parentdoc?.pricingRuleDetail?.length;
|
||||
|
||||
if (appliedPricingRuleCount !== pricingRule?.length) {
|
||||
appliedPricingRuleCount = pricingRule?.length;
|
||||
await this.row.parentdoc?.appendPricingRuleDetail(pricingRule);
|
||||
|
||||
await this.row.parentdoc?.appendPricingRuleDetail(pricingRule);
|
||||
await this.row.parentdoc?.applyProductDiscount();
|
||||
}
|
||||
}, 1);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
@ -1085,11 +1085,11 @@ export default defineComponent({
|
||||
return;
|
||||
}
|
||||
|
||||
setTimeout(async () => {
|
||||
const appliedPricingRuleCount = this.sinvDoc?.items?.filter(
|
||||
(val) => val.isFreeItem
|
||||
).length;
|
||||
|
||||
setTimeout(async () => {
|
||||
if (appliedPricingRuleCount !== hasPricingRules?.length) {
|
||||
await this.sinvDoc.appendPricingRuleDetail(hasPricingRules);
|
||||
await this.sinvDoc.applyProductDiscount();
|
||||
|
Loading…
Reference in New Issue
Block a user