2
0
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:
AbleKSaju 2024-10-22 15:58:26 +05:30
parent 83b8ed0c6e
commit 86b21c50e2
3 changed files with 16 additions and 16 deletions

View File

@ -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();

View File

@ -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);
},
},
});

View File

@ -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();