Compare commits
2 Commits
a56d67e1a1
...
d5be958de0
Author | SHA1 | Date | |
---|---|---|---|
d5be958de0 | |||
23a50ec6ec |
@ -350,13 +350,12 @@ class User extends Authenticatable implements IDs
|
||||
->select([
|
||||
'invoice_id',
|
||||
DB::raw('invoice_items.id AS invoice_item_id'),
|
||||
DB::raw('IFNULL(invoice_items.discount_amt,0) AS discount'),
|
||||
DB::raw('ROUND(CAST(quantity*price_base AS decimal(8,2)),2) AS base'),
|
||||
DB::raw('ROUND(invoice_item_taxes.amount,2) AS tax'),
|
||||
|
||||
DB::raw('COALESCE(invoice_items.discount_amt,0) AS discount'),
|
||||
DB::raw('quantity*price_base AS base'),
|
||||
DB::raw('invoice_item_taxes.amount AS tax'),
|
||||
])
|
||||
->leftjoin('invoice_item_taxes',['invoice_item_taxes.invoice_item_id'=>'invoice_items.id'])
|
||||
->where('active',TRUE);
|
||||
->where('invoice_items.active',TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -381,6 +380,7 @@ class User extends Authenticatable implements IDs
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder
|
||||
* @todo change this to just return outstanding invoices as a collection.
|
||||
* @deprecated Use account->invoiceSummary
|
||||
*/
|
||||
public function query_invoice_summary()
|
||||
{
|
||||
@ -390,23 +390,23 @@ class User extends Authenticatable implements IDs
|
||||
DB::raw('SUM(discount) AS discount'),
|
||||
DB::raw('SUM(base) AS base'),
|
||||
DB::raw('SUM(tax) AS tax'),
|
||||
DB::raw('ROUND(SUM(base)+SUM(tax)-SUM(discount),2) AS total'),
|
||||
DB::raw('false AS payments'),
|
||||
DB::raw('false AS payment_fees'),
|
||||
DB::raw('base+tax-discount AS total'),
|
||||
DB::raw('0 AS payments'),
|
||||
DB::raw('0 AS payment_fees'),
|
||||
])
|
||||
->from($this->query_invoice_items(),'II')
|
||||
->join('invoices',['invoices.id'=>'II.invoice_id'])
|
||||
->whereIN('account_id',$this->accounts->pluck('id'))
|
||||
->where('invoices.active',TRUE)
|
||||
->groupBy(['invoice_id']);
|
||||
->groupBy(['invoice_id','base','tax','discount']);
|
||||
|
||||
$payments = (new Payment)
|
||||
->select([
|
||||
'invoice_id',
|
||||
DB::raw('false AS discount'),
|
||||
DB::raw('false AS base'),
|
||||
DB::raw('false AS tax'),
|
||||
DB::raw('false AS total'),
|
||||
DB::raw('0 AS discount'),
|
||||
DB::raw('0 AS base'),
|
||||
DB::raw('0 AS tax'),
|
||||
DB::raw('0 AS total'),
|
||||
DB::raw('SUM(allocate) AS payments'),
|
||||
DB::raw('SUM(fees_amt) AS payment_fees'),
|
||||
])
|
||||
@ -442,11 +442,12 @@ class User extends Authenticatable implements IDs
|
||||
'invoice_total',
|
||||
'payments',
|
||||
'payment_fees',
|
||||
DB::raw('ROUND(invoice_total-payments,2) AS balance'),
|
||||
DB::raw('invoice_total-payments AS balance'),
|
||||
])
|
||||
->join('invoices',['invoices.id'=>'invoice_id'])
|
||||
->with(['items.taxes'])
|
||||
->from($summary,'summary');
|
||||
->from($summary,'summary')
|
||||
->groupBy(['id','account_id','discount','invoice_base','invoice_tax','invoice_total','payments','payment_fees']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,7 @@
|
||||
<div class="error-page">
|
||||
<h2 class="headline text-red">500</h2>
|
||||
<div class="error-content">
|
||||
<h3><i class="fa fa-warning text-red pt-4"></i> Oops! {{ $exception->getMessage() }}</h3>
|
||||
<h3><i class="fa fa-warning text-red pt-4"></i> Oops!</h3>
|
||||
<p>
|
||||
{{ trans('adminlte_lang::message.wewillwork') }}
|
||||
{{ trans('adminlte_lang::message.mainwhile') }} <a href='{{ url('/home') }}'>{{ trans('adminlte_lang::message.returndashboard') }}</a>.
|
||||
|
@ -6,7 +6,7 @@
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
@if($o->query_invoice_summary()->having('balance','>',0)->count())
|
||||
@if($o->query_invoice_summary()->havingRaw('invoice_total-payments > 0')->count())
|
||||
<table class="table table-bordered w-100" id="reseller_invoices_due">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -21,7 +21,7 @@
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach ($o->query_invoice_summary()->having('balance','>',0)->get() as $oo)
|
||||
@foreach ($o->query_invoice_summary()->havingRaw('invoice_total-payments > 0')->get() as $oo)
|
||||
<tr @if ($oo->due_at->isPast()) class="table-danger" @endif>
|
||||
<td>{{ $oo->account->name }}</td>
|
||||
<td><a href="{{ url('u/invoice',$oo->id) }}">{{ $oo->sid }}</a></td>
|
||||
|
Loading…
Reference in New Issue
Block a user