From 1c8bcd8cb2c7ec15d97ad043223f1b352456ecf0 Mon Sep 17 00:00:00 2001 From: denisdulici Date: Mon, 30 Apr 2018 11:49:47 +0300 Subject: [PATCH] decimal quantity --- app/Http/Controllers/Expenses/Bills.php | 12 +++--- app/Http/Controllers/Incomes/Invoices.php | 12 +++--- app/Http/Controllers/Items/Items.php | 2 +- composer.json | 1 + ...nge_quantity_column_invoice_bill_items.php | 38 +++++++++++++++++++ .../views/expenses/bills/create.blade.php | 10 ++--- resources/views/expenses/bills/edit.blade.php | 14 +++---- .../views/expenses/payments/create.blade.php | 2 +- .../views/expenses/payments/edit.blade.php | 2 +- .../views/incomes/invoices/create.blade.php | 10 ++--- .../views/incomes/invoices/edit.blade.php | 14 +++---- .../views/incomes/revenues/create.blade.php | 2 +- .../views/incomes/revenues/edit.blade.php | 2 +- resources/views/items/items/create.blade.php | 4 +- resources/views/items/items/edit.blade.php | 4 +- 15 files changed, 84 insertions(+), 45 deletions(-) create mode 100644 database/migrations/2018_04_30_000000_change_quantity_column_invoice_bill_items.php diff --git a/app/Http/Controllers/Expenses/Bills.php b/app/Http/Controllers/Expenses/Bills.php index 7bfc98a0c..ecb0594c1 100644 --- a/app/Http/Controllers/Expenses/Bills.php +++ b/app/Http/Controllers/Expenses/Bills.php @@ -178,7 +178,7 @@ class Bills extends Controller $tax_id = $item['tax_id']; - $tax = (($item['price'] * $item['quantity']) / 100) * $tax_object->rate; + $tax = (((double) $item['price'] * (double) $item['quantity']) / 100) * $tax_object->rate; // Apply discount to tax if ($discount) { @@ -189,11 +189,11 @@ class Bills extends Controller $bill_item['item_id'] = $item['item_id']; $bill_item['name'] = str_limit($item['name'], 180, ''); $bill_item['sku'] = $item_sku; - $bill_item['quantity'] = $item['quantity']; + $bill_item['quantity'] = (double) $item['quantity']; $bill_item['price'] = (double) $item['price']; $bill_item['tax'] = $tax; $bill_item['tax_id'] = $tax_id; - $bill_item['total'] = (double) $item['price'] * $item['quantity']; + $bill_item['total'] = (double) $item['price'] * (double) $item['quantity']; BillItem::create($bill_item); @@ -385,7 +385,7 @@ class Bills extends Controller $tax_id = $item['tax_id']; - $tax = (($item['price'] * $item['quantity']) / 100) * $tax_object->rate; + $tax = (((double) $item['price'] * (double) $item['quantity']) / 100) * $tax_object->rate; // Apply discount to tax if ($discount) { @@ -396,11 +396,11 @@ class Bills extends Controller $bill_item['item_id'] = $item['item_id']; $bill_item['name'] = str_limit($item['name'], 180, ''); $bill_item['sku'] = $item_sku; - $bill_item['quantity'] = $item['quantity']; + $bill_item['quantity'] = (double) $item['quantity']; $bill_item['price'] = (double) $item['price']; $bill_item['tax'] = $tax; $bill_item['tax_id'] = $tax_id; - $bill_item['total'] = (double) $item['price'] * $item['quantity']; + $bill_item['total'] = (double) $item['price'] * (double) $item['quantity']; if (isset($tax_object)) { if (array_key_exists($tax_object->id, $taxes)) { diff --git a/app/Http/Controllers/Incomes/Invoices.php b/app/Http/Controllers/Incomes/Invoices.php index 8398304f3..f56140581 100644 --- a/app/Http/Controllers/Incomes/Invoices.php +++ b/app/Http/Controllers/Incomes/Invoices.php @@ -193,7 +193,7 @@ class Invoices extends Controller $tax_id = $item['tax_id']; - $tax = (($item['price'] * $item['quantity']) / 100) * $tax_object->rate; + $tax = (((double) $item['price'] * (double) $item['quantity']) / 100) * $tax_object->rate; // Apply discount to tax if ($discount) { @@ -204,11 +204,11 @@ class Invoices extends Controller $invoice_item['item_id'] = $item['item_id']; $invoice_item['name'] = str_limit($item['name'], 180, ''); $invoice_item['sku'] = $item_sku; - $invoice_item['quantity'] = $item['quantity']; + $invoice_item['quantity'] = (double) $item['quantity']; $invoice_item['price'] = (double) $item['price']; $invoice_item['tax'] = $tax; $invoice_item['tax_id'] = $tax_id; - $invoice_item['total'] = (double) $item['price'] * $item['quantity']; + $invoice_item['total'] = (double) $item['price'] * (double) $item['quantity']; InvoiceItem::create($invoice_item); @@ -406,7 +406,7 @@ class Invoices extends Controller $tax_id = $item['tax_id']; - $tax = (($item['price'] * $item['quantity']) / 100) * $tax_object->rate; + $tax = (((double) $item['price'] * (double) $item['quantity']) / 100) * $tax_object->rate; // Apply discount to tax if ($discount) { @@ -417,11 +417,11 @@ class Invoices extends Controller $invoice_item['item_id'] = $item['item_id']; $invoice_item['name'] = str_limit($item['name'], 180, ''); $invoice_item['sku'] = $item_sku; - $invoice_item['quantity'] = $item['quantity']; + $invoice_item['quantity'] = (double) $item['quantity']; $invoice_item['price'] = (double) $item['price']; $invoice_item['tax'] = $tax; $invoice_item['tax_id'] = $tax_id; - $invoice_item['total'] = (double) $item['price'] * $item['quantity']; + $invoice_item['total'] = (double) $item['price'] * (double) $item['quantity']; if (isset($tax_object)) { if (array_key_exists($tax_object->id, $taxes)) { diff --git a/app/Http/Controllers/Items/Items.php b/app/Http/Controllers/Items/Items.php index e1227a7ce..be9105e93 100644 --- a/app/Http/Controllers/Items/Items.php +++ b/app/Http/Controllers/Items/Items.php @@ -262,7 +262,7 @@ class Items extends Controller if ($input_items) { foreach ($input_items as $key => $item) { $price = (double) $item['price']; - $quantity = (int) $item['quantity']; + $quantity = (double) $item['quantity']; $item_tax_total= 0; $item_sub_total = ($price * $quantity); diff --git a/composer.json b/composer.json index 5c2b55bf0..bb0ceebda 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,7 @@ "bkwld/cloner": "3.2.*", "consoletvs/charts": "4.6.*", "dingo/api": "1.0.0-beta8", + "doctrine/dbal": "2.5.*", "fideloper/proxy": "3.3.*", "guzzlehttp/guzzle": "6.3.*", "intervention/image": "2.3.*", diff --git a/database/migrations/2018_04_30_000000_change_quantity_column_invoice_bill_items.php b/database/migrations/2018_04_30_000000_change_quantity_column_invoice_bill_items.php new file mode 100644 index 000000000..1580e564e --- /dev/null +++ b/database/migrations/2018_04_30_000000_change_quantity_column_invoice_bill_items.php @@ -0,0 +1,38 @@ +double('quantity', 7, 2)->change(); + }); + + Schema::table('bill_items', function ($table) { + $table->double('quantity', 7, 2)->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('invoice_items', function ($table) { + $table->integer('quantity')->change(); + }); + + Schema::table('bill_items', function ($table) { + $table->integer('quantity')->change(); + }); + } +} diff --git a/resources/views/expenses/bills/create.blade.php b/resources/views/expenses/bills/create.blade.php index 89a9879e6..141b8e06e 100644 --- a/resources/views/expenses/bills/create.blade.php +++ b/resources/views/expenses/bills/create.blade.php @@ -31,7 +31,7 @@ {{ Form::textGroup('order_number', trans('bills.order_number'), 'shopping-cart',[]) }}
- {!! Form::label('items', trans_choice('general.items', 1), ['class' => 'control-label']) !!} + {!! Form::label('items', trans_choice('general.items', 2), ['class' => 'control-label']) !!}
@@ -55,10 +55,10 @@ '; html += ' '; html += ' '; html += '
- + - + {!! Form::select('item[' . $item_row . '][tax_id]', $taxes, setting('general.default_tax'), ['id'=> 'item-tax-'. $item_row, 'class' => 'form-control tax-select2', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)])]) !!} @@ -153,10 +153,10 @@ html += ' '; html += ' '; - html += ' '; + html += ' '; html += ' '; - html += ' '; + html += ' '; html += ' '; html += ' @@ -46,10 +46,10 @@ '; html += ' '; html += ' '; html += '
- + - + {!! Form::select('item[' . $item_row . '][tax_id]', $taxes, $item->tax_id, ['id'=> 'item-tax-'. $item_row, 'class' => 'form-control select2', 'placeholder' => trans('general.form.enter', ['field' => trans_choice('general.taxes', 1)])]) !!} @@ -70,10 +70,10 @@ - + - + {!! Form::select('item[' . $item_row . '][tax_id]', $taxes, null, ['id'=> 'item-tax-'. $item_row, 'class' => 'form-control tax-select2', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)])]) !!} @@ -159,10 +159,10 @@ html += ' '; html += ' '; - html += ' '; + html += ' '; html += ' '; - html += ' '; + html += ' '; html += ' '; html += ' @@ -55,10 +55,10 @@ '; html += ' '; html += ' '; html += '
- + - + {!! Form::select('item[' . $item_row . '][tax_id]', $taxes, setting('general.default_tax'), ['id'=> 'item-tax-'. $item_row, 'class' => 'form-control tax-select2', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)])]) !!} @@ -154,10 +154,10 @@ html += ' '; html += ' '; - html += ' '; + html += ' '; html += ' '; - html += ' '; + html += ' '; html += ' '; html += ' @@ -45,10 +45,10 @@ '; html += ' '; html += ' '; html += '
- + - + {!! Form::select('item[' . $item_row . '][tax_id]', $taxes, $item->tax_id, ['id'=> 'item-tax-'. $item_row, 'class' => 'form-control tax-select2', 'placeholder' => trans('general.form.enter', ['field' => trans_choice('general.taxes', 1)])]) !!} @@ -69,10 +69,10 @@ - + - + {!! Form::select('item[' . $item_row . '][tax_id]', $taxes, null, ['id'=> 'item-tax-'. $item_row, 'class' => 'form-control select2', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)])]) !!} @@ -158,10 +158,10 @@ html += ' '; html += ' '; - html += ' '; + html += ' '; html += ' '; - html += ' '; + html += ' '; html += ' '; html += '