Skip to content

Firefly III: a personal finances manager

Fix #3263

James Cole54933fda2ec3
diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php
index ed0e426bcf..91e1cdaf18 100644
--- a/app/Factory/TransactionJournalFactory.php
+++ b/app/Factory/TransactionJournalFactory.php
@@ -280,25 +280,29 @@ class TransactionJournalFactory
/** create or get source and destination accounts */
$sourceInfo = [
- 'id' => (int) $row['source_id'],
- 'name' => $row['source_name'],
- 'iban' => $row['source_iban'],
- 'number' => $row['source_number'],
- 'bic' => $row['source_bic'],
+ 'id' => (int) $row['source_id'],
+ 'name' => $row['source_name'],
+ 'iban' => $row['source_iban'],
+ 'number' => $row['source_number'],
+ 'bic' => $row['source_bic'],
+ 'currency_id' => $currency->id,
];
$destInfo = [
- 'id' => (int) $row['destination_id'],
- 'name' => $row['destination_name'],
- 'iban' => $row['destination_iban'],
- 'number' => $row['destination_number'],
- 'bic' => $row['destination_bic'],
+ 'id' => (int) $row['destination_id'],
+ 'name' => $row['destination_name'],
+ 'iban' => $row['destination_iban'],
+ 'number' => $row['destination_number'],
+ 'bic' => $row['destination_bic'],
+ 'currency_id' => $currency->id,
];
Log::debug('Source info:', $sourceInfo);
Log::debug('Destination info:', $destInfo);
-
- $sourceAccount = $this->getAccount($type->type, 'source', $sourceInfo);
+ Log::debug('Now calling getAccount for the source.');
+ $sourceAccount = $this->getAccount($type->type, 'source', $sourceInfo);
+ Log::debug('Now calling getAccount for the destination.');
$destinationAccount = $this->getAccount($type->type, 'destination', $destInfo);
+ Log::debug('Done with getAccount(2x)');
$currency = $this->getCurrencyByAccount($type->type, $currency, $sourceAccount, $destinationAccount);
$foreignCurrency = $this->compareCurrencies($currency, $foreignCurrency);
$foreignCurrency = $this->getForeignByAccount($type->type, $foreignCurrency, $destinationAccount);
@@ -468,6 +472,7 @@ class TransactionJournalFactory
*/
private function getCurrency(?TransactionCurrency $currency, Account $account): TransactionCurrency
{
+ Log::debug('Now in getCurrency()');
$preference = $this->accountRepository->getAccountCurrency($account);
if (null === $preference && null === $currency) {
// return user's default:
@@ -489,6 +494,7 @@ class TransactionJournalFactory
*/
private function getCurrencyByAccount(string $type, ?TransactionCurrency $currency, Account $source, Account $destination): TransactionCurrency
{
+ Log::debug('Now ingetCurrencyByAccount()');
switch ($type) {
default:
case TransactionType::WITHDRAWAL:
diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.php
index 82ffa2086c..6fcd63bab4 100644
--- a/app/Http/Controllers/Json/BoxController.php
+++ b/app/Http/Controllers/Json/BoxController.php
@@ -263,7 +263,7 @@ class BoxController extends Controller
*/
public function netWorth(): JsonResponse
{
- $date = Carbon::now()->startOfDay();
+ $date = Carbon::now()->endOfDay();
// start and end in the future? use $end
if ($this->notInSessionRange($date)) {
diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.php
index 8f1f8149ab..579cb1d5ee 100644
--- a/app/Http/Controllers/NewUserController.php
+++ b/app/Http/Controllers/NewUserController.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
use FireflyIII\Http\Requests\NewUserFormRequest;
+use FireflyIII\Models\AccountType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Support\Http\Controllers\CreateStuff;
@@ -110,6 +111,12 @@ class NewUserController extends Controller
// store currency preference:
app('preferences')->set('currencyPreference', $currency->code);
+
+ // store frontpage preferences:
+ $accounts = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray();
+ app('preferences')->set('frontPageAccounts', $accounts);
+
+ // mark.
app('preferences')->mark();
// set default optional fields:
diff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.php
index dc000903b0..f91030ddc0 100644
--- a/app/Services/Internal/Support/AccountServiceTrait.php
+++ b/app/Services/Internal/Support/AccountServiceTrait.php
@@ -237,7 +237,6 @@ trait AccountServiceTrait
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
-
// @codeCoverageIgnoreEnd
return $group;
diff --git a/app/Services/Internal/Support/JournalServiceTrait.php b/app/Services/Internal/Support/JournalServiceTrait.php
index b181d2c723..3b23c13d9a 100644
--- a/app/Services/Internal/Support/JournalServiceTrait.php
+++ b/app/Services/Internal/Support/JournalServiceTrait.php
@@ -345,6 +345,7 @@ trait JournalServiceTrait
*/
private function createAccount(?Account $account, array $data, string $preferredType): Account
{
+ Log::debug('Now in createAccount()', $data);
// return new account.
if (null === $account) {
$data['name'] = $data['name'] ?? '(no name)';
@@ -362,6 +363,7 @@ trait JournalServiceTrait
'virtual_balance' => null,
'active' => true,
'iban' => $data['iban'],
+ 'currency_id' => $data['currency_id'] ?? null,
]
);
// store BIC
@@ -376,6 +378,14 @@ trait JournalServiceTrait
$metaFactory = app(AccountMetaFactory::class);
$metaFactory->create(['account_id' => $account->id, 'name' => 'account_number', 'data' => $data['bic']]);
}
+
+// // store currency preference:
+// if (isset($data['currency_id']) && null !== $data['currency_id']) {
+// Log::debug(sprintf('Stored currency_id for account %d with value %d', $account->id, $data['currency_id']));
+// /** @var AccountMetaFactory $metaFactory */
+// $metaFactory = app(AccountMetaFactory::class);
+// $metaFactory->create(['account_id' => $account->id, 'name' => 'currency_id', 'data' => $data['currency_id']]);
+// }
}
return $account;
diff --git a/app/Support/Import/Routine/Spectre/StageImportDataHandler.php b/app/Support/Import/Routine/Spectre/StageImportDataHandler.php
index 717b5482da..64e9796e2f 100644
--- a/app/Support/Import/Routine/Spectre/StageImportDataHandler.php
+++ b/app/Support/Import/Routine/Spectre/StageImportDataHandler.php
@@ -183,30 +183,30 @@ class StageImportDataHandler
// transaction data:
'transactions' => [
[
- 'date' => $transaction->getMadeOn()->format('Y-m-d'),
- 'tags' => $tags,
- 'user' => $this->importJob->user_id,
- 'notes' => $notes,
+ 'date' => $transaction->getMadeOn()->format('Y-m-d'),
+ 'tags' => $tags,
+ 'user' => $this->importJob->user_id,
+ 'notes' => trim($notes),
// all custom fields:
- 'external_id' => (string)$transaction->getId(),
+ 'external_id' => (string)$transaction->getId(),
// journal data:
- 'description' => $transaction->getDescription(),
- 'piggy_bank_id' => null,
- 'piggy_bank_name' => null,
- 'bill_id' => null,
- 'bill_name' => null,
- 'original-source' => sprintf('spectre-v%s', config('firefly.version')),
- 'type' => $type,
- 'currency_id' => null,
- 'currency_code' => $currencyCode,
- 'amount' => $amount,
- 'budget_id' => null,
- 'budget_name' => null,
- 'category_id' => null,
- 'category_name' => $transaction->getCategory(),
- 'source_id' => $source->id,
+ 'description' => $transaction->getDescription(),
+ 'piggy_bank_id' => null,
+ 'piggy_bank_name' => null,
+ 'bill_id' => null,
+ 'bill_name' => null,
+ 'original-source' => sprintf('spectre-v%s', config('firefly.version')),
+ 'type' => $type,
+ 'currency_id' => null,
+ 'currency_code' => $currencyCode,
+ 'amount' => $amount,
+ 'budget_id' => null,
+ 'budget_name' => null,
+ 'category_id' => null,
+ 'category_name' => $transaction->getCategory(),
+ 'source_id' => $source->id,
'source_name' => null,
'destination_id' => $destination->id,
'destination_name' => null,
diff --git a/app/Support/Steam.php b/app/Support/Steam.php
index be4e10579f..1eb16f90dc 100644
--- a/app/Support/Steam.php
+++ b/app/Support/Steam.php
@@ -70,11 +70,10 @@ class Steam
->where('transactions.transaction_currency_id', $currency->id)
->get(['transactions.amount'])->toArray();
$nativeBalance = $this->sumTransactions($transactions, 'amount');
-
// get all balances in foreign currency:
$transactions = $account->transactions()
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
- ->where('transaction_journals.date', '<=', $date->format('Y-m-d'))
+ ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
->where('transactions.foreign_currency_id', $currency->id)
->where('transactions.transaction_currency_id', '!=', $currency->id)
->get(['transactions.foreign_amount'])->toArray();