Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix sqlite issues.
James Colef83ab0a7dc08
diff --git a/app/Helpers/Collector/Extensions/CollectorProperties.php b/app/Helpers/Collector/Extensions/CollectorProperties.phpindex 544478e881..39c8e50b6a 100644--- a/app/Helpers/Collector/Extensions/CollectorProperties.php+++ b/app/Helpers/Collector/Extensions/CollectorProperties.php@@ -33,6 +33,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;trait CollectorProperties{private array $fields;+ private array $stringFields;private bool $hasAccountInfo;private bool $hasBillInformation;private bool $hasBudgetInformation;diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.phpindex 358914c74a..b36f9c251b 100644--- a/app/Helpers/Collector/GroupCollector.php+++ b/app/Helpers/Collector/GroupCollector.php@@ -87,6 +87,7 @@ class GroupCollector implements GroupCollectorInterface'category_id','budget_id',];+ $this->stringFields = ['amount', 'foreign_amount'];$this->total = 0;$this->fields = [# group@@ -375,6 +376,9 @@ class GroupCollector implements GroupCollectorInterface// convert values to integers:$result = $this->convertToInteger($result);+ // convert back to strings because SQLite is dumb like that.+ $result = $this->convertToStrings($result);+$result['reconciled'] = 1 === (int) $result['reconciled'];if (array_key_exists('tag_id', $result) && null !== $result['tag_id']) { // assume the other fields are present as well.$tagId = (int) $augumentedJournal['tag_id'];@@ -506,7 +510,7 @@ class GroupCollector implements GroupCollectorInterface$groups[$groudId]['sums'][$currencyId]['currency_decimal_places'] = $transaction['currency_decimal_places'];$groups[$groudId]['sums'][$currencyId]['amount'] = '0';}- $groups[$groudId]['sums'][$currencyId]['amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], (string)($transaction['amount'] ?? '0'));+ $groups[$groudId]['sums'][$currencyId]['amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $transaction['amount']);if (null !== $transaction['foreign_amount'] && null !== $transaction['foreign_currency_id']) {$currencyId = (int) $transaction['foreign_currency_id'];@@ -815,4 +819,17 @@ class GroupCollector implements GroupCollectorInterfacereturn $this;}++ /**+ * @param array $array+ * @return array+ */+ private function convertToStrings(array $array): array+ {+ foreach ($this->stringFields as $field) {+ $array[$field] = array_key_exists($field, $array) ? (string) $array[$field] : '0';+ }++ return $array;+ }}