mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-09 23:15:45 -06:00
Fix #996
This commit is contained in:
parent
64fc6b6523
commit
1045ed13fa
@ -81,7 +81,7 @@ class BudgetController extends Controller
|
||||
*/
|
||||
public function amount(Request $request, Budget $budget)
|
||||
{
|
||||
$amount = intval($request->get('amount'));
|
||||
$amount = strval($request->get('amount'));
|
||||
$start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
|
||||
$end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
|
||||
$budgetLimit = $this->repository->updateLimitAmount($budget, $start, $end, $amount);
|
||||
|
@ -87,6 +87,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
/** @var AccountRepositoryInterface $accountRepository */
|
||||
$accountRepository = app(AccountRepositoryInterface::class);
|
||||
$accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$return = [];
|
||||
/** @var Budget $budget */
|
||||
foreach ($budgets as $budget) {
|
||||
@ -105,7 +106,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
if ($limit->start_date->isSameDay($start) && $limit->end_date->isSameDay($end)
|
||||
) {
|
||||
$return[$budgetId]['currentLimit'] = $limit;
|
||||
$return[$budgetId]['budgeted'] = $limit->amount;
|
||||
$return[$budgetId]['budgeted'] = round($limit->amount, $defaultCurrency->decimal_places);
|
||||
continue;
|
||||
}
|
||||
// otherwise it's just one of the many relevant repetitions:
|
||||
@ -599,11 +600,11 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
* @param Budget $budget
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param int $amount
|
||||
* @param string $amount
|
||||
*
|
||||
* @return BudgetLimit
|
||||
*/
|
||||
public function updateLimitAmount(Budget $budget, Carbon $start, Carbon $end, int $amount): BudgetLimit
|
||||
public function updateLimitAmount(Budget $budget, Carbon $start, Carbon $end, string $amount): BudgetLimit
|
||||
{
|
||||
// count the limits:
|
||||
$limits = $budget->budgetlimits()
|
||||
@ -626,7 +627,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
}
|
||||
|
||||
// delete if amount is zero.
|
||||
if (null !== $limit && $amount <= 0.0) {
|
||||
if (null !== $limit && bccomp('0', $amount) < 0) {
|
||||
$limit->delete();
|
||||
|
||||
return new BudgetLimit;
|
||||
|
@ -214,5 +214,5 @@ interface BudgetRepositoryInterface
|
||||
*
|
||||
* @return BudgetLimit
|
||||
*/
|
||||
public function updateLimitAmount(Budget $budget, Carbon $start, Carbon $end, int $amount): BudgetLimit;
|
||||
public function updateLimitAmount(Budget $budget, Carbon $start, Carbon $end, string $amount): BudgetLimit;
|
||||
}
|
||||
|
@ -164,7 +164,7 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
{% if budgetInformation[budget.id]['currentLimit'] %}
|
||||
{% set repAmount = budgetInformation[budget.id]['currentLimit'].amount %}
|
||||
{% set repAmount = budgetInformation[budget.id]['budgeted'] %}
|
||||
{% else %}
|
||||
{% set repAmount = '0' %}
|
||||
{% endif %}
|
||||
@ -174,8 +174,8 @@
|
||||
<div class="input-group-addon">{{ defaultCurrency.symbol|raw }}</div>
|
||||
<input type="hidden" name="balance_currency_id" value="{{ defaultCurrency.id }}"/>
|
||||
<input class="form-control budgetAmount" data-original="{{ repAmount }}"
|
||||
data-id="{{ budget.id }}" value="{{ repAmount|round }}" autocomplete="off"
|
||||
step="1" min="0" name="amount" type="number">
|
||||
data-id="{{ budget.id }}" value="{{ repAmount }}" autocomplete="off"
|
||||
min="0" name="amount" type="number">
|
||||
</div>
|
||||
</td>
|
||||
<td class="hidden-sm hidden-xs spent" data-id="{{ budget.id }}" data-spent="{{ budgetInformation[budget.id]['spent'] }}"
|
||||
|
Loading…
Reference in New Issue
Block a user