mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #6694 from turbo124/v5-develop
Cient Statement Fixes
This commit is contained in:
commit
640e0e5737
@ -283,13 +283,18 @@ class Statement
|
|||||||
$from = $ranges[0];
|
$from = $ranges[0];
|
||||||
$to = $ranges[1];
|
$to = $ranges[1];
|
||||||
|
|
||||||
|
nlog("from ".$from->format("Y-m-d"));
|
||||||
|
nlog("to ".$to->format("Y-m-d"));
|
||||||
|
|
||||||
$client = Client::where('id', $this->client->id)->first();
|
$client = Client::where('id', $this->client->id)->first();
|
||||||
|
|
||||||
$amount = Invoice::where('company_id', $this->client->company->id)
|
$amount = Invoice::where('company_id', $this->client->company->id)
|
||||||
->where('client_id', $client->id)
|
->where('client_id', $client->id)
|
||||||
|
->where('company_id', $this->client->company_id)
|
||||||
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
||||||
->where('balance', '>', 0)
|
->where('balance', '>', 0)
|
||||||
->whereBetween('date', [$from, $to])
|
->where('is_deleted', 0)
|
||||||
|
->whereBetween('date', [$to, $from])
|
||||||
->sum('balance');
|
->sum('balance');
|
||||||
|
|
||||||
return Number::formatMoney($amount, $client);
|
return Number::formatMoney($amount, $client);
|
||||||
@ -307,35 +312,29 @@ class Statement
|
|||||||
|
|
||||||
switch ($range) {
|
switch ($range) {
|
||||||
case '30':
|
case '30':
|
||||||
$ranges[0] = now();
|
$ranges[0] = now()->startOfDay();
|
||||||
$ranges[1] = now()->subDays(30);
|
$ranges[1] = now()->startOfDay()->subDays(30);
|
||||||
return $ranges;
|
return $ranges;
|
||||||
break;
|
|
||||||
case '60':
|
case '60':
|
||||||
$ranges[0] = now()->subDays(30);
|
$ranges[0] = now()->startOfDay()->subDays(30);
|
||||||
$ranges[1] = now()->subDays(60);
|
$ranges[1] = now()->startOfDay()->subDays(60);
|
||||||
return $ranges;
|
return $ranges;
|
||||||
break;
|
|
||||||
case '90':
|
case '90':
|
||||||
$ranges[0] = now()->subDays(60);
|
$ranges[0] = now()->startOfDay()->subDays(60);
|
||||||
$ranges[1] = now()->subDays(90);
|
$ranges[1] = now()->startOfDay()->subDays(90);
|
||||||
return $ranges;
|
return $ranges;
|
||||||
break;
|
|
||||||
case '120':
|
case '120':
|
||||||
$ranges[0] = now()->subDays(90);
|
$ranges[0] = now()->startOfDay()->subDays(90);
|
||||||
$ranges[1] = now()->subDays(120);
|
$ranges[1] = now()->startOfDay()->subDays(120);
|
||||||
return $ranges;
|
return $ranges;
|
||||||
break;
|
|
||||||
case '120+':
|
case '120+':
|
||||||
$ranges[0] = now()->subDays(120);
|
$ranges[0] = now()->startOfDay()->subDays(120);
|
||||||
$ranges[1] = now()->subYears(40);
|
$ranges[1] = now()->startOfDay()->subYears(40);
|
||||||
return $ranges;
|
return $ranges;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
$ranges[0] = now()->subDays(0);
|
$ranges[0] = now()->startOfDay()->subDays(0);
|
||||||
$ranges[1] = now()->subDays(30);
|
$ranges[1] = now()->subDays(30);
|
||||||
return $ranges;
|
return $ranges;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,7 +428,7 @@ class Design extends BaseDesign
|
|||||||
|
|
||||||
public function statementPaymentTableTotals(): array
|
public function statementPaymentTableTotals(): array
|
||||||
{
|
{
|
||||||
if (is_null($this->payments) && $this->type !== self::STATEMENT) {
|
if (is_null($this->payments) || !$this->payments->first() || $this->type !== self::STATEMENT) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user