Document discount calculate issue fixed ( #31zyb44 )

This commit is contained in:
Cüneyt Şentürk 2022-06-16 12:37:15 +03:00
parent 9a00e07462
commit 326d2ae875
2 changed files with 34 additions and 3 deletions

View File

@ -68,7 +68,13 @@ const app = new Vue({
dynamic_taxes: [], dynamic_taxes: [],
show_discount: false, show_discount: false,
show_discount_text: true, show_discount_text: true,
delete_discount: false delete_discount: false,
regex_condition: [
'..',
'.,',
',.',
',,'
],
} }
}, },
@ -488,11 +494,14 @@ const app = new Vue({
onChangeDiscountType(type) { onChangeDiscountType(type) {
this.form.discount_type = type; this.form.discount_type = type;
this.onAddTotalDiscount();
this.onCalculateTotal(); this.onCalculateTotal();
}, },
onChangeLineDiscountType(item_index, type) { onChangeLineDiscountType(item_index, type) {
this.items[item_index].discount_type = type; this.items[item_index].discount_type = type;
this.onCalculateTotal(); this.onCalculateTotal();
}, },
@ -1062,5 +1071,27 @@ const app = new Vue({
} }
this.page_loaded = true; this.page_loaded = true;
} },
watch: {
'form.discount': function (newVal, oldVal) {
if (newVal != '' && newVal.search('^(?=.*?[0-9])[0-9.,]+$') !== 0) {
this.form.discount = oldVal;
this.form.discount = this.form.discount.replace(',', '.');
return;
}
for (let item of this.regex_condition) {
if (this.form.discount.includes(item)) {
const removeLastChar = newVal.length - 1;
const inputShown = newVal.slice(0, removeLastChar);
this.form.discount = inputShown;
}
}
this.form.discount = this.form.discount.replace(',', '.');
},
},
}); });

View File

@ -106,7 +106,7 @@
</button> </button>
</div> </div>
<x-form.group.number name="pre_discount" id="pre-discount" form-group-class="-mt-1" v-model="form.discount" @input="onAddTotalDiscount" /> <x-form.group.text name="pre_discount" id="pre-discount" form-group-class="-mt-1" v-model="form.discount" @input="onAddTotalDiscount" />
</div> </div>
</td> </td>