mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Fix dashboard totals when 'First month' is set
This commit is contained in:
parent
b172267eec
commit
a919f8dc72
@ -1732,6 +1732,18 @@ class Account extends Eloquent
|
|||||||
|
|
||||||
return Carbon::now($this->getTimezone())->addDays($numDays)->format('Y-m-d');
|
return Carbon::now($this->getTimezone())->addDays($numDays)->format('Y-m-d');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
@ -7,7 +7,6 @@ use App\Models\Invoice;
|
|||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
use DatePeriod;
|
use DatePeriod;
|
||||||
use Carbon;
|
|
||||||
|
|
||||||
class DashboardRepository
|
class DashboardRepository
|
||||||
{
|
{
|
||||||
@ -206,12 +205,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')
|
||||||
@ -241,8 +235,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