Invoice/ bill item price row calculate..

This commit is contained in:
Cüneyt Şentürk 2020-02-10 00:24:18 +03:00
parent 1271a23755
commit a2cdc2c3d9
13 changed files with 259 additions and 78 deletions

View File

@ -10,7 +10,7 @@
</span> </span>
</div> </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>
<div class="invalid-feedback d-block" v-if="error" v-html="error"></div> <div class="invalid-feedback d-block" v-if="error" v-html="error"></div>
@ -43,11 +43,7 @@ export default {
default: null, default: null,
description: "Selectbox attribute name" description: "Selectbox attribute name"
}, },
value: { value: 0,
type: String,
default: null,
description: "Selectbox selected value"
},
icon: { icon: {
type: String, type: String,
description: "Prepend icon (left)" description: "Prepend icon (left)"
@ -67,6 +63,11 @@ export default {
default: null, default: null,
description: "Selectbox disabled status" description: "Selectbox disabled status"
}, },
required: {
type: Boolean,
default: false,
description: "Selectbox disabled status"
},
readonly: { readonly: {
type: Boolean, type: Boolean,
default: false, default: false,
@ -77,6 +78,19 @@ export default {
default: false, default: false,
description: "Selectbox disabled status" description: "Selectbox disabled status"
}, },
dynamicCurrency: {
type: Object,
default: function () {
return {
decimal_mark: '.',
thousands_separator: ',',
symbol_first: 1,
symbol: '$',
precision: 2,
};
},
description: "Dynamic currency"
},
currency: { currency: {
type: Object, type: Object,
default: function () { default: function () {
@ -85,7 +99,7 @@ export default {
thousands_separator: ',', thousands_separator: ',',
symbol_first: 1, symbol_first: 1,
symbol: '$', symbol: '$',
precision: '2', precision: 2,
}; };
}, },
description: "Default currency" description: "Default currency"
@ -105,7 +119,7 @@ export default {
thousands: this.currency.thousands_separator, thousands: this.currency.thousands_separator,
prefix: (this.currency.symbol_first) ? this.currency.symbol : '', prefix: (this.currency.symbol_first) ? this.currency.symbol : '',
suffix: (!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 masked: this.masked
} }
} }
@ -117,16 +131,41 @@ export default {
methods: { methods: {
change() { change() {
this.$emit('change', this.model); //this.$emit('change', this.model);
this.$emit('interface', this.model); //this.$emit('interface', this.model);
}, },
input(event) {
console.log(event);
this.model = event;
this.$emit('change', event);
this.$emit('interface', event);
}
}, },
watch: { 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); this.$emit('interface', this.model);
} }
}, },
} }
</script> </script>
<style scoped>
.text-right.input-price .v-money {
text-align: right;
}
</style>

View File

@ -603,6 +603,9 @@ export default {
options: function (options) { options: function (options) {
// update options // update options
this.selectOptions = options; this.selectOptions = options;
},
value: function (value) {
this.real_model = value;
} }
}, },
} }

View File

@ -705,6 +705,9 @@ export default {
options: function (options) { options: function (options) {
// update options // update options
//this.selectOptions = options; //this.selectOptions = options;
},
value: function (value) {
this.real_model = value;
} }
}, },
} }

View File

@ -79,11 +79,8 @@ export default class BulkAction {
'selected': this.selected 'selected': this.selected
}) })
.then(response => { .then(response => {
//this.loading = false;
//this.modal = false;
if (response.data.redirect) { if (response.data.redirect) {
window.location.reload(false); window.location.reload(false);
} else {
} }
}) })
.catch(error => { .catch(error => {

View File

@ -50,7 +50,8 @@ const app = new Vue({
}, },
transaction: [], transaction: [],
items: '', items: '',
discount: false discount: false,
currency: null,
} }
}, },
@ -105,6 +106,7 @@ const app = new Vue({
} }
}) })
.then(response => { .then(response => {
this.currency = response.data;
this.form.currency_code = response.data.currency_code; this.form.currency_code = response.data.currency_code;
this.form.currency_rate = response.data.currency_rate; this.form.currency_rate = response.data.currency_rate;
}) })
@ -113,6 +115,37 @@ const app = new Vue({
}, },
onCalculateTotal() { 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', { axios.post(url + '/common/items/total', {
items: this.form.items, items: this.form.items,
discount: this.form.discount, discount: this.form.discount,
@ -134,9 +167,10 @@ const app = new Vue({
this.totals.discount_text = response.data.discount_text; this.totals.discount_text = response.data.discount_text;
}) })
.catch(error => { .catch(error => {
}); });*/
}, },
// add bill item row
onAddItem() { onAddItem() {
let row = []; let row = [];
@ -182,9 +216,10 @@ const app = new Vue({
this.form.items[index].price = (item.purchase_price).toFixed(2); this.form.items[index].price = (item.purchase_price).toFixed(2);
this.form.items[index].quantity = 1; this.form.items[index].quantity = 1;
this.form.items[index].tax_id = [item.tax_id.toString()]; 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) { onDeleteItem(index) {
this.form.items.splice(index, 1); this.form.items.splice(index, 1);
}, },

View File

@ -50,7 +50,8 @@ const app = new Vue({
}, },
transaction: [], transaction: [],
items: '', items: '',
discount: false discount: false,
currency: null,
} }
}, },
@ -105,6 +106,7 @@ const app = new Vue({
} }
}) })
.then(response => { .then(response => {
this.currency = response.data;
this.form.currency_code = response.data.currency_code; this.form.currency_code = response.data.currency_code;
this.form.currency_rate = response.data.currency_rate; this.form.currency_rate = response.data.currency_rate;
}) })
@ -113,6 +115,37 @@ const app = new Vue({
}, },
onCalculateTotal() { 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', { axios.post(url + '/common/items/total', {
items: this.form.items, items: this.form.items,
discount: this.form.discount, discount: this.form.discount,
@ -134,9 +167,10 @@ const app = new Vue({
this.totals.discount_text = response.data.discount_text; this.totals.discount_text = response.data.discount_text;
}) })
.catch(error => { .catch(error => {
}); });*/
}, },
// add invoice item row
onAddItem() { onAddItem() {
let row = []; let row = [];
@ -182,9 +216,10 @@ const app = new Vue({
this.form.items[index].price = (item.purchase_price).toFixed(2); this.form.items[index].price = (item.purchase_price).toFixed(2);
this.form.items[index].quantity = 1; this.form.items[index].quantity = 1;
this.form.items[index].tax_id = [item.tax_id.toString()]; 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) { onDeleteItem(index) {
this.form.items.splice(index, 1); this.form.items.splice(index, 1);
}, },

View File

@ -1,7 +1,9 @@
@stack($name . '_input_start') @stack($name . '_input_start')
<akaunting-money :col="'{{ $col }}'" <akaunting-money :col="'{{ $col }}'"
:required="{{ isset($attributes['required']) ? true : false }}" @if (isset($attributes['readonly']))
:required="{{ $attributes['required'] }}"
@endif
@if (isset($attributes['readonly'])) @if (isset($attributes['readonly']))
:readonly="'{{ $attributes['readonly'] }}'" :readonly="'{{ $attributes['readonly'] }}'"
@ -12,7 +14,7 @@
@endif @endif
@if (isset($attributes['masked'])) @if (isset($attributes['masked']))
:masked="'{{ $attributes['masked'] }}'" :masked="{{ ($attributes['masked']) ? 'true' : 'false' }}"
@endif @endif
:error="{{ isset($attributes['v-error']) ? $attributes['v-error'] : 'form.errors.get("' . $name . '")' }}" :error="{{ isset($attributes['v-error']) ? $attributes['v-error'] : 'form.errors.get("' . $name . '")' }}"
@ -23,6 +25,18 @@
:currency="{{ json_encode($attributes['currency']) }}" :currency="{{ json_encode($attributes['currency']) }}"
:value="{{ $value }}" :value="{{ $value }}"
@if (!empty($attributes['dynamic-currency']))
:dynamic-currency="{{ $attributes['dynamic-currency'] }}"
@endif
@if (!empty($attributes['v-model']))
v-model="{{ $attributes['v-model'] }}"
@endif
@if (!empty($attributes['change']))
@change="{{ $attributes['change'] }}($event)"
@endif
@if (!empty($attributes['v-model'])) @if (!empty($attributes['v-model']))
@interface="{{ $attributes['v-model'] . ' = $event' }}" @interface="{{ $attributes['v-model'] . ' = $event' }}"
@elseif (!empty($attributes['data-field'])) @elseif (!empty($attributes['data-field']))

View File

@ -65,7 +65,10 @@
@stack('add_item_td_start') @stack('add_item_td_start')
<tr class="row" id="addItem"> <tr class="row" id="addItem">
<td class="col-md-1 action-column border-right-0 border-bottom-0"><button type="button" @click="onAddItem" id="button-add-item" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-icon btn-outline-success btn-lg" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i></button></td> <td class="col-md-1 action-column border-right-0 border-bottom-0">
<button type="button" @click="onAddItem" id="button-add-item" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-icon btn-outline-success btn-lg" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i>
</button>
</td>
<td class="col-md-11 text-right border-bottom-0"></td> <td class="col-md-11 text-right border-bottom-0"></td>
</tr> </tr>
@stack('add_item_td_end') @stack('add_item_td_end')
@ -76,6 +79,7 @@
<strong>{{ trans('bills.sub_total') }}</strong> <strong>{{ trans('bills.sub_total') }}</strong>
</td> </td>
<td class="col-md-2 text-right border-bottom-0 long-texts"> <td class="col-md-2 text-right border-bottom-0 long-texts">
{{ Form::moneyGroup('sub_total', '', '', ['disabled' => 'disabled', 'required' => 'required', 'v-model' => 'totals.sub', 'currency' => $currency, 'dynamic-currency' => 'currency', 'masked' => 'true'], 0.00, 'text-right d-none') }}
<span id="sub-total" v-html="totals.sub">0</span> <span id="sub-total" v-html="totals.sub">0</span>
</td> </td>
</tr> </tr>
@ -112,7 +116,7 @@
<div class="discount card-footer"> <div class="discount card-footer">
<div class="row text-center"> <div class="row text-center">
<div class="col-md-12"> <div class="col-md-12">
<a href="javascript:void(0)" @click="discount = false" class="btn btn-icon btn-outline-secondary"> <a href="javascript:void(0)" @click="discount = false" class="btn btn-icon btn-outline-secondary">
<span class="btn-inner--icon"><i class="fas fa-times"></i></span> <span class="btn-inner--icon"><i class="fas fa-times"></i></span>
<span class="btn-inner--text">{{ trans('general.cancel') }}</span> <span class="btn-inner--text">{{ trans('general.cancel') }}</span>
</a> </a>
@ -138,6 +142,7 @@
<strong>{{ trans_choice('general.taxes', 1) }}</strong> <strong>{{ trans_choice('general.taxes', 1) }}</strong>
</td> </td>
<td class="col-md-2 text-right border-bottom-0 long-texts"> <td class="col-md-2 text-right border-bottom-0 long-texts">
{{ Form::moneyGroup('tax_total', '', '', ['disabled' => 'disabled', 'required' => 'required', 'v-model' => 'totals.tax', 'currency' => $currency, 'dynamic-currency' => 'currency', 'masked' => 'true'], 0.00, 'text-right d-none') }}
<span id="tax-total" v-html="totals.tax">0</span> <span id="tax-total" v-html="totals.tax">0</span>
</td> </td>
</tr> </tr>
@ -149,6 +154,7 @@
<strong>{{ trans('bills.total') }}</strong> <strong>{{ trans('bills.total') }}</strong>
</td> </td>
<td class="col-md-2 text-right long-texts"> <td class="col-md-2 text-right long-texts">
{{ Form::moneyGroup('grand_total', '', '', ['disabled' => 'disabled', 'required' => 'required', 'v-model' => 'totals.total', 'currency' => $currency, 'dynamic-currency' => 'currency', 'masked' => 'true'], 0.00, 'text-right d-none') }}
<span id="grand-total" v-html="totals.total">0</span> <span id="grand-total" v-html="totals.total">0</span>
</td> </td>
</tr> </tr>

View File

@ -66,7 +66,10 @@
@stack('add_item_td_start') @stack('add_item_td_start')
<tr class="row" id="addItem"> <tr class="row" id="addItem">
<td class="col-md-1 action-column border-right-0 border-bottom-0"><button type="button" @click="onAddItem" id="button-add-item" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-icon btn-outline-success btn-lg" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i></button></td> <td class="col-md-1 action-column border-right-0 border-bottom-0">
<button type="button" @click="onAddItem" id="button-add-item" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-icon btn-outline-success btn-lg" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i>
</button>
</td>
<td class="col-md-11 text-right border-bottom-0"></td> <td class="col-md-11 text-right border-bottom-0"></td>
</tr> </tr>
@stack('add_item_td_end') @stack('add_item_td_end')
@ -77,6 +80,7 @@
<strong>{{ trans('bills.sub_total') }}</strong> <strong>{{ trans('bills.sub_total') }}</strong>
</td> </td>
<td class="col-md-2 text-right border-bottom-0 long-texts"> <td class="col-md-2 text-right border-bottom-0 long-texts">
{{ Form::moneyGroup('sub_total', '', '', ['disabled' => 'disabled', 'required' => 'required', 'v-model' => 'totals.sub', 'currency' => $currency, 'dynamic-currency' => 'currency', 'masked' => 'true'], 0.00, 'text-right d-none') }}
<span id="sub-total" v-html="totals.sub">0</span> <span id="sub-total" v-html="totals.sub">0</span>
</td> </td>
</tr> </tr>
@ -139,6 +143,7 @@
<strong>{{ trans_choice('general.taxes', 1) }}</strong> <strong>{{ trans_choice('general.taxes', 1) }}</strong>
</td> </td>
<td class="col-md-2 text-right border-bottom-0 long-texts"> <td class="col-md-2 text-right border-bottom-0 long-texts">
{{ Form::moneyGroup('tax_total', '', '', ['disabled' => 'disabled', 'required' => 'required', 'v-model' => 'totals.tax', 'currency' => $currency, 'dynamic-currency' => 'currency', 'masked' => 'true'], 0.00, 'text-right d-none') }}
<span id="tax-total" v-html="totals.tax">0</span> <span id="tax-total" v-html="totals.tax">0</span>
</td> </td>
</tr> </tr>
@ -150,6 +155,7 @@
<strong>{{ trans('bills.total') }}</strong> <strong>{{ trans('bills.total') }}</strong>
</td> </td>
<td class="col-md-2 text-right long-texts"> <td class="col-md-2 text-right long-texts">
{{ Form::moneyGroup('grand_total', '', '', ['disabled' => 'disabled', 'required' => 'required', 'v-model' => 'totals.total', 'currency' => $currency, 'dynamic-currency' => 'currency', 'masked' => 'true'], 0.00, 'text-right d-none') }}
<span id="grand-total" v-html="totals.total">0</span> <span id="grand-total" v-html="totals.total">0</span>
</td> </td>
</tr> </tr>

View File

@ -21,7 +21,7 @@
:placeholder="'{{ trans('general.type_item_name') }}'" :placeholder="'{{ trans('general.type_item_name') }}'"
:name="'item_id'" :name="'item_id'"
:options="{{ json_encode($items) }}" :options="{{ json_encode($items) }}"
:value="'{{ old('item_id', '') }}'" :value="form.items[index].item_id"
:add-new="{{ json_encode([ :add-new="{{ json_encode([
'status' => true, 'status' => true,
'text' => trans('general.add_new'), 'text' => trans('general.add_new'),
@ -69,15 +69,7 @@
@stack('price_td_start') @stack('price_td_start')
<td class="col-md-2 border-right-0 border-bottom-0"> <td class="col-md-2 border-right-0 border-bottom-0">
@stack('price_input_start') @stack('price_input_start')
<input class="form-control text-right input-price" {{ Form::moneyGroup('name', '', '', ['required' => 'required', 'v-model' => 'row.price', 'data-item' => 'price', 'currency' => $currency, 'dynamic-currency' => 'currency', 'change' => 'row.price = $event; onCalculateTotal'], 0.00, 'text-right input-price') }}
autocomplete="off"
required="required"
data-item="price"
v-model.lazy="row.price"
v-money="money"
@input="onCalculateTotal"
name="items[][price]"
type="text">
<input name="items[][currency]" <input name="items[][currency]"
data-item="currency" data-item="currency"
v-model="row.currency" v-model="row.currency"
@ -91,30 +83,55 @@
@stack('taxes_td_start') @stack('taxes_td_start')
<td class="col-md-3 border-right-0 border-bottom-0"> <td class="col-md-3 border-right-0 border-bottom-0">
@stack('tax_id_input_start') @stack('tax_id_input_start')
{{ Form::multiSelectAddNewGroup('tax_id', '', '', $taxes, '', [ <akaunting-select
'data-item' => 'tax_id', class="mb-0 select-tax"
'v-model' => 'row.tax_id', :form-classes="[{'has-error': form.errors.get('tax_id') }]"
'change' => 'onCalculateTotal', :icon="''"
'class' => 'form-control', :title="''"
'collapse' => 'false', :placeholder="'{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}'"
'path' => route('modals.taxes.create') :name="'tax_id'"
], 'mb-0 select-tax') }} :options="{{ json_encode($taxes) }}"
:value="row.tax_id"
:multiple="true"
:add-new="{{ json_encode([
'status' => true,
'text' => trans('general.add_new'),
'path' => route('modals.taxes.create'),
'type' => 'modal',
'field' => 'name',
'buttons' => [
'cancel' => [
'text' => trans('general.cancel'),
'icon' => 'fas fa-times',
'class' => 'btn-outline-secondary'
],
'confirm' => [
'text' => trans('general.save'),
'icon' => 'fas fa-save',
'class' => 'btn-success'
]
]
])}}"
:collapse="false"
@interface="row.tax_id = $event"
@change="onCalculateTotal($event)"
:form-error="form.errors.get('tax_id')"
:no-data-text="'{{ trans('general.no_data') }}'"
:no-matching-data-text="'{{ trans('general.no_matching_data') }}'"
></akaunting-select>
@stack('tax_id_input_end') @stack('tax_id_input_end')
</td> </td>
@stack('taxes_td_end') @stack('taxes_td_end')
@stack('total_td_start') @stack('total_td_start')
<td class="col-md-2 text-right total-column border-bottom-0 long-texts"> <td class="col-md-2 text-right total-column border-bottom-0 long-texts">
<input name="item[][total]" {{ Form::moneyGroup('total', '', '', ['required' => 'required', 'v-model' => 'row.total', 'data-item' => 'total', 'currency' => $currency, 'dynamic-currency' => 'currency', 'masked' => 'true'], 0.00, 'text-right input-price d-none') }}
data-item="total"
v-model.lazy="row.total"
v-money="money"
type="hidden">
@stack('total_input_start') @stack('total_input_start')
<span id="item-total" v-if="row.total" v-html="row.total">0</span>
@if (empty($item) || !isset($item->total)) @if (empty($item) || !isset($item->total))
<span id="item-total" v-html="row.total">0</span> <span id="item-total" v-else>@money(0, $currency->code, true)</span>
@else @else
<span id="item-total" v-html="row.total">@money($item->total, $bill->currency_code, true)</span> <span id="item-total" v-else>@money($item->total, $bill->currency_code, true)</span>
@endif @endif
@stack('total_input_end') @stack('total_input_end')
</td> </td>

View File

@ -79,6 +79,7 @@
<strong>{{ trans('invoices.sub_total') }}</strong> <strong>{{ trans('invoices.sub_total') }}</strong>
</td> </td>
<td class="col-md-2 text-right border-bottom-0 long-texts"> <td class="col-md-2 text-right border-bottom-0 long-texts">
{{ Form::moneyGroup('sub_total', '', '', ['disabled' => 'disabled', 'required' => 'required', 'v-model' => 'totals.sub', 'currency' => $currency, 'dynamic-currency' => 'currency', 'masked' => 'true'], 0.00, 'text-right d-none') }}
<span id="sub-total" v-html="totals.sub">0</span> <span id="sub-total" v-html="totals.sub">0</span>
</td> </td>
</tr> </tr>
@ -115,7 +116,7 @@
<div class="discount card-footer"> <div class="discount card-footer">
<div class="row text-center"> <div class="row text-center">
<div class="col-md-12"> <div class="col-md-12">
<a href="javascript:void(0)" @click="discount = false" class="btn btn-icon btn-outline-secondary"> <a href="javascript:void(0)" @click="discount = false" class="btn btn-icon btn-outline-secondary">
<span class="btn-inner--icon"><i class="fas fa-times"></i></span> <span class="btn-inner--icon"><i class="fas fa-times"></i></span>
<span class="btn-inner--text">{{ trans('general.cancel') }}</span> <span class="btn-inner--text">{{ trans('general.cancel') }}</span>
</a> </a>
@ -141,6 +142,7 @@
<strong>{{ trans_choice('general.taxes', 1) }}</strong> <strong>{{ trans_choice('general.taxes', 1) }}</strong>
</td> </td>
<td class="col-md-2 text-right border-bottom-0 long-texts"> <td class="col-md-2 text-right border-bottom-0 long-texts">
{{ Form::moneyGroup('tax_total', '', '', ['disabled' => 'disabled', 'required' => 'required', 'v-model' => 'totals.tax', 'currency' => $currency, 'dynamic-currency' => 'currency', 'masked' => 'true'], 0.00, 'text-right d-none') }}
<span id="tax-total" v-html="totals.tax">0</span> <span id="tax-total" v-html="totals.tax">0</span>
</td> </td>
</tr> </tr>
@ -152,6 +154,7 @@
<strong>{{ trans('invoices.total') }}</strong> <strong>{{ trans('invoices.total') }}</strong>
</td> </td>
<td class="col-md-2 text-right long-texts"> <td class="col-md-2 text-right long-texts">
{{ Form::moneyGroup('grand_total', '', '', ['disabled' => 'disabled', 'required' => 'required', 'v-model' => 'totals.total', 'currency' => $currency, 'dynamic-currency' => 'currency', 'masked' => 'true'], 0.00, 'text-right d-none') }}
<span id="grand-total" v-html="totals.total">0</span> <span id="grand-total" v-html="totals.total">0</span>
</td> </td>
</tr> </tr>

View File

@ -66,7 +66,10 @@
@stack('add_item_td_start') @stack('add_item_td_start')
<tr class="row" id="addItem"> <tr class="row" id="addItem">
<td class="col-md-1 action-column border-right-0 border-bottom-0"><button type="button" @click="onAddItem" id="button-add-item" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-icon btn-outline-success btn-lg" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i></button></td> <td class="col-md-1 action-column border-right-0 border-bottom-0">
<button type="button" @click="onAddItem" id="button-add-item" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-icon btn-outline-success btn-lg" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i>
</button>
</td>
<td class="col-md-11 text-right border-bottom-0"></td> <td class="col-md-11 text-right border-bottom-0"></td>
</tr> </tr>
@stack('add_item_td_end') @stack('add_item_td_end')
@ -77,6 +80,7 @@
<strong>{{ trans('invoices.sub_total') }}</strong> <strong>{{ trans('invoices.sub_total') }}</strong>
</td> </td>
<td class="col-md-2 text-right border-bottom-0 long-texts"> <td class="col-md-2 text-right border-bottom-0 long-texts">
{{ Form::moneyGroup('sub_total', '', '', ['disabled' => 'disabled', 'required' => 'required', 'v-model' => 'totals.sub', 'currency' => $currency, 'dynamic-currency' => 'currency', 'masked' => 'true'], 0.00, 'text-right d-none') }}
<span id="sub-total" v-html="totals.sub">0</span> <span id="sub-total" v-html="totals.sub">0</span>
</td> </td>
</tr> </tr>
@ -139,6 +143,7 @@
<strong>{{ trans_choice('general.taxes', 1) }}</strong> <strong>{{ trans_choice('general.taxes', 1) }}</strong>
</td> </td>
<td class="col-md-2 text-right border-bottom-0 long-texts"> <td class="col-md-2 text-right border-bottom-0 long-texts">
{{ Form::moneyGroup('tax_total', '', '', ['disabled' => 'disabled', 'required' => 'required', 'v-model' => 'totals.tax', 'currency' => $currency, 'dynamic-currency' => 'currency', 'masked' => 'true'], 0.00, 'text-right d-none') }}
<span id="tax-total" v-html="totals.tax">0</span> <span id="tax-total" v-html="totals.tax">0</span>
</td> </td>
</tr> </tr>
@ -150,6 +155,7 @@
<strong>{{ trans('invoices.total') }}</strong> <strong>{{ trans('invoices.total') }}</strong>
</td> </td>
<td class="col-md-2 text-right long-texts"> <td class="col-md-2 text-right long-texts">
{{ Form::moneyGroup('grand_total', '', '', ['disabled' => 'disabled', 'required' => 'required', 'v-model' => 'totals.total', 'currency' => $currency, 'dynamic-currency' => 'currency', 'masked' => 'true'], 0.00, 'text-right d-none') }}
<span id="grand-total" v-html="totals.total">0</span> <span id="grand-total" v-html="totals.total">0</span>
</td> </td>
</tr> </tr>

View File

@ -21,7 +21,7 @@
:placeholder="'{{ trans('general.type_item_name') }}'" :placeholder="'{{ trans('general.type_item_name') }}'"
:name="'item_id'" :name="'item_id'"
:options="{{ json_encode($items) }}" :options="{{ json_encode($items) }}"
:value="'{{ old('item_id', '') }}'" :value="form.items[index].item_id"
:add-new="{{ json_encode([ :add-new="{{ json_encode([
'status' => true, 'status' => true,
'text' => trans('general.add_new'), 'text' => trans('general.add_new'),
@ -69,15 +69,7 @@
@stack('price_td_start') @stack('price_td_start')
<td class="col-md-2 border-right-0 border-bottom-0"> <td class="col-md-2 border-right-0 border-bottom-0">
@stack('price_input_start') @stack('price_input_start')
<input class="form-control text-right input-price" {{ Form::moneyGroup('name', '', '', ['required' => 'required', 'v-model' => 'row.price', 'data-item' => 'price', 'currency' => $currency, 'dynamic-currency' => 'currency', 'change' => 'row.price = $event; onCalculateTotal'], 0.00, 'text-right input-price') }}
autocomplete="off"
required="required"
data-item="price"
v-model.lazy="row.price"
v-money="money"
@input="onCalculateTotal"
name="items[][price]"
type="text">
<input name="items[][currency]" <input name="items[][currency]"
data-item="currency" data-item="currency"
v-model="row.currency" v-model="row.currency"
@ -91,30 +83,55 @@
@stack('taxes_td_start') @stack('taxes_td_start')
<td class="col-md-3 border-right-0 border-bottom-0"> <td class="col-md-3 border-right-0 border-bottom-0">
@stack('tax_id_input_start') @stack('tax_id_input_start')
{{ Form::multiSelectAddNewGroup('tax_id', '', '', $taxes, '', [ <akaunting-select
'data-item' => 'tax_id', class="mb-0 select-tax"
'v-model' => 'row.tax_id', :form-classes="[{'has-error': form.errors.get('tax_id') }]"
'change' => 'onCalculateTotal', :icon="''"
'class' => 'form-control', :title="''"
'collapse' => 'false', :placeholder="'{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}'"
'path' => route('modals.taxes.create') :name="'tax_id'"
], 'mb-0 select-tax') }} :options="{{ json_encode($taxes) }}"
:value="row.tax_id"
:multiple="true"
:add-new="{{ json_encode([
'status' => true,
'text' => trans('general.add_new'),
'path' => route('modals.taxes.create'),
'type' => 'modal',
'field' => 'name',
'buttons' => [
'cancel' => [
'text' => trans('general.cancel'),
'icon' => 'fas fa-times',
'class' => 'btn-outline-secondary'
],
'confirm' => [
'text' => trans('general.save'),
'icon' => 'fas fa-save',
'class' => 'btn-success'
]
]
])}}"
:collapse="false"
@interface="row.tax_id = $event"
@change="onCalculateTotal($event)"
:form-error="form.errors.get('tax_id')"
:no-data-text="'{{ trans('general.no_data') }}'"
:no-matching-data-text="'{{ trans('general.no_matching_data') }}'"
></akaunting-select>
@stack('tax_id_input_end') @stack('tax_id_input_end')
</td> </td>
@stack('taxes_td_end') @stack('taxes_td_end')
@stack('total_td_start') @stack('total_td_start')
<td class="col-md-2 text-right total-column border-bottom-0 long-texts"> <td class="col-md-2 text-right total-column border-bottom-0 long-texts">
<input name="item[][total]" {{ Form::moneyGroup('total', '', '', ['required' => 'required', 'v-model' => 'row.total', 'data-item' => 'total', 'currency' => $currency, 'dynamic-currency' => 'currency', 'masked' => 'true'], 0.00, 'text-right input-price d-none') }}
data-item="total"
v-model.lazy="row.total"
v-money="money"
type="hidden">
@stack('total_input_start') @stack('total_input_start')
<span id="item-total" v-if="row.total" v-html="row.total">0</span>
@if (empty($item) || !isset($item->total)) @if (empty($item) || !isset($item->total))
<span id="item-total" v-html="row.total">0</span> <span id="item-total" v-else>@money(0, $currency->code, true)</span>
@else @else
<span id="item-total" v-html="row.total">@money($item->total, $invoice->currency_code, true)</span> <span id="item-total" v-else>@money($item->total, $invoice->currency_code, true)</span>
@endif @endif
@stack('total_input_end') @stack('total_input_end')
</td> </td>