mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-26 05:26:17 +00:00
Small bugfixes for issues in beta 2
This commit is contained in:
@@ -335,6 +335,9 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
if ('none' === $type) {
|
||||
return $newBudget;
|
||||
}
|
||||
if (0 === $type) {
|
||||
return $newBudget;
|
||||
}
|
||||
|
||||
if ('reset' === $type) {
|
||||
$type = AutoBudget::AUTO_BUDGET_RESET;
|
||||
@@ -343,7 +346,8 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
$type = AutoBudget::AUTO_BUDGET_ROLLOVER;
|
||||
}
|
||||
|
||||
$repos = app(CurrencyRepositoryInterface::class);
|
||||
$repos = app(CurrencyRepositoryInterface::class);
|
||||
$currency = null;
|
||||
if (array_key_exists('currency_id', $data)) {
|
||||
$currency = $repos->findNull((int)$data['currency_id']);
|
||||
}
|
||||
@@ -420,6 +424,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
if (null === $autoBudget
|
||||
&& array_key_exists('auto_budget_type', $data)
|
||||
&& array_key_exists('auto_budget_amount', $data)
|
||||
&& 0 !== $data['auto_budget_type']
|
||||
) {
|
||||
// only create if all are here:
|
||||
$autoBudget = new AutoBudget;
|
||||
@@ -428,7 +433,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
}
|
||||
|
||||
// update existing type
|
||||
if (array_key_exists('auto_budget_type', $data)) {
|
||||
if (array_key_exists('auto_budget_type', $data) && 0 !== $data['auto_budget_type']) {
|
||||
$autoBudgetType = $data['auto_budget_type'];
|
||||
if ('reset' === $autoBudgetType) {
|
||||
$autoBudget->auto_budget_type = AutoBudget::AUTO_BUDGET_RESET;
|
||||
@@ -442,10 +447,10 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
return $budget;
|
||||
}
|
||||
}
|
||||
if (array_key_exists('auto_budget_amount', $data)) {
|
||||
if (array_key_exists('auto_budget_amount', $data) && null !== $autoBudget) {
|
||||
$autoBudget->amount = $data['auto_budget_amount'];
|
||||
}
|
||||
if (array_key_exists('auto_budget_period', $data)) {
|
||||
if (array_key_exists('auto_budget_period', $data) && null !== $autoBudget) {
|
||||
$autoBudget->period = $data['auto_budget_period'];
|
||||
}
|
||||
if (null !== $autoBudget) {
|
||||
|
||||
@@ -258,29 +258,6 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
return $filtered;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Rule $rule
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function moveDown(Rule $rule): bool
|
||||
{
|
||||
$order = $rule->order;
|
||||
|
||||
// find the rule with order+1 and give it order-1
|
||||
$other = $rule->ruleGroup->rules()->where('order', $order + 1)->first();
|
||||
if ($other) {
|
||||
--$other->order;
|
||||
$other->save();
|
||||
}
|
||||
|
||||
++$rule->order;
|
||||
$rule->save();
|
||||
$this->resetRuleOrder($rule->ruleGroup);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@@ -295,29 +272,6 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
return $rule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Rule $rule
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function moveUp(Rule $rule): bool
|
||||
{
|
||||
$order = $rule->order;
|
||||
|
||||
// find the rule with order-1 and give it order+1
|
||||
$other = $rule->ruleGroup->rules()->where('order', $order - 1)->first();
|
||||
if ($other) {
|
||||
++$other->order;
|
||||
$other->save();
|
||||
}
|
||||
|
||||
--$rule->order;
|
||||
$rule->save();
|
||||
$this->resetRuleOrder($rule->ruleGroup);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Rule $rule
|
||||
* @param array $ids
|
||||
|
||||
@@ -123,13 +123,6 @@ interface RuleRepositoryInterface
|
||||
*/
|
||||
public function getUpdateRules(): Collection;
|
||||
|
||||
/**
|
||||
* @param Rule $rule
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function moveDown(Rule $rule): bool;
|
||||
|
||||
/**
|
||||
* @param Rule $rule
|
||||
* @param RuleGroup $ruleGroup
|
||||
@@ -139,13 +132,6 @@ interface RuleRepositoryInterface
|
||||
*/
|
||||
public function moveRule(Rule $rule, RuleGroup $ruleGroup, int $order): Rule;
|
||||
|
||||
/**
|
||||
* @param Rule $rule
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function moveUp(Rule $rule): bool;
|
||||
|
||||
/**
|
||||
* @param Rule $rule
|
||||
* @param array $ids
|
||||
|
||||
@@ -277,52 +277,6 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
return (int)$this->user->ruleGroups()->max('order');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function moveDown(RuleGroup $ruleGroup): bool
|
||||
{
|
||||
$order = $ruleGroup->order;
|
||||
|
||||
// find the rule with order+1 and give it order-1
|
||||
$other = $this->user->ruleGroups()->where('order', $order + 1)->first();
|
||||
if ($other) {
|
||||
--$other->order;
|
||||
$other->save();
|
||||
}
|
||||
|
||||
++$ruleGroup->order;
|
||||
$ruleGroup->save();
|
||||
$this->resetRuleGroupOrder();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function moveUp(RuleGroup $ruleGroup): bool
|
||||
{
|
||||
$order = $ruleGroup->order;
|
||||
|
||||
// find the rule with order-1 and give it order+1
|
||||
$other = $this->user->ruleGroups()->where('order', $order - 1)->first();
|
||||
if ($other) {
|
||||
++$other->order;
|
||||
$other->save();
|
||||
}
|
||||
|
||||
--$ruleGroup->order;
|
||||
$ruleGroup->save();
|
||||
$this->resetRuleGroupOrder();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -128,20 +128,6 @@ interface RuleGroupRepositoryInterface
|
||||
*/
|
||||
public function maxOrder(): int;
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function moveDown(RuleGroup $ruleGroup): bool;
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function moveUp(RuleGroup $ruleGroup): bool;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user