mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Merge branch 'develop' into feature/credit_calc
# Conflicts: # app/Factory/TransactionJournalMetaFactory.php # app/Repositories/Account/AccountRepository.php # app/Transformers/AccountTransformer.php # config/firefly.php # frontend/src/components/accounts/Create.vue
This commit is contained in:
@@ -46,6 +46,7 @@ interface AccountRepositoryInterface
|
||||
*/
|
||||
public function count(array $types): int;
|
||||
|
||||
|
||||
/**
|
||||
* Moved here from account CRUD.
|
||||
*
|
||||
@@ -65,6 +66,14 @@ interface AccountRepositoryInterface
|
||||
*/
|
||||
public function expandWithDoubles(Collection $accounts): Collection;
|
||||
|
||||
/**
|
||||
* @param string $number
|
||||
* @param array $types
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
public function findByAccountNumber(string $number, array $types): ?Account;
|
||||
|
||||
/**
|
||||
* @param string $iban
|
||||
* @param array $types
|
||||
|
@@ -98,10 +98,10 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
$budgets = $this->getBudgets();
|
||||
/** @var Budget $budget */
|
||||
foreach ($budgets as $budget) {
|
||||
DB::table('budget_transaction')->where('budget_id', $budget->id)->delete();
|
||||
DB::table('budget_transaction_journal')->where('budget_id', $budget->id)->delete();
|
||||
RecurrenceTransactionMeta::where('name', 'budget_id')->where('value', $budget->id)->delete();
|
||||
RuleAction::where('action_type', 'set_budget')->where('action_value', $budget->id)->delete();
|
||||
DB::table('budget_transaction')->where('budget_id', (int)$budget->id)->delete();
|
||||
DB::table('budget_transaction_journal')->where('budget_id', (int)$budget->id)->delete();
|
||||
RecurrenceTransactionMeta::where('name', 'budget_id')->where('value', (string)$budget->id)->delete();
|
||||
RuleAction::where('action_type', 'set_budget')->where('action_value', (string)$budget->id)->delete();
|
||||
$budget->delete();
|
||||
}
|
||||
}
|
||||
@@ -328,7 +328,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
Log::error($e->getTraceAsString());
|
||||
throw new FireflyException('400002: Could not store budget.', 0, $e);
|
||||
}
|
||||
if (!array_key_exists('auto_budget_type', $data)) {
|
||||
if (!array_key_exists('auto_budget_type', $data) || !array_key_exists('auto_budget_amount', $data) || !array_key_exists('auto_budget_period', $data)) {
|
||||
return $newBudget;
|
||||
}
|
||||
$type = $data['auto_budget_type'];
|
||||
|
@@ -258,6 +258,58 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $filter
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllRuleGroupsWithRules(?string $filter): Collection
|
||||
{
|
||||
$groups = $this->user->ruleGroups()
|
||||
->orderBy('order', 'ASC')
|
||||
->with(
|
||||
[
|
||||
'rules' => static function (HasMany $query) {
|
||||
$query->orderBy('order', 'ASC');
|
||||
},
|
||||
'rules.ruleTriggers' => static function (HasMany $query) {
|
||||
$query->orderBy('order', 'ASC');
|
||||
},
|
||||
'rules.ruleActions' => static function (HasMany $query) {
|
||||
$query->orderBy('order', 'ASC');
|
||||
},
|
||||
]
|
||||
)->get();
|
||||
if (null === $filter) {
|
||||
return $groups;
|
||||
}
|
||||
Log::debug(sprintf('Will filter getRuleGroupsWithRules on "%s".', $filter));
|
||||
|
||||
return $groups->map(
|
||||
function (RuleGroup $group) use ($filter) {
|
||||
Log::debug(sprintf('Now filtering group #%d', $group->id));
|
||||
// filter the rules in the rule group:
|
||||
$group->rules = $group->rules->filter(
|
||||
function (Rule $rule) use ($filter) {
|
||||
Log::debug(sprintf('Now filtering rule #%d', $rule->id));
|
||||
foreach ($rule->ruleTriggers as $trigger) {
|
||||
if ('user_action' === $trigger->trigger_type && $filter === $trigger->trigger_value) {
|
||||
Log::debug(sprintf('Rule #%d triggers on %s, include it.', $rule->id, $filter));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Log::debug(sprintf('Rule #%d does not trigger on %s, do not include it.', $rule->id, $filter));
|
||||
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
return $group;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RuleGroup $group
|
||||
*
|
||||
|
@@ -114,6 +114,15 @@ interface RuleGroupRepositoryInterface
|
||||
*/
|
||||
public function getRuleGroupsWithRules(?string $filter): Collection;
|
||||
|
||||
/**
|
||||
* Also inactive groups.
|
||||
*
|
||||
* @param string|null $filter
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllRuleGroupsWithRules(?string $filter): Collection;
|
||||
|
||||
/**
|
||||
* @param RuleGroup $group
|
||||
*
|
||||
|
Reference in New Issue
Block a user