invoice and bill currency issue some fix

This commit is contained in:
Batuhan Baş
2018-08-29 19:45:50 +03:00
parent fa6a5d7f47
commit 51503e688c
11 changed files with 140 additions and 62 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("incomes/invoices/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']);
@ -371,6 +373,11 @@
$('#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({
@ -401,13 +408,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 ) {
@ -422,6 +422,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({

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("incomes/invoices/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']);
@ -379,6 +381,11 @@
$('#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({
@ -403,12 +410,11 @@
});
function totalItem() {
$.ajax({
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) {
@ -424,6 +430,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({

View File

@ -25,6 +25,7 @@
<td>
@stack('price_input_start')
<input value="{{ empty($item) ? '' : $item->price }}" class="form-control text-right input-price" required="required" name="item[{{ $item_row }}][price]" type="text" id="item-price-{{ $item_row }}">
<input value="{{ $currency->code }}" name="item[{{ $item_row }}][currency]" type="hidden" id="item-currency-{{ $item_row }}">
@stack('price_input_end')
</td>
@stack('price_td_end')