mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Also create initial budget limit.
This commit is contained in:
parent
c475f05652
commit
a00f46faa9
@ -321,6 +321,23 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
$autoBudget->period = $data['auto_budget_period'] ?? 'monthly';
|
$autoBudget->period = $data['auto_budget_period'] ?? 'monthly';
|
||||||
$autoBudget->save();
|
$autoBudget->save();
|
||||||
|
|
||||||
|
// create initial budget limit.
|
||||||
|
$today = new Carbon;
|
||||||
|
$start = app('navigation')->startOfPeriod($today, $autoBudget->period);
|
||||||
|
$end = app('navigation')->startOfPeriod($start, $autoBudget->period);
|
||||||
|
|
||||||
|
$limitRepos = app(BudgetLimitRepositoryInterface::class);
|
||||||
|
$limitRepos->setUser($this->user);
|
||||||
|
$limitRepos->store(
|
||||||
|
[
|
||||||
|
'budget_id' => $newBudget->id,
|
||||||
|
'transaction_currency_id' => $autoBudget->transaction_currency_id,
|
||||||
|
'start_date' => $start->format('Y-m-d'),
|
||||||
|
'end_date' => $end->format('Y-m-d'),
|
||||||
|
'amount' => $autoBudget->amount,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
return $newBudget;
|
return $newBudget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user