close #581: Decimals problem for bill and invoice

This commit is contained in:
cuneytsenturk 2018-11-02 15:54:26 +03:00
parent c412f2c4ab
commit af95d9b552
2 changed files with 9 additions and 5 deletions

View File

@ -39,10 +39,10 @@ class BillPayments extends Controller
$currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code')->toArray(); $currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code')->toArray();
$currency = Currency::where('code', setting('general.default_currency'))->first();
$account_currency_code = Account::where('id', setting('general.default_account'))->pluck('currency_code')->first(); $account_currency_code = Account::where('id', setting('general.default_account'))->pluck('currency_code')->first();
$currency = Currency::where('code', $account_currency_code)->first();
$payment_methods = Modules::getPaymentMethods(); $payment_methods = Modules::getPaymentMethods();
$bill->paid = $this->getPaid($bill); $bill->paid = $this->getPaid($bill);
@ -52,7 +52,9 @@ class BillPayments extends Controller
$bill->{$bill_total->code} = $bill_total->amount; $bill->{$bill_total->code} = $bill_total->amount;
} }
$bill->grand_total = $bill->total; $total = money($bill->total, $currency->code, true)->format();
$bill->grand_total = money($total, $currency->code)->getAmount();
if (!empty($paid)) { if (!empty($paid)) {
$bill->grand_total = $bill->total - $paid; $bill->grand_total = $bill->total - $paid;

View File

@ -52,7 +52,9 @@ class InvoicePayments extends Controller
$invoice->{$invoice_total->code} = $invoice_total->amount; $invoice->{$invoice_total->code} = $invoice_total->amount;
} }
$invoice->grand_total = $invoice->total; $total = money($invoice->total, $currency->code, true)->format();
$invoice->grand_total = money($total, $currency->code)->getAmount();
if (!empty($paid)) { if (!empty($paid)) {
$invoice->grand_total = $invoice->total - $paid; $invoice->grand_total = $invoice->total - $paid;