refs #1421
This commit is contained in:
29
resources/assets/js/views/purchases/bills.js
vendored
29
resources/assets/js/views/purchases/bills.js
vendored
@ -69,7 +69,9 @@ const app = new Vue({
|
||||
|
||||
if (typeof bill_items !== 'undefined' && bill_items) {
|
||||
let items = [];
|
||||
let item_backup = this.form.item_backup[0];
|
||||
let currency_code = this.form.currency_code;
|
||||
|
||||
this.edit.status = true;
|
||||
|
||||
bill_items.forEach(function(item) {
|
||||
@ -119,18 +121,18 @@ const app = new Vue({
|
||||
onCalculateTotal() {
|
||||
let sub_total = 0;
|
||||
let discount_total = 0;
|
||||
let item_discount_total = 0;
|
||||
let line_item_discount_total = 0;
|
||||
let tax_total = 0;
|
||||
let grand_total = 0;
|
||||
let items = this.form.items;
|
||||
let discount_in_totals = this.form.discount;
|
||||
let discount = '';
|
||||
|
||||
if (items.length) {
|
||||
let index = 0;
|
||||
|
||||
// get all items.
|
||||
for (index = 0; index < items.length; index++) {
|
||||
let discount = 0;
|
||||
// get row item and set item variable.
|
||||
let item = items[index];
|
||||
|
||||
@ -138,6 +140,15 @@ const app = new Vue({
|
||||
let item_total = item.price * item.quantity;
|
||||
|
||||
// item discount calculate.
|
||||
let line_discount_amount = 0;
|
||||
|
||||
if (item.discount) {
|
||||
line_discount_amount = item_total * (item.discount / 100);
|
||||
|
||||
item_discounted_total = item_total -= line_discount_amount;
|
||||
discount = item.discount;
|
||||
}
|
||||
|
||||
let item_discounted_total = item_total;
|
||||
|
||||
if (discount_in_totals) {
|
||||
@ -145,14 +156,6 @@ const app = new Vue({
|
||||
discount = discount_in_totals;
|
||||
}
|
||||
|
||||
let discount_amount = 0;
|
||||
|
||||
if (item.discount) {
|
||||
discount_amount = item_total * (item.discount / 100);
|
||||
item_discounted_total = item_total - discount_amount;
|
||||
discount = item.discount;
|
||||
}
|
||||
|
||||
// item tax calculate.
|
||||
let item_tax_total = 0;
|
||||
|
||||
@ -220,7 +223,7 @@ const app = new Vue({
|
||||
}
|
||||
|
||||
// calculate sub, tax, discount all items.
|
||||
item_discount_total += discount_amount;
|
||||
line_item_discount_total += line_discount_amount;
|
||||
sub_total += item_total;
|
||||
tax_total += item_tax_total;
|
||||
}
|
||||
@ -229,9 +232,7 @@ const app = new Vue({
|
||||
// set global total variable.
|
||||
this.totals.sub = sub_total;
|
||||
this.totals.tax = tax_total;
|
||||
this.totals.item_discount = item_discount_total;
|
||||
|
||||
sub_total -= item_discount_total;
|
||||
this.totals.item_discount = line_item_discount_total;
|
||||
|
||||
// Apply discount to total
|
||||
if (discount_in_totals) {
|
||||
|
29
resources/assets/js/views/sales/invoices.js
vendored
29
resources/assets/js/views/sales/invoices.js
vendored
@ -69,7 +69,9 @@ const app = new Vue({
|
||||
|
||||
if (typeof invoice_items !== 'undefined' && invoice_items) {
|
||||
let items = [];
|
||||
let item_backup = this.form.item_backup[0];
|
||||
let currency_code = this.form.currency_code;
|
||||
|
||||
this.edit.status = true;
|
||||
|
||||
invoice_items.forEach(function(item) {
|
||||
@ -119,18 +121,18 @@ const app = new Vue({
|
||||
onCalculateTotal() {
|
||||
let sub_total = 0;
|
||||
let discount_total = 0;
|
||||
let item_discount_total = 0;
|
||||
let line_item_discount_total = 0;
|
||||
let tax_total = 0;
|
||||
let grand_total = 0;
|
||||
let items = this.form.items;
|
||||
let discount_in_totals = this.form.discount;
|
||||
let discount = '';
|
||||
|
||||
if (items.length) {
|
||||
let index = 0;
|
||||
|
||||
// get all items.
|
||||
for (index = 0; index < items.length; index++) {
|
||||
let discount = 0;
|
||||
// get row item and set item variable.
|
||||
let item = items[index];
|
||||
|
||||
@ -138,6 +140,15 @@ const app = new Vue({
|
||||
let item_total = item.price * item.quantity;
|
||||
|
||||
// item discount calculate.
|
||||
let line_discount_amount = 0;
|
||||
|
||||
if (item.discount) {
|
||||
line_discount_amount = item_total * (item.discount / 100);
|
||||
|
||||
item_discounted_total = item_total -= line_discount_amount;
|
||||
discount = item.discount;
|
||||
}
|
||||
|
||||
let item_discounted_total = item_total;
|
||||
|
||||
if (discount_in_totals) {
|
||||
@ -145,14 +156,6 @@ const app = new Vue({
|
||||
discount = discount_in_totals;
|
||||
}
|
||||
|
||||
let discount_amount = 0;
|
||||
|
||||
if (item.discount) {
|
||||
discount_amount = item_total * (item.discount / 100);
|
||||
item_discounted_total = item_total - discount_amount;
|
||||
discount = item.discount;
|
||||
}
|
||||
|
||||
// item tax calculate.
|
||||
let item_tax_total = 0;
|
||||
|
||||
@ -220,7 +223,7 @@ const app = new Vue({
|
||||
}
|
||||
|
||||
// calculate sub, tax, discount all items.
|
||||
item_discount_total += discount_amount;
|
||||
line_item_discount_total += line_discount_amount;
|
||||
sub_total += item_total;
|
||||
tax_total += item_tax_total;
|
||||
}
|
||||
@ -229,9 +232,7 @@ const app = new Vue({
|
||||
// set global total variable.
|
||||
this.totals.sub = sub_total;
|
||||
this.totals.tax = tax_total;
|
||||
this.totals.item_discount = item_discount_total;
|
||||
|
||||
sub_total -= item_discount_total;
|
||||
this.totals.item_discount = line_item_discount_total;
|
||||
|
||||
// Apply discount to total
|
||||
if (discount_in_totals) {
|
||||
|
@ -106,5 +106,9 @@ const app = new Vue({
|
||||
.catch(error => {
|
||||
});
|
||||
},
|
||||
|
||||
onSubmit() {
|
||||
this.form.oldSubmit();
|
||||
},
|
||||
}
|
||||
});
|
||||
|
4
resources/assets/js/views/wizard/taxes.js
vendored
4
resources/assets/js/views/wizard/taxes.js
vendored
@ -78,5 +78,9 @@ const app = new Vue({
|
||||
|
||||
this.show = true;
|
||||
},
|
||||
|
||||
onSubmit() {
|
||||
this.form.oldSubmit();
|
||||
},
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user