Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Double check on integers for https://github.com/firefly-iii/firefly-iii/issues/3554
James Cole8a9f6b189630
diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.phpindex db7d2abc05..dd46dd8b75 100644--- a/app/Transformers/AccountTransformer.php+++ b/app/Transformers/AccountTransformer.php@@ -181,12 +181,12 @@ class AccountTransformer extends AbstractTransformer{$currency = $this->repository->getAccountCurrency($account);$default = app('amount')->getDefaultCurrencyByUser($account->user);- $currencyId = $default->id;+ $currencyId = (int) $default->id;$currencyCode = $default->code;$decimalPlaces = $default->decimal_places;$currencySymbol = $default->symbol;if (null !== $currency) {- $currencyId = $currency->id;+ $currencyId = (int) $currency->id;$currencyCode = $currency->code;$decimalPlaces = $currency->decimal_places;$currencySymbol = $currency->symbol;diff --git a/app/Transformers/AttachmentTransformer.php b/app/Transformers/AttachmentTransformer.phpindex 0eac9fa90a..b2ff1d8729 100644--- a/app/Transformers/AttachmentTransformer.php+++ b/app/Transformers/AttachmentTransformer.php@@ -64,7 +64,7 @@ class AttachmentTransformer extends AbstractTransformer'id' => (int)$attachment->id,'created_at' => $attachment->created_at->toAtomString(),'updated_at' => $attachment->updated_at->toAtomString(),- 'attachable_id' => $attachment->attachable_id,+ 'attachable_id' => (int) $attachment->attachable_id,'attachable_type' => str_replace('FireflyIII\\Models\\', '', $attachment->attachable_type),'md5' => $attachment->md5,'filename' => $attachment->filename,diff --git a/app/Transformers/AvailableBudgetTransformer.php b/app/Transformers/AvailableBudgetTransformer.phpindex a70cfe9f9a..46bf5289f5 100644--- a/app/Transformers/AvailableBudgetTransformer.php+++ b/app/Transformers/AvailableBudgetTransformer.php@@ -74,10 +74,10 @@ class AvailableBudgetTransformer extends AbstractTransformer'id' => (int)$availableBudget->id,'created_at' => $availableBudget->created_at->toAtomString(),'updated_at' => $availableBudget->updated_at->toAtomString(),- 'currency_id' => $currency->id,+ 'currency_id' => (int) $currency->id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,- 'currency_decimal_places' => $currency->decimal_places,+ 'currency_decimal_places' => (int) $currency->decimal_places,'amount' => number_format((float) $availableBudget->amount, $currency->decimal_places, '.', ''),'start' => $availableBudget->start_date->format('Y-m-d'),'end' => $availableBudget->end_date->format('Y-m-d'),diff --git a/app/Transformers/BillTransformer.php b/app/Transformers/BillTransformer.phpindex 8920417a17..5d14bfb6a3 100644--- a/app/Transformers/BillTransformer.php+++ b/app/Transformers/BillTransformer.php@@ -84,10 +84,10 @@ class BillTransformer extends AbstractTransformer'id' => (int)$bill->id,'created_at' => $bill->created_at->toAtomString(),'updated_at' => $bill->updated_at->toAtomString(),- 'currency_id' => $bill->transaction_currency_id,+ 'currency_id' => (int) $bill->transaction_currency_id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,- 'currency_decimal_places' => $currency->decimal_places,+ 'currency_decimal_places' => (int) $currency->decimal_places,'name' => $bill->name,'amount_min' => number_format((float) $bill->amount_min, $currency->decimal_places, '.', ''),'amount_max' => number_format((float) $bill->amount_max, $currency->decimal_places, '.', ''),diff --git a/app/Transformers/BudgetLimitTransformer.php b/app/Transformers/BudgetLimitTransformer.phpindex 83f1adec2e..2486777992 100644--- a/app/Transformers/BudgetLimitTransformer.php+++ b/app/Transformers/BudgetLimitTransformer.php@@ -61,7 +61,7 @@ class BudgetLimitTransformer extends AbstractTransformer$currencySymbol = null;if (null !== $currency) {$amount = $budgetLimit->amount;- $currencyId = $currency->id;+ $currencyId = (int) $currency->id;$currencyName = $currency->name;$currencyCode = $currency->code;$currencySymbol = $currency->symbol;@@ -74,7 +74,7 @@ class BudgetLimitTransformer extends AbstractTransformer'updated_at' => $budgetLimit->updated_at->toAtomString(),'start' => $budgetLimit->start_date->format('Y-m-d'),'end' => $budgetLimit->end_date->format('Y-m-d'),- 'budget_id' => $budgetLimit->budget_id,+ 'budget_id' => (int) $budgetLimit->budget_id,'currency_id' => $currencyId,'currency_code' => $currencyCode,'currency_name' => $currencyName,diff --git a/app/Transformers/BudgetTransformer.php b/app/Transformers/BudgetTransformer.phpindex 684f0d6f23..00af00361c 100644--- a/app/Transformers/BudgetTransformer.php+++ b/app/Transformers/BudgetTransformer.php@@ -85,7 +85,7 @@ class BudgetTransformer extends AbstractTransformer];if (null !== $autoBudget) {- $abCurrencyId = $autoBudget->transactionCurrency->id;+ $abCurrencyId = (int) $autoBudget->transactionCurrency->id;$abCurrencyCode = $autoBudget->transactionCurrency->code;$abType = $types[$autoBudget->auto_budget_type];$abAmount = number_format((float) $autoBudget->amount, $autoBudget->transactionCurrency->decimal_places, '.', '');diff --git a/app/Transformers/CurrencyExchangeRateTransformer.php b/app/Transformers/CurrencyExchangeRateTransformer.phpindex 26109ec74b..ccff93976c 100644--- a/app/Transformers/CurrencyExchangeRateTransformer.php+++ b/app/Transformers/CurrencyExchangeRateTransformer.php@@ -58,16 +58,16 @@ class CurrencyExchangeRateTransformer extends AbstractTransformer'id' => (int)$rate->id,'created_at' => $rate->created_at->toAtomString(),'updated_at' => $rate->updated_at->toAtomString(),- 'from_currency_id' => $rate->fromCurrency->id,+ 'from_currency_id' => (int) $rate->fromCurrency->id,'from_currency_name' => $rate->fromCurrency->name,'from_currency_code' => $rate->fromCurrency->code,'from_currency_symbol' => $rate->fromCurrency->symbol,- 'from_currency_decimal_places' => $rate->fromCurrency->decimal_places,- 'to_currency_id' => $rate->toCurrency->id,+ 'from_currency_decimal_places' => (int) $rate->fromCurrency->decimal_places,+ 'to_currency_id' => (int) $rate->toCurrency->id,'to_currency_name' => $rate->toCurrency->name,'to_currency_code' => $rate->toCurrency->code,'to_currency_symbol' => $rate->toCurrency->symbol,- 'to_currency_decimal_places' => $rate->toCurrency->decimal_places,+ 'to_currency_decimal_places' => (int) $rate->toCurrency->decimal_places,'date' => $rate->date->format('Y-m-d'),'rate' => (float)$rate->rate,'amount' => $result,diff --git a/app/Transformers/PiggyBankEventTransformer.php b/app/Transformers/PiggyBankEventTransformer.phpindex 46fd23d311..ee952434e3 100644--- a/app/Transformers/PiggyBankEventTransformer.php+++ b/app/Transformers/PiggyBankEventTransformer.php@@ -78,20 +78,21 @@ class PiggyBankEventTransformer extends AbstractTransformer$currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUser($account->user);// get associated journal and transaction, if any:- $journalId = (int)$event->transaction_journal_id;+ $journalId = $event->transaction_journal_id;$groupId = null;- if (0 !== $journalId) {- $groupId = (int)$event->transactionJournal->transaction_group_id;+ if (0 !== (int) $journalId) {+ $groupId = (int) $event->transactionJournal->transaction_group_id;+ $journalId = (int) $journalId;}$data = ['id' => (int) $event->id,'created_at' => $event->created_at->toAtomString(),'updated_at' => $event->updated_at->toAtomString(),'amount' => number_format((float) $event->amount, $currency->decimal_places, '.', ''),- 'currency_id' => $currency->id,+ 'currency_id' => (int) $currency->id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,- 'currency_decimal_places' => $currency->decimal_places,+ 'currency_decimal_places' => (int) $currency->decimal_places,'transaction_journal_id' => $journalId,'transaction_group_id' => $groupId,'links' => [diff --git a/app/Transformers/PiggyBankTransformer.php b/app/Transformers/PiggyBankTransformer.phpindex 3d79f34396..ccff382712 100644--- a/app/Transformers/PiggyBankTransformer.php+++ b/app/Transformers/PiggyBankTransformer.php@@ -112,13 +112,13 @@ class PiggyBankTransformer extends AbstractTransformer'id' => (int) $piggyBank->id,'created_at' => $piggyBank->created_at->toAtomString(),'updated_at' => $piggyBank->updated_at->toAtomString(),- 'account_id' => $piggyBank->account_id,+ 'account_id' => (int) $piggyBank->account_id,'account_name' => $piggyBank->account->name,'name' => $piggyBank->name,- 'currency_id' => $currency->id,+ 'currency_id' => (int) $currency->id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,- 'currency_decimal_places' => $currency->decimal_places,+ 'currency_decimal_places' => (int) $currency->decimal_places,'target_amount' => number_format((float) $targetAmount, $currency->decimal_places, '.', ''),'percentage' => $percentage,'current_amount' => $currentAmount,diff --git a/app/Transformers/RecurrenceTransformer.php b/app/Transformers/RecurrenceTransformer.phpindex 0444dfef50..7d72d6fb50 100644--- a/app/Transformers/RecurrenceTransformer.php+++ b/app/Transformers/RecurrenceTransformer.php@@ -133,13 +133,13 @@ class RecurrenceTransformer extends AbstractTransformer/** @var RecurrenceRepetition $repetition */foreach ($recurrence->recurrenceRepetitions as $repetition) {$repetitionArray = [- 'id' => $repetition->id,+ 'id' => (int) $repetition->id,'created_at' => $repetition->created_at->toAtomString(),'updated_at' => $repetition->updated_at->toAtomString(),'type' => $repetition->repetition_type,'moment' => $repetition->repetition_moment,- 'skip' => (int)$repetition->repetition_skip,- 'weekend' => (int)$repetition->weekend,+ 'skip' => (int) $repetition->repetition_skip,+ 'weekend' => (int) $repetition->weekend,'description' => $this->repository->repetitionDescription($repetition),'occurrences' => [],];@@ -188,21 +188,21 @@ class RecurrenceTransformer extends AbstractTransformercase 'piggy_bank_id':$piggy = $this->piggyRepos->findNull((int)$transactionMeta->value);if (null !== $piggy) {- $array['piggy_bank_id'] = $piggy->id;+ $array['piggy_bank_id'] = (int) $piggy->id;$array['piggy_bank_name'] = $piggy->name;}break;case 'category_name':$category = $this->factory->findOrCreate(null, $transactionMeta->value);if (null !== $category) {- $array['category_id'] = $category->id;+ $array['category_id'] = (int) $category->id;$array['category_name'] = $category->name;}break;case 'budget_id':$budget = $this->budgetRepos->findNull((int)$transactionMeta->value);if (null !== $budget) {- $array['budget_id'] = $budget->id;+ $array['budget_id'] = (int) $budget->id;$array['budget_name'] = $budget->name;}break;@@ -231,10 +231,12 @@ class RecurrenceTransformer extends AbstractTransformer$foreignCurrencyCode = null;$foreignCurrencySymbol = null;$foreignCurrencyDp = null;+ $foreignCurrencyId = null;if (null !== $transaction->foreign_currency_id) {+ $foreignCurrencyId = (int) $transaction->foreign_currency_id;$foreignCurrencyCode = $transaction->foreignCurrency->code;$foreignCurrencySymbol = $transaction->foreignCurrency->symbol;- $foreignCurrencyDp = $transaction->foreignCurrency->decimal_places;+ $foreignCurrencyDp = (int) $transaction->foreignCurrency->decimal_places;}// source info:@@ -244,7 +246,7 @@ class RecurrenceTransformer extends AbstractTransformer$sourceIban = null;if (null !== $sourceAccount) {$sourceName = $sourceAccount->name;- $sourceId = $sourceAccount->id;+ $sourceId = (int) $sourceAccount->id;$sourceType = $sourceAccount->accountType->type;$sourceIban = $sourceAccount->iban;}@@ -254,7 +256,7 @@ class RecurrenceTransformer extends AbstractTransformer$destinationIban = null;if (null !== $destinationAccount) {$destinationName = $destinationAccount->name;- $destinationId = $destinationAccount->id;+ $destinationId = (int) $destinationAccount->id;$destinationType = $destinationAccount->accountType->type;$destinationIban = $destinationAccount->iban;}@@ -266,11 +268,11 @@ class RecurrenceTransformer extends AbstractTransformer$foreignAmount = number_format($transaction->foreign_amount, $foreignCurrencyDp, '.', '');}$transactionArray = [- 'currency_id' => $transaction->transaction_currency_id,+ 'currency_id' => (int) $transaction->transaction_currency_id,'currency_code' => $transaction->transactionCurrency->code,'currency_symbol' => $transaction->transactionCurrency->symbol,- 'currency_decimal_places' => $transaction->transactionCurrency->decimal_places,- 'foreign_currency_id' => $transaction->foreign_currency_id,+ 'currency_decimal_places' => (int) $transaction->transactionCurrency->decimal_places,+ 'foreign_currency_id' => $foreignCurrencyId,'foreign_currency_code' => $foreignCurrencyCode,'foreign_currency_symbol' => $foreignCurrencySymbol,'foreign_currency_decimal_places' => $foreignCurrencyDp,diff --git a/app/Transformers/TransactionGroupTransformer.php b/app/Transformers/TransactionGroupTransformer.phpindex bb7f55bbdd..bbe25538d6 100644--- a/app/Transformers/TransactionGroupTransformer.php+++ b/app/Transformers/TransactionGroupTransformer.php@@ -162,7 +162,7 @@ class TransactionGroupTransformer extends AbstractTransformerif (null === $bill) {return $array;}- $array['id'] = $bill->id;+ $array['id'] = (int) $bill->id;$array['name'] = $bill->name;return $array;@@ -182,7 +182,7 @@ class TransactionGroupTransformer extends AbstractTransformerif (null === $budget) {return $array;}- $array['id'] = $budget->id;+ $array['id'] = (int) $budget->id;$array['name'] = $budget->name;return $array;@@ -202,7 +202,7 @@ class TransactionGroupTransformer extends AbstractTransformerif (null === $category) {return $array;}- $array['id'] = $category->id;+ $array['id'] = (int) $category->id;$array['name'] = $category->name;return $array;@@ -286,10 +286,10 @@ class TransactionGroupTransformer extends AbstractTransformerif (null === $currency) {return $array;}- $array['id'] = $currency->id;+ $array['id'] = (int) $currency->id;$array['code'] = $currency->code;$array['symbol'] = $currency->symbol;- $array['decimal_places'] = $currency->decimal_places;+ $array['decimal_places'] = (int) $currency->decimal_places;return $array;}@@ -341,15 +341,15 @@ class TransactionGroupTransformer extends AbstractTransformerreturn ['user' => (int) $journal->user_id,- 'transaction_journal_id' => $journal->id,+ 'transaction_journal_id' => (int) $journal->id,'type' => strtolower($type),'date' => $journal->date->toAtomString(),'order' => $journal->order,- 'currency_id' => $currency->id,+ 'currency_id' => (int) $currency->id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,- 'currency_decimal_places' => $currency->decimal_places,+ 'currency_decimal_places' => (int) $currency->decimal_places,'foreign_currency_id' => $foreignCurrency['id'],'foreign_currency_code' => $foreignCurrency['code'],@@ -361,12 +361,12 @@ class TransactionGroupTransformer extends AbstractTransformer'description' => $journal->description,- 'source_id' => $source->account_id,+ 'source_id' => (int) $source->account_id,'source_name' => $source->account->name,'source_iban' => $source->account->iban,'source_type' => $source->account->accountType->type,- 'destination_id' => $destination->account_id,+ 'destination_id' => (int) $destination->account_id,'destination_name' => $destination->account->name,'destination_iban' => $destination->account->iban,'destination_type' => $destination->account->accountType->type,@@ -450,19 +450,19 @@ class TransactionGroupTransformer extends AbstractTransformer$metaDateData = $this->groupRepos->getMetaDateFields((int)$row['transaction_journal_id'], $this->metaDateFields);$result[] = [- 'user' => (int)$row['user_id'],- 'transaction_journal_id' => $row['transaction_journal_id'],+ 'user' => (int) $row['user_id'],+ 'transaction_journal_id' => (int) $row['transaction_journal_id'],'type' => strtolower($type),'date' => $row['date']->toAtomString(),'order' => $row['order'],- 'currency_id' => $row['currency_id'],+ 'currency_id' => (int) $row['currency_id'],'currency_code' => $row['currency_code'],'currency_name' => $row['currency_name'],'currency_symbol' => $row['currency_symbol'],- 'currency_decimal_places' => $row['currency_decimal_places'],+ 'currency_decimal_places' => (int) $row['currency_decimal_places'],- 'foreign_currency_id' => $row['foreign_currency_id'],+ 'foreign_currency_id' => $row['foreign_currency_id'] ? (int) $row['foreign_currency_id'] : null,'foreign_currency_code' => $row['foreign_currency_code'],'foreign_currency_symbol' => $row['foreign_currency_symbol'],'foreign_currency_decimal_places' => $row['foreign_currency_decimal_places'],@@ -472,23 +472,23 @@ class TransactionGroupTransformer extends AbstractTransformer'description' => $row['description'],- 'source_id' => $row['source_account_id'],+ 'source_id' => (int) $row['source_account_id'],'source_name' => $row['source_account_name'],'source_iban' => $row['source_account_iban'],'source_type' => $row['source_account_type'],- 'destination_id' => $row['destination_account_id'],+ 'destination_id' => (int) $row['destination_account_id'],'destination_name' => $row['destination_account_name'],'destination_iban' => $row['destination_account_iban'],'destination_type' => $row['destination_account_type'],- 'budget_id' => $row['budget_id'],+ 'budget_id' => $row['budget_id'] ? (int) $row['budget_id'] : null,'budget_name' => $row['budget_name'],- 'category_id' => $row['category_id'],+ 'category_id' => $row['category_id'] ? (int) $row['category_id'] : null,'category_name' => $row['category_name'],- 'bill_id' => $row['bill_id'],+ 'bill_id' => $row['bill_id'] ? (int) $row['bill_id'] : null,'bill_name' => $row['bill_name'],'reconciled' => $row['reconciled'],diff --git a/app/Transformers/TransactionLinkTransformer.php b/app/Transformers/TransactionLinkTransformer.phpindex 28bb330962..8c6d7fafac 100644--- a/app/Transformers/TransactionLinkTransformer.php+++ b/app/Transformers/TransactionLinkTransformer.php@@ -63,9 +63,9 @@ class TransactionLinkTransformer extends AbstractTransformer'id' => (int)$link->id,'created_at' => $link->created_at->toAtomString(),'updated_at' => $link->updated_at->toAtomString(),- 'inward_id' => $link->source_id,- 'outward_id' => $link->destination_id,- 'link_type_id' => $link->link_type_id,+ 'inward_id' => (int) $link->source_id,+ 'outward_id' => (int) $link->destination_id,+ 'link_type_id' => (int) $link->link_type_id,'notes' => '' === $notes ? null : $notes,'links' => [[