close #2213 Fixed: Document add new tax not calculate totals
This commit is contained in:
parent
31f2732ae4
commit
cef1ee1b42
122
resources/assets/js/views/common/documents.js
vendored
122
resources/assets/js/views/common/documents.js
vendored
@ -26,69 +26,71 @@ const app = new Vue({
|
|||||||
],
|
],
|
||||||
|
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
form: new Form('document'),
|
form: new Form('document'),
|
||||||
bulk_action: new BulkAction('documents'),
|
bulk_action: new BulkAction('documents'),
|
||||||
totals: {
|
totals: {
|
||||||
sub: 0,
|
sub: 0,
|
||||||
item_discount: '',
|
item_discount: '',
|
||||||
discount: '',
|
discount: '',
|
||||||
discount_text: false,
|
discount_text: false,
|
||||||
taxes: [],
|
taxes: [],
|
||||||
total: 0
|
total: 0
|
||||||
},
|
},
|
||||||
transaction: [],
|
transaction: [],
|
||||||
edit: {
|
edit: {
|
||||||
status: false,
|
status: false,
|
||||||
currency: false,
|
currency: false,
|
||||||
items: 0,
|
items: 0,
|
||||||
},
|
},
|
||||||
colspan: 6,
|
colspan: 6,
|
||||||
discount: false,
|
discount: false,
|
||||||
tax: false,
|
tax: false,
|
||||||
discounts: [],
|
discounts: [],
|
||||||
tax_id: [],
|
tax_id: [],
|
||||||
|
|
||||||
items: [],
|
items: [],
|
||||||
taxes: [],
|
taxes: [],
|
||||||
page_loaded: false,
|
page_loaded: false,
|
||||||
currencies: [],
|
currencies: [],
|
||||||
min_due_date: false,
|
min_due_date: false,
|
||||||
currency_symbol: {
|
currency_symbol: {
|
||||||
"name":"US Dollar",
|
"name":"US Dollar",
|
||||||
"code":"USD",
|
"code":"USD",
|
||||||
"rate":1,
|
"rate":1,
|
||||||
"precision":2,
|
"precision":2,
|
||||||
"symbol":"$",
|
"symbol":"$",
|
||||||
"symbol_first":1,
|
"symbol_first":1,
|
||||||
"decimal_mark":".",
|
"decimal_mark":".",
|
||||||
"thousands_separator":","
|
"thousands_separator":","
|
||||||
},
|
},
|
||||||
dropdown_visible: true
|
dropdown_visible: true,
|
||||||
}
|
dynamic_taxes: [],
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.edit.status) {
|
if (!this.edit.status) {
|
||||||
this.dropdown_visible = false;
|
this.dropdown_visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currency_symbol.rate = this.form.currency_rate;
|
this.currency_symbol.rate = this.form.currency_rate;
|
||||||
|
|
||||||
if (company_currency_code) {
|
if (company_currency_code) {
|
||||||
let default_currency_symbol = null;
|
let default_currency_symbol = null;
|
||||||
|
|
||||||
for (let symbol of this.currencies) {
|
for (let symbol of this.currencies) {
|
||||||
if(symbol.code == company_currency_code) {
|
if(symbol.code == company_currency_code) {
|
||||||
default_currency_symbol = symbol.symbol;
|
default_currency_symbol = symbol.symbol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.currency_symbol.symbol = default_currency_symbol;
|
|
||||||
}
|
this.currency_symbol.symbol = default_currency_symbol;
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -97,7 +99,7 @@ const app = new Vue({
|
|||||||
let global_discount = parseFloat(this.form.discount);
|
let global_discount = parseFloat(this.form.discount);
|
||||||
let discount_total = 0;
|
let discount_total = 0;
|
||||||
let line_item_discount_total = 0;
|
let line_item_discount_total = 0;
|
||||||
let taxes = document_taxes;
|
let taxes = this.dynamic_taxes;
|
||||||
let sub_total = 0;
|
let sub_total = 0;
|
||||||
let totals_taxes = [];
|
let totals_taxes = [];
|
||||||
let grand_total = 0;
|
let grand_total = 0;
|
||||||
@ -349,7 +351,7 @@ const app = new Vue({
|
|||||||
|
|
||||||
let selected_tax;
|
let selected_tax;
|
||||||
|
|
||||||
document_taxes.forEach(function(tax) {
|
this.dynamic_taxes.forEach(function(tax) {
|
||||||
if (tax.id == this.tax_id) {
|
if (tax.id == this.tax_id) {
|
||||||
selected_tax = tax;
|
selected_tax = tax;
|
||||||
}
|
}
|
||||||
@ -682,7 +684,7 @@ const app = new Vue({
|
|||||||
|
|
||||||
this.page_loaded = true;
|
this.page_loaded = true;
|
||||||
|
|
||||||
if (document_currencies) {
|
if (typeof document_currencies !== 'undefined' && document_currencies) {
|
||||||
this.currencies = document_currencies;
|
this.currencies = document_currencies;
|
||||||
|
|
||||||
this.currencies.forEach(function (currency, index) {
|
this.currencies.forEach(function (currency, index) {
|
||||||
@ -693,5 +695,9 @@ const app = new Vue({
|
|||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof document_taxes !== 'undefined' && document_taxes) {
|
||||||
|
this.dynamic_taxes = document_taxes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -215,11 +215,12 @@
|
|||||||
:placeholder="'{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}'"
|
:placeholder="'{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}'"
|
||||||
:name="'items.' + index + '.taxes.' + row_tax_index"
|
:name="'items.' + index + '.taxes.' + row_tax_index"
|
||||||
:options="{{ json_encode($taxes->pluck('title', 'id')) }}"
|
:options="{{ json_encode($taxes->pluck('title', 'id')) }}"
|
||||||
|
:dynamic-options="dynamic_taxes"
|
||||||
:disabled-options="form.items[index].tax_ids"
|
:disabled-options="form.items[index].tax_ids"
|
||||||
:value="row_tax.id"
|
:value="row_tax.id"
|
||||||
@interface="row_tax.id = $event"
|
@interface="row_tax.id = $event"
|
||||||
@change="onCalculateTotal()"
|
@change="onCalculateTotal()"
|
||||||
@new="taxes.push($event)"
|
@new="dynamic_taxes.push($event)"
|
||||||
:form-error="form.errors.get('items.' + index + '.taxes')"
|
:form-error="form.errors.get('items.' + index + '.taxes')"
|
||||||
:no-data-text="'{{ trans('general.no_data') }}'"
|
:no-data-text="'{{ trans('general.no_data') }}'"
|
||||||
:no-matching-data-text="'{{ trans('general.no_matching_data') }}'"
|
:no-matching-data-text="'{{ trans('general.no_matching_data') }}'"
|
||||||
@ -254,6 +255,7 @@
|
|||||||
:placeholder="'{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}'"
|
:placeholder="'{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}'"
|
||||||
:name="'items.' + index + '.taxes.999'"
|
:name="'items.' + index + '.taxes.999'"
|
||||||
:options="{{ json_encode($taxes->pluck('title', 'id')) }}"
|
:options="{{ json_encode($taxes->pluck('title', 'id')) }}"
|
||||||
|
:dynamic-options="dynamic_taxes"
|
||||||
:disabled-options="form.items[index].tax_ids"
|
:disabled-options="form.items[index].tax_ids"
|
||||||
:value="tax_id"
|
:value="tax_id"
|
||||||
:add-new="{{ json_encode([
|
:add-new="{{ json_encode([
|
||||||
@ -279,7 +281,7 @@
|
|||||||
])}}"
|
])}}"
|
||||||
@interface="tax_id = $event"
|
@interface="tax_id = $event"
|
||||||
@visible-change="onSelectedTax(index)"
|
@visible-change="onSelectedTax(index)"
|
||||||
@new="taxes.push($event)"
|
@new="dynamic_taxes.push($event)"
|
||||||
:form-error="form.errors.get('items.' + index + '.taxes')"
|
:form-error="form.errors.get('items.' + index + '.taxes')"
|
||||||
:no-data-text="'{{ trans('general.no_data') }}'"
|
:no-data-text="'{{ trans('general.no_data') }}'"
|
||||||
:no-matching-data-text="'{{ trans('general.no_matching_data') }}'"
|
:no-matching-data-text="'{{ trans('general.no_matching_data') }}'"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user