Skip to content

Firefly III: a personal finances manager

Fix parameters, re-order.

James Cole594f9822c7f2
diff --git a/app/Http/Controllers/RuleGroupController.php b/app/Http/Controllers/RuleGroupController.php
index 6a29094a5b..deb8bb2c8f 100644
--- a/app/Http/Controllers/RuleGroupController.php
+++ b/app/Http/Controllers/RuleGroupController.php
@@ -10,8 +10,8 @@ use FireflyIII\Http\Requests\RuleGroupFormRequest;
use FireflyIII\Http\Requests\SelectTransactionsRequest;
use FireflyIII\Jobs\ExecuteRuleGroupOnExistingTransactions;
use FireflyIII\Models\RuleGroup;
-use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
+use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use Input;
use Preferences;
use Session;
@@ -133,6 +133,60 @@ class RuleGroupController extends Controller
}
+ /**
+ * Execute the given rulegroup on a set of existing transactions
+ *
+ * @param SelectTransactionsRequest $request
+ * @param AccountRepositoryInterface $repository
+ * @param RuleGroup $ruleGroup
+ *
+ * @return \Illuminate\Http\RedirectResponse
+ */
+ public function execute(SelectTransactionsRequest $request, AccountRepositoryInterface $repository, RuleGroup $ruleGroup)
+ {
+ // Get parameters specified by the user
+ $accounts = $repository->get($request->get('accounts'));
+ $startDate = new Carbon($request->get('start_date'));
+ $endDate = new Carbon($request->get('end_date'));
+
+ // Create a job to do the work asynchronously
+ $job = new ExecuteRuleGroupOnExistingTransactions($ruleGroup);
+
+ // Apply parameters to the job
+ $job->setUser(Auth::user());
+ $job->setAccounts($accounts);
+ $job->setStartDate($startDate);
+ $job->setEndDate($endDate);
+
+ // Dispatch a new job to execute it in a queue
+ $this->dispatch($job);
+
+ // Tell the user that the job is queued
+ Session::flash('success', trans('firefly.executed_group_on_existing_transactions', ['title' => $ruleGroup->title]));
+
+ return redirect()->route('rules.index');
+ }
+
+ /**
+ * Shows a form for the user to select a range of transactions to execute this rulegroup for
+ *
+ * @param AccountRepositoryInterface $repository
+ * @param RuleGroup $ruleGroup
+ *
+ * @return View
+ */
+ public function selectTransactions(AccountRepositoryInterface $repository, RuleGroup $ruleGroup)
+ {
+ // does the user have shared accounts?
+ $accounts = $repository->getAccounts(['Default account', 'Asset account']);
+ $accountList = ExpandedForm::makeSelectList($accounts);
+ $checkedAccounts = array_keys($accountList);
+ $first = session('first')->format('Y-m-d');
+ $today = Carbon::create()->format('Y-m-d');
+
+ return view('rules.rule-group.select-transactions', compact('checkedAccounts', 'accountList', 'first', 'today', 'ruleGroup'));
+ }
+
/**
* @param RuleGroupFormRequest $request
* @param RuleGroupRepositoryInterface $repository
@@ -144,7 +198,7 @@ class RuleGroupController extends Controller
$data = [
'title' => $request->input('title'),
'description' => $request->input('description'),
- 'user_id' => Auth::user()->id,
+ 'user_id' => Auth::user()->id,
];
$ruleGroup = $repository->store($data);
@@ -208,48 +262,4 @@ class RuleGroupController extends Controller
return redirect(session('rules.rule-group.edit.url'));
}
-
- /**
- * Shows a form for the user to select a range of transactions to execute this rulegroup for
- * @param RuleGroup $ruleGroup
- */
- public function selectTransactions(AccountRepositoryInterface $repository, RuleGroup $ruleGroup)
- {
- // does the user have shared accounts?
- $accounts = $repository->getAccounts(['Default account', 'Asset account']);
- $accountList = ExpandedForm::makeSelectList($accounts);
- $checkedAccounts = array_keys($accountList);
- $first = session('first')->format('Y-m-d');
- $today = Carbon::create()->format('Y-m-d');
-
- return view('rules.rule-group.select-transactions', compact('checkedAccounts', 'accountList', 'first', 'today', 'ruleGroup'));
- }
-
- /**
- * Execute the given rulegroup on a set of existing transactions
- * @param RuleGroup $ruleGroup
- */
- public function execute(SelectTransactionsRequest $request, AccountRepositoryInterface $repository, RuleGroup $ruleGroup)
- {
- // Get parameters specified by the user
- $accounts = $repository->get($request->get('accounts'));
- $startDate = new Carbon($request->get('start_date'));
- $endDate = new Carbon($request->get('end_date'));
-
- // Create a job to do the work asynchronously
- $job = new ExecuteRuleGroupOnExistingTransactions($ruleGroup);
-
- // Apply parameters to the job
- $job->setUser(Auth::user());
- $job->setAccounts($accounts);
- $job->setStartDate($startDate);
- $job->setEndDate($endDate);
-
- // Dispatch a new job to execute it in a queue
- $this->dispatch($job);
-
- // Tell the user that the job is queued
- Session::flash('success', trans('firefly.executed_group_on_existing_transactions', ['title' => $ruleGroup->title]));
- return redirect()->route('rules.index');
- }
}
diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php
index 58ec65daa9..8bc25e8485 100644
--- a/app/Repositories/Account/AccountRepositoryInterface.php
+++ b/app/Repositories/Account/AccountRepositoryInterface.php
@@ -48,7 +48,7 @@ interface AccountRepositoryInterface
*
* @param array $ids
*
- * @return Collection
+ * @return \Illuminate\Support\Collection
*/
public function get(array $ids): Collection;