Skip to content

Commit

Permalink
Partial payment fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Batuhan Baş committed Feb 1, 2019
1 parent 941989d commit 69e456b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/Expenses/Bills.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ public function payment(PaymentRequest $request)
$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');
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Incomes/Invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,8 @@ public function payment(PaymentRequest $request)
$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');
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/Modals/BillPayments.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function create(Bill $bill)
$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();
Expand Down Expand Up @@ -121,8 +121,8 @@ public function store(Bill $bill, Request $request)
$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;
Expand Down
8 changes: 4 additions & 4 deletions app/Http/Controllers/Modals/InvoicePayments.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function create(Invoice $invoice)
$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();
Expand Down Expand Up @@ -121,8 +121,8 @@ public function store(Invoice $invoice, Request $request)
$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;
Expand Down Expand Up @@ -158,7 +158,7 @@ public function store(Invoice $invoice, Request $request)
'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';
Expand Down

0 comments on commit 69e456b

Please sign in to comment.