Skip to content

Commit

Permalink
close #1336 Fixed: Wrong amount sent to backend
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Mar 9, 2020
1 parent 27b12da commit de0d74b
Showing 1 changed file with 3 additions and 26 deletions.
29 changes: 3 additions & 26 deletions app/Http/Middleware/Money.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,10 @@ public function handle($request, Closure $next)
$sale_price = $request->get('sale_price');
$purchase_price = $request->get('purchase_price');
$opening_balance = $request->get('opening_balance');
$currency_code = $request->get('currency_code');
$items = $request->get('items');

if (empty($currency_code)) {
$currency_code = setting('default.currency');
}

if (!empty($amount)) {
$amount = money($request->get('amount'), $currency_code)->getAmount();
$amount = money($amount)->getAmount();

$request->request->set('amount', $amount);
}
Expand All @@ -42,36 +37,18 @@ public function handle($request, Closure $next)
continue;
}

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();
}
$items[$key]['price'] = money($item['price'])->getAmount();
}

$request->request->set('items', $items);
}
}

if (isset($opening_balance)) {
$opening_balance = money($opening_balance, $currency_code)->getAmount();
$opening_balance = money($opening_balance)->getAmount();

$request->request->set('opening_balance', $opening_balance);
}

/* check item price use money
if (isset($sale_price)) {
$sale_price = money($sale_price, $currency_code)->getAmount();
$request->request->set('sale_price', $sale_price);
}
if (isset($purchase_price)) {
$purchase_price = money($purchase_price, $currency_code)->getAmount();
$request->request->set('purchase_price', $purchase_price);
}
*/
}

return $next($request);
Expand Down

0 comments on commit de0d74b

Please sign in to comment.