Merge pull request #1161 from burakcakirel/show-grand-total-for-bills-invoices

Show grand total for bills/invoices
This commit is contained in:
Cüneyt Şentürk 2020-02-09 12:13:02 +03:00 committed by GitHub
commit 5aef495563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 2 deletions

View File

@ -13,6 +13,7 @@ use App\Jobs\Purchase\DeleteBill;
use App\Jobs\Purchase\DuplicateBill;
use App\Jobs\Purchase\UpdateBill;
use App\Models\Banking\Account;
use App\Models\Banking\Transaction;
use App\Models\Common\Contact;
use App\Models\Common\Item;
use App\Models\Purchase\Bill;
@ -73,6 +74,19 @@ class Bills extends Controller
$date_format = $this->getCompanyDateFormat();
// Get Bill Totals
foreach ($bill->totals as $bill_total) {
$bill->{$bill_total->code} = $bill_total->amount;
}
$total = money($bill->total, $currency->code, true)->format();
$bill->grand_total = money($total, $currency->code)->getAmount();
if (!empty($bill->paid)) {
$bill->grand_total = round($bill->total - $bill->paid, $currency->precision) ;
}
return view('purchases.bills.show', compact('bill', 'accounts', 'currencies', 'currency', 'account_currency_code', 'vendors', 'categories', 'payment_methods', 'date_format'));
}

View File

@ -13,6 +13,7 @@ use App\Jobs\Sale\DeleteInvoice;
use App\Jobs\Sale\DuplicateInvoice;
use App\Jobs\Sale\UpdateInvoice;
use App\Models\Banking\Account;
use App\Models\Banking\Transaction;
use App\Models\Common\Contact;
use App\Models\Common\Item;
use App\Models\Sale\Invoice;
@ -77,6 +78,19 @@ class Invoices extends Controller
$date_format = $this->getCompanyDateFormat();
// Get Invoice Totals
foreach ($invoice->totals as $invoice_total) {
$invoice->{$invoice_total->code} = $invoice_total->amount;
}
$total = money($invoice->total, $currency->code, true)->format();
$invoice->grand_total = money($total, $currency->code)->getAmount();
if (!empty($invoice->paid)) {
$invoice->grand_total = round($invoice->total - $invoice->paid, $currency->precision);
}
return view('sales.invoices.show', compact('invoice', 'accounts', 'currencies', 'currency', 'account_currency_code', 'customers', 'categories', 'payment_methods', 'signed_url', 'date_format'));
}

View File

@ -206,7 +206,6 @@ const app = new Vue({
this.transaction_form.paid_at = form.paid_at;
this.transaction_form.account_id = form.account_id;
this.transaction_form.payment_method = form.payment_method;
this.transaction_form.amount = form.amount;
},
addPayment() {

View File

@ -206,7 +206,6 @@ const app = new Vue({
this.transaction_form.paid_at = form.paid_at;
this.transaction_form.account_id = form.account_id;
this.transaction_form.payment_method = form.payment_method;
this.transaction_form.amount = form.amount;
},
addPayment() {