Adding discount as an amount #kbcqjv
This commit is contained in:
22
resources/assets/js/views/common/documents.js
vendored
22
resources/assets/js/views/common/documents.js
vendored
@ -70,6 +70,8 @@ const app = new Vue({
|
|||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.form.discount_type = 'percentage';
|
||||||
|
|
||||||
if ((document.getElementById('items') != null) && (document.getElementById('items').rows)) {
|
if ((document.getElementById('items') != null) && (document.getElementById('items').rows)) {
|
||||||
this.colspan = document.getElementById("items").rows[0].cells.length - 1;
|
this.colspan = document.getElementById("items").rows[0].cells.length - 1;
|
||||||
}
|
}
|
||||||
@ -117,9 +119,16 @@ const app = new Vue({
|
|||||||
|
|
||||||
if (item.discount) {
|
if (item.discount) {
|
||||||
if (item.discount_type === 'percentage') {
|
if (item.discount_type === 'percentage') {
|
||||||
|
if (item.discount > 100) {
|
||||||
|
item.discount = 100;
|
||||||
|
}
|
||||||
|
|
||||||
line_discount_amount = item.total * (item.discount / 100);
|
line_discount_amount = item.total * (item.discount / 100);
|
||||||
} else {
|
} 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
|
item.discount_amount = line_discount_amount
|
||||||
@ -130,16 +139,6 @@ const app = new Vue({
|
|||||||
|
|
||||||
let item_discounted_total = item.total;
|
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.
|
// item tax calculate.
|
||||||
if (item.tax_ids) {
|
if (item.tax_ids) {
|
||||||
let inclusives = [];
|
let inclusives = [];
|
||||||
@ -399,6 +398,7 @@ const app = new Vue({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onAddLineDiscount(item_index) {
|
onAddLineDiscount(item_index) {
|
||||||
|
this.items[item_index].discount_type = 'percentage';
|
||||||
this.items[item_index].add_discount = true;
|
this.items[item_index].add_discount = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
<el-popover
|
<el-popover
|
||||||
popper-class="p-0 h-0"
|
popper-class="p-0 h-0"
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
width="300"
|
width="350"
|
||||||
v-model="discount">
|
v-model="discount">
|
||||||
<div class="card d-none" :class="[{'show' : discount}]">
|
<div class="card d-none" :class="[{'show' : discount}]">
|
||||||
<div class="discount card-body">
|
<div class="discount card-body">
|
||||||
|
Reference in New Issue
Block a user