Skip to content

Commit

Permalink
refs #451 Bill Item
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Aug 29, 2018
1 parent ebf79a3 commit bbd7046
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 15 deletions.
27 changes: 26 additions & 1 deletion resources/views/expenses/bills/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -412,6 +415,28 @@ function totalItem() {
$('#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');
});
}
}
});
Expand Down
29 changes: 27 additions & 2 deletions resources/views/expenses/bills/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -406,7 +409,7 @@ function totalItem() {
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) {
Expand All @@ -420,6 +423,28 @@ function totalItem() {
$('#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');
});
}
}
});
Expand Down
17 changes: 5 additions & 12 deletions resources/views/incomes/invoices/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -408,13 +403,6 @@ function totalItem() {
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 ) {
Expand All @@ -429,6 +417,11 @@ function totalItem() {
$('#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({
Expand Down

0 comments on commit bbd7046

Please sign in to comment.