mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 04:03:26 +00:00
Fix #4003
This commit is contained in:
@@ -47,7 +47,7 @@ class BudgetFormStoreRequest extends FormRequest
|
|||||||
'name' => $this->string('name'),
|
'name' => $this->string('name'),
|
||||||
'active' => $this->boolean('active'),
|
'active' => $this->boolean('active'),
|
||||||
'auto_budget_type' => $this->integer('auto_budget_type'),
|
'auto_budget_type' => $this->integer('auto_budget_type'),
|
||||||
'transaction_currency_id' => $this->integer('transaction_currency_id'),
|
'transaction_currency_id' => $this->integer('auto_budget_currency_id'),
|
||||||
'auto_budget_amount' => $this->string('auto_budget_amount'),
|
'auto_budget_amount' => $this->string('auto_budget_amount'),
|
||||||
'auto_budget_period' => $this->string('auto_budget_period'),
|
'auto_budget_period' => $this->string('auto_budget_period'),
|
||||||
];
|
];
|
||||||
|
@@ -161,6 +161,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
if (null !== $journal) {
|
if (null !== $journal) {
|
||||||
return $journal->date;
|
return $journal->date;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,7 +209,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $query
|
* @param string $query
|
||||||
* @param int $limit
|
* @param int $limit
|
||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
@@ -220,7 +221,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
$search->where('name', 'LIKE', sprintf('%%%s%%', $query));
|
$search->where('name', 'LIKE', sprintf('%%%s%%', $query));
|
||||||
}
|
}
|
||||||
$search->orderBy('order', 'ASC')
|
$search->orderBy('order', 'ASC')
|
||||||
->orderBy('name', 'ASC')->where('active', 1);
|
->orderBy('name', 'ASC')->where('active', 1);
|
||||||
|
|
||||||
return $search->take($limit)->get();
|
return $search->take($limit)->get();
|
||||||
}
|
}
|
||||||
@@ -277,15 +278,15 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
if ('rollover' === $type) {
|
if ('rollover' === $type) {
|
||||||
$type = AutoBudget::AUTO_BUDGET_ROLLOVER;
|
$type = AutoBudget::AUTO_BUDGET_ROLLOVER;
|
||||||
}
|
}
|
||||||
$repos = app(CurrencyRepositoryInterface::class);
|
$repos = app(CurrencyRepositoryInterface::class);
|
||||||
$currencyId = (int)($data['transaction_currency_id'] ?? 0);
|
$currencyId = (int)($data['transaction_currency_id'] ?? 0);
|
||||||
$currencyCode = (string)($data['transaction_currency_code'] ?? '');
|
$currencyCode = (string)($data['transaction_currency_code'] ?? '');
|
||||||
|
|
||||||
$currency = $repos->findNull($currencyId);
|
$currency = $repos->findNull($currencyId);
|
||||||
if(null === $currency) {
|
if (null === $currency) {
|
||||||
$currency = $repos->findByCodeNull($currencyCode);
|
$currency = $repos->findByCodeNull($currencyCode);
|
||||||
}
|
}
|
||||||
if(null === $currency) {
|
if (null === $currency) {
|
||||||
$currency = app('amount')->getDefaultCurrencyByUser($this->user);
|
$currency = app('amount')->getDefaultCurrencyByUser($this->user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,11 +307,11 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
$limitRepos->setUser($this->user);
|
$limitRepos->setUser($this->user);
|
||||||
$limitRepos->store(
|
$limitRepos->store(
|
||||||
[
|
[
|
||||||
'budget_id' => $newBudget->id,
|
'budget_id' => $newBudget->id,
|
||||||
'transaction_currency_id' => $autoBudget->transaction_currency_id,
|
'currency_id' => $autoBudget->transaction_currency_id,
|
||||||
'start_date' => $start,
|
'start_date' => $start,
|
||||||
'end_date' => $end,
|
'end_date' => $end,
|
||||||
'amount' => $autoBudget->amount,
|
'amount' => $autoBudget->amount,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -348,15 +349,15 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
$autoBudget->budget()->associate($budget);
|
$autoBudget->budget()->associate($budget);
|
||||||
}
|
}
|
||||||
|
|
||||||
$repos = app(CurrencyRepositoryInterface::class);
|
$repos = app(CurrencyRepositoryInterface::class);
|
||||||
$currencyId = (int)($data['transaction_currency_id'] ?? 0);
|
$currencyId = (int)($data['transaction_currency_id'] ?? 0);
|
||||||
$currencyCode = (string)($data['transaction_currency_code'] ?? '');
|
$currencyCode = (string)($data['transaction_currency_code'] ?? '');
|
||||||
|
|
||||||
$currency = $repos->findNull($currencyId);
|
$currency = $repos->findNull($currencyId);
|
||||||
if(null === $currency) {
|
if (null === $currency) {
|
||||||
$currency = $repos->findByCodeNull($currencyCode);
|
$currency = $repos->findByCodeNull($currencyCode);
|
||||||
}
|
}
|
||||||
if(null === $currency) {
|
if (null === $currency) {
|
||||||
$currency = app('amount')->getDefaultCurrencyByUser($this->user);
|
$currency = app('amount')->getDefaultCurrencyByUser($this->user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user