close #421 Fixed: Payments for expenses, wrong calculation error

This commit is contained in:
cuneytsenturk 2018-07-18 16:28:56 +03:00
parent 9c9a85150f
commit 968c0b2016
2 changed files with 18 additions and 6 deletions

View File

@ -66,9 +66,15 @@ class Bills extends Controller
$paid = 0; $paid = 0;
foreach ($bill->payments as $item) { foreach ($bill->payments as $item) {
$amount = $item->amount;
if ($bill->currency_code != $item->currency_code) {
$item->default_currency_code = $bill->currency_code; $item->default_currency_code = $bill->currency_code;
$paid += $item->getDynamicConvertedAmount(); $amount = $item->getDynamicConvertedAmount();
}
$paid += $amount;
} }
$bill->paid = $paid; $bill->paid = $paid;
@ -713,9 +719,15 @@ class Bills extends Controller
$paid = 0; $paid = 0;
foreach ($bill->payments as $item) { foreach ($bill->payments as $item) {
$amount = $item->amount;
if ($bill->currency_code != $item->currency_code) {
$item->default_currency_code = $bill->currency_code; $item->default_currency_code = $bill->currency_code;
$paid += $item->getDynamicConvertedAmount(); $amount = $item->getDynamicConvertedAmount();
}
$paid += $amount;
} }
$bill->paid = $paid; $bill->paid = $paid;

View File

@ -691,7 +691,7 @@ class Invoices extends Controller
$request['payment_method'] = setting('general.default_payment_method', 'offlinepayment.cash.1'); $request['payment_method'] = setting('general.default_payment_method', 'offlinepayment.cash.1');
$request['currency_code'] = $invoice->currency_code; $request['currency_code'] = $invoice->currency_code;
$request['amount'] = $amount; $request['amount'] = $amount;
$request['paid_at'] = Date::now(); $request['paid_at'] = Date::now()->format('Y-m-d');
$request['_token'] = csrf_token(); $request['_token'] = csrf_token();
$this->payment($request); $this->payment($request);