This commit is contained in:
James Cole 2020-10-28 06:14:12 +01:00
parent 7b9f2b6ce5
commit 3aa835a985
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D
2 changed files with 17 additions and 16 deletions

View File

@ -47,7 +47,7 @@ class BudgetFormStoreRequest extends FormRequest
'name' => $this->string('name'),
'active' => $this->boolean('active'),
'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_period' => $this->string('auto_budget_period'),
];

View File

@ -161,6 +161,7 @@ class BudgetRepository implements BudgetRepositoryInterface
if (null !== $journal) {
return $journal->date;
}
return null;
}
@ -208,7 +209,7 @@ class BudgetRepository implements BudgetRepositoryInterface
/**
* @param string $query
* @param int $limit
* @param int $limit
*
* @return Collection
*/
@ -220,7 +221,7 @@ class BudgetRepository implements BudgetRepositoryInterface
$search->where('name', 'LIKE', sprintf('%%%s%%', $query));
}
$search->orderBy('order', 'ASC')
->orderBy('name', 'ASC')->where('active', 1);
->orderBy('name', 'ASC')->where('active', 1);
return $search->take($limit)->get();
}
@ -277,15 +278,15 @@ class BudgetRepository implements BudgetRepositoryInterface
if ('rollover' === $type) {
$type = AutoBudget::AUTO_BUDGET_ROLLOVER;
}
$repos = app(CurrencyRepositoryInterface::class);
$currencyId = (int)($data['transaction_currency_id'] ?? 0);
$repos = app(CurrencyRepositoryInterface::class);
$currencyId = (int)($data['transaction_currency_id'] ?? 0);
$currencyCode = (string)($data['transaction_currency_code'] ?? '');
$currency = $repos->findNull($currencyId);
if(null === $currency) {
if (null === $currency) {
$currency = $repos->findByCodeNull($currencyCode);
}
if(null === $currency) {
if (null === $currency) {
$currency = app('amount')->getDefaultCurrencyByUser($this->user);
}
@ -306,11 +307,11 @@ class BudgetRepository implements BudgetRepositoryInterface
$limitRepos->setUser($this->user);
$limitRepos->store(
[
'budget_id' => $newBudget->id,
'transaction_currency_id' => $autoBudget->transaction_currency_id,
'start_date' => $start,
'end_date' => $end,
'amount' => $autoBudget->amount,
'budget_id' => $newBudget->id,
'currency_id' => $autoBudget->transaction_currency_id,
'start_date' => $start,
'end_date' => $end,
'amount' => $autoBudget->amount,
]
);
@ -348,15 +349,15 @@ class BudgetRepository implements BudgetRepositoryInterface
$autoBudget->budget()->associate($budget);
}
$repos = app(CurrencyRepositoryInterface::class);
$currencyId = (int)($data['transaction_currency_id'] ?? 0);
$repos = app(CurrencyRepositoryInterface::class);
$currencyId = (int)($data['transaction_currency_id'] ?? 0);
$currencyCode = (string)($data['transaction_currency_code'] ?? '');
$currency = $repos->findNull($currencyId);
if(null === $currency) {
if (null === $currency) {
$currency = $repos->findByCodeNull($currencyCode);
}
if(null === $currency) {
if (null === $currency) {
$currency = app('amount')->getDefaultCurrencyByUser($this->user);
}