refs #451 Bill Item

This commit is contained in:
cuneytsenturk 2018-08-29 18:15:26 +03:00
parent ebf79a315c
commit bbd704635c
3 changed files with 58 additions and 15 deletions

View File

@ -161,11 +161,13 @@
var item_row = '{{ $item_row }}';
$(document).on('click', '#button-add-item', function (e) {
var currency_code = $('#currency_code').val();
$.ajax({
url: '{{ url("expenses/bills/addItem") }}',
type: 'GET',
dataType: 'JSON',
data: {item_row: item_row, currency_code : $('#currency_code').val()},
data: {item_row: item_row, currency_code : currency_code},
success: function(json) {
if (json['success']) {
$('#items tbody #addItem').before(json['html']);
@ -285,6 +287,7 @@
$('#item-tax-' + item_id).val(data.tax_id);
// This event Select2 Stylesheet
$('#item-price-' + item_id).trigger('focusout');
$('#item-tax-' + item_id).trigger('change');
$('#item-total-' + item_id).html(data.total);
@ -412,6 +415,28 @@
$('#discount-total').html(data.discount_total);
$('#tax-total').html(data.tax_total);
$('#grand-total').html(data.grand_total);
$('.input-price').each(function(){
input_price_id = $(this).attr('id');
input_currency_id = input_price_id.replace('price', 'currency');
$('#' + input_currency_id).val(data.currency_code);
amount = $(this).maskMoney('unmasked')[0];
$(this).maskMoney({
thousands : data.thousands_separator,
decimal : data.decimal_mark,
precision : data.precision,
allowZero : true,
prefix : (data.symbol_first) ? data.symbol : '',
suffix : (data.symbol_first) ? '' : data.symbol
});
$(this).val(amount);
$(this).trigger('focusout');
});
}
}
});

View File

@ -142,11 +142,13 @@
var item_row = '{{ $item_row }}';
$(document).on('click', '#button-add-item', function (e) {
var currency_code = $('#currency_code').val();
$.ajax({
url: '{{ url("expenses/bills/addItem") }}',
type: 'GET',
dataType: 'JSON',
data: {item_row: item_row},
data: {item_row: item_row, currency_code : currency_code},
success: function(json) {
if (json['success']) {
$('#items tbody #addItem').before(json['html']);
@ -293,6 +295,7 @@
$('#item-tax-' + item_id).val(data.tax_id);
// This event Select2 Stylesheet
$('#item-price-' + item_id).trigger('focusout');
$('#item-tax-' + item_id).trigger('change');
$('#item-total-' + item_id).html(data.total);
@ -406,7 +409,7 @@
url: '{{ url("common/items/totalItem") }}',
type: 'POST',
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'),
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
success: function(data) {
if (data) {
@ -420,6 +423,28 @@
$('#discount-total').html(data.discount_total);
$('#tax-total').html(data.tax_total);
$('#grand-total').html(data.grand_total);
$('.input-price').each(function(){
input_price_id = $(this).attr('id');
input_currency_id = input_price_id.replace('price', 'currency');
$('#' + input_currency_id).val(data.currency_code);
amount = $(this).maskMoney('unmasked')[0];
$(this).maskMoney({
thousands : data.thousands_separator,
decimal : data.decimal_mark,
precision : data.precision,
allowZero : true,
prefix : (data.symbol_first) ? data.symbol : '',
suffix : (data.symbol_first) ? '' : data.symbol
});
$(this).val(amount);
$(this).trigger('focusout');
});
}
}
});

View File

@ -373,11 +373,6 @@
$('#currency_rate').val(data.currency_rate);
$('.input-price').each(function(){
input_price_id = $(this).attr('id');
input_currency_id = input_price_id.replace('price', 'currency');
$('#' + input_currency_id).val(data.currency_code);
amount = $(this).maskMoney('unmasked')[0];
$(this).maskMoney({
@ -408,13 +403,6 @@
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'),
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
before: function () {
$('.input-price').each(function(){
amount = $(this).maskMoney('unmasked')[0];
$(this).val(amount);
});
},
success: function(data) {
if (data) {
$.each( data.items, function( key, value ) {
@ -429,6 +417,11 @@
$('#grand-total').html(data.grand_total);
$('.input-price').each(function(){
input_price_id = $(this).attr('id');
input_currency_id = input_price_id.replace('price', 'currency');
$('#' + input_currency_id).val(data.currency_code);
amount = $(this).maskMoney('unmasked')[0];
$(this).maskMoney({