Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Deposit works as well.
James Colebd917f648494
diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.phpindex efb0a35bcb..34691e4129 100644--- a/app/Http/Controllers/TransactionController.php+++ b/app/Http/Controllers/TransactionController.php@@ -187,7 +187,7 @@ class TransactionController extends Controllerif ($journal->hasMeta('original_currency_id')) {/** @var CurrencyRepositoryInterface $repository */$repository = app(CurrencyRepositoryInterface::class);- $originalCurrency = $repository->find(intval($journal->hasMeta('original_currency_id')));+ $originalCurrency = $repository->find(intval($journal->getMeta('original_currency_id')));}return view('transactions.show', compact('journal', 'events', 'subTitle', 'what', 'transactions', 'originalCurrency'));diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.phpindex 8fec36bf6d..340670307b 100644--- a/app/Repositories/Journal/JournalRepository.php+++ b/app/Repositories/Journal/JournalRepository.php@@ -187,6 +187,15 @@ class JournalRepository implements JournalRepositoryInterface$amount = strval($data['exchanged_amount']);}break;+ case TransactionType::DEPOSIT:+ $accountCurrencyId = intval($accounts['destination']->getMeta('currency_id'));+ if ($accountCurrencyId !== $currencyId) {+ $data['original_amount'] = $data['amount'];+ $data['original_currency_id'] = $currencyId;+ $currencyId = $accountCurrencyId;+ $amount = strval($data['exchanged_amount']);+ }+ break;default:throw new FireflyException(sprintf('Currency exchange routine cannot handle %s', $transactionType->type));}diff --git a/public/js/ff/transactions/single/create.js b/public/js/ff/transactions/single/create.jsindex 5b7388693e..a72fcf1370 100644--- a/public/js/ff/transactions/single/create.js+++ b/public/js/ff/transactions/single/create.js@@ -261,5 +261,8 @@ function getAccountId() {if(what === "withdrawal") {return $('select[name="source_account_id"]').val();}+ if(what === "deposit") {+ return $('select[name="destination_account_id"]').val();+ }alert('Cannot handle ' + what);}\ No newline at end of filediff --git a/public/js/ff/transactions/single/edit.js b/public/js/ff/transactions/single/edit.jsindex 0b632f9992..05cddafaf6 100644--- a/public/js/ff/transactions/single/edit.js+++ b/public/js/ff/transactions/single/edit.js@@ -60,6 +60,7 @@ $(document).ready(function () {});$('.currency-option').on('click', triggerCurrencyChange);+ $('#ffInput_amount').on('change', getExchangeRate);// always update the exchanged_amount to match the correct currencyvar journalCurrency = currencyInfo[journal.transaction_currency_id].symbol;@@ -135,5 +136,9 @@ function getAccountId() {if(journal.transaction_type.type === "Withdrawal") {return $('select[name="source_account_id"]').val();}+ if(journal.transaction_type.type === "Deposit") {+ return $('select[name="destination_account_id"]').val();+ }+alert('Cannot handle ' + journal.transaction_type.type);}