mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-14 16:13:54 +00:00
Fix #10824
This commit is contained in:
@@ -114,6 +114,7 @@ class AccountController extends Controller
|
||||
'id' => (string) $account->id,
|
||||
'name' => $account->name,
|
||||
'name_with_balance' => $nameWithBalance,
|
||||
'active' => $account->active,
|
||||
'type' => $account->accountType->type,
|
||||
'currency_id' => (string) $useCurrency->id,
|
||||
'currency_name' => $useCurrency->name,
|
||||
|
@@ -69,6 +69,7 @@ class BudgetController extends Controller
|
||||
static fn (Budget $item) => [
|
||||
'id' => (string) $item->id,
|
||||
'name' => $item->name,
|
||||
'active' => $item->active,
|
||||
]
|
||||
);
|
||||
|
||||
|
@@ -337,6 +337,9 @@ class ConvertController extends Controller
|
||||
'type' => $transactionType->type,
|
||||
];
|
||||
|
||||
$sourceTransaction = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
$amount = $sourceTransaction?->amount ?? '0';
|
||||
|
||||
// also set the currency to the currency of the source account, in case you're converting a deposit into a transfer.
|
||||
if (TransactionTypeEnum::TRANSFER->value === $transactionType->type && TransactionTypeEnum::DEPOSIT->value === $journal->transactionType->type) {
|
||||
$source = $this->accountRepository->find((int) $sourceId);
|
||||
@@ -346,7 +349,20 @@ class ConvertController extends Controller
|
||||
if ($sourceCurrency instanceof TransactionCurrency && $destCurrency instanceof TransactionCurrency && $sourceCurrency->code !== $destCurrency->code) {
|
||||
$update['currency_id'] = $sourceCurrency->id;
|
||||
$update['foreign_currency_id'] = $destCurrency->id;
|
||||
$update['foreign_amount'] = '1'; // not the best solution but at this point the amount is hard to get.
|
||||
$update['foreign_amount'] = Steam::positive($amount); // not the best solution but at this point the amount is hard to get.
|
||||
}
|
||||
}
|
||||
|
||||
// same thing for converting a withdrawal into a transfer, but with the currency of the destination account.
|
||||
if (TransactionTypeEnum::TRANSFER->value === $transactionType->type && TransactionTypeEnum::WITHDRAWAL->value === $journal->transactionType->type) {
|
||||
$source = $this->accountRepository->find((int) $sourceId);
|
||||
$sourceCurrency = $this->accountRepository->getAccountCurrency($source);
|
||||
$dest = $this->accountRepository->find((int) $destinationId);
|
||||
$destCurrency = $this->accountRepository->getAccountCurrency($dest);
|
||||
if ($sourceCurrency instanceof TransactionCurrency && $destCurrency instanceof TransactionCurrency && $sourceCurrency->code !== $destCurrency->code) {
|
||||
$update['currency_id'] = $sourceCurrency->id;
|
||||
$update['foreign_currency_id'] = $destCurrency->id;
|
||||
$update['foreign_amount'] = Steam::positive($amount); // not the best solution but at this point the amount is hard to get.
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- [Issue 10813](https://github.com/firefly-iii/firefly-iii/issues/10813) (Error "Argument #2 ($symbol) must be of type string" while try open subscriptions section) reported by @mrResident
|
||||
- #10819
|
||||
- #10820
|
||||
- #10824
|
||||
|
||||
### API
|
||||
|
||||
|
@@ -48,6 +48,7 @@ Route::group(
|
||||
// Auto complete routes
|
||||
Route::get('accounts', ['uses' => 'AccountController@accounts', 'as' => 'accounts']);
|
||||
Route::get('bills', ['uses' => 'BillController@bills', 'as' => 'bills']);
|
||||
Route::get('subscriptions', ['uses' => 'BillController@bills', 'as' => 'subscriptions']);
|
||||
Route::get('budgets', ['uses' => 'BudgetController@budgets', 'as' => 'budgets']);
|
||||
Route::get('categories', ['uses' => 'CategoryController@categories', 'as' => 'categories']);
|
||||
Route::get('currencies', ['uses' => 'CurrencyController@currencies', 'as' => 'currencies']);
|
||||
|
Reference in New Issue
Block a user