Invoice/ bill item price row calculate..
This commit is contained in:
@ -10,7 +10,7 @@
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<money :name="name" :placeholder="placeholder" v-model="model" v-bind="money" class="form-control"></money>
|
||||
<money :name="name" @input="input" :placeholder="placeholder" v-bind="money" :value="value" :masked="masked" class="form-control"></money>
|
||||
</div>
|
||||
|
||||
<div class="invalid-feedback d-block" v-if="error" v-html="error"></div>
|
||||
@ -43,11 +43,7 @@ export default {
|
||||
default: null,
|
||||
description: "Selectbox attribute name"
|
||||
},
|
||||
value: {
|
||||
type: String,
|
||||
default: null,
|
||||
description: "Selectbox selected value"
|
||||
},
|
||||
value: 0,
|
||||
icon: {
|
||||
type: String,
|
||||
description: "Prepend icon (left)"
|
||||
@ -67,6 +63,11 @@ export default {
|
||||
default: null,
|
||||
description: "Selectbox disabled status"
|
||||
},
|
||||
required: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
description: "Selectbox disabled status"
|
||||
},
|
||||
readonly: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
@ -77,6 +78,19 @@ export default {
|
||||
default: false,
|
||||
description: "Selectbox disabled status"
|
||||
},
|
||||
dynamicCurrency: {
|
||||
type: Object,
|
||||
default: function () {
|
||||
return {
|
||||
decimal_mark: '.',
|
||||
thousands_separator: ',',
|
||||
symbol_first: 1,
|
||||
symbol: '$',
|
||||
precision: 2,
|
||||
};
|
||||
},
|
||||
description: "Dynamic currency"
|
||||
},
|
||||
currency: {
|
||||
type: Object,
|
||||
default: function () {
|
||||
@ -85,7 +99,7 @@ export default {
|
||||
thousands_separator: ',',
|
||||
symbol_first: 1,
|
||||
symbol: '$',
|
||||
precision: '2',
|
||||
precision: 2,
|
||||
};
|
||||
},
|
||||
description: "Default currency"
|
||||
@ -105,7 +119,7 @@ export default {
|
||||
thousands: this.currency.thousands_separator,
|
||||
prefix: (this.currency.symbol_first) ? this.currency.symbol : '',
|
||||
suffix: (!this.currency.symbol_first) ? this.currency.symbol : '',
|
||||
precision: this.currency.precision,
|
||||
precision: parseInt(this.currency.precision),
|
||||
masked: this.masked
|
||||
}
|
||||
}
|
||||
@ -117,16 +131,41 @@ export default {
|
||||
|
||||
methods: {
|
||||
change() {
|
||||
this.$emit('change', this.model);
|
||||
this.$emit('interface', this.model);
|
||||
//this.$emit('change', this.model);
|
||||
//this.$emit('interface', this.model);
|
||||
},
|
||||
input(event) {
|
||||
console.log(event);
|
||||
this.model = event;
|
||||
this.$emit('change', event);
|
||||
this.$emit('interface', event);
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
model: function (options) {
|
||||
|
||||
dynamicCurrency: function (currency) {
|
||||
this.money = {
|
||||
decimal: currency.decimal_mark,
|
||||
thousands: currency.thousands_separator,
|
||||
prefix: (currency.symbol_first) ? currency.symbol : '',
|
||||
suffix: (!currency.symbol_first) ? currency.symbol : '',
|
||||
precision: parseInt(currency.precision),
|
||||
masked: this.masked
|
||||
};
|
||||
},
|
||||
value: function (value) {
|
||||
this.model = value;
|
||||
},
|
||||
model: function (model) {
|
||||
this.$emit('change', this.model);
|
||||
this.$emit('interface', this.model);
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.text-right.input-price .v-money {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
@ -603,6 +603,9 @@ export default {
|
||||
options: function (options) {
|
||||
// update options
|
||||
this.selectOptions = options;
|
||||
},
|
||||
value: function (value) {
|
||||
this.real_model = value;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@ -705,6 +705,9 @@ export default {
|
||||
options: function (options) {
|
||||
// update options
|
||||
//this.selectOptions = options;
|
||||
},
|
||||
value: function (value) {
|
||||
this.real_model = value;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
3
resources/assets/js/plugins/bulk-action.js
vendored
3
resources/assets/js/plugins/bulk-action.js
vendored
@ -79,11 +79,8 @@ export default class BulkAction {
|
||||
'selected': this.selected
|
||||
})
|
||||
.then(response => {
|
||||
//this.loading = false;
|
||||
//this.modal = false;
|
||||
if (response.data.redirect) {
|
||||
window.location.reload(false);
|
||||
} else {
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
|
41
resources/assets/js/views/purchases/bills.js
vendored
41
resources/assets/js/views/purchases/bills.js
vendored
@ -50,7 +50,8 @@ const app = new Vue({
|
||||
},
|
||||
transaction: [],
|
||||
items: '',
|
||||
discount: false
|
||||
discount: false,
|
||||
currency: null,
|
||||
}
|
||||
},
|
||||
|
||||
@ -105,6 +106,7 @@ const app = new Vue({
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
this.currency = response.data;
|
||||
this.form.currency_code = response.data.currency_code;
|
||||
this.form.currency_rate = response.data.currency_rate;
|
||||
})
|
||||
@ -113,6 +115,37 @@ const app = new Vue({
|
||||
},
|
||||
|
||||
onCalculateTotal() {
|
||||
let sub_total = 0;
|
||||
let discount_total = 0;
|
||||
let tax_total = 0;
|
||||
let grand_total = 0;
|
||||
let items = this.form.items;
|
||||
let discount = this.form.discount;
|
||||
|
||||
if (items.length) {
|
||||
let index = 0;
|
||||
|
||||
for (index = 0; index < items.length; index++) {
|
||||
let item = items[index];
|
||||
|
||||
let item_sub_total = item.price * item.quantity;
|
||||
let item_tax_total = 0;
|
||||
let item_discount_total = (discount) ? item_sub_total - (item_sub_total * (discount / 100)) : 0;
|
||||
|
||||
items[index].total = item_sub_total;
|
||||
|
||||
sub_total += items[index].total;
|
||||
discount_total += item_discount_total;
|
||||
tax_total += item_tax_total;
|
||||
grand_total += sub_total + tax_total;
|
||||
}
|
||||
}
|
||||
|
||||
this.totals.sub = sub_total;
|
||||
this.totals.discount = discount_total;
|
||||
this.totals.tax = tax_total;
|
||||
this.totals.total = grand_total;
|
||||
/*
|
||||
axios.post(url + '/common/items/total', {
|
||||
items: this.form.items,
|
||||
discount: this.form.discount,
|
||||
@ -134,9 +167,10 @@ const app = new Vue({
|
||||
this.totals.discount_text = response.data.discount_text;
|
||||
})
|
||||
.catch(error => {
|
||||
});
|
||||
});*/
|
||||
},
|
||||
|
||||
// add bill item row
|
||||
onAddItem() {
|
||||
let row = [];
|
||||
|
||||
@ -182,9 +216,10 @@ const app = new Vue({
|
||||
this.form.items[index].price = (item.purchase_price).toFixed(2);
|
||||
this.form.items[index].quantity = 1;
|
||||
this.form.items[index].tax_id = [item.tax_id.toString()];
|
||||
this.form.items[index].total = item.total;
|
||||
this.form.items[index].total = (item.purchase_price).toFixed(2);
|
||||
},
|
||||
|
||||
// remove bill item row => row_id = index
|
||||
onDeleteItem(index) {
|
||||
this.form.items.splice(index, 1);
|
||||
},
|
||||
|
41
resources/assets/js/views/sales/invoices.js
vendored
41
resources/assets/js/views/sales/invoices.js
vendored
@ -50,7 +50,8 @@ const app = new Vue({
|
||||
},
|
||||
transaction: [],
|
||||
items: '',
|
||||
discount: false
|
||||
discount: false,
|
||||
currency: null,
|
||||
}
|
||||
},
|
||||
|
||||
@ -105,6 +106,7 @@ const app = new Vue({
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
this.currency = response.data;
|
||||
this.form.currency_code = response.data.currency_code;
|
||||
this.form.currency_rate = response.data.currency_rate;
|
||||
})
|
||||
@ -113,6 +115,37 @@ const app = new Vue({
|
||||
},
|
||||
|
||||
onCalculateTotal() {
|
||||
let sub_total = 0;
|
||||
let discount_total = 0;
|
||||
let tax_total = 0;
|
||||
let grand_total = 0;
|
||||
let items = this.form.items;
|
||||
let discount = this.form.discount;
|
||||
|
||||
if (items.length) {
|
||||
let index = 0;
|
||||
|
||||
for (index = 0; index < items.length; index++) {
|
||||
let item = items[index];
|
||||
|
||||
let item_sub_total = item.price * item.quantity;
|
||||
let item_tax_total = 0;
|
||||
let item_discount_total = (discount) ? item_sub_total - (item_sub_total * (discount / 100)) : 0;
|
||||
|
||||
items[index].total = item_sub_total;
|
||||
|
||||
sub_total += items[index].total;
|
||||
discount_total += item_discount_total;
|
||||
tax_total += item_tax_total;
|
||||
grand_total += sub_total + tax_total;
|
||||
}
|
||||
}
|
||||
|
||||
this.totals.sub = sub_total;
|
||||
this.totals.discount = discount_total;
|
||||
this.totals.tax = tax_total;
|
||||
this.totals.total = grand_total;
|
||||
/*
|
||||
axios.post(url + '/common/items/total', {
|
||||
items: this.form.items,
|
||||
discount: this.form.discount,
|
||||
@ -134,9 +167,10 @@ const app = new Vue({
|
||||
this.totals.discount_text = response.data.discount_text;
|
||||
})
|
||||
.catch(error => {
|
||||
});
|
||||
});*/
|
||||
},
|
||||
|
||||
// add invoice item row
|
||||
onAddItem() {
|
||||
let row = [];
|
||||
|
||||
@ -182,9 +216,10 @@ const app = new Vue({
|
||||
this.form.items[index].price = (item.purchase_price).toFixed(2);
|
||||
this.form.items[index].quantity = 1;
|
||||
this.form.items[index].tax_id = [item.tax_id.toString()];
|
||||
this.form.items[index].total = item.total;
|
||||
this.form.items[index].total = (item.purchase_price).toFixed(2);
|
||||
},
|
||||
|
||||
// remove invocie item row => row_id = index
|
||||
onDeleteItem(index) {
|
||||
this.form.items.splice(index, 1);
|
||||
},
|
||||
|
Reference in New Issue
Block a user