mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-08-26 21:27:44 -05:00
🤖 Auto commit for release 'develop' on 2026-01-23
This commit is contained in:
@@ -77,17 +77,17 @@ class CreateController extends Controller
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function create(Request $request, null|RuleGroup $ruleGroup = null): Factory|\Illuminate\Contracts\View\View
|
||||
public function create(Request $request, ?RuleGroup $ruleGroup = null): Factory|\Illuminate\Contracts\View\View
|
||||
{
|
||||
$this->createDefaultRuleGroup();
|
||||
$preFilled = ['strict' => true];
|
||||
$oldTriggers = [];
|
||||
$oldActions = [];
|
||||
$preFilled = ['strict' => true];
|
||||
$oldTriggers = [];
|
||||
$oldActions = [];
|
||||
|
||||
// build triggers from query, if present.
|
||||
$query = (string) $request->get('from_query');
|
||||
$query = (string) $request->get('from_query');
|
||||
if ('' !== $query) {
|
||||
$search = app(SearchInterface::class);
|
||||
$search = app(SearchInterface::class);
|
||||
$search->parseQuery($query);
|
||||
$words = $search->getWords();
|
||||
$excludedWords = $search->getExcludedWords();
|
||||
@@ -104,7 +104,7 @@ class CreateController extends Controller
|
||||
$operators[] = ['type' => '-description_contains', 'value' => $excludedWord];
|
||||
}
|
||||
}
|
||||
$oldTriggers = $this->parseFromOperators($operators);
|
||||
$oldTriggers = $this->parseFromOperators($operators);
|
||||
}
|
||||
// var_dump($oldTriggers);exit;
|
||||
|
||||
@@ -119,7 +119,7 @@ class CreateController extends Controller
|
||||
$subTitleIcon = 'fa-clone';
|
||||
|
||||
// title depends on whether or not there is a rule group:
|
||||
$subTitle = (string) trans('firefly.make_new_rule_no_group');
|
||||
$subTitle = (string) trans('firefly.make_new_rule_no_group');
|
||||
if ($ruleGroup instanceof RuleGroup) {
|
||||
$subTitle = (string) trans('firefly.make_new_rule', ['title' => $ruleGroup->title]);
|
||||
}
|
||||
@@ -141,7 +141,7 @@ class CreateController extends Controller
|
||||
'triggerCount' => $triggerCount,
|
||||
'actionCount' => $actionCount,
|
||||
'ruleGroup' => $ruleGroup,
|
||||
'subTitle' => $subTitle
|
||||
'subTitle' => $subTitle,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -157,17 +157,17 @@ class CreateController extends Controller
|
||||
$request->session()->flash('info', (string) trans('firefly.instructions_rule_from_bill', ['name' => e($bill->name)]));
|
||||
|
||||
$this->createDefaultRuleGroup();
|
||||
$preFilled = [
|
||||
$preFilled = [
|
||||
'strict' => true,
|
||||
'title' => (string) trans('firefly.new_rule_for_bill_title', ['name' => $bill->name]),
|
||||
'description' => (string) trans('firefly.new_rule_for_bill_description', ['name' => $bill->name])
|
||||
'description' => (string) trans('firefly.new_rule_for_bill_description', ['name' => $bill->name]),
|
||||
];
|
||||
|
||||
// make triggers and actions from the bill itself.
|
||||
|
||||
// get triggers and actions for bill:
|
||||
$oldTriggers = $this->getTriggersForBill($bill);
|
||||
$oldActions = $this->getActionsForBill($bill);
|
||||
$oldTriggers = $this->getTriggersForBill($bill);
|
||||
$oldActions = $this->getActionsForBill($bill);
|
||||
|
||||
// restore actions and triggers from old input:
|
||||
if (null !== $request->old() && is_array($request->old()) && count($request->old()) > 0) {
|
||||
@@ -180,7 +180,7 @@ class CreateController extends Controller
|
||||
$subTitleIcon = 'fa-clone';
|
||||
|
||||
// title depends on whether there is a rule group:
|
||||
$subTitle = (string) trans('firefly.make_new_rule_no_group');
|
||||
$subTitle = (string) trans('firefly.make_new_rule_no_group');
|
||||
|
||||
// flash old data
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
@@ -198,7 +198,7 @@ class CreateController extends Controller
|
||||
'oldActions' => $oldActions,
|
||||
'triggerCount' => $triggerCount,
|
||||
'actionCount' => $actionCount,
|
||||
'subTitle' => $subTitle
|
||||
'subTitle' => $subTitle,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -213,16 +213,16 @@ class CreateController extends Controller
|
||||
$subTitle = (string) trans('firefly.make_new_rule_no_group');
|
||||
|
||||
// get triggers and actions for journal.
|
||||
$oldTriggers = $this->getTriggersForJournal($journal);
|
||||
$oldActions = [];
|
||||
$oldTriggers = $this->getTriggersForJournal($journal);
|
||||
$oldActions = [];
|
||||
|
||||
$this->createDefaultRuleGroup();
|
||||
|
||||
// collect pre-filled information:
|
||||
$preFilled = [
|
||||
$preFilled = [
|
||||
'strict' => true,
|
||||
'title' => (string) trans('firefly.new_rule_for_journal_title', ['description' => $journal->description]),
|
||||
'description' => (string) trans('firefly.new_rule_for_journal_description', ['description' => $journal->description])
|
||||
'description' => (string) trans('firefly.new_rule_for_journal_description', ['description' => $journal->description]),
|
||||
];
|
||||
|
||||
// restore actions and triggers from old input:
|
||||
@@ -250,7 +250,7 @@ class CreateController extends Controller
|
||||
'oldActions' => $oldActions,
|
||||
'triggerCount' => $triggerCount,
|
||||
'actionCount' => $actionCount,
|
||||
'subTitle' => $subTitle
|
||||
'subTitle' => $subTitle,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -272,8 +272,8 @@ class CreateController extends Controller
|
||||
*/
|
||||
public function store(RuleFormRequest $request)
|
||||
{
|
||||
$data = $request->getRuleData();
|
||||
$rule = $this->ruleRepos->store($data);
|
||||
$data = $request->getRuleData();
|
||||
$rule = $this->ruleRepos->store($data);
|
||||
session()->flash('success_url', route('rules.select-transactions', [$rule->id]));
|
||||
session()->flash('success', (string) trans('firefly.stored_new_rule', ['title' => $rule->title]));
|
||||
Preferences::mark();
|
||||
|
||||
@@ -78,15 +78,15 @@ class EditController extends Controller
|
||||
*/
|
||||
public function edit(Request $request, Rule $rule): Factory|\Illuminate\Contracts\View\View
|
||||
{
|
||||
$triggerCount = 0;
|
||||
$actionCount = 0;
|
||||
$oldActions = [];
|
||||
$oldTriggers = [];
|
||||
$triggerCount = 0;
|
||||
$actionCount = 0;
|
||||
$oldActions = [];
|
||||
$oldTriggers = [];
|
||||
|
||||
// build triggers from query, if present.
|
||||
$query = (string) $request->get('from_query');
|
||||
$query = (string) $request->get('from_query');
|
||||
if ('' !== $query) {
|
||||
$search = app(SearchInterface::class);
|
||||
$search = app(SearchInterface::class);
|
||||
$search->parseQuery($query);
|
||||
$words = $search->getWords();
|
||||
$excludedWords = $search->getExcludedWords();
|
||||
@@ -103,15 +103,15 @@ class EditController extends Controller
|
||||
$operators[] = ['type' => '-description_contains', 'value' => $excludedWord];
|
||||
}
|
||||
}
|
||||
$oldTriggers = $this->parseFromOperators($operators);
|
||||
$oldTriggers = $this->parseFromOperators($operators);
|
||||
}
|
||||
// has old input?
|
||||
if (null !== $request->old() && is_array($request->old()) && count($request->old()) > 0) {
|
||||
$oldTriggers = $this->getPreviousTriggers($request);
|
||||
$oldActions = $this->getPreviousActions($request);
|
||||
}
|
||||
$triggerCount = count($oldTriggers);
|
||||
$actionCount = count($oldActions);
|
||||
$triggerCount = count($oldTriggers);
|
||||
$actionCount = count($oldActions);
|
||||
|
||||
// overrule old input and query data when it has no rule data:
|
||||
if (0 === $triggerCount && 0 === $actionCount) {
|
||||
@@ -121,11 +121,11 @@ class EditController extends Controller
|
||||
$actionCount = count($oldActions);
|
||||
}
|
||||
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$preFilled = [
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$preFilled = [
|
||||
'active' => $hasOldInput ? (bool) $request->old('active') : $rule->active,
|
||||
'stop_processing' => $hasOldInput ? (bool) $request->old('stop_processing') : $rule->stop_processing,
|
||||
'strict' => $hasOldInput ? (bool) $request->old('strict') : $rule->strict
|
||||
'strict' => $hasOldInput ? (bool) $request->old('strict') : $rule->strict,
|
||||
];
|
||||
|
||||
// get rule trigger for update / store-journal:
|
||||
@@ -147,7 +147,7 @@ class EditController extends Controller
|
||||
'oldTriggers' => $oldTriggers,
|
||||
'oldActions' => $oldActions,
|
||||
'triggerCount' => $triggerCount,
|
||||
'actionCount' => $actionCount
|
||||
'actionCount' => $actionCount,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ class EditController extends Controller
|
||||
}
|
||||
asort($triggers);
|
||||
|
||||
$index = 0;
|
||||
$index = 0;
|
||||
foreach ($submittedOperators as $operator) {
|
||||
try {
|
||||
$renderedEntries[] = view('rules.partials.trigger', [
|
||||
@@ -175,7 +175,7 @@ class EditController extends Controller
|
||||
'oldValue' => $operator['value'],
|
||||
'oldChecked' => false,
|
||||
'count' => $index + 1,
|
||||
'triggers' => $triggers
|
||||
'triggers' => $triggers,
|
||||
])->render();
|
||||
} catch (Throwable $e) {
|
||||
$message = sprintf('Throwable was thrown in getPreviousTriggers(): %s', $e->getMessage());
|
||||
@@ -197,7 +197,7 @@ class EditController extends Controller
|
||||
*/
|
||||
public function update(RuleFormRequest $request, Rule $rule)
|
||||
{
|
||||
$data = $request->getRuleData();
|
||||
$data = $request->getRuleData();
|
||||
|
||||
$this->ruleRepos->update($rule, $data);
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class IndexController extends Controller
|
||||
app('view')->share('title', (string) trans('firefly.rules'));
|
||||
app('view')->share('mainTitleIcon', 'fa-random');
|
||||
$this->ruleGroupRepos = app(RuleGroupRepositoryInterface::class);
|
||||
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
||||
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
});
|
||||
|
||||
@@ -71,8 +71,8 @@ class SelectController extends Controller
|
||||
{
|
||||
// Get parameters specified by the user
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$accounts = implode(',', $request->get('accounts'));
|
||||
$user = auth()->user();
|
||||
$accounts = implode(',', $request->get('accounts'));
|
||||
// create new rule engine:
|
||||
$newRuleEngine = app(RuleEngineInterface::class);
|
||||
$newRuleEngine->setUser($user);
|
||||
@@ -93,7 +93,7 @@ class SelectController extends Controller
|
||||
// set rules:
|
||||
$newRuleEngine->setRules(new Collection()->push($rule));
|
||||
$newRuleEngine->fire();
|
||||
$resultCount = $newRuleEngine->getResults();
|
||||
$resultCount = $newRuleEngine->getResults();
|
||||
|
||||
session()->flash('success', trans_choice('firefly.applied_rule_selection', $resultCount, ['title' => $rule->title]));
|
||||
|
||||
@@ -125,14 +125,14 @@ class SelectController extends Controller
|
||||
public function testTriggers(TestRuleFormRequest $request): JsonResponse
|
||||
{
|
||||
// build fake rule
|
||||
$rule = new Rule();
|
||||
$rule = new Rule();
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<int, RuleTrigger> $triggers */
|
||||
$triggers = new Collection();
|
||||
$rule->strict = '1' === $request->get('strict');
|
||||
$triggers = new Collection();
|
||||
$rule->strict = '1' === $request->get('strict');
|
||||
|
||||
// build trigger array from response
|
||||
$textTriggers = $this->getValidTriggerList($request);
|
||||
$textTriggers = $this->getValidTriggerList($request);
|
||||
|
||||
// warn if nothing.
|
||||
if (0 === count($textTriggers)) {
|
||||
@@ -140,10 +140,10 @@ class SelectController extends Controller
|
||||
}
|
||||
|
||||
foreach ($textTriggers as $textTrigger) {
|
||||
$needsContext = config(sprintf('search.operators.%s.needs_context', $textTrigger['type'])) ?? true;
|
||||
$trigger = new RuleTrigger();
|
||||
$trigger->trigger_type = $textTrigger['type'];
|
||||
$trigger->trigger_value = $textTrigger['value'];
|
||||
$needsContext = config(sprintf('search.operators.%s.needs_context', $textTrigger['type'])) ?? true;
|
||||
$trigger = new RuleTrigger();
|
||||
$trigger->trigger_type = $textTrigger['type'];
|
||||
$trigger->trigger_value = $textTrigger['value'];
|
||||
if (false === $needsContext) {
|
||||
$trigger->trigger_value = 'true';
|
||||
}
|
||||
@@ -158,22 +158,22 @@ class SelectController extends Controller
|
||||
|
||||
// create new rule engine:
|
||||
/** @var RuleEngineInterface $newRuleEngine */
|
||||
$newRuleEngine = app(RuleEngineInterface::class);
|
||||
$newRuleEngine = app(RuleEngineInterface::class);
|
||||
|
||||
// set rules:
|
||||
$newRuleEngine->setRules(new Collection()->push($rule));
|
||||
$newRuleEngine->setRefreshTriggers(false);
|
||||
$collection = $newRuleEngine->find();
|
||||
$collection = $collection->slice(0, 20);
|
||||
$collection = $newRuleEngine->find();
|
||||
$collection = $collection->slice(0, 20);
|
||||
|
||||
// Warn the user if only a subset of transactions is returned
|
||||
$warning = '';
|
||||
$warning = '';
|
||||
if (0 === count($collection)) {
|
||||
$warning = (string) trans('firefly.warning_no_matching_transactions');
|
||||
}
|
||||
|
||||
// Return json response
|
||||
$view = 'ERROR, see logs.';
|
||||
$view = 'ERROR, see logs.';
|
||||
|
||||
try {
|
||||
$view = view('list.journals-array-tiny', ['groups' => $collection])->render();
|
||||
@@ -196,7 +196,7 @@ class SelectController extends Controller
|
||||
*/
|
||||
public function testTriggersByRule(Rule $rule): JsonResponse
|
||||
{
|
||||
$triggers = $rule->ruleTriggers;
|
||||
$triggers = $rule->ruleTriggers;
|
||||
|
||||
if (0 === count($triggers)) {
|
||||
return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]);
|
||||
@@ -206,16 +206,16 @@ class SelectController extends Controller
|
||||
|
||||
// set rules:
|
||||
$newRuleEngine->setRules(new Collection()->push($rule));
|
||||
$collection = $newRuleEngine->find();
|
||||
$collection = $collection->slice(0, 20);
|
||||
$collection = $newRuleEngine->find();
|
||||
$collection = $collection->slice(0, 20);
|
||||
|
||||
$warning = '';
|
||||
$warning = '';
|
||||
if (0 === count($collection)) {
|
||||
$warning = (string) trans('firefly.warning_no_matching_transactions');
|
||||
}
|
||||
|
||||
// Return json response
|
||||
$view = 'ERROR, see logs.';
|
||||
$view = 'ERROR, see logs.';
|
||||
|
||||
try {
|
||||
$view = view('list.journals-array-tiny', ['groups' => $collection])->render();
|
||||
|
||||
Reference in New Issue
Block a user