diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php index ec74a52d0c..0aafb0fdeb 100644 --- a/app/Factory/TransactionJournalFactory.php +++ b/app/Factory/TransactionJournalFactory.php @@ -170,6 +170,7 @@ class TransactionJournalFactory Log::debug('Find currency or return default.'); $currency = $this->currencyRepository->findCurrency((int) $row['currency_id'], $row['currency_code']); Log::debug('Find foreign currency or return NULL.'); + $foreignCurrency = $this->currencyRepository->findCurrencyNull($row['foreign_currency_id'], $row['foreign_currency_code']); $bill = $this->billRepository->findBill((int) $row['bill_id'], $row['bill_name']); $billId = TransactionTypeEnum::WITHDRAWAL->value === $type->type && null !== $bill ? $bill->id : null; @@ -218,6 +219,7 @@ class TransactionJournalFactory $destinationAccount = $this->getAccount($type->type, 'destination', $destInfo); Log::debug('Done with getAccount(2x)'); + // this is the moment for a reconciliation sanity check (again). if (TransactionTypeEnum::RECONCILIATION->value === $type->type) { [$sourceAccount, $destinationAccount] = $this->reconciliationSanityCheck($sourceAccount, $destinationAccount); @@ -282,8 +284,8 @@ class TransactionJournalFactory // see the currency they expect to see. $amount = (string) $row['amount']; $foreignAmount = (string) $row['foreign_amount']; - if (null !== $foreignCurrency && $foreignCurrency->id !== $currency->id - && TransactionTypeEnum::TRANSFER->value === $type->type + if (null !== $foreignCurrency && $foreignCurrency->id !== $currency->id && + (TransactionTypeEnum::TRANSFER->value === $type->type || $this->isBetweenAssetAndLiability($sourceAccount, $destinationAccount)) ) { $transactionFactory->setCurrency($foreignCurrency); $transactionFactory->setForeignCurrency($currency); @@ -623,22 +625,19 @@ class TransactionJournalFactory private function isBetweenAssetAndLiability(Account $source, Account $destination): bool { - if (null === $source || null === $destination) { - Log::warning('Either is false, stop.'); - return false; - } $sourceTypes = [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value]; // source is liability, destination is asset - if (in_array($source->accountType->type, $sourceTypes, true) && AccountTypeEnum::ASSET->value === $destination->accountType->type) { + if(in_array($source->accountType->type, $sourceTypes, true) && AccountTypeEnum::ASSET->value === $destination->accountType->type) { Log::debug('Source is a liability account, destination is an asset account, return TRUE.'); return true; } // source is asset, destination is liability - if (in_array($destination->accountType->type, $sourceTypes, true) && AccountTypeEnum::ASSET->value === $source->accountType->type) { + if(in_array($destination->accountType->type, $sourceTypes, true) && AccountTypeEnum::ASSET->value === $source->accountType->type) { Log::debug('Destination is a liability account, source is an asset account, return TRUE.'); return true; } + Log::debug('Not between asset and liability, return FALSE'); return false; } } diff --git a/app/Http/Controllers/Account/IndexController.php b/app/Http/Controllers/Account/IndexController.php index 99ae94aa15..4e8ded5f1e 100644 --- a/app/Http/Controllers/Account/IndexController.php +++ b/app/Http/Controllers/Account/IndexController.php @@ -163,7 +163,9 @@ class IndexController extends Controller /** @var Carbon $end */ $end = clone session('end', today(config('app.timezone'))->endOfMonth()); - $start->subDay(); + + // 2025-05-11 removed this so start is exactly the start of the month. + // $start->subDay(); $ids = $accounts->pluck('id')->toArray(); Log::debug(sprintf('index start: finalAccountsBalance("%s")', $start->format('Y-m-d H:i:s'))); diff --git a/resources/views/javascript/variables.twig b/resources/views/javascript/variables.twig index 37c6ab8c13..8cc69e7538 100644 --- a/resources/views/javascript/variables.twig +++ b/resources/views/javascript/variables.twig @@ -55,9 +55,9 @@ var edit_selected_txt = "{{ trans('firefly.mass_edit')|escape('js') }}"; var edit_bulk_selected_txt = "{{ trans('firefly.bulk_edit')|escape('js') }}"; var delete_selected_txt = "{{ trans('firefly.mass_delete')|escape('js') }}"; -var mass_edit_url = '{{ route('transactions.mass.edit', ['']) }}'; -var bulk_edit_url = '{{ route('transactions.bulk.edit', ['']) }}'; -var mass_delete_url = '{{ route('transactions.mass.delete', ['']) }}'; +var mass_edit_url = '{{ route('transactions.mass.edit', ['0']) }}'; +var bulk_edit_url = '{{ route('transactions.bulk.edit', ['0']) }}'; +var mass_delete_url = '{{ route('transactions.mass.delete', ['0']) }}'; // for demo: var nextLabel = "{{ trans('firefly.intro_next_label')|escape('js') }}"; diff --git a/resources/views/list/groups.twig b/resources/views/list/groups.twig index dbe736414d..69cb65289c 100644 --- a/resources/views/list/groups.twig +++ b/resources/views/list/groups.twig @@ -259,7 +259,17 @@ {% if transaction.transaction_type_type == 'Deposit' %} {{ formatAmountBySymbol(transaction.destination_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }} {% elseif transaction.transaction_type_type == 'Withdrawal' %} - {{ formatAmountBySymbol(transaction.source_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }} + {% if 'Loan' == transaction.destination_account_type or 'Mortgage' == transaction.destination_account_type or 'Debt' == transaction.destination_account_type %} + {% if currency.id == transaction.currency_id %} + {{ formatAmountBySymbol(transaction.destination_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }} + {% endif %} + {% if currency.id == transaction.foreign_currency_id %} + {{ formatAmountBySymbol(transaction.destination_balance_after, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }} + {% endif %} + + {% else %} + {{ formatAmountBySymbol(transaction.source_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }} + {% endif %} {% elseif transaction.transaction_type_type == 'Opening balance' %} {% if transaction.source_account_type == 'Initial balance account' %} {{ formatAmountBySymbol(transaction.destination_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }}