diff --git a/resources/views/expenses/bills/create.blade.php b/resources/views/expenses/bills/create.blade.php index f60fe4506..adefdfe1c 100644 --- a/resources/views/expenses/bills/create.blade.php +++ b/resources/views/expenses/bills/create.blade.php @@ -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'); + }); } } }); diff --git a/resources/views/expenses/bills/edit.blade.php b/resources/views/expenses/bills/edit.blade.php index 142f39eef..29d7f32a9 100644 --- a/resources/views/expenses/bills/edit.blade.php +++ b/resources/views/expenses/bills/edit.blade.php @@ -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'); + }); } } }); diff --git a/resources/views/incomes/invoices/create.blade.php b/resources/views/incomes/invoices/create.blade.php index 7391668cb..2acd9db12 100644 --- a/resources/views/incomes/invoices/create.blade.php +++ b/resources/views/incomes/invoices/create.blade.php @@ -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({