Merge branch 'master' into invoice_template
This commit is contained in:
39
resources/assets/js/views/common/documents.js
vendored
39
resources/assets/js/views/common/documents.js
vendored
@ -162,10 +162,17 @@ const app = new Vue({
|
||||
sub_total += item.total;
|
||||
grand_total += item.grand_total;
|
||||
|
||||
let item_tax_ids = [];
|
||||
|
||||
item.tax_ids.forEach(function(item_tax, item_tax_index) {
|
||||
item_tax_ids.push(item_tax.id);
|
||||
});
|
||||
|
||||
this.form.items[index].name = item.name;
|
||||
this.form.items[index].description = item.description;
|
||||
this.form.items[index].quantity = item.quantity;
|
||||
this.form.items[index].price = item.price;
|
||||
this.form.items[index].tax_ids = item_tax_ids;
|
||||
this.form.items[index].discount = item.discount;
|
||||
this.form.items[index].discount_type = item.discount_type;
|
||||
this.form.items[index].total = item.total;
|
||||
@ -262,6 +269,7 @@ const app = new Vue({
|
||||
|
||||
if (inclusives.length) {
|
||||
inclusives.forEach(function(inclusive) {
|
||||
item.tax_ids[inclusive.tax_index].name = inclusive.tax_name;
|
||||
item.tax_ids[inclusive.tax_index].price = item.grand_total - (item.grand_total / (1 + inclusive.tax_rate / 100));
|
||||
|
||||
inclusive_tax_total += item.tax_ids[inclusive.tax_index].price;
|
||||
@ -274,6 +282,7 @@ const app = new Vue({
|
||||
|
||||
if (fixed.length) {
|
||||
fixed.forEach(function(fixed) {
|
||||
item.tax_ids[fixed.tax_index].name = fixed.tax_name;
|
||||
item.tax_ids[fixed.tax_index].price = fixed.tax_rate * item.quantity;
|
||||
|
||||
total_tax_amount += item.tax_ids[fixed.tax_index].price;
|
||||
@ -290,6 +299,7 @@ const app = new Vue({
|
||||
|
||||
if (normal.length) {
|
||||
normal.forEach(function(normal) {
|
||||
item.tax_ids[normal.tax_index].name = normal.tax_name;
|
||||
item.tax_ids[normal.tax_index].price = price_for_tax * (normal.tax_rate / 100);
|
||||
|
||||
total_tax_amount += item.tax_ids[normal.tax_index].price;
|
||||
@ -300,6 +310,7 @@ const app = new Vue({
|
||||
|
||||
if (withholding.length) {
|
||||
withholding.forEach(function(withholding) {
|
||||
item.tax_ids[withholding.tax_index].name = withholding.tax_name;
|
||||
item.tax_ids[withholding.tax_index].price = -(price_for_tax * (withholding.tax_rate / 100));
|
||||
|
||||
total_tax_amount += item.tax_ids[withholding.tax_index].price;
|
||||
@ -312,6 +323,7 @@ const app = new Vue({
|
||||
|
||||
if (compounds.length) {
|
||||
compounds.forEach(function(compound) {
|
||||
item.tax_ids[compound.tax_index].name = compound.tax_name;
|
||||
item.tax_ids[compound.tax_index].price = (item.grand_total / 100) * compound.tax_rate;
|
||||
|
||||
totals_taxes = this.calculateTotalsTax(totals_taxes, compound.tax_id, compound.tax_name, item.tax_ids[compound.tax_index].price);
|
||||
@ -448,6 +460,7 @@ const app = new Vue({
|
||||
},
|
||||
|
||||
onSelectedTax(item_index) {
|
||||
|
||||
if (! this.tax_id) {
|
||||
return;
|
||||
}
|
||||
@ -476,6 +489,7 @@ const app = new Vue({
|
||||
}
|
||||
|
||||
this.tax_id = '';
|
||||
this.items[item_index].add_tax = false;
|
||||
|
||||
this.onCalculateTotal();
|
||||
},
|
||||
@ -954,6 +968,7 @@ const app = new Vue({
|
||||
|
||||
form_html.querySelectorAll('[type="submit"]').forEach((submit) => {
|
||||
submit.addEventListener('click', () => {
|
||||
this.minor_form_loading = false;
|
||||
window.onbeforeunload = null;
|
||||
});
|
||||
});
|
||||
@ -968,9 +983,33 @@ const app = new Vue({
|
||||
},
|
||||
|
||||
onSubmitViaSendEmail() {
|
||||
let type_submit_icon = document.querySelector('[type="submit"]').querySelector('i');
|
||||
let type_submit_span = document.querySelector('[type="submit"]').querySelector('span');
|
||||
|
||||
this.form['senddocument'] = true;
|
||||
|
||||
this.minor_form_loading = true;
|
||||
|
||||
if (this.form.loading) {
|
||||
type_submit_icon.classList.add('hidden');
|
||||
type_submit_span.classList.add('opacity-100');
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
if (type_submit_icon && type_submit_span) {
|
||||
type_submit_icon.classList.remove('hidden');
|
||||
type_submit_span.classList.remove('opacity-100');
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
this.onSubmit();
|
||||
|
||||
setTimeout(() => {
|
||||
if (Object.keys(this.form.errors.errors.length > 0)) {
|
||||
this.minor_form_loading = false;
|
||||
return;
|
||||
}
|
||||
}, 200);
|
||||
},
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user