mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-26 13:11:24 +00:00
Compare commits
9 Commits
develop-20
...
develop-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e7d750a5a | ||
|
|
94961466f9 | ||
|
|
0f3fe45b06 | ||
|
|
0650457ea5 | ||
|
|
2e1ce03f13 | ||
|
|
9b345db623 | ||
|
|
c1afcc5219 | ||
|
|
fb394b7f45 | ||
|
|
381598f1bb |
@@ -476,7 +476,7 @@ class TransactionJournalFactory
|
||||
*/
|
||||
private function getCurrency(?TransactionCurrency $currency, Account $account): TransactionCurrency
|
||||
{
|
||||
Log::debug(sprintf('Now in getCurrency(#%d, "%s")', $currency->id, $account->name));
|
||||
Log::debug(sprintf('Now in getCurrency(#%d, "%s")', $currency?->id, $account->name));
|
||||
|
||||
/** @var null|TransactionCurrency $preference */
|
||||
$preference = $this->accountRepository->getAccountCurrency($account);
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace FireflyIII\Services\Internal\Update;
|
||||
use Carbon\Carbon;
|
||||
use Carbon\Exceptions\InvalidDateException;
|
||||
use Carbon\Exceptions\InvalidFormatException;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Events\TriggeredAuditLog;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@@ -723,14 +724,17 @@ class JournalUpdateService
|
||||
// the correct fields to update in the destination transaction are NOT the foreign amount and currency
|
||||
// but rather the normal amount and currency. This is new behavior.
|
||||
$isTransfer = TransactionTypeEnum::TRANSFER->value === $this->transactionJournal->transactionType->type;
|
||||
if ($isTransfer) {
|
||||
// also check if it is not between an asset account and a liability, because then the same rule applies.
|
||||
$isBetween = $this->isBetweenAssetAndLiability();
|
||||
|
||||
if ($isTransfer || $isBetween) {
|
||||
Log::debug('Switch amounts, store in amount and not foreign_amount');
|
||||
$dest->transaction_currency_id = $foreignCurrency->id;
|
||||
$dest->amount = app('steam')->positive($foreignAmount);
|
||||
$dest->foreign_amount = app('steam')->positive($source->amount);
|
||||
$dest->foreign_currency_id = $source->transaction_currency_id;
|
||||
}
|
||||
if (!$isTransfer) {
|
||||
if (!$isTransfer && !$isBetween) {
|
||||
$dest->foreign_currency_id = $foreignCurrency->id;
|
||||
$dest->foreign_amount = app('steam')->positive($foreignAmount);
|
||||
}
|
||||
@@ -768,4 +772,48 @@ class JournalUpdateService
|
||||
$this->sourceTransaction->refresh();
|
||||
$this->destinationTransaction->refresh();
|
||||
}
|
||||
|
||||
private function isBetweenAssetAndLiability(): bool
|
||||
{
|
||||
/** @var Transaction $sourceTransaction */
|
||||
$sourceTransaction = $this->transactionJournal->transactions()->where('amount', '<', 0)->first();
|
||||
|
||||
/** @var Transaction $destinationTransaction */
|
||||
$destinationTransaction = $this->transactionJournal->transactions()->where('amount', '>', 0)->first();
|
||||
if (null === $sourceTransaction || null === $destinationTransaction) {
|
||||
Log::warning('Either transaction is false, stop.');
|
||||
|
||||
return false;
|
||||
}
|
||||
if (null === $sourceTransaction->foreign_amount || null === $destinationTransaction->foreign_amount) {
|
||||
Log::warning('Either foreign amount is false, stop.');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$source = $sourceTransaction->account;
|
||||
$destination = $destinationTransaction->account;
|
||||
|
||||
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) {
|
||||
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) {
|
||||
Log::debug('Destination is a liability account, source is an asset account, return TRUE.');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
12
composer.lock
generated
12
composer.lock
generated
@@ -11564,16 +11564,16 @@
|
||||
},
|
||||
{
|
||||
"name": "rector/rector",
|
||||
"version": "2.0.15",
|
||||
"version": "2.0.16",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/rectorphp/rector.git",
|
||||
"reference": "abbbf32474a67e242d26bffc098a712a05b3d32a"
|
||||
"reference": "f1366d1f8c7490541c8f7af6e5c7cef7cca1b5a2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/rectorphp/rector/zipball/abbbf32474a67e242d26bffc098a712a05b3d32a",
|
||||
"reference": "abbbf32474a67e242d26bffc098a712a05b3d32a",
|
||||
"url": "https://api.github.com/repos/rectorphp/rector/zipball/f1366d1f8c7490541c8f7af6e5c7cef7cca1b5a2",
|
||||
"reference": "f1366d1f8c7490541c8f7af6e5c7cef7cca1b5a2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -11611,7 +11611,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/rectorphp/rector/issues",
|
||||
"source": "https://github.com/rectorphp/rector/tree/2.0.15"
|
||||
"source": "https://github.com/rectorphp/rector/tree/2.0.16"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -11619,7 +11619,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2025-05-05T10:00:41+00:00"
|
||||
"time": "2025-05-12T16:37:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/cli-parser",
|
||||
|
||||
@@ -78,7 +78,7 @@ return [
|
||||
'running_balance_column' => env('USE_RUNNING_BALANCE', false),
|
||||
// see cer.php for exchange rates feature flag.
|
||||
],
|
||||
'version' => 'develop/2025-05-12',
|
||||
'version' => 'develop/2025-05-13',
|
||||
'api_version' => '2.1.0', // field is no longer used.
|
||||
'db_version' => 25,
|
||||
|
||||
|
||||
18
package-lock.json
generated
18
package-lock.json
generated
@@ -4417,9 +4417,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/caniuse-lite": {
|
||||
"version": "1.0.30001717",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001717.tgz",
|
||||
"integrity": "sha512-auPpttCq6BDEG8ZAuHJIplGw6GODhjw+/11e7IjpnYCxZcW/ONgPs0KVBJ0d1bY3e2+7PRe5RCLyP+PfwVgkYw==",
|
||||
"version": "1.0.30001718",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001718.tgz",
|
||||
"integrity": "sha512-AflseV1ahcSunK53NfEs9gFWgOEmzr0f+kaMFA4xiLZlr9Hzt7HxcSpIFcnNCUkz6R6dWKa54rUz3HUmI3nVcw==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
@@ -5632,9 +5632,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/electron-to-chromium": {
|
||||
"version": "1.5.151",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.151.tgz",
|
||||
"integrity": "sha512-Rl6uugut2l9sLojjS4H4SAr3A4IgACMLgpuEMPYCVcKydzfyPrn5absNRju38IhQOf/NwjJY8OGWjlteqYeBCA==",
|
||||
"version": "1.5.152",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.152.tgz",
|
||||
"integrity": "sha512-xBOfg/EBaIlVsHipHl2VdTPJRSvErNUaqW8ejTq5OlOlIYx1wOllCHsAvAIrr55jD1IYEfdR86miUEt8H5IeJg==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
@@ -10155,9 +10155,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/semver": {
|
||||
"version": "7.7.1",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz",
|
||||
"integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==",
|
||||
"version": "7.7.2",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz",
|
||||
"integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
|
||||
@@ -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', ['0']) }}';
|
||||
var bulk_edit_url = '{{ route('transactions.bulk.edit', ['0']) }}';
|
||||
var mass_delete_url = '{{ route('transactions.mass.delete', ['0']) }}';
|
||||
var mass_edit_url = '{{ route('transactions.mass.edit', ['']) }}';
|
||||
var bulk_edit_url = '{{ route('transactions.bulk.edit', ['']) }}';
|
||||
var mass_delete_url = '{{ route('transactions.mass.delete', ['']) }}';
|
||||
|
||||
// for demo:
|
||||
var nextLabel = "{{ trans('firefly.intro_next_label')|escape('js') }}";
|
||||
|
||||
@@ -840,7 +840,7 @@ Route::group(
|
||||
Route::get('default', ['uses' => 'ShowController@showDefault', 'as' => 'show.default']);
|
||||
Route::get('native', ['uses' => 'ShowController@showDefault', 'as' => 'show.native']);
|
||||
Route::get('{currency_code}', ['uses' => 'ShowController@show', 'as' => 'show']);
|
||||
Route::put('{currency_code}', ['uses' => 'UpdateController@update', 'as' => 'update']);
|
||||
Route::put('{currency_code?}', ['uses' => 'UpdateController@update', 'as' => 'update']);
|
||||
Route::delete('{currency_code}', ['uses' => 'DestroyController@destroy', 'as' => 'delete']);
|
||||
|
||||
Route::post('{currency_code}/enable', ['uses' => 'UpdateController@enable', 'as' => 'enable']);
|
||||
|
||||
@@ -1303,8 +1303,8 @@ Route::group(
|
||||
Route::group(
|
||||
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Transaction', 'prefix' => 'transactions/mass', 'as' => 'transactions.mass.'],
|
||||
static function (): void {
|
||||
Route::get('edit/{journalList}', ['uses' => 'MassController@edit', 'as' => 'edit']);
|
||||
Route::get('delete/{journalList}', ['uses' => 'MassController@delete', 'as' => 'delete']);
|
||||
Route::get('edit/{journalList?}', ['uses' => 'MassController@edit', 'as' => 'edit']);
|
||||
Route::get('delete/{journalList?}', ['uses' => 'MassController@delete', 'as' => 'delete']);
|
||||
Route::post('update', ['uses' => 'MassController@update', 'as' => 'update']);
|
||||
Route::post('destroy', ['uses' => 'MassController@destroy', 'as' => 'destroy']);
|
||||
}
|
||||
@@ -1314,7 +1314,7 @@ Route::group(
|
||||
Route::group(
|
||||
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Transaction', 'prefix' => 'transactions/bulk', 'as' => 'transactions.bulk.'],
|
||||
static function (): void {
|
||||
Route::get('edit/{journalList}', ['uses' => 'BulkController@edit', 'as' => 'edit']);
|
||||
Route::get('edit/{journalList?}', ['uses' => 'BulkController@edit', 'as' => 'edit']);
|
||||
Route::post('update', ['uses' => 'BulkController@update', 'as' => 'update']);
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user