Merge branch 'develop' into 5.8-dev

# Conflicts:
#	app/Api/V1/Controllers/Chart/AccountController.php
#	app/Api/V1/Controllers/Insight/Expense/AccountController.php
#	app/Api/V1/Controllers/Insight/Expense/BillController.php
#	app/Api/V1/Controllers/Insight/Expense/BudgetController.php
#	app/Api/V1/Controllers/Insight/Expense/CategoryController.php
#	app/Api/V1/Controllers/Insight/Expense/PeriodController.php
#	app/Console/Commands/Upgrade/MigrateToGroups.php
#	app/Http/Controllers/Account/IndexController.php
#	app/Http/Controllers/Budget/AvailableBudgetController.php
#	app/Http/Controllers/Budget/BudgetLimitController.php
#	app/Http/Controllers/Budget/EditController.php
#	app/Http/Controllers/Chart/AccountController.php
#	app/Http/Controllers/Json/FrontpageController.php
#	app/Http/Controllers/PiggyBank/EditController.php
This commit is contained in:
James Cole
2022-12-24 06:15:26 +01:00
47 changed files with 428 additions and 306 deletions

View File

@@ -140,7 +140,7 @@ class AccountTasker implements AccountTaskerInterface
// Obtain a list of columns
$sum = [];
foreach ($report['accounts'] as $accountId => $row) {
$sum[$accountId] = (float) $row['sum'];
$sum[$accountId] = (float) $row['sum']; // intentional float
}
array_multisort($sum, SORT_ASC, $report['accounts']);
@@ -235,7 +235,7 @@ class AccountTasker implements AccountTaskerInterface
// Obtain a list of columns
$sum = [];
foreach ($report['accounts'] as $accountId => $row) {
$sum[$accountId] = (float) $row['sum'];
$sum[$accountId] = (float) $row['sum']; // intentional float
}
array_multisort($sum, SORT_DESC, $report['accounts']);

View File

@@ -138,7 +138,7 @@ class NoBudgetRepository implements NoBudgetRepositoryInterface
'currency_name' => $currency['name'],
'currency_symbol' => $currency['symbol'],
'currency_decimal_places' => $currency['decimal_places'],
'amount' => number_format((float) $spent, $currency['decimal_places'], '.', ''),
'amount' => app('steam')->bcround($spent, $currency['decimal_places']),
];
}

View File

@@ -273,7 +273,7 @@ class OperationsRepository implements OperationsRepositoryInterface
'currency_name' => $currency['name'],
'currency_symbol' => $currency['symbol'],
'currency_decimal_places' => $currency['decimal_places'],
'amount' => number_format((float) $spent, $currency['decimal_places'], '.', ''),
'amount' => app('steam')->bcround($spent, $currency['decimal_places']),
];
}

View File

@@ -96,7 +96,7 @@ trait ModifiesPiggyBanks
$savedSoFar = (string)$this->getRepetition($piggyBank)->currentamount;
$maxAmount = $leftOnAccount;
$leftToSave = null;
if (0.0 !== (float)$piggyBank->targetamount) {
if (0 !== bccomp($piggyBank->targetamount, '0')) {
$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);
$maxAmount = 1 === bccomp($leftOnAccount, $leftToSave) ? $leftToSave : $leftOnAccount;
}
@@ -383,7 +383,7 @@ trait ModifiesPiggyBanks
// if the piggy bank is now smaller than the current relevant rep,
// remove money from the rep.
$repetition = $this->getRepetition($piggyBank);
if (null !== $repetition && $repetition->currentamount > $piggyBank->targetamount && 0.0 !== (float)$piggyBank->targetamount) {
if (null !== $repetition && $repetition->currentamount > $piggyBank->targetamount && 0 !== bccomp($piggyBank->targetamount, '0')) {
$difference = bcsub($piggyBank->targetamount, $repetition->currentamount);
// an amount will be removed, create "negative" event:
@@ -446,6 +446,9 @@ trait ModifiesPiggyBanks
if (array_key_exists('targetamount', $data) && '' !== $data['targetamount']) {
$piggyBank->targetamount = $data['targetamount'];
}
if (array_key_exists('targetamount', $data) && '' === $data['targetamount']) {
$piggyBank->targetamount = '0';
}
if (array_key_exists('targetdate', $data) && '' !== $data['targetdate']) {
$piggyBank->targetdate = $data['targetdate'];
}