mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fix dashboard totals when 'First month' is set
This commit is contained in:
parent
e4d536a8c0
commit
41096a7bce
@ -1804,6 +1804,18 @@ class Account extends Eloquent
|
|||||||
{
|
{
|
||||||
return $this->company->accounts->count() > 1;
|
return $this->company->accounts->count() > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function financialYearStart()
|
||||||
|
{
|
||||||
|
$yearStart = Carbon::parse($this->financial_year_start);
|
||||||
|
$yearStart->year = date('Y');
|
||||||
|
|
||||||
|
if ($yearStart->isFuture()) {
|
||||||
|
$yearStart->subYear();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $yearStart->format('Y-m-d');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Account::updated(function ($account) {
|
Account::updated(function ($account) {
|
||||||
|
@ -8,7 +8,6 @@ use App\Models\Task;
|
|||||||
use DateInterval;
|
use DateInterval;
|
||||||
use DatePeriod;
|
use DatePeriod;
|
||||||
use DB;
|
use DB;
|
||||||
use Carbon;
|
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
|
||||||
class DashboardRepository
|
class DashboardRepository
|
||||||
@ -211,12 +210,7 @@ class DashboardRepository
|
|||||||
if ($startDate) {
|
if ($startDate) {
|
||||||
$paidToDate->where('payments.payment_date', '>=', $startDate);
|
$paidToDate->where('payments.payment_date', '>=', $startDate);
|
||||||
} elseif ($account->financial_year_start) {
|
} elseif ($account->financial_year_start) {
|
||||||
$yearStart = Carbon::parse($account->financial_year_start);
|
$paidToDate->where('payments.payment_date', '>=', $account->financialYearStart());
|
||||||
$yearStart->year = date('Y');
|
|
||||||
if ($yearStart->isFuture()) {
|
|
||||||
$yearStart->subYear();
|
|
||||||
}
|
|
||||||
$paidToDate->where('payments.payment_date', '>=', $yearStart->format('Y-m-d'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $paidToDate->groupBy('payments.account_id')
|
return $paidToDate->groupBy('payments.account_id')
|
||||||
@ -246,8 +240,7 @@ class DashboardRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($account->financial_year_start) {
|
if ($account->financial_year_start) {
|
||||||
$yearStart = str_replace('2000', date('Y'), $account->financial_year_start);
|
$averageInvoice->where('invoices.invoice_date', '>=', $account->financialYearStart());
|
||||||
$averageInvoice->where('invoices.invoice_date', '>=', $yearStart);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $averageInvoice->groupBy('accounts.id')
|
return $averageInvoice->groupBy('accounts.id')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user