mirror of
https://github.com/frappe/books.git
synced 2025-02-02 20:18:26 +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
|
||||
name="trash"
|
||||
class="w-4 text-xl text-red-500"
|
||||
@click="$emit('removeItem', row.idx)"
|
||||
@click="removeAddedItem(row)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@ -273,7 +273,7 @@ export default defineComponent({
|
||||
props: {
|
||||
row: { type: SalesInvoiceItem, required: true },
|
||||
},
|
||||
emits: ['removeItem', 'runSinvFormulas', 'setItemSerialNumbers'],
|
||||
emits: ['runSinvFormulas', 'setItemSerialNumbers', 'addItem'],
|
||||
setup() {
|
||||
return {
|
||||
isDiscountingEnabled: inject('isDiscountingEnabled') as boolean,
|
||||
@ -362,6 +362,28 @@ export default defineComponent({
|
||||
this.row._applyFormula('transferQuantity');
|
||||
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>
|
||||
|
@ -37,7 +37,6 @@
|
||||
>
|
||||
<SelectedItemRow
|
||||
:row="(row as SalesInvoiceItem)"
|
||||
@remove-item="removeItem"
|
||||
@run-sinv-formulas="runSinvFormulas"
|
||||
/>
|
||||
</Row>
|
||||
@ -138,9 +137,6 @@ export default defineComponent({
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
removeItem(idx: number) {
|
||||
this.sinvDoc.remove('items', idx);
|
||||
},
|
||||
async runSinvFormulas() {
|
||||
await this.sinvDoc.runFormulas();
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user