Make sure integers are converted to strings because sqlite sucks.

This commit is contained in:
James Cole
2024-12-29 06:32:50 +01:00
parent 9a9dd9e075
commit 3c20e5f3af
11 changed files with 21 additions and 14 deletions

View File

@@ -198,8 +198,10 @@ class FrontpageChartGenerator
}
$useNative = $this->convertToNative && $this->default->id !== $limit->transaction_currency_id;
$amount = $limit->amount;
if ($useNative) {
Log::debug(sprintf('Amount is "%s".', $amount));
if ($useNative && $limit->transaction_currency_id !== $this->default->id) {
$amount = $limit->native_amount;
Log::debug(sprintf('Amount is now "%s".', $amount));
}
@@ -208,7 +210,6 @@ class FrontpageChartGenerator
$data[1]['entries'][$title] ??= '0';
$data[2]['entries'][$title] ??= '0';
$data[0]['entries'][$title] = bcadd($data[0]['entries'][$title], 1 === bccomp($sumSpent, $amount) ? $amount : $sumSpent); // spent
$data[1]['entries'][$title] = bcadd($data[1]['entries'][$title], 1 === bccomp($amount, $sumSpent) ? bcadd($entry['sum'], $amount) : '0'); // left to spent
$data[2]['entries'][$title] = bcadd($data[2]['entries'][$title], 1 === bccomp($amount, $sumSpent) ? '0' : bcmul(bcadd($entry['sum'], $amount), '-1')); // overspent