Adding discount as an amount #kbcqjv

This commit is contained in:
Burak Çakırel
2021-08-13 13:24:08 +01:00
parent 8d87832481
commit 538e116fb2
2 changed files with 12 additions and 12 deletions

View File

@ -70,6 +70,8 @@ const app = new Vue({
},
mounted() {
this.form.discount_type = 'percentage';
if ((document.getElementById('items') != null) && (document.getElementById('items').rows)) {
this.colspan = document.getElementById("items").rows[0].cells.length - 1;
}
@ -117,9 +119,16 @@ const app = new Vue({
if (item.discount) {
if (item.discount_type === 'percentage') {
if (item.discount > 100) {
item.discount = 100;
}
line_discount_amount = item.total * (item.discount / 100);
} else {
line_discount_amount = item.discount;
if (parseInt(item.discount) > item.price) {
item.discount = item.price;
}
line_discount_amount = parseFloat(item.discount);
}
item.discount_amount = line_discount_amount
@ -130,16 +139,6 @@ const app = new Vue({
let item_discounted_total = item.total;
if (global_discount) {
if (this.form.discount_type === 'percentage') {
item_discounted_total = item.total - (item.total * (global_discount / 100));
} else {
item_discounted_total = item.total - global_discount;
}
item_discount = global_discount;
}
// item tax calculate.
if (item.tax_ids) {
let inclusives = [];
@ -399,6 +398,7 @@ const app = new Vue({
},
onAddLineDiscount(item_index) {
this.items[item_index].discount_type = 'percentage';
this.items[item_index].add_discount = true;
},