close #799 Fixed: Customer Login - Invoice Sorting not working
This commit is contained in:
@ -6,7 +6,6 @@ use App\Http\Controllers\Controller;
|
||||
use App\Events\InvoicePrinting;
|
||||
use App\Models\Banking\Account;
|
||||
use App\Models\Income\Customer;
|
||||
use App\Models\Income\Revenue;
|
||||
use App\Models\Income\Invoice;
|
||||
use App\Models\Income\InvoiceStatus;
|
||||
use App\Models\Setting\Category;
|
||||
@ -33,12 +32,18 @@ class Invoices extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$invoices = Invoice::with('status')->accrued()->where('customer_id', auth()->user()->customer->id)->paginate();
|
||||
$invoices = Invoice::with(['customer', 'status', 'items', 'payments', 'histories'])
|
||||
->accrued()->where('customer_id', auth()->user()->customer->id)
|
||||
->collect(['invoice_number'=> 'desc']);
|
||||
|
||||
$status = collect(InvoiceStatus::all()->pluck('name', 'code'))
|
||||
->prepend(trans('general.all_type', ['type' => trans_choice('general.statuses', 2)]), '');
|
||||
$categories = collect(Category::enabled()->type('income')->orderBy('name')->pluck('name', 'id'));
|
||||
|
||||
return view('customers.invoices.index', compact('invoices', 'status'));
|
||||
$statuses = collect(InvoiceStatus::get()->each(function ($item) {
|
||||
$item->name = trans('invoices.status.' . $item->code);
|
||||
return $item;
|
||||
})->pluck('name', 'code'));
|
||||
|
||||
return view('customers.invoices.index', compact('invoices', 'categories', 'statuses'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,31 +55,15 @@ class Invoices extends Controller
|
||||
*/
|
||||
public function show(Invoice $invoice)
|
||||
{
|
||||
$paid = 0;
|
||||
$accounts = Account::enabled()->orderBy('name')->pluck('name', 'id');
|
||||
|
||||
foreach ($invoice->payments as $item) {
|
||||
$amount = $item->amount;
|
||||
|
||||
if ($invoice->currency_code != $item->currency_code) {
|
||||
$item->default_currency_code = $invoice->currency_code;
|
||||
|
||||
$amount = $item->getDynamicConvertedAmount();
|
||||
}
|
||||
|
||||
$paid += $amount;
|
||||
}
|
||||
|
||||
$invoice->paid = $paid;
|
||||
|
||||
$accounts = Account::enabled()->pluck('name', 'id');
|
||||
|
||||
$currencies = Currency::enabled()->pluck('name', 'code')->toArray();
|
||||
$currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code')->toArray();
|
||||
|
||||
$account_currency_code = Account::where('id', setting('general.default_account'))->pluck('currency_code')->first();
|
||||
|
||||
$customers = Customer::enabled()->pluck('name', 'id');
|
||||
$customers = Customer::enabled()->orderBy('name')->pluck('name', 'id');
|
||||
|
||||
$categories = Category::enabled()->type('income')->pluck('name', 'id');
|
||||
$categories = Category::enabled()->type('income')->orderBy('name')->pluck('name', 'id');
|
||||
|
||||
$payment_methods = Modules::getPaymentMethods();
|
||||
|
||||
@ -106,7 +95,9 @@ class Invoices extends Controller
|
||||
{
|
||||
$invoice = $this->prepareInvoice($invoice);
|
||||
|
||||
$view = view($invoice->template_path, compact('invoice'))->render();
|
||||
$currency_style = true;
|
||||
|
||||
$view = view($invoice->template_path, compact('invoice', 'currency_style'))->render();
|
||||
$html = mb_convert_encoding($view, 'HTML-ENTITIES');
|
||||
|
||||
$pdf = \App::make('dompdf.wrapper');
|
||||
|
Reference in New Issue
Block a user