Merge branch 'akaunting:master' into master

This commit is contained in:
Burak Civan 2022-06-16 14:10:08 +03:00 committed by GitHub
commit 79f9703635
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 3 deletions

View File

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

View File

@ -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>