mirror of
https://github.com/frappe/books.git
synced 2025-03-12 06:02:22 +00:00
fix: remove free item when its pricing rule item is removed
This commit is contained in:
parent
6d88a6dbd3
commit
0d2108f8a8
@ -69,7 +69,7 @@
|
|||||||
<feather-icon
|
<feather-icon
|
||||||
name="trash"
|
name="trash"
|
||||||
class="w-4 text-xl text-red-500"
|
class="w-4 text-xl text-red-500"
|
||||||
@click="$emit('removeItem', row.idx)"
|
@click="removeAddedItem(row)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ export default defineComponent({
|
|||||||
props: {
|
props: {
|
||||||
row: { type: SalesInvoiceItem, required: true },
|
row: { type: SalesInvoiceItem, required: true },
|
||||||
},
|
},
|
||||||
emits: ['removeItem', 'runSinvFormulas', 'setItemSerialNumbers'],
|
emits: ['runSinvFormulas', 'setItemSerialNumbers', 'addItem'],
|
||||||
setup() {
|
setup() {
|
||||||
return {
|
return {
|
||||||
isDiscountingEnabled: inject('isDiscountingEnabled') as boolean,
|
isDiscountingEnabled: inject('isDiscountingEnabled') as boolean,
|
||||||
@ -362,6 +362,28 @@ export default defineComponent({
|
|||||||
this.row._applyFormula('transferQuantity');
|
this.row._applyFormula('transferQuantity');
|
||||||
this.$emit('runSinvFormulas');
|
this.$emit('runSinvFormulas');
|
||||||
},
|
},
|
||||||
|
removeAddedItem(row: SalesInvoiceItem) {
|
||||||
|
this.row.parentdoc?.remove('items', row?.idx as number);
|
||||||
|
|
||||||
|
if (!row.isFreeItem) {
|
||||||
|
this.updatePricingRuleItem();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async updatePricingRuleItem() {
|
||||||
|
const pricingRule = await this.row.parentdoc?.getPricingRule() as ApplicablePricingRules[];
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
const appliedPricingRuleCount = this.row.parentdoc?.items?.filter(
|
||||||
|
(val) => val.isFreeItem
|
||||||
|
).length;
|
||||||
|
|
||||||
|
if (appliedPricingRuleCount !== pricingRule?.length) {
|
||||||
|
this.row.parentdoc?.appendPricingRuleDetail(pricingRule);
|
||||||
|
|
||||||
|
this.row.parentdoc?.applyProductDiscount();
|
||||||
|
}
|
||||||
|
}, 1);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -37,7 +37,6 @@
|
|||||||
>
|
>
|
||||||
<SelectedItemRow
|
<SelectedItemRow
|
||||||
:row="(row as SalesInvoiceItem)"
|
:row="(row as SalesInvoiceItem)"
|
||||||
@remove-item="removeItem"
|
|
||||||
@run-sinv-formulas="runSinvFormulas"
|
@run-sinv-formulas="runSinvFormulas"
|
||||||
/>
|
/>
|
||||||
</Row>
|
</Row>
|
||||||
@ -138,9 +137,6 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
removeItem(idx: number) {
|
|
||||||
this.sinvDoc.remove('items', idx);
|
|
||||||
},
|
|
||||||
async runSinvFormulas() {
|
async runSinvFormulas() {
|
||||||
await this.sinvDoc.runFormulas();
|
await this.sinvDoc.runFormulas();
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user