diff --git a/app/Http/Controllers/Expenses/Bills.php b/app/Http/Controllers/Expenses/Bills.php index d314b4e90..5c7a99c66 100644 --- a/app/Http/Controllers/Expenses/Bills.php +++ b/app/Http/Controllers/Expenses/Bills.php @@ -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; diff --git a/app/Http/Controllers/Incomes/Invoices.php b/app/Http/Controllers/Incomes/Invoices.php index d8849096f..250ee3012 100644 --- a/app/Http/Controllers/Incomes/Invoices.php +++ b/app/Http/Controllers/Incomes/Invoices.php @@ -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);