fixed #572
This commit is contained in:
parent
ff01b4ff04
commit
abad89a873
@ -63,43 +63,41 @@ class RecurringCheck extends Command
|
|||||||
|
|
||||||
$company->setSettings();
|
$company->setSettings();
|
||||||
|
|
||||||
foreach ($company->recurring as $recur) {
|
foreach ($company->recurring as $recurring) {
|
||||||
if (!$current = $recur->current()) {
|
foreach ($recurring->schedule() as $recur) {
|
||||||
continue;
|
$recur_date = Date::parse($recur->getStart()->format('Y-m-d'));
|
||||||
}
|
|
||||||
|
|
||||||
$current_date = Date::parse($current->format('Y-m-d'));
|
// Check if should recur today
|
||||||
|
if ($this->today->ne($recur_date)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if should recur today
|
$model = $recurring->recurable;
|
||||||
if ($this->today->ne($current_date)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$model = $recur->recurable;
|
if (!$model) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$model) {
|
switch ($recurring->recurable_type) {
|
||||||
continue;
|
case 'App\Models\Expense\Bill':
|
||||||
}
|
$this->recurBill($company, $model);
|
||||||
|
break;
|
||||||
|
case 'App\Models\Income\Invoice':
|
||||||
|
$this->recurInvoice($company, $model);
|
||||||
|
break;
|
||||||
|
case 'App\Models\Expense\Payment':
|
||||||
|
case 'App\Models\Income\Revenue':
|
||||||
|
$model->cloneable_relations = [];
|
||||||
|
|
||||||
switch ($recur->recurable_type) {
|
// Create new record
|
||||||
case 'App\Models\Expense\Bill':
|
$clone = $model->duplicate();
|
||||||
$this->recurBill($company, $model);
|
|
||||||
break;
|
|
||||||
case 'App\Models\Income\Invoice':
|
|
||||||
$this->recurInvoice($company, $model);
|
|
||||||
break;
|
|
||||||
case 'App\Models\Expense\Payment':
|
|
||||||
case 'App\Models\Income\Revenue':
|
|
||||||
$model->cloneable_relations = [];
|
|
||||||
|
|
||||||
// Create new record
|
$clone->parent_id = $model->id;
|
||||||
$clone = $model->duplicate();
|
$clone->paid_at = $this->today->format('Y-m-d');
|
||||||
|
$clone->save();
|
||||||
|
|
||||||
$clone->parent_id = $model->id;
|
break;
|
||||||
$clone->paid_at = $this->today->format('Y-m-d');
|
}
|
||||||
$clone->save();
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user