refs #451 Invoice item currency
This commit is contained in:
parent
398c8d38a6
commit
4594bc6a72
@ -755,7 +755,7 @@ class Bills extends Controller
|
||||
// it should be integer for amount mask
|
||||
$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([
|
||||
'success' => true,
|
||||
|
@ -892,7 +892,7 @@ class Invoices extends Controller
|
||||
// it should be integer for amount mask
|
||||
$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([
|
||||
'success' => true,
|
||||
|
@ -38,7 +38,11 @@ class Money
|
||||
if (isset($bill_number) || isset($invoice_number) || !empty($items)) {
|
||||
if (!empty($items)) {
|
||||
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);
|
||||
|
@ -25,6 +25,7 @@
|
||||
<td>
|
||||
@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="{{ $currency->code }}" name="item[{{ $item_row }}][currency]" type="hidden" id="item-currency-{{ $item_row }}">
|
||||
@stack('price_input_end')
|
||||
</td>
|
||||
@stack('price_td_end')
|
||||
|
@ -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({
|
||||
|
@ -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']);
|
||||
@ -403,12 +405,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 +425,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({
|
||||
|
@ -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')
|
||||
|
Loading…
x
Reference in New Issue
Block a user