Merge branch 'master' into master
This commit is contained in:
@ -3,12 +3,17 @@
|
||||
namespace App\Utilities;
|
||||
|
||||
use App\Models\Document\Document;
|
||||
use App\Traits\DateTime;
|
||||
use Date;
|
||||
|
||||
class Recurring
|
||||
{
|
||||
use DateTime;
|
||||
|
||||
public static function reflect(&$items, $issued_date_field)
|
||||
{
|
||||
$financial_year = (new static)->getFinancialYear();
|
||||
|
||||
foreach ($items as $key => $item) {
|
||||
// @todo cache recurrings
|
||||
if (!$item->recurring || !empty($item->parent_id)) {
|
||||
@ -18,18 +23,17 @@ class Recurring
|
||||
foreach ($item->recurring->getRecurringSchedule(false) as $schedule) {
|
||||
$issued = Date::parse($item->$issued_date_field);
|
||||
$start = $schedule->getStart();
|
||||
|
||||
if ($issued->format('Y') != $start->format('Y')) {
|
||||
continue;
|
||||
}
|
||||
$start_date = Date::parse($start->format('Y-m-d'));
|
||||
|
||||
if (($issued->format('Y-m') == $start->format('Y-m')) && ($issued->format('d') >= $start->format('d'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$clone = clone $item;
|
||||
if ($start_date->lessThan($financial_year->getStartDate()) || $start_date->greaterThan($financial_year->getEndDate())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$start_date = Date::parse($start->format('Y-m-d'));
|
||||
$clone = clone $item;
|
||||
|
||||
if ($clone instanceof Document) {
|
||||
// Days between invoiced/billed and due date
|
||||
|
Reference in New Issue
Block a user