mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Working on the calendar
This commit is contained in:
parent
e0bcd698ac
commit
647c44ee57
@ -30,6 +30,12 @@ class GenerateCalendarEvents extends Job
|
||||
|
||||
foreach ($data as $type => $source) {
|
||||
if (! count($filter) || in_array($type, $filter)) {
|
||||
$source->where(function($query) use ($type) {
|
||||
$start = date_create(request()->start);
|
||||
$end = date_create(request()->end);
|
||||
return $query->dateRange($start, $end);
|
||||
});
|
||||
|
||||
foreach ($source->with(['account', 'client.contacts'])->get() as $entity) {
|
||||
if ($entity->client && $entity->client->trashed()) {
|
||||
continue;
|
||||
|
@ -227,6 +227,16 @@ class Expense extends EntityModel
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeDateRange($query, $startDate, $endDate)
|
||||
{
|
||||
return $query->whereBetween('expense_date', [$startDate, $endDate]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
* @param null $bankdId
|
||||
|
@ -423,6 +423,20 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
->where('is_recurring', '=', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeDateRange($query, $startDate, $endDate)
|
||||
{
|
||||
return $query->where(function ($query) use ($startDate, $endDate) {
|
||||
$query->whereBetween('invoice_date', [$startDate, $endDate]);
|
||||
})->orWhere(function ($query) use ($startDate, $endDate) {
|
||||
$query->whereBetween('due_date', [$startDate, $endDate]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
*
|
||||
|
@ -146,6 +146,16 @@ class Payment extends EntityModel
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeDateRange($query, $startDate, $endDate)
|
||||
{
|
||||
return $query->whereBetween('payment_date', [$startDate, $endDate]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user