diff --git a/app/Http/Controllers/Common/Items.php b/app/Http/Controllers/Common/Items.php index 0f0d09eb9..dda60fb07 100644 --- a/app/Http/Controllers/Common/Items.php +++ b/app/Http/Controllers/Common/Items.php @@ -234,8 +234,8 @@ class Items extends Controller */ public function export() { - \Excel::create('items', function($excel) { - $excel->sheet('items', function($sheet) { + \Excel::create('items', function ($excel) { + $excel->sheet('items', function ($sheet) { $sheet->fromModel(Item::filter(request()->input())->get()->makeHidden([ 'id', 'company_id', 'item_id', 'created_at', 'updated_at', 'deleted_at' ])); @@ -315,7 +315,7 @@ class Items extends Controller if ($input_items) { foreach ($input_items as $key => $item) { - $price = (double) $item['price']; + $price = money($item['price'], $currency_code)->getAmount(); $quantity = (double) $item['quantity']; $item_tax_total= 0; diff --git a/app/Http/Controllers/Expenses/Bills.php b/app/Http/Controllers/Expenses/Bills.php index 4b25f6513..9521f19eb 100644 --- a/app/Http/Controllers/Expenses/Bills.php +++ b/app/Http/Controllers/Expenses/Bills.php @@ -142,7 +142,6 @@ class Bills extends Controller $bill_item = []; $bill_item['company_id'] = $request['company_id']; $bill_item['bill_id'] = $bill->id; - $bill_item['currency_code'] = $request['currency_code']; if ($request['item']) { foreach ($request['item'] as $item) { @@ -357,7 +356,6 @@ class Bills extends Controller $bill_item = []; $bill_item['company_id'] = $request['company_id']; $bill_item['bill_id'] = $bill->id; - $bill_item['currency_code'] = $request['currency_code']; if ($request['item']) { BillItem::where('bill_id', $bill->id)->delete(); @@ -757,7 +755,6 @@ class Bills extends Controller 'code' => 'sub_total', 'name' => 'bills.sub_total', 'amount' => $sub_total, - 'currency_code' => $bill->currency_code, 'sort_order' => $sort_order, ]); @@ -771,7 +768,6 @@ class Bills extends Controller 'code' => 'discount', 'name' => 'bills.discount', 'amount' => $discount_total, - 'currency_code' => $bill->currency_code, 'sort_order' => $sort_order, ]); @@ -790,7 +786,6 @@ class Bills extends Controller 'code' => 'tax', 'name' => $tax['name'], 'amount' => $tax['amount'], - 'currency_code' => $bill->currency_code, 'sort_order' => $sort_order, ]); @@ -805,7 +800,6 @@ class Bills extends Controller 'code' => 'total', 'name' => 'bills.total', 'amount' => $sub_total + $tax_total, - 'currency_code' => $bill->currency_code, 'sort_order' => $sort_order, ]); } diff --git a/app/Http/Controllers/Incomes/Invoices.php b/app/Http/Controllers/Incomes/Invoices.php index 044a2c670..8b63402ad 100644 --- a/app/Http/Controllers/Incomes/Invoices.php +++ b/app/Http/Controllers/Incomes/Invoices.php @@ -229,7 +229,9 @@ class Invoices extends Controller $s_total = $s_total - $s_discount; } - $request['amount'] = $s_total + $tax_total; + $amount = $s_total + $tax_total; + + $request['amount'] = money($amount, $request['currency_code'])->getAmount(); $invoice->update($request->input()); @@ -441,7 +443,9 @@ class Invoices extends Controller $s_total = $s_total - $s_discount; } - $request['amount'] = $s_total + $tax_total; + $amount = $s_total + $tax_total; + + $request['amount'] = money($amount, $request['currency_code'])->getAmount(); $invoice->update($request->input()); @@ -524,6 +528,7 @@ class Invoices extends Controller $hidden_fields = ['id', 'company_id', 'created_at', 'updated_at', 'deleted_at', 'title']; $i = 1; + foreach ($invoices as $invoice) { $model = $invoice->$table->makeHidden($hidden_fields); @@ -750,7 +755,7 @@ class Invoices extends Controller for ($i = 0; $i < $currency->precision; $i++) { $multiplier *= 10; } - + $amount *= $multiplier; $total_amount *= $multiplier;