Invoice edit item multible tax changes
This commit is contained in:
parent
7f9239e602
commit
8fcfccc4b0
@ -29,6 +29,11 @@ class InvoiceItem extends Model
|
|||||||
return $this->belongsTo('App\Models\Common\Item');
|
return $this->belongsTo('App\Models\Common\Item');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function itemTaxes()
|
||||||
|
{
|
||||||
|
return $this->hasMany('App\Models\Income\InvoiceItemTax', 'invoice_item_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
public function tax()
|
public function tax()
|
||||||
{
|
{
|
||||||
return $this->belongsTo('App\Models\Setting\Tax');
|
return $this->belongsTo('App\Models\Setting\Tax');
|
||||||
@ -66,4 +71,23 @@ class InvoiceItem extends Model
|
|||||||
{
|
{
|
||||||
$this->attributes['tax'] = (double) $value;
|
$this->attributes['tax'] = (double) $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert tax to double.
|
||||||
|
*
|
||||||
|
* @param string $value
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function getTaxIdAttribute($value)
|
||||||
|
{
|
||||||
|
$tax_ids = [];
|
||||||
|
|
||||||
|
if (!empty($value)) {
|
||||||
|
$tax_ids[] = $value;
|
||||||
|
|
||||||
|
return $tax_ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->itemTaxes->pluck('tax_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,6 +170,14 @@
|
|||||||
placeholder: {
|
placeholder: {
|
||||||
id: '-1', // the value of the option
|
id: '-1', // the value of the option
|
||||||
text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}"
|
text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}"
|
||||||
|
},
|
||||||
|
escapeMarkup: function (markup) {
|
||||||
|
return markup;
|
||||||
|
},
|
||||||
|
language: {
|
||||||
|
noResults: function () {
|
||||||
|
return '<span id="tax-add-new"><i class="fa fa-plus"> {{ trans('general.title.new', ['type' => trans_choice('general.tax_rates', 1)]) }}</span>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -192,6 +200,24 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '#tax-add-new', function(e){
|
||||||
|
tax_name = $('.select2-search__field').val();
|
||||||
|
|
||||||
|
$('#modal-create-tax').remove();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '{{ url("modals/taxes/create") }}',
|
||||||
|
type: 'GET',
|
||||||
|
dataType: 'JSON',
|
||||||
|
data: {name: tax_name},
|
||||||
|
success: function(json) {
|
||||||
|
if (json['success']) {
|
||||||
|
$('body').append(json['html']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$(".input-price").maskMoney({
|
$(".input-price").maskMoney({
|
||||||
thousands : '{{ $currency->thousands_separator }}',
|
thousands : '{{ $currency->thousands_separator }}',
|
||||||
@ -231,6 +257,14 @@
|
|||||||
placeholder: {
|
placeholder: {
|
||||||
id: '-1', // the value of the option
|
id: '-1', // the value of the option
|
||||||
text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}"
|
text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}"
|
||||||
|
},
|
||||||
|
escapeMarkup: function (markup) {
|
||||||
|
return markup;
|
||||||
|
},
|
||||||
|
language: {
|
||||||
|
noResults: function () {
|
||||||
|
return '<span id="tax-add-new"><i class="fa fa-plus"> {{ trans('general.title.new', ['type' => trans_choice('general.tax_rates', 1)]) }}</span>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -446,7 +480,7 @@
|
|||||||
url: '{{ url("common/items/totalItem") }}',
|
url: '{{ url("common/items/totalItem") }}',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: 'JSON',
|
dataType: 'JSON',
|
||||||
data: $('#currency_code, #discount input[type=\'number\'], #items input[type=\'text\'], #items input[type=\'number\'], #items input[type=\'hidden\'], #items textarea, #items select'),
|
data: $('#currency_code, #discount input[type=\'number\'], #items input[type=\'text\'], #items input[type=\'number\'], #items input[type=\'hidden\'], #items textarea, #items select').serialize(),
|
||||||
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user