Merge pull request #3286 from CihanSenturk/update-recurring-relations

Update recurring relations
This commit is contained in:
Cihan Şentürk 2025-04-22 22:32:38 +03:00 committed by GitHub
commit 4c25459dd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 1 deletions

View File

@ -218,12 +218,14 @@ class RecurringCheck extends Command
$model->created_from = 'core::recurring';
$model->save();
$this->updateRelationTypes($model, $template->cloneable_relations);
return $model;
}
protected function getTransactionModel(Transaction $template, Date $schedule_date): Transaction
{
$template->cloneable_relations = [];
$template->cloneable_relations = ['taxes'];
$model = $template->duplicate();
@ -233,6 +235,8 @@ class RecurringCheck extends Command
$model->created_from = 'core::recurring';
$model->save();
$this->updateRelationTypes($model, $template->cloneable_relations);
return $model;
}
@ -266,4 +270,15 @@ class RecurringCheck extends Command
{
return Str::replace('-recurring', '', $recurring_type);
}
public function updateRelationTypes($model, $relations)
{
foreach ($relations as $relation) {
if (! method_exists($model, $relation)) {
continue;
}
$model->$relation()->update(['type' => $model->type]);
}
}
}