mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-20 19:35:16 +00:00
Code cleanup
This commit is contained in:
@@ -67,7 +67,7 @@ class RuleController extends Controller
|
|||||||
'stop_processing' => $request->get('stop_processing'),
|
'stop_processing' => $request->get('stop_processing'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$rule = $repository->storeRule($data);
|
$rule = $repository->store($data);
|
||||||
Session::flash('success', trans('firefly.stored_new_rule', ['title' => $rule->title]));
|
Session::flash('success', trans('firefly.stored_new_rule', ['title' => $rule->title]));
|
||||||
Preferences::mark();
|
Preferences::mark();
|
||||||
|
|
||||||
@@ -313,7 +313,7 @@ class RuleController extends Controller
|
|||||||
'rule-action-stop' => $request->get('rule-action-stop'),
|
'rule-action-stop' => $request->get('rule-action-stop'),
|
||||||
'stop_processing' => intval($request->get('stop_processing')) == 1,
|
'stop_processing' => intval($request->get('stop_processing')) == 1,
|
||||||
];
|
];
|
||||||
$repository->updateRule($rule, $data);
|
$repository->update($rule, $data);
|
||||||
|
|
||||||
Session::flash('success', trans('firefly.updated_rule', ['title' => $rule->title]));
|
Session::flash('success', trans('firefly.updated_rule', ['title' => $rule->title]));
|
||||||
Preferences::mark();
|
Preferences::mark();
|
||||||
@@ -358,7 +358,7 @@ class RuleController extends Controller
|
|||||||
{
|
{
|
||||||
|
|
||||||
$title = $rule->title;
|
$title = $rule->title;
|
||||||
$repository->destroyRule($rule);
|
$repository->destroy($rule);
|
||||||
|
|
||||||
Session::flash('success', trans('firefly.deleted_rule', ['title' => $title]));
|
Session::flash('success', trans('firefly.deleted_rule', ['title' => $title]));
|
||||||
Preferences::mark();
|
Preferences::mark();
|
||||||
@@ -439,7 +439,7 @@ class RuleController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function up(RuleRepositoryInterface $repository, Rule $rule)
|
public function up(RuleRepositoryInterface $repository, Rule $rule)
|
||||||
{
|
{
|
||||||
$repository->moveRuleUp($rule);
|
$repository->moveUp($rule);
|
||||||
|
|
||||||
return redirect(route('rules.index'));
|
return redirect(route('rules.index'));
|
||||||
|
|
||||||
@@ -453,7 +453,7 @@ class RuleController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function down(RuleRepositoryInterface $repository, Rule $rule)
|
public function down(RuleRepositoryInterface $repository, Rule $rule)
|
||||||
{
|
{
|
||||||
$repository->moveRuleDown($rule);
|
$repository->moveDown($rule);
|
||||||
|
|
||||||
return redirect(route('rules.index'));
|
return redirect(route('rules.index'));
|
||||||
|
|
||||||
|
@@ -64,7 +64,7 @@ class RuleGroupController extends Controller
|
|||||||
'user' => Auth::user()->id,
|
'user' => Auth::user()->id,
|
||||||
];
|
];
|
||||||
|
|
||||||
$ruleGroup = $repository->storeRuleGroup($data);
|
$ruleGroup = $repository->store($data);
|
||||||
|
|
||||||
Session::flash('success', trans('firefly.created_new_rule_group', ['title' => $ruleGroup->title]));
|
Session::flash('success', trans('firefly.created_new_rule_group', ['title' => $ruleGroup->title]));
|
||||||
Preferences::mark();
|
Preferences::mark();
|
||||||
@@ -116,7 +116,7 @@ class RuleGroupController extends Controller
|
|||||||
'active' => intval($request->input('active')) == 1,
|
'active' => intval($request->input('active')) == 1,
|
||||||
];
|
];
|
||||||
|
|
||||||
$repository->updateRuleGroup($ruleGroup, $data);
|
$repository->update($ruleGroup, $data);
|
||||||
|
|
||||||
Session::flash('success', trans('firefly.updated_rule_group', ['title' => $ruleGroup->title]));
|
Session::flash('success', trans('firefly.updated_rule_group', ['title' => $ruleGroup->title]));
|
||||||
Preferences::mark();
|
Preferences::mark();
|
||||||
@@ -143,7 +143,7 @@ class RuleGroupController extends Controller
|
|||||||
{
|
{
|
||||||
$subTitle = trans('firefly.delete_rule_group', ['title' => $ruleGroup->title]);
|
$subTitle = trans('firefly.delete_rule_group', ['title' => $ruleGroup->title]);
|
||||||
|
|
||||||
$ruleGroupList = Expandedform::makeSelectList($repository->getRuleGroups(), true);
|
$ruleGroupList = Expandedform::makeSelectList($repository->get(), true);
|
||||||
unset($ruleGroupList[$ruleGroup->id]);
|
unset($ruleGroupList[$ruleGroup->id]);
|
||||||
|
|
||||||
// put previous url in session
|
// put previous url in session
|
||||||
@@ -167,7 +167,7 @@ class RuleGroupController extends Controller
|
|||||||
$title = $ruleGroup->title;
|
$title = $ruleGroup->title;
|
||||||
$moveTo = Auth::user()->ruleGroups()->find(intval(Input::get('move_rules_before_delete')));
|
$moveTo = Auth::user()->ruleGroups()->find(intval(Input::get('move_rules_before_delete')));
|
||||||
|
|
||||||
$repository->destroyRuleGroup($ruleGroup, $moveTo);
|
$repository->destroy($ruleGroup, $moveTo);
|
||||||
|
|
||||||
|
|
||||||
Session::flash('success', trans('firefly.deleted_rule_group', ['title' => $title]));
|
Session::flash('success', trans('firefly.deleted_rule_group', ['title' => $title]));
|
||||||
@@ -186,7 +186,7 @@ class RuleGroupController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function up(RuleGroupRepositoryInterface $repository, RuleGroup $ruleGroup)
|
public function up(RuleGroupRepositoryInterface $repository, RuleGroup $ruleGroup)
|
||||||
{
|
{
|
||||||
$repository->moveRuleGroupUp($ruleGroup);
|
$repository->moveUp($ruleGroup);
|
||||||
|
|
||||||
return redirect(route('rules.index'));
|
return redirect(route('rules.index'));
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ class RuleGroupController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function down(RuleGroupRepositoryInterface $repository, RuleGroup $ruleGroup)
|
public function down(RuleGroupRepositoryInterface $repository, RuleGroup $ruleGroup)
|
||||||
{
|
{
|
||||||
$repository->moveRuleGroupDown($ruleGroup);
|
$repository->moveDown($ruleGroup);
|
||||||
|
|
||||||
return redirect(route('rules.index'));
|
return redirect(route('rules.index'));
|
||||||
|
|
||||||
|
@@ -80,6 +80,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
return strtolower($account->name);
|
return strtolower($account->name);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +114,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
DB::Raw('SUM(`transactions`.`amount`) AS `balance`')
|
DB::Raw('SUM(`transactions`.`amount`) AS `balance`')
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
return $set;
|
return $set;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,6 +145,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result = $query->get(['accounts.*']);
|
$result = $query->get(['accounts.*']);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,6 +176,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
->orderBy('transaction_journals.id', 'DESC')
|
->orderBy('transaction_journals.id', 'DESC')
|
||||||
->take(10)
|
->take(10)
|
||||||
->get(['transaction_journals.*', 'transaction_currencies.symbol', 'transaction_types.type']);
|
->get(['transaction_journals.*', 'transaction_currencies.symbol', 'transaction_types.type']);
|
||||||
|
|
||||||
return $set;
|
return $set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -146,6 +146,7 @@ class BillRepository implements BillRepositoryInterface
|
|||||||
->orderBy('transaction_journals.order', 'ASC')
|
->orderBy('transaction_journals.order', 'ASC')
|
||||||
->orderBy('transaction_journals.id', 'DESC')
|
->orderBy('transaction_journals.id', 'DESC')
|
||||||
->get(['transaction_journals.*', 'transactions.amount as journalAmount']);
|
->get(['transaction_journals.*', 'transactions.amount as journalAmount']);
|
||||||
|
|
||||||
return $set;
|
return $set;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -460,6 +461,7 @@ class BillRepository implements BillRepositoryInterface
|
|||||||
$amount = bcadd($amount, $paid->sum_amount);
|
$amount = bcadd($amount, $paid->sum_amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $amount;
|
return $amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,6 +517,7 @@ class BillRepository implements BillRepositoryInterface
|
|||||||
$amount = bcadd($amount, $bill->expectedAmount);
|
$amount = bcadd($amount, $bill->expectedAmount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $amount;
|
return $amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,7 +14,6 @@ use FireflyIII\Models\Rule;
|
|||||||
use FireflyIII\Models\RuleAction;
|
use FireflyIII\Models\RuleAction;
|
||||||
use FireflyIII\Models\RuleGroup;
|
use FireflyIII\Models\RuleGroup;
|
||||||
use FireflyIII\Models\RuleTrigger;
|
use FireflyIII\Models\RuleTrigger;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RuleRepository
|
* Class RuleRepository
|
||||||
@@ -48,6 +47,7 @@ class RuleRepository implements RuleRepositoryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param RuleGroup $ruleGroup
|
* @param RuleGroup $ruleGroup
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function resetRulesInGroupOrder(RuleGroup $ruleGroup)
|
public function resetRulesInGroupOrder(RuleGroup $ruleGroup)
|
||||||
@@ -98,7 +98,7 @@ class RuleRepository implements RuleRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function moveRuleUp(Rule $rule)
|
public function moveUp(Rule $rule)
|
||||||
{
|
{
|
||||||
$order = $rule->order;
|
$order = $rule->order;
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ class RuleRepository implements RuleRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function moveRuleDown(Rule $rule)
|
public function moveDown(Rule $rule)
|
||||||
{
|
{
|
||||||
$order = $rule->order;
|
$order = $rule->order;
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ class RuleRepository implements RuleRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return Rule
|
* @return Rule
|
||||||
*/
|
*/
|
||||||
public function storeRule(array $data)
|
public function store(array $data)
|
||||||
{
|
{
|
||||||
/** @var RuleGroup $ruleGroup */
|
/** @var RuleGroup $ruleGroup */
|
||||||
$ruleGroup = Auth::user()->ruleGroups()->find($data['rule_group_id']);
|
$ruleGroup = Auth::user()->ruleGroups()->find($data['rule_group_id']);
|
||||||
@@ -213,7 +213,7 @@ class RuleRepository implements RuleRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function destroyRule(Rule $rule)
|
public function destroy(Rule $rule)
|
||||||
{
|
{
|
||||||
foreach ($rule->ruleTriggers as $trigger) {
|
foreach ($rule->ruleTriggers as $trigger) {
|
||||||
$trigger->delete();
|
$trigger->delete();
|
||||||
@@ -264,9 +264,10 @@ class RuleRepository implements RuleRepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* @param Rule $rule
|
* @param Rule $rule
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
*
|
||||||
* @return Rule
|
* @return Rule
|
||||||
*/
|
*/
|
||||||
public function updateRule(Rule $rule, array $data)
|
public function update(Rule $rule, array $data)
|
||||||
{
|
{
|
||||||
// update rule:
|
// update rule:
|
||||||
$rule->active = $data['active'];
|
$rule->active = $data['active'];
|
||||||
|
@@ -13,7 +13,6 @@ use FireflyIII\Models\Rule;
|
|||||||
use FireflyIII\Models\RuleAction;
|
use FireflyIII\Models\RuleAction;
|
||||||
use FireflyIII\Models\RuleGroup;
|
use FireflyIII\Models\RuleGroup;
|
||||||
use FireflyIII\Models\RuleTrigger;
|
use FireflyIII\Models\RuleTrigger;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface RuleRepositoryInterface
|
* Interface RuleRepositoryInterface
|
||||||
@@ -27,7 +26,7 @@ interface RuleRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function destroyRule(Rule $rule);
|
public function destroy(Rule $rule);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param RuleGroup $ruleGroup
|
* @param RuleGroup $ruleGroup
|
||||||
@@ -39,6 +38,7 @@ interface RuleRepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* @param Rule $rule
|
* @param Rule $rule
|
||||||
* @param array $ids
|
* @param array $ids
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function reorderRuleTriggers(Rule $rule, array $ids);
|
public function reorderRuleTriggers(Rule $rule, array $ids);
|
||||||
@@ -46,41 +46,46 @@ interface RuleRepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* @param Rule $rule
|
* @param Rule $rule
|
||||||
* @param array $ids
|
* @param array $ids
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function reorderRuleActions(Rule $rule, array $ids);
|
public function reorderRuleActions(Rule $rule, array $ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param RuleGroup $ruleGroup
|
* @param RuleGroup $ruleGroup
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function resetRulesInGroupOrder(RuleGroup $ruleGroup);
|
public function resetRulesInGroupOrder(RuleGroup $ruleGroup);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Rule $rule
|
* @param Rule $rule
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function moveRuleUp(Rule $rule);
|
public function moveUp(Rule $rule);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Rule $rule
|
* @param Rule $rule
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
*
|
||||||
* @return Rule
|
* @return Rule
|
||||||
*/
|
*/
|
||||||
public function updateRule(Rule $rule, array $data);
|
public function update(Rule $rule, array $data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Rule $rule
|
* @param Rule $rule
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function moveRuleDown(Rule $rule);
|
public function moveDown(Rule $rule);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return Rule
|
* @return Rule
|
||||||
*/
|
*/
|
||||||
public function storeRule(array $data);
|
public function store(array $data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Rule $rule
|
* @param Rule $rule
|
||||||
|
Reference in New Issue
Block a user