Document discount calculate issue fixed ( #31zyb44 )
This commit is contained in:
parent
9a00e07462
commit
326d2ae875
35
resources/assets/js/views/common/documents.js
vendored
35
resources/assets/js/views/common/documents.js
vendored
@ -68,7 +68,13 @@ const app = new Vue({
|
||||
dynamic_taxes: [],
|
||||
show_discount: false,
|
||||
show_discount_text: true,
|
||||
delete_discount: false
|
||||
delete_discount: false,
|
||||
regex_condition: [
|
||||
'..',
|
||||
'.,',
|
||||
',.',
|
||||
',,'
|
||||
],
|
||||
}
|
||||
},
|
||||
|
||||
@ -488,11 +494,14 @@ const app = new Vue({
|
||||
|
||||
onChangeDiscountType(type) {
|
||||
this.form.discount_type = type;
|
||||
|
||||
this.onAddTotalDiscount();
|
||||
this.onCalculateTotal();
|
||||
},
|
||||
|
||||
onChangeLineDiscountType(item_index, type) {
|
||||
this.items[item_index].discount_type = type;
|
||||
|
||||
this.onCalculateTotal();
|
||||
},
|
||||
|
||||
@ -1062,5 +1071,27 @@ const app = new Vue({
|
||||
}
|
||||
|
||||
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(',', '.');
|
||||
},
|
||||
},
|
||||
});
|
||||
|
@ -106,7 +106,7 @@
|
||||
</button>
|
||||
</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>
|
||||
</td>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user