mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for statements
This commit is contained in:
parent
761d19c857
commit
375e6f1faf
@ -949,3 +949,19 @@ ORDER BY clients.id;
|
||||
return $type.'s';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* query if we want to company company ledger to client balance
|
||||
$results = \DB::select( \DB::raw("
|
||||
SELECT
|
||||
clients.id as client_id,
|
||||
clients.balance as client_balance
|
||||
from clients,
|
||||
(select max(company_ledgers.id) as cid, company_ledgers.client_id as client_id, company_ledgers.balance as balance
|
||||
FROM company_ledgers) ledger
|
||||
where clients.id=ledger.client_id
|
||||
AND clients.balance != ledger.balance
|
||||
GROUP BY clients.id
|
||||
ORDER BY clients.id;
|
||||
") );
|
||||
*/
|
@ -30,6 +30,7 @@ use App\Utils\PhantomJS\Phantom;
|
||||
use App\Utils\Traits\Pdf\PdfMaker as PdfMakerTrait;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\LazyCollection;
|
||||
|
||||
@ -220,15 +221,16 @@ class Statement
|
||||
*
|
||||
* @return Invoice[]|\Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
protected function getInvoices(): Builder
|
||||
protected function getInvoices(): \Illuminate\Support\LazyCollection
|
||||
{
|
||||
return Invoice::withTrashed()
|
||||
->where('is_deleted', false)
|
||||
->where('company_id', $this->client->company_id)
|
||||
->where('client_id', $this->client->id)
|
||||
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL, Invoice::STATUS_PAID])
|
||||
->whereBetween('date', [$this->options['start_date'], $this->options['end_date']])
|
||||
->orderBy('number', 'ASC');
|
||||
->whereBetween('date', [Carbon::parse($this->options['start_date']), Carbon::parse($this->options['end_date'])])
|
||||
->orderBy('number', 'ASC')
|
||||
->cursor();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -236,7 +238,7 @@ class Statement
|
||||
*
|
||||
* @return Payment[]|\Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
protected function getPayments(): Builder
|
||||
protected function getPayments(): \Illuminate\Support\LazyCollection
|
||||
{
|
||||
return Payment::withTrashed()
|
||||
->with('client.country','invoices')
|
||||
@ -244,8 +246,9 @@ class Statement
|
||||
->where('company_id', $this->client->company_id)
|
||||
->where('client_id', $this->client->id)
|
||||
->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment::STATUS_PARTIALLY_REFUNDED, Payment::STATUS_REFUNDED])
|
||||
->whereBetween('date', [$this->options['start_date'], $this->options['end_date']])
|
||||
->orderBy('number', 'ASC');
|
||||
->whereBetween('date', [Carbon::parse($this->options['start_date']), Carbon::parse($this->options['end_date'])])
|
||||
->orderBy('number', 'ASC')
|
||||
->cursor();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -359,7 +359,7 @@ class Design extends BaseDesign
|
||||
|
||||
$tbody = [];
|
||||
|
||||
foreach ($this->invoices->cursor() as $invoice) {
|
||||
foreach ($this->invoices as $invoice) {
|
||||
$element = ['element' => 'tr', 'elements' => []];
|
||||
|
||||
$element['elements'][] = ['element' => 'td', 'content' => $invoice->number];
|
||||
@ -407,7 +407,7 @@ class Design extends BaseDesign
|
||||
|
||||
$tbody = [];
|
||||
|
||||
foreach ($this->payments->cursor() as $payment) {
|
||||
foreach ($this->payments as $payment) {
|
||||
foreach ($payment->invoices as $invoice) {
|
||||
$element = ['element' => 'tr', 'elements' => []];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user