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;
foreach ($bill->payments as $item) {
$item->default_currency_code = $bill->currency_code;
$amount = $item->amount;
$paid += $item->getDynamicConvertedAmount();
if ($bill->currency_code != $item->currency_code) {
$item->default_currency_code = $bill->currency_code;
$amount = $item->getDynamicConvertedAmount();
}
$paid += $amount;
}
$bill->paid = $paid;
@ -607,7 +613,7 @@ class Bills extends Controller
for ($i = 0; $i < $currency->precision; $i++) {
$multiplier *= 10;
}
$amount *= $multiplier;
$total_amount *= $multiplier;
@ -713,9 +719,15 @@ class Bills extends Controller
$paid = 0;
foreach ($bill->payments as $item) {
$item->default_currency_code = $bill->currency_code;
$amount = $item->amount;
$paid += $item->getDynamicConvertedAmount();
if ($bill->currency_code != $item->currency_code) {
$item->default_currency_code = $bill->currency_code;
$amount = $item->getDynamicConvertedAmount();
}
$paid += $amount;
}
$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['currency_code'] = $invoice->currency_code;
$request['amount'] = $amount;
$request['paid_at'] = Date::now();
$request['paid_at'] = Date::now()->format('Y-m-d');
$request['_token'] = csrf_token();
$this->payment($request);