Skip to content

Commit

Permalink
close #434 Fixed: Cannot Import Data
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Aug 7, 2018
1 parent 9d80298 commit 36df336
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions app/Http/Controllers/Common/Items.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ public function destroy(Item $item)
*/
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'
]));
Expand Down Expand Up @@ -315,7 +315,7 @@ public function totalItem()

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;
Expand Down
6 changes: 0 additions & 6 deletions app/Http/Controllers/Expenses/Bills.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ public function store(Request $request)
$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) {
Expand Down Expand Up @@ -357,7 +356,6 @@ public function update(Bill $bill, Request $request)
$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();
Expand Down Expand Up @@ -757,7 +755,6 @@ protected function addTotals($bill, $request, $taxes, $sub_total, $discount_tota
'code' => 'sub_total',
'name' => 'bills.sub_total',
'amount' => $sub_total,
'currency_code' => $bill->currency_code,
'sort_order' => $sort_order,
]);

Expand All @@ -771,7 +768,6 @@ protected function addTotals($bill, $request, $taxes, $sub_total, $discount_tota
'code' => 'discount',
'name' => 'bills.discount',
'amount' => $discount_total,
'currency_code' => $bill->currency_code,
'sort_order' => $sort_order,
]);

Expand All @@ -790,7 +786,6 @@ protected function addTotals($bill, $request, $taxes, $sub_total, $discount_tota
'code' => 'tax',
'name' => $tax['name'],
'amount' => $tax['amount'],
'currency_code' => $bill->currency_code,
'sort_order' => $sort_order,
]);

Expand All @@ -805,7 +800,6 @@ protected function addTotals($bill, $request, $taxes, $sub_total, $discount_tota
'code' => 'total',
'name' => 'bills.total',
'amount' => $sub_total + $tax_total,
'currency_code' => $bill->currency_code,
'sort_order' => $sort_order,
]);
}
Expand Down
11 changes: 8 additions & 3 deletions app/Http/Controllers/Incomes/Invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ public function store(Request $request)
$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());

Expand Down Expand Up @@ -441,7 +443,9 @@ public function update(Invoice $invoice, Request $request)
$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());

Expand Down Expand Up @@ -524,6 +528,7 @@ public function export()
$hidden_fields = ['id', 'company_id', 'created_at', 'updated_at', 'deleted_at', 'title'];

$i = 1;

foreach ($invoices as $invoice) {
$model = $invoice->$table->makeHidden($hidden_fields);

Expand Down Expand Up @@ -750,7 +755,7 @@ public function payment(PaymentRequest $request)
for ($i = 0; $i < $currency->precision; $i++) {
$multiplier *= 10;
}

$amount *= $multiplier;
$total_amount *= $multiplier;

Expand Down

0 comments on commit 36df336

Please sign in to comment.