invoice and bill currency issue some fix
This commit is contained in:
parent
fa6a5d7f47
commit
51503e688c
@ -280,8 +280,8 @@ class Items extends Controller
|
|||||||
$item_tax_price = ($item->sale_price / 100) * $tax->rate;
|
$item_tax_price = ($item->sale_price / 100) * $tax->rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
$item->sale_price = $this->convertPrice($item->sale_price, $currency_code, $currency->rate);
|
//$item->sale_price = $this->convertPrice($item->sale_price, $currency_code, $currency->rate);
|
||||||
$item->purchase_price = $this->convertPrice($item->purchase_price, $currency_code, $currency->rate);
|
//$item->purchase_price = $this->convertPrice($item->purchase_price, $currency_code, $currency->rate);
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'bill':
|
case 'bill':
|
||||||
|
@ -755,7 +755,7 @@ class Bills extends Controller
|
|||||||
// it should be integer for amount mask
|
// it should be integer for amount mask
|
||||||
$currency->precision = (int) $currency->precision;
|
$currency->precision = (int) $currency->precision;
|
||||||
|
|
||||||
$html = view('expenses.bills.item', compact('item_row', 'taxes'))->render();
|
$html = view('expenses.bills.item', compact('item_row', 'taxes', 'currency'))->render();
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
|
@ -76,7 +76,9 @@ class Invoices extends Controller
|
|||||||
foreach ($invoice->payments as $item) {
|
foreach ($invoice->payments as $item) {
|
||||||
$default_amount = $item->amount;
|
$default_amount = $item->amount;
|
||||||
|
|
||||||
if ($invoice->currency_code != $item->currency_code) {
|
if ($invoice->currency_code == $item->currency_code) {
|
||||||
|
$amount = (double)$default_amount;
|
||||||
|
} else {
|
||||||
$default_amount_model = new InvoicePayment();
|
$default_amount_model = new InvoicePayment();
|
||||||
|
|
||||||
$default_amount_model->default_currency_code = $invoice->currency_code;
|
$default_amount_model->default_currency_code = $invoice->currency_code;
|
||||||
@ -85,17 +87,17 @@ class Invoices extends Controller
|
|||||||
$default_amount_model->currency_rate = $_currencies[$item->currency_code];
|
$default_amount_model->currency_rate = $_currencies[$item->currency_code];
|
||||||
|
|
||||||
$default_amount = (double) $default_amount_model->getDivideConvertedAmount();
|
$default_amount = (double) $default_amount_model->getDivideConvertedAmount();
|
||||||
|
|
||||||
|
$convert_amount = new InvoicePayment();
|
||||||
|
|
||||||
|
$convert_amount->default_currency_code = $item->currency_code;
|
||||||
|
$convert_amount->amount = $default_amount;
|
||||||
|
$convert_amount->currency_code = $invoice->currency_code;
|
||||||
|
$convert_amount->currency_rate = $_currencies[$invoice->currency_code];
|
||||||
|
|
||||||
|
$amount = (double) $convert_amount->getDynamicConvertedAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
$convert_amount = new InvoicePayment();
|
|
||||||
|
|
||||||
$convert_amount->default_currency_code = $item->currency_code;
|
|
||||||
$convert_amount->amount = $default_amount;
|
|
||||||
$convert_amount->currency_code = $invoice->currency_code;
|
|
||||||
$convert_amount->currency_rate = $_currencies[$invoice->currency_code];
|
|
||||||
|
|
||||||
$amount = (double) $convert_amount->getDynamicConvertedAmount();
|
|
||||||
|
|
||||||
$paid += $amount;
|
$paid += $amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -892,7 +894,7 @@ class Invoices extends Controller
|
|||||||
// it should be integer for amount mask
|
// it should be integer for amount mask
|
||||||
$currency->precision = (int) $currency->precision;
|
$currency->precision = (int) $currency->precision;
|
||||||
|
|
||||||
$html = view('incomes.invoices.item', compact('item_row', 'taxes'))->render();
|
$html = view('incomes.invoices.item', compact('item_row', 'taxes', 'currency'))->render();
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
|
@ -39,13 +39,13 @@ class InvoicePayments extends Controller
|
|||||||
|
|
||||||
$currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code')->toArray();
|
$currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code')->toArray();
|
||||||
|
|
||||||
$currency = Currency::where('code', setting('general.default_currency'))->first();
|
|
||||||
|
|
||||||
$account_currency_code = Account::where('id', setting('general.default_account'))->pluck('currency_code')->first();
|
$account_currency_code = Account::where('id', setting('general.default_account'))->pluck('currency_code')->first();
|
||||||
|
|
||||||
|
$currency = Currency::where('code', $account_currency_code)->first();
|
||||||
|
|
||||||
$payment_methods = Modules::getPaymentMethods();
|
$payment_methods = Modules::getPaymentMethods();
|
||||||
|
|
||||||
$invoice->paid = $this->getPaid($invoice);
|
$paid = $this->getPaid($invoice);
|
||||||
|
|
||||||
// Get Invoice Totals
|
// Get Invoice Totals
|
||||||
foreach ($invoice->totals as $invoice_total) {
|
foreach ($invoice->totals as $invoice_total) {
|
||||||
@ -88,7 +88,9 @@ class InvoicePayments extends Controller
|
|||||||
|
|
||||||
$default_amount = (double) $request['amount'];
|
$default_amount = (double) $request['amount'];
|
||||||
|
|
||||||
if ($invoice->currency_code != $request['currency_code']) {
|
if ($invoice->currency_code == $request['currency_code']) {
|
||||||
|
$amount = $default_amount;
|
||||||
|
} else {
|
||||||
$default_amount_model = new InvoicePayment();
|
$default_amount_model = new InvoicePayment();
|
||||||
|
|
||||||
$default_amount_model->default_currency_code = $invoice->currency_code;
|
$default_amount_model->default_currency_code = $invoice->currency_code;
|
||||||
@ -97,17 +99,17 @@ class InvoicePayments extends Controller
|
|||||||
$default_amount_model->currency_rate = $currencies[$request['currency_code']];
|
$default_amount_model->currency_rate = $currencies[$request['currency_code']];
|
||||||
|
|
||||||
$default_amount = (double) $default_amount_model->getDivideConvertedAmount();
|
$default_amount = (double) $default_amount_model->getDivideConvertedAmount();
|
||||||
|
|
||||||
|
$convert_amount = new InvoicePayment();
|
||||||
|
|
||||||
|
$convert_amount->default_currency_code = $request['currency_code'];
|
||||||
|
$convert_amount->amount = $default_amount;
|
||||||
|
$convert_amount->currency_code = $invoice->currency_code;
|
||||||
|
$convert_amount->currency_rate = $currencies[$invoice->currency_code];
|
||||||
|
|
||||||
|
$amount = (double) $convert_amount->getDynamicConvertedAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
$convert_amount = new InvoicePayment();
|
|
||||||
|
|
||||||
$convert_amount->default_currency_code = $request['currency_code'];
|
|
||||||
$convert_amount->amount = $default_amount;
|
|
||||||
$convert_amount->currency_code = $invoice->currency_code;
|
|
||||||
$convert_amount->currency_rate = $currencies[$invoice->currency_code];
|
|
||||||
|
|
||||||
$amount = (double) $convert_amount->getDynamicConvertedAmount();
|
|
||||||
|
|
||||||
if ($invoice->payments()->count()) {
|
if ($invoice->payments()->count()) {
|
||||||
$total_amount -= $this->getPaid($invoice);
|
$total_amount -= $this->getPaid($invoice);
|
||||||
}
|
}
|
||||||
@ -134,18 +136,18 @@ class InvoicePayments extends Controller
|
|||||||
$error_amount_model->currency_rate = $currencies[$invoice->currency_code];
|
$error_amount_model->currency_rate = $currencies[$invoice->currency_code];
|
||||||
|
|
||||||
$error_amount = (double) $error_amount_model->getDivideConvertedAmount();
|
$error_amount = (double) $error_amount_model->getDivideConvertedAmount();
|
||||||
|
|
||||||
|
$convert_amount = new InvoicePayment();
|
||||||
|
|
||||||
|
$convert_amount->default_currency_code = $invoice->currency_code;
|
||||||
|
$convert_amount->amount = $error_amount;
|
||||||
|
$convert_amount->currency_code = $request['currency_code'];
|
||||||
|
$convert_amount->currency_rate = $currencies[$request['currency_code']];
|
||||||
|
|
||||||
|
$error_amount = (double) $convert_amount->getDynamicConvertedAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
$convert_amount = new InvoicePayment();
|
$message = trans('messages.error.over_payment', ['amount' => money($error_amount, $request['currency_code'],true)]);
|
||||||
|
|
||||||
$convert_amount->default_currency_code = $invoice->currency_code;
|
|
||||||
$convert_amount->amount = $error_amount;
|
|
||||||
$convert_amount->currency_code = $request['currency_code'];
|
|
||||||
$convert_amount->currency_rate = $currencies[$request['currency_code']];
|
|
||||||
|
|
||||||
$error_amount = (double) $convert_amount->getDynamicConvertedAmount();
|
|
||||||
|
|
||||||
$message = trans('messages.error.over_payment', ['amount' => money($error_amount, $request['currency_code'], true)]);
|
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => false,
|
'success' => false,
|
||||||
@ -217,7 +219,9 @@ class InvoicePayments extends Controller
|
|||||||
foreach ($invoice->payments as $item) {
|
foreach ($invoice->payments as $item) {
|
||||||
$default_amount = $item->amount;
|
$default_amount = $item->amount;
|
||||||
|
|
||||||
if ($invoice->currency_code != $item->currency_code) {
|
if ($invoice->currency_code == $item->currency_code) {
|
||||||
|
$amount = (double) $default_amount;
|
||||||
|
} else {
|
||||||
$default_amount_model = new InvoicePayment();
|
$default_amount_model = new InvoicePayment();
|
||||||
|
|
||||||
$default_amount_model->default_currency_code = $invoice->currency_code;
|
$default_amount_model->default_currency_code = $invoice->currency_code;
|
||||||
@ -226,17 +230,17 @@ class InvoicePayments extends Controller
|
|||||||
$default_amount_model->currency_rate = $_currencies[$item->currency_code];
|
$default_amount_model->currency_rate = $_currencies[$item->currency_code];
|
||||||
|
|
||||||
$default_amount = (double) $default_amount_model->getDivideConvertedAmount();
|
$default_amount = (double) $default_amount_model->getDivideConvertedAmount();
|
||||||
|
|
||||||
|
$convert_amount = new InvoicePayment();
|
||||||
|
|
||||||
|
$convert_amount->default_currency_code = $item->currency_code;
|
||||||
|
$convert_amount->amount = $default_amount;
|
||||||
|
$convert_amount->currency_code = $invoice->currency_code;
|
||||||
|
$convert_amount->currency_rate = $_currencies[$invoice->currency_code];
|
||||||
|
|
||||||
|
$amount = (double) $convert_amount->getDynamicConvertedAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
$convert_amount = new InvoicePayment();
|
|
||||||
|
|
||||||
$convert_amount->default_currency_code = $item->currency_code;
|
|
||||||
$convert_amount->amount = $default_amount;
|
|
||||||
$convert_amount->currency_code = $invoice->currency_code;
|
|
||||||
$convert_amount->currency_rate = $_currencies[$invoice->currency_code];
|
|
||||||
|
|
||||||
$amount = (double) $convert_amount->getDynamicConvertedAmount();
|
|
||||||
|
|
||||||
$paid += $amount;
|
$paid += $amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,11 @@ class Money
|
|||||||
if (isset($bill_number) || isset($invoice_number) || !empty($items)) {
|
if (isset($bill_number) || isset($invoice_number) || !empty($items)) {
|
||||||
if (!empty($items)) {
|
if (!empty($items)) {
|
||||||
foreach ($items as $key => $item) {
|
foreach ($items as $key => $item) {
|
||||||
$items[$key]['price'] = money($item['price'], $currency_code)->getAmount();
|
if (isset($item['currency']) && $item['currency'] != $currency_code) {
|
||||||
|
$items[$key]['price'] = money($item['price'], $item['currency'])->getAmount();
|
||||||
|
} else {
|
||||||
|
$items[$key]['price'] = money($item['price'], $currency_code)->getAmount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$request->request->set('item', $items);
|
$request->request->set('item', $items);
|
||||||
|
@ -161,11 +161,13 @@
|
|||||||
var item_row = '{{ $item_row }}';
|
var item_row = '{{ $item_row }}';
|
||||||
|
|
||||||
$(document).on('click', '#button-add-item', function (e) {
|
$(document).on('click', '#button-add-item', function (e) {
|
||||||
|
var currency_code = $('#currency_code').val();
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '{{ url("expenses/bills/addItem") }}',
|
url: '{{ url("expenses/bills/addItem") }}',
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
dataType: 'JSON',
|
dataType: 'JSON',
|
||||||
data: {item_row: item_row, currency_code : $('#currency_code').val()},
|
data: {item_row: item_row, currency_code : currency_code},
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
if (json['success']) {
|
if (json['success']) {
|
||||||
$('#items tbody #addItem').before(json['html']);
|
$('#items tbody #addItem').before(json['html']);
|
||||||
@ -285,6 +287,7 @@
|
|||||||
$('#item-tax-' + item_id).val(data.tax_id);
|
$('#item-tax-' + item_id).val(data.tax_id);
|
||||||
|
|
||||||
// This event Select2 Stylesheet
|
// This event Select2 Stylesheet
|
||||||
|
$('#item-price-' + item_id).trigger('focusout');
|
||||||
$('#item-tax-' + item_id).trigger('change');
|
$('#item-tax-' + item_id).trigger('change');
|
||||||
|
|
||||||
$('#item-total-' + item_id).html(data.total);
|
$('#item-total-' + item_id).html(data.total);
|
||||||
@ -412,6 +415,28 @@
|
|||||||
$('#discount-total').html(data.discount_total);
|
$('#discount-total').html(data.discount_total);
|
||||||
$('#tax-total').html(data.tax_total);
|
$('#tax-total').html(data.tax_total);
|
||||||
$('#grand-total').html(data.grand_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');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -142,11 +142,13 @@
|
|||||||
var item_row = '{{ $item_row }}';
|
var item_row = '{{ $item_row }}';
|
||||||
|
|
||||||
$(document).on('click', '#button-add-item', function (e) {
|
$(document).on('click', '#button-add-item', function (e) {
|
||||||
|
var currency_code = $('#currency_code').val();
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '{{ url("expenses/bills/addItem") }}',
|
url: '{{ url("expenses/bills/addItem") }}',
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
dataType: 'JSON',
|
dataType: 'JSON',
|
||||||
data: {item_row: item_row},
|
data: {item_row: item_row, currency_code : currency_code},
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
if (json['success']) {
|
if (json['success']) {
|
||||||
$('#items tbody #addItem').before(json['html']);
|
$('#items tbody #addItem').before(json['html']);
|
||||||
@ -293,6 +295,7 @@
|
|||||||
$('#item-tax-' + item_id).val(data.tax_id);
|
$('#item-tax-' + item_id).val(data.tax_id);
|
||||||
|
|
||||||
// This event Select2 Stylesheet
|
// This event Select2 Stylesheet
|
||||||
|
$('#item-price-' + item_id).trigger('focusout');
|
||||||
$('#item-tax-' + item_id).trigger('change');
|
$('#item-tax-' + item_id).trigger('change');
|
||||||
|
|
||||||
$('#item-total-' + item_id).html(data.total);
|
$('#item-total-' + item_id).html(data.total);
|
||||||
@ -406,7 +409,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'),
|
||||||
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -420,6 +423,28 @@
|
|||||||
$('#discount-total').html(data.discount_total);
|
$('#discount-total').html(data.discount_total);
|
||||||
$('#tax-total').html(data.tax_total);
|
$('#tax-total').html(data.tax_total);
|
||||||
$('#grand-total').html(data.grand_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');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
<td>
|
<td>
|
||||||
@stack('price_input_start')
|
@stack('price_input_start')
|
||||||
<input value="{{ empty($item) ? '' : $item->price }}" class="form-control text-right" required="required" name="item[{{ $item_row }}][price]" type="text" id="item-price-{{ $item_row }}">
|
<input value="{{ empty($item) ? '' : $item->price }}" class="form-control text-right" 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')
|
@stack('price_input_end')
|
||||||
</td>
|
</td>
|
||||||
@stack('price_td_end')
|
@stack('price_td_end')
|
||||||
|
@ -161,11 +161,13 @@
|
|||||||
var item_row = '{{ $item_row }}';
|
var item_row = '{{ $item_row }}';
|
||||||
|
|
||||||
$(document).on('click', '#button-add-item', function (e) {
|
$(document).on('click', '#button-add-item', function (e) {
|
||||||
|
var currency_code = $('#currency_code').val();
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '{{ url("incomes/invoices/addItem") }}',
|
url: '{{ url("incomes/invoices/addItem") }}',
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
dataType: 'JSON',
|
dataType: 'JSON',
|
||||||
data: {item_row: item_row, currency_code : $('#currency_code').val()},
|
data: {item_row: item_row, currency_code : currency_code},
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
if (json['success']) {
|
if (json['success']) {
|
||||||
$('#items tbody #addItem').before(json['html']);
|
$('#items tbody #addItem').before(json['html']);
|
||||||
@ -371,6 +373,11 @@
|
|||||||
$('#currency_rate').val(data.currency_rate);
|
$('#currency_rate').val(data.currency_rate);
|
||||||
|
|
||||||
$('.input-price').each(function(){
|
$('.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];
|
amount = $(this).maskMoney('unmasked')[0];
|
||||||
|
|
||||||
$(this).maskMoney({
|
$(this).maskMoney({
|
||||||
@ -401,13 +408,6 @@
|
|||||||
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'),
|
||||||
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
||||||
before: function () {
|
|
||||||
$('.input-price').each(function(){
|
|
||||||
amount = $(this).maskMoney('unmasked')[0];
|
|
||||||
|
|
||||||
$(this).val(amount);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
$.each( data.items, function( key, value ) {
|
$.each( data.items, function( key, value ) {
|
||||||
@ -422,6 +422,11 @@
|
|||||||
$('#grand-total').html(data.grand_total);
|
$('#grand-total').html(data.grand_total);
|
||||||
|
|
||||||
$('.input-price').each(function(){
|
$('.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];
|
amount = $(this).maskMoney('unmasked')[0];
|
||||||
|
|
||||||
$(this).maskMoney({
|
$(this).maskMoney({
|
||||||
|
@ -142,11 +142,13 @@
|
|||||||
var item_row = '{{ $item_row }}';
|
var item_row = '{{ $item_row }}';
|
||||||
|
|
||||||
$(document).on('click', '#button-add-item', function (e) {
|
$(document).on('click', '#button-add-item', function (e) {
|
||||||
|
var currency_code = $('#currency_code').val();
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '{{ url("incomes/invoices/addItem") }}',
|
url: '{{ url("incomes/invoices/addItem") }}',
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
dataType: 'JSON',
|
dataType: 'JSON',
|
||||||
data: {item_row: item_row},
|
data: {item_row: item_row, currency_code : currency_code},
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
if (json['success']) {
|
if (json['success']) {
|
||||||
$('#items tbody #addItem').before(json['html']);
|
$('#items tbody #addItem').before(json['html']);
|
||||||
@ -379,6 +381,11 @@
|
|||||||
$('#currency_rate').val(data.currency_rate);
|
$('#currency_rate').val(data.currency_rate);
|
||||||
|
|
||||||
$('.input-price').each(function(){
|
$('.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];
|
amount = $(this).maskMoney('unmasked')[0];
|
||||||
|
|
||||||
$(this).maskMoney({
|
$(this).maskMoney({
|
||||||
@ -403,12 +410,11 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
function totalItem() {
|
function totalItem() {
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
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'),
|
||||||
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -424,6 +430,11 @@
|
|||||||
$('#grand-total').html(data.grand_total);
|
$('#grand-total').html(data.grand_total);
|
||||||
|
|
||||||
$('.input-price').each(function(){
|
$('.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];
|
amount = $(this).maskMoney('unmasked')[0];
|
||||||
|
|
||||||
$(this).maskMoney({
|
$(this).maskMoney({
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
<td>
|
<td>
|
||||||
@stack('price_input_start')
|
@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="{{ 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')
|
@stack('price_input_end')
|
||||||
</td>
|
</td>
|
||||||
@stack('price_td_end')
|
@stack('price_td_end')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user