mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-17 17:57:09 +00:00
Fix #3263
This commit is contained in:
@@ -285,6 +285,7 @@ class TransactionJournalFactory
|
|||||||
'iban' => $row['source_iban'],
|
'iban' => $row['source_iban'],
|
||||||
'number' => $row['source_number'],
|
'number' => $row['source_number'],
|
||||||
'bic' => $row['source_bic'],
|
'bic' => $row['source_bic'],
|
||||||
|
'currency_id' => $currency->id,
|
||||||
];
|
];
|
||||||
|
|
||||||
$destInfo = [
|
$destInfo = [
|
||||||
@@ -293,12 +294,15 @@ class TransactionJournalFactory
|
|||||||
'iban' => $row['destination_iban'],
|
'iban' => $row['destination_iban'],
|
||||||
'number' => $row['destination_number'],
|
'number' => $row['destination_number'],
|
||||||
'bic' => $row['destination_bic'],
|
'bic' => $row['destination_bic'],
|
||||||
|
'currency_id' => $currency->id,
|
||||||
];
|
];
|
||||||
Log::debug('Source info:', $sourceInfo);
|
Log::debug('Source info:', $sourceInfo);
|
||||||
Log::debug('Destination info:', $destInfo);
|
Log::debug('Destination info:', $destInfo);
|
||||||
|
Log::debug('Now calling getAccount for the source.');
|
||||||
$sourceAccount = $this->getAccount($type->type, 'source', $sourceInfo);
|
$sourceAccount = $this->getAccount($type->type, 'source', $sourceInfo);
|
||||||
|
Log::debug('Now calling getAccount for the destination.');
|
||||||
$destinationAccount = $this->getAccount($type->type, 'destination', $destInfo);
|
$destinationAccount = $this->getAccount($type->type, 'destination', $destInfo);
|
||||||
|
Log::debug('Done with getAccount(2x)');
|
||||||
$currency = $this->getCurrencyByAccount($type->type, $currency, $sourceAccount, $destinationAccount);
|
$currency = $this->getCurrencyByAccount($type->type, $currency, $sourceAccount, $destinationAccount);
|
||||||
$foreignCurrency = $this->compareCurrencies($currency, $foreignCurrency);
|
$foreignCurrency = $this->compareCurrencies($currency, $foreignCurrency);
|
||||||
$foreignCurrency = $this->getForeignByAccount($type->type, $foreignCurrency, $destinationAccount);
|
$foreignCurrency = $this->getForeignByAccount($type->type, $foreignCurrency, $destinationAccount);
|
||||||
@@ -468,6 +472,7 @@ class TransactionJournalFactory
|
|||||||
*/
|
*/
|
||||||
private function getCurrency(?TransactionCurrency $currency, Account $account): TransactionCurrency
|
private function getCurrency(?TransactionCurrency $currency, Account $account): TransactionCurrency
|
||||||
{
|
{
|
||||||
|
Log::debug('Now in getCurrency()');
|
||||||
$preference = $this->accountRepository->getAccountCurrency($account);
|
$preference = $this->accountRepository->getAccountCurrency($account);
|
||||||
if (null === $preference && null === $currency) {
|
if (null === $preference && null === $currency) {
|
||||||
// return user's default:
|
// return user's default:
|
||||||
@@ -489,6 +494,7 @@ class TransactionJournalFactory
|
|||||||
*/
|
*/
|
||||||
private function getCurrencyByAccount(string $type, ?TransactionCurrency $currency, Account $source, Account $destination): TransactionCurrency
|
private function getCurrencyByAccount(string $type, ?TransactionCurrency $currency, Account $source, Account $destination): TransactionCurrency
|
||||||
{
|
{
|
||||||
|
Log::debug('Now ingetCurrencyByAccount()');
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
default:
|
default:
|
||||||
case TransactionType::WITHDRAWAL:
|
case TransactionType::WITHDRAWAL:
|
||||||
|
@@ -263,7 +263,7 @@ class BoxController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function netWorth(): JsonResponse
|
public function netWorth(): JsonResponse
|
||||||
{
|
{
|
||||||
$date = Carbon::now()->startOfDay();
|
$date = Carbon::now()->endOfDay();
|
||||||
|
|
||||||
// start and end in the future? use $end
|
// start and end in the future? use $end
|
||||||
if ($this->notInSessionRange($date)) {
|
if ($this->notInSessionRange($date)) {
|
||||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use FireflyIII\Http\Requests\NewUserFormRequest;
|
use FireflyIII\Http\Requests\NewUserFormRequest;
|
||||||
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Support\Http\Controllers\CreateStuff;
|
use FireflyIII\Support\Http\Controllers\CreateStuff;
|
||||||
@@ -110,6 +111,12 @@ class NewUserController extends Controller
|
|||||||
|
|
||||||
// store currency preference:
|
// store currency preference:
|
||||||
app('preferences')->set('currencyPreference', $currency->code);
|
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();
|
app('preferences')->mark();
|
||||||
|
|
||||||
// set default optional fields:
|
// set default optional fields:
|
||||||
|
@@ -237,7 +237,6 @@ trait AccountServiceTrait
|
|||||||
Log::error($e->getMessage());
|
Log::error($e->getMessage());
|
||||||
Log::error($e->getTraceAsString());
|
Log::error($e->getTraceAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
return $group;
|
return $group;
|
||||||
|
@@ -345,6 +345,7 @@ trait JournalServiceTrait
|
|||||||
*/
|
*/
|
||||||
private function createAccount(?Account $account, array $data, string $preferredType): Account
|
private function createAccount(?Account $account, array $data, string $preferredType): Account
|
||||||
{
|
{
|
||||||
|
Log::debug('Now in createAccount()', $data);
|
||||||
// return new account.
|
// return new account.
|
||||||
if (null === $account) {
|
if (null === $account) {
|
||||||
$data['name'] = $data['name'] ?? '(no name)';
|
$data['name'] = $data['name'] ?? '(no name)';
|
||||||
@@ -362,6 +363,7 @@ trait JournalServiceTrait
|
|||||||
'virtual_balance' => null,
|
'virtual_balance' => null,
|
||||||
'active' => true,
|
'active' => true,
|
||||||
'iban' => $data['iban'],
|
'iban' => $data['iban'],
|
||||||
|
'currency_id' => $data['currency_id'] ?? null,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// store BIC
|
// store BIC
|
||||||
@@ -376,6 +378,14 @@ trait JournalServiceTrait
|
|||||||
$metaFactory = app(AccountMetaFactory::class);
|
$metaFactory = app(AccountMetaFactory::class);
|
||||||
$metaFactory->create(['account_id' => $account->id, 'name' => 'account_number', 'data' => $data['bic']]);
|
$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;
|
return $account;
|
||||||
|
@@ -186,7 +186,7 @@ class StageImportDataHandler
|
|||||||
'date' => $transaction->getMadeOn()->format('Y-m-d'),
|
'date' => $transaction->getMadeOn()->format('Y-m-d'),
|
||||||
'tags' => $tags,
|
'tags' => $tags,
|
||||||
'user' => $this->importJob->user_id,
|
'user' => $this->importJob->user_id,
|
||||||
'notes' => $notes,
|
'notes' => trim($notes),
|
||||||
|
|
||||||
// all custom fields:
|
// all custom fields:
|
||||||
'external_id' => (string)$transaction->getId(),
|
'external_id' => (string)$transaction->getId(),
|
||||||
|
@@ -70,11 +70,10 @@ class Steam
|
|||||||
->where('transactions.transaction_currency_id', $currency->id)
|
->where('transactions.transaction_currency_id', $currency->id)
|
||||||
->get(['transactions.amount'])->toArray();
|
->get(['transactions.amount'])->toArray();
|
||||||
$nativeBalance = $this->sumTransactions($transactions, 'amount');
|
$nativeBalance = $this->sumTransactions($transactions, 'amount');
|
||||||
|
|
||||||
// get all balances in foreign currency:
|
// get all balances in foreign currency:
|
||||||
$transactions = $account->transactions()
|
$transactions = $account->transactions()
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->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.foreign_currency_id', $currency->id)
|
||||||
->where('transactions.transaction_currency_id', '!=', $currency->id)
|
->where('transactions.transaction_currency_id', '!=', $currency->id)
|
||||||
->get(['transactions.foreign_amount'])->toArray();
|
->get(['transactions.foreign_amount'])->toArray();
|
||||||
|
Reference in New Issue
Block a user