diff --git a/app/Http/Controllers/Expenses/Bills.php b/app/Http/Controllers/Expenses/Bills.php index 7ee651476..12ff4da3e 100644 --- a/app/Http/Controllers/Expenses/Bills.php +++ b/app/Http/Controllers/Expenses/Bills.php @@ -391,8 +391,8 @@ class Bills extends Controller $multiplier *= 10; } - $amount *= $multiplier; - $total_amount *= $multiplier; + $amount_check = (int) ($amount * $multiplier); + $total_amount_check = (int) (round($total_amount, $currency->precision) * $multiplier); if ($amount > $total_amount) { $message = trans('messages.error.over_payment'); diff --git a/app/Http/Controllers/Incomes/Invoices.php b/app/Http/Controllers/Incomes/Invoices.php index 4d5a9c0d8..e442cf4b6 100644 --- a/app/Http/Controllers/Incomes/Invoices.php +++ b/app/Http/Controllers/Incomes/Invoices.php @@ -520,8 +520,8 @@ class Invoices extends Controller $multiplier *= 10; } - $amount *= $multiplier; - $total_amount *= $multiplier; + $amount_check = (int) ($amount * $multiplier); + $total_amount_check = (int) (round($total_amount, $currency->precision) * $multiplier); if ($amount > $total_amount) { $message = trans('messages.error.over_payment'); diff --git a/app/Http/Controllers/Modals/BillPayments.php b/app/Http/Controllers/Modals/BillPayments.php index bcf82c334..7f684d2cb 100644 --- a/app/Http/Controllers/Modals/BillPayments.php +++ b/app/Http/Controllers/Modals/BillPayments.php @@ -55,7 +55,7 @@ class BillPayments extends Controller $bill->grand_total = money($total, $currency->code)->getAmount(); if (!empty($paid)) { - $bill->grand_total = $bill->total - $paid; + $bill->grand_total = round($bill->total - $paid, $currency->precision) ; } $html = view('modals.bills.payment', compact('bill', 'accounts', 'currencies', 'currency', 'payment_methods'))->render(); @@ -121,8 +121,8 @@ class BillPayments extends Controller $multiplier *= 10; } - $amount_check = $amount * $multiplier; - $total_amount_check = $total_amount * $multiplier; + $amount_check = (int) ($amount * $multiplier); + $total_amount_check = (int) (round($total_amount, $currency->precision) * $multiplier); if ($amount_check > $total_amount_check) { $error_amount = $total_amount; diff --git a/app/Http/Controllers/Modals/InvoicePayments.php b/app/Http/Controllers/Modals/InvoicePayments.php index ce0214bf4..b8a4fcdf9 100644 --- a/app/Http/Controllers/Modals/InvoicePayments.php +++ b/app/Http/Controllers/Modals/InvoicePayments.php @@ -55,7 +55,7 @@ class InvoicePayments extends Controller $invoice->grand_total = money($total, $currency->code)->getAmount(); if (!empty($paid)) { - $invoice->grand_total = $invoice->total - $paid; + $invoice->grand_total = round($invoice->total - $paid, $currency->precision) ; } $html = view('modals.invoices.payment', compact('invoice', 'accounts', 'currencies', 'currency', 'payment_methods'))->render(); @@ -121,8 +121,8 @@ class InvoicePayments extends Controller $multiplier *= 10; } - $amount_check = $amount * $multiplier; - $total_amount_check = $total_amount * $multiplier; + $amount_check = (int) ($amount * $multiplier); + $total_amount_check = (int) (round($total_amount, $currency->precision) * $multiplier); if ($amount_check > $total_amount_check) { $error_amount = $total_amount; @@ -158,7 +158,7 @@ class InvoicePayments extends Controller 'message' => $message, 'html' => 'null', ]); - } elseif ($amount == $total_amount) { + } elseif ($amount_check == $total_amount_check) { $invoice->invoice_status_code = 'paid'; } else { $invoice->invoice_status_code = 'partial';