refs #451 Items
This commit is contained in:
parent
b2e25990a1
commit
398c8d38a6
@ -365,6 +365,19 @@ class Items extends Controller
|
|||||||
|
|
||||||
$json->grand_total = money($grand_total, $currency_code, true)->format();
|
$json->grand_total = money($grand_total, $currency_code, true)->format();
|
||||||
|
|
||||||
|
// Get currency object
|
||||||
|
$currency = Currency::where('code', $currency_code)->first();
|
||||||
|
|
||||||
|
$json->currency_name = $currency->name;
|
||||||
|
$json->currency_code = $currency_code;
|
||||||
|
$json->currency_rate = $currency->rate;
|
||||||
|
|
||||||
|
$json->thousands_separator = $currency->thousands_separator;
|
||||||
|
$json->decimal_mark = $currency->decimal_mark;
|
||||||
|
$json->precision = (int) $currency->precision;
|
||||||
|
$json->symbol_first = $currency->symbol_first;
|
||||||
|
$json->symbol = $currency->symbol;
|
||||||
|
|
||||||
return response()->json($json);
|
return response()->json($json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ class Money
|
|||||||
$purchase_price = $request->get('purchase_price');
|
$purchase_price = $request->get('purchase_price');
|
||||||
$opening_balance = $request->get('opening_balance');
|
$opening_balance = $request->get('opening_balance');
|
||||||
$currency_code = $request->get('currency_code');
|
$currency_code = $request->get('currency_code');
|
||||||
|
$items = $request->get('item');
|
||||||
|
|
||||||
if (empty($currency_code)) {
|
if (empty($currency_code)) {
|
||||||
$currency_code = setting('general.default_currency');
|
$currency_code = setting('general.default_currency');
|
||||||
@ -34,9 +35,7 @@ class Money
|
|||||||
$request->request->set('amount', $amount);
|
$request->request->set('amount', $amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($bill_number) || isset($invoice_number)) {
|
if (isset($bill_number) || isset($invoice_number) || !empty($items)) {
|
||||||
$items = $request->get('item');
|
|
||||||
|
|
||||||
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();
|
$items[$key]['price'] = money($item['price'], $currency_code)->getAmount();
|
||||||
|
@ -285,6 +285,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);
|
||||||
@ -400,6 +401,13 @@
|
|||||||
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 ) {
|
||||||
@ -412,6 +420,23 @@
|
|||||||
$('#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(){
|
||||||
|
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');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -293,6 +293,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);
|
||||||
@ -402,6 +403,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
function totalItem() {
|
function totalItem() {
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '{{ url("common/items/totalItem") }}',
|
url: '{{ url("common/items/totalItem") }}',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
@ -420,6 +422,23 @@
|
|||||||
$('#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(){
|
||||||
|
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');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -22,7 +22,7 @@ Route::group(['middleware' => 'language'], function () {
|
|||||||
Route::get('dashboard/cashflow', 'Common\Dashboard@cashFlow')->name('dashboard.cashflow');
|
Route::get('dashboard/cashflow', 'Common\Dashboard@cashFlow')->name('dashboard.cashflow');
|
||||||
Route::get('import/{group}/{type}', 'Common\Import@create')->name('import.create');
|
Route::get('import/{group}/{type}', 'Common\Import@create')->name('import.create');
|
||||||
Route::get('items/autocomplete', 'Common\Items@autocomplete')->name('items.autocomplete');
|
Route::get('items/autocomplete', 'Common\Items@autocomplete')->name('items.autocomplete');
|
||||||
Route::post('items/totalItem', 'Common\Items@totalItem')->name('items.total');
|
Route::post('items/totalItem', 'Common\Items@totalItem')->middleware(['money'])->name('items.total');
|
||||||
Route::get('items/{item}/duplicate', 'Common\Items@duplicate')->name('items.duplicate');
|
Route::get('items/{item}/duplicate', 'Common\Items@duplicate')->name('items.duplicate');
|
||||||
Route::post('items/import', 'Common\Items@import')->name('items.import');
|
Route::post('items/import', 'Common\Items@import')->name('items.import');
|
||||||
Route::get('items/export', 'Common\Items@export')->name('items.export');
|
Route::get('items/export', 'Common\Items@export')->name('items.export');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user