mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-01 19:47:11 +00:00
Compare commits
88 Commits
branch-v6.
...
develop-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0579c8565d | ||
|
|
9f25880a59 | ||
|
|
05f1819f7d | ||
|
|
fa2149f957 | ||
|
|
c21a79e029 | ||
|
|
03e31ebb5e | ||
|
|
3c20e5f3af | ||
|
|
9a9dd9e075 | ||
|
|
7189986c03 | ||
|
|
b407d8d315 | ||
|
|
41fa2a6208 | ||
|
|
fe00c4c373 | ||
|
|
7248a76c63 | ||
|
|
ee3c618797 | ||
|
|
a1241ebedb | ||
|
|
af78d998db | ||
|
|
d96c235ffe | ||
|
|
79ca1b5f4e | ||
|
|
0f68735e1c | ||
|
|
82abee37de | ||
|
|
507040f1fd | ||
|
|
42dc8486e9 | ||
|
|
6c655634bc | ||
|
|
f2166b97b8 | ||
|
|
da88e02be0 | ||
|
|
0d56b7d251 | ||
|
|
0a089efcac | ||
|
|
89ab360391 | ||
|
|
2bd97d9a99 | ||
|
|
103b9056e4 | ||
|
|
23c4352c18 | ||
|
|
2dddaa36d5 | ||
|
|
8ab7cf2388 | ||
|
|
f191086adb | ||
|
|
68b446db18 | ||
|
|
3d49d81856 | ||
|
|
96493425d1 | ||
|
|
419975285c | ||
|
|
aa5bde122e | ||
|
|
0fa3c2bd8d | ||
|
|
b9249a4d96 | ||
|
|
6638ca270f | ||
|
|
9bfef892f8 | ||
|
|
32e5efec7c | ||
|
|
36457455ca | ||
|
|
062c148e43 | ||
|
|
2314ce8004 | ||
|
|
a3ff73903a | ||
|
|
7c8445707e | ||
|
|
291e73da4b | ||
|
|
286a29ca3e | ||
|
|
71cf6c6a5e | ||
|
|
1e8f0adaf8 | ||
|
|
33531244aa | ||
|
|
06049a9a28 | ||
|
|
d313f5fdf5 | ||
|
|
f4868126c1 | ||
|
|
00147e98dd | ||
|
|
6d22663ca2 | ||
|
|
756bb9cf5e | ||
|
|
399d7968f5 | ||
|
|
966b68f42e | ||
|
|
134c551c12 | ||
|
|
9aeca15355 | ||
|
|
6c6d31830b | ||
|
|
e8cc321898 | ||
|
|
e73fe06f7e | ||
|
|
98b579c042 | ||
|
|
7b3a5c1afd | ||
|
|
7e2e49e129 | ||
|
|
e8ef630424 | ||
|
|
8805bcf6f6 | ||
|
|
ff5c9a3aa0 | ||
|
|
3a274dcaa7 | ||
|
|
ddfededf02 | ||
|
|
e1785898ba | ||
|
|
ae09200f42 | ||
|
|
847984f678 | ||
|
|
42305672ac | ||
|
|
25a56d9f72 | ||
|
|
cea52c0ac7 | ||
|
|
1b33ff9c25 | ||
|
|
594ba205bb | ||
|
|
495f5c71c3 | ||
|
|
7e80f607b7 | ||
|
|
d93732e451 | ||
|
|
1b57bc7889 | ||
|
|
e2f1fc307f |
@@ -29,7 +29,7 @@ $paths = [
|
||||
$current . '/../../database',
|
||||
$current . '/../../routes',
|
||||
$current . '/../../tests',
|
||||
$current . '/../../resources/lang',
|
||||
$current . '/../../resources/lang/en_US',
|
||||
];
|
||||
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
|
||||
50
.ci/php-cs-fixer/composer.lock
generated
50
.ci/php-cs-fixer/composer.lock
generated
@@ -406,16 +406,16 @@
|
||||
},
|
||||
{
|
||||
"name": "friendsofphp/php-cs-fixer",
|
||||
"version": "v3.65.0",
|
||||
"version": "v3.66.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
|
||||
"reference": "79d4f3e77b250a7d8043d76c6af8f0695e8a469f"
|
||||
"reference": "5f5f2a142ff36b93c41885bca29cc5f861c013e6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/79d4f3e77b250a7d8043d76c6af8f0695e8a469f",
|
||||
"reference": "79d4f3e77b250a7d8043d76c6af8f0695e8a469f",
|
||||
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/5f5f2a142ff36b93c41885bca29cc5f861c013e6",
|
||||
"reference": "5f5f2a142ff36b93c41885bca29cc5f861c013e6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -441,7 +441,7 @@
|
||||
"symfony/polyfill-mbstring": "^1.28",
|
||||
"symfony/polyfill-php80": "^1.28",
|
||||
"symfony/polyfill-php81": "^1.28",
|
||||
"symfony/process": "^5.4 || ^6.0 || ^7.0",
|
||||
"symfony/process": "^5.4 || ^6.0 || ^7.0 <7.2",
|
||||
"symfony/stopwatch": "^5.4 || ^6.0 || ^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
@@ -497,7 +497,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
|
||||
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.65.0"
|
||||
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.66.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -505,7 +505,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2024-11-25T00:39:24+00:00"
|
||||
"time": "2024-12-29T13:46:23+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/container",
|
||||
@@ -1369,12 +1369,12 @@
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"thanks": {
|
||||
"url": "https://github.com/symfony/contracts",
|
||||
"name": "symfony/contracts"
|
||||
},
|
||||
"branch-alias": {
|
||||
"dev-main": "3.5-dev"
|
||||
},
|
||||
"thanks": {
|
||||
"name": "symfony/contracts",
|
||||
"url": "https://github.com/symfony/contracts"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -1517,12 +1517,12 @@
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"thanks": {
|
||||
"url": "https://github.com/symfony/contracts",
|
||||
"name": "symfony/contracts"
|
||||
},
|
||||
"branch-alias": {
|
||||
"dev-main": "3.5-dev"
|
||||
},
|
||||
"thanks": {
|
||||
"name": "symfony/contracts",
|
||||
"url": "https://github.com/symfony/contracts"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -2246,16 +2246,16 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/process",
|
||||
"version": "v7.2.0",
|
||||
"version": "v7.1.8",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/process.git",
|
||||
"reference": "d34b22ba9390ec19d2dd966c40aa9e8462f27a7e"
|
||||
"reference": "42783370fda6e538771f7c7a36e9fa2ee3a84892"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/process/zipball/d34b22ba9390ec19d2dd966c40aa9e8462f27a7e",
|
||||
"reference": "d34b22ba9390ec19d2dd966c40aa9e8462f27a7e",
|
||||
"url": "https://api.github.com/repos/symfony/process/zipball/42783370fda6e538771f7c7a36e9fa2ee3a84892",
|
||||
"reference": "42783370fda6e538771f7c7a36e9fa2ee3a84892",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2287,7 +2287,7 @@
|
||||
"description": "Executes commands in sub-processes",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/process/tree/v7.2.0"
|
||||
"source": "https://github.com/symfony/process/tree/v7.1.8"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -2303,7 +2303,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-11-06T14:24:19+00:00"
|
||||
"time": "2024-11-06T14:23:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/service-contracts",
|
||||
@@ -2329,12 +2329,12 @@
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"thanks": {
|
||||
"url": "https://github.com/symfony/contracts",
|
||||
"name": "symfony/contracts"
|
||||
},
|
||||
"branch-alias": {
|
||||
"dev-main": "3.5-dev"
|
||||
},
|
||||
"thanks": {
|
||||
"name": "symfony/contracts",
|
||||
"url": "https://github.com/symfony/contracts"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
||||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -10,7 +10,7 @@ on:
|
||||
phpversion:
|
||||
description: 'PHP version'
|
||||
required: true
|
||||
default: '8.3'
|
||||
default: '8.4'
|
||||
schedule:
|
||||
- cron: '0 3 * * MON'
|
||||
|
||||
|
||||
2
.github/workflows/sonarcloud.yml
vendored
2
.github/workflows/sonarcloud.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
||||
- name: Setup PHP with Xdebug
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.3'
|
||||
php-version: '8.4'
|
||||
coverage: xdebug
|
||||
extensions: >-
|
||||
bcmath
|
||||
|
||||
@@ -26,12 +26,13 @@ namespace FireflyIII\Api\V1\Controllers\Autocomplete;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\Support\Http\Api\AccountFilter;
|
||||
use FireflyIII\Support\Steam;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -62,7 +63,7 @@ class AccountController extends Controller
|
||||
return $next($request);
|
||||
}
|
||||
);
|
||||
$this->balanceTypes = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];
|
||||
$this->balanceTypes = [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,27 +75,27 @@ class AccountController extends Controller
|
||||
*/
|
||||
public function accounts(AutocompleteRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getData();
|
||||
$types = $data['types'];
|
||||
$query = $data['query'];
|
||||
$date = $data['date'] ?? today(config('app.timezone'));
|
||||
$return = [];
|
||||
$result = $this->repository->searchAccount((string) $query, $types, $this->parameters->get('limit'));
|
||||
|
||||
// TODO this code is duplicated in the V2 Autocomplete controller, which means this code is due to be deprecated.
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$data = $request->getData();
|
||||
$types = $data['types'];
|
||||
$query = $data['query'];
|
||||
$date = $data['date'] ?? today(config('app.timezone'));
|
||||
$return = [];
|
||||
$result = $this->repository->searchAccount((string) $query, $types, $this->parameters->get('limit'));
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($result as $account) {
|
||||
$nameWithBalance = $account->name;
|
||||
$currency = $this->repository->getAccountCurrency($account) ?? $defaultCurrency;
|
||||
$currency = $this->repository->getAccountCurrency($account) ?? $this->defaultCurrency;
|
||||
|
||||
if (in_array($account->accountType->type, $this->balanceTypes, true)) {
|
||||
$balance = Steam::finalAccountBalance($account, $date);
|
||||
$key = $this->convertToNative && $currency->id !== $this->defaultCurrency->id ? 'native_balance' : 'balance';
|
||||
$useCurrency = $this->convertToNative && $currency->id !== $this->defaultCurrency->id ? $this->defaultCurrency : $currency;
|
||||
$amount = $balance[$key] ?? '0';
|
||||
$nameWithBalance = sprintf(
|
||||
'%s (%s)',
|
||||
$account->name,
|
||||
app('amount')->formatAnything($currency, $balance['balance'], false)
|
||||
app('amount')->formatAnything($useCurrency, $amount, false)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -103,11 +104,11 @@ class AccountController extends Controller
|
||||
'name' => $account->name,
|
||||
'name_with_balance' => $nameWithBalance,
|
||||
'type' => $account->accountType->type,
|
||||
'currency_id' => (string) $currency->id,
|
||||
'currency_name' => $currency->name,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_decimal_places' => $currency->decimal_places,
|
||||
'currency_id' => (string) $useCurrency->id,
|
||||
'currency_name' => $useCurrency->name,
|
||||
'currency_code' => $useCurrency->code,
|
||||
'currency_symbol' => $useCurrency->symbol,
|
||||
'currency_decimal_places' => $useCurrency->decimal_places,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ namespace FireflyIII\Api\V1\Controllers\Chart;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Data\DateRequest;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Api\ApiSupport;
|
||||
@@ -81,11 +81,10 @@ class AccountController extends Controller
|
||||
$end = $dates['end'];
|
||||
|
||||
// user's preferences
|
||||
$defaultSet = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray();
|
||||
$defaultSet = $this->repository->getAccountsByType([AccountTypeEnum::ASSET->value])->pluck('id')->toArray();
|
||||
|
||||
/** @var Preference $frontpage */
|
||||
$frontpage = app('preferences')->get('frontpageAccounts', $defaultSet);
|
||||
$default = app('amount')->getDefaultCurrency();
|
||||
|
||||
if (!(is_array($frontpage->data) && count($frontpage->data) > 0)) {
|
||||
$frontpage->data = $defaultSet;
|
||||
@@ -98,10 +97,8 @@ class AccountController extends Controller
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
$currency = $this->repository->getAccountCurrency($account);
|
||||
if (null === $currency) {
|
||||
$currency = $default;
|
||||
}
|
||||
$currency = $this->repository->getAccountCurrency($account) ?? $this->defaultCurrency;
|
||||
$field = $this->convertToNative && $currency->id !== $this->defaultCurrency->id ? 'native_balance' : 'balance';
|
||||
$currentSet = [
|
||||
'label' => $account->name,
|
||||
'currency_id' => (string) $currency->id,
|
||||
@@ -116,13 +113,12 @@ class AccountController extends Controller
|
||||
];
|
||||
// TODO this code is also present in the V2 chart account controller so this method is due to be deprecated.
|
||||
$currentStart = clone $start;
|
||||
$range = app('steam')->finalAccountBalanceInRange($account, $start, clone $end);
|
||||
// 2022-10-11 this method no longer converts to float.
|
||||
$previous = array_values($range)[0];
|
||||
$range = app('steam')->finalAccountBalanceInRange($account, $start, clone $end, $this->convertToNative);
|
||||
$previous = array_values($range)[0][$field];
|
||||
while ($currentStart <= $end) {
|
||||
$format = $currentStart->format('Y-m-d');
|
||||
$label = $currentStart->toAtomString();
|
||||
$balance = array_key_exists($format, $range) ? $range[$format]['balance'] : $previous;
|
||||
$balance = array_key_exists($format, $range) ? $range[$format][$field] : $previous;
|
||||
$previous = $balance;
|
||||
$currentStart->addDay();
|
||||
$currentSet['entries'][$label] = $balance;
|
||||
|
||||
@@ -28,6 +28,9 @@ use Carbon\Carbon;
|
||||
use Carbon\Exceptions\InvalidDateException;
|
||||
use Carbon\Exceptions\InvalidFormatException;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
@@ -50,11 +53,13 @@ abstract class Controller extends BaseController
|
||||
use DispatchesJobs;
|
||||
use ValidatesRequests;
|
||||
|
||||
protected const string CONTENT_TYPE = 'application/vnd.api+json';
|
||||
protected const string CONTENT_TYPE = 'application/vnd.api+json';
|
||||
|
||||
/** @var array<int, string> */
|
||||
protected array $allowedSort;
|
||||
protected ParameterBag $parameters;
|
||||
protected bool $convertToNative = false;
|
||||
protected TransactionCurrency $defaultCurrency;
|
||||
|
||||
/**
|
||||
* Controller constructor.
|
||||
@@ -67,8 +72,11 @@ abstract class Controller extends BaseController
|
||||
function ($request, $next) {
|
||||
$this->parameters = $this->getParameters();
|
||||
if (auth()->check()) {
|
||||
$language = app('steam')->getLanguage();
|
||||
$language = Steam::getLanguage();
|
||||
$this->convertToNative = Amount::convertToNative();
|
||||
$this->defaultCurrency = Amount::getDefaultCurrency();
|
||||
app()->setLocale($language);
|
||||
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
||||
@@ -26,10 +26,10 @@ namespace FireflyIII\Api\V1\Controllers\Data;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Data\DestroyRequest;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
@@ -66,9 +66,9 @@ class DestroyController extends Controller
|
||||
$objects = $request->getObjects();
|
||||
$this->unused = $request->boolean('unused', false);
|
||||
|
||||
$allExceptAssets = [AccountType::BENEFICIARY, AccountType::CASH, AccountType::CREDITCARD, AccountType::DEFAULT, AccountType::EXPENSE, AccountType::IMPORT, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT, AccountType::RECONCILIATION, AccountType::REVENUE];
|
||||
$all = [AccountType::ASSET, AccountType::BENEFICIARY, AccountType::CASH, AccountType::CREDITCARD, AccountType::DEBT, AccountType::DEFAULT, AccountType::EXPENSE, AccountType::IMPORT, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::RECONCILIATION];
|
||||
$liabilities = [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD];
|
||||
$allExceptAssets = [AccountTypeEnum::BENEFICIARY->value, AccountTypeEnum::CASH->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::DEFAULT->value, AccountTypeEnum::EXPENSE->value, AccountTypeEnum::IMPORT->value, AccountTypeEnum::INITIAL_BALANCE->value, AccountTypeEnum::LIABILITY_CREDIT->value, AccountTypeEnum::RECONCILIATION->value, AccountTypeEnum::REVENUE->value];
|
||||
$all = [AccountTypeEnum::ASSET->value, AccountTypeEnum::BENEFICIARY->value, AccountTypeEnum::CASH->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::DEFAULT->value, AccountTypeEnum::EXPENSE->value, AccountTypeEnum::IMPORT->value, AccountTypeEnum::INITIAL_BALANCE->value, AccountTypeEnum::LIABILITY_CREDIT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::RECONCILIATION->value];
|
||||
$liabilities = [AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::CREDITCARD->value];
|
||||
$transactions = [TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::DEPOSIT->value, TransactionTypeEnum::TRANSFER->value, TransactionTypeEnum::RECONCILIATION->value];
|
||||
|
||||
match ($objects) {
|
||||
@@ -82,9 +82,9 @@ class DestroyController extends Controller
|
||||
'object_groups' => $this->destroyObjectGroups(),
|
||||
'not_assets_liabilities' => $this->destroyAccounts($allExceptAssets),
|
||||
'accounts' => $this->destroyAccounts($all),
|
||||
'asset_accounts' => $this->destroyAccounts([AccountType::ASSET, AccountType::DEFAULT]),
|
||||
'expense_accounts' => $this->destroyAccounts([AccountType::BENEFICIARY, AccountType::EXPENSE]),
|
||||
'revenue_accounts' => $this->destroyAccounts([AccountType::REVENUE]),
|
||||
'asset_accounts' => $this->destroyAccounts([AccountTypeEnum::ASSET->value, AccountTypeEnum::DEFAULT->value]),
|
||||
'expense_accounts' => $this->destroyAccounts([AccountTypeEnum::BENEFICIARY->value, AccountTypeEnum::EXPENSE->value]),
|
||||
'revenue_accounts' => $this->destroyAccounts([AccountTypeEnum::REVENUE->value]),
|
||||
'liabilities' => $this->destroyAccounts($liabilities),
|
||||
'transactions' => $this->destroyTransactions($transactions),
|
||||
'withdrawals' => $this->destroyTransactions([TransactionTypeEnum::WITHDRAWAL->value]),
|
||||
|
||||
@@ -29,7 +29,9 @@ use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class BillController
|
||||
@@ -63,11 +65,13 @@ class BillController extends Controller
|
||||
*/
|
||||
public function bill(GenericRequest $request): JsonResponse
|
||||
{
|
||||
$accounts = $request->getAssetAccounts();
|
||||
$bills = $request->getBills();
|
||||
$start = $request->getStart();
|
||||
$end = $request->getEnd();
|
||||
$response = [];
|
||||
$accounts = $request->getAssetAccounts();
|
||||
$bills = $request->getBills();
|
||||
$start = $request->getStart();
|
||||
$end = $request->getEnd();
|
||||
$convertToNative = Amount::convertToNative();
|
||||
$default = Amount::getDefaultCurrency();
|
||||
$response = [];
|
||||
|
||||
// get all bills:
|
||||
if (0 === $bills->count()) {
|
||||
@@ -75,17 +79,30 @@ class BillController extends Controller
|
||||
}
|
||||
|
||||
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts);
|
||||
$collector->setBills($bills);
|
||||
|
||||
$genericSet = $collector->getExtractedJournals();
|
||||
$genericSet = $collector->getExtractedJournals();
|
||||
foreach ($genericSet as $journal) {
|
||||
$billId = (int) $journal['bill_id'];
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$foreignCurrencyId = (int) $journal['foreign_currency_id'];
|
||||
$key = sprintf('%d-%d', $billId, $currencyId);
|
||||
$foreignKey = sprintf('%d-%d', $billId, $foreignCurrencyId);
|
||||
$billId = (int) $journal['bill_id'];
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$currencyCode = $journal['currency_code'];
|
||||
$field = 'amount';
|
||||
|
||||
// use the native amount if the user wants to convert to native currency
|
||||
if ($convertToNative && $currencyId !== $default->id) {
|
||||
$currencyId = $default->id;
|
||||
$currencyCode = $default->code;
|
||||
$field = 'native_amount';
|
||||
}
|
||||
// use foreign amount when the foreign currency IS the default currency.
|
||||
if ($convertToNative && $journal['currency_id'] !== $default->id && $default->id === $journal['foreign_currency_id']) {
|
||||
$field = 'foreign_amount';
|
||||
}
|
||||
Log::debug(sprintf('Journal #%d in bill #%d will use %s (%s %s)', $journal['transaction_group_id'], $billId, $field, $currencyCode, $journal[$field] ?? '0'));
|
||||
|
||||
$key = sprintf('%d-%d', $billId, $currencyId);
|
||||
|
||||
if (0 !== $currencyId) {
|
||||
$response[$key] ??= [
|
||||
@@ -94,21 +111,11 @@ class BillController extends Controller
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $journal['currency_code'],
|
||||
'currency_code' => $currencyCode,
|
||||
];
|
||||
$response[$key]['difference'] = bcadd($response[$key]['difference'], $journal['amount']);
|
||||
$response[$key]['difference'] = bcadd($response[$key]['difference'], (string) ($journal[$field] ?? '0'));
|
||||
$response[$key]['difference_float'] = (float) $response[$key]['difference']; // intentional float
|
||||
}
|
||||
if (0 !== $foreignCurrencyId) {
|
||||
$response[$foreignKey] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $foreignCurrencyId,
|
||||
'currency_code' => $journal['foreign_currency_code'],
|
||||
];
|
||||
$response[$foreignKey]['difference'] = bcadd($response[$foreignKey]['difference'], $journal['foreign_amount']);
|
||||
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // intentional float
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json(array_values($response));
|
||||
@@ -122,42 +129,47 @@ class BillController extends Controller
|
||||
*/
|
||||
public function noBill(GenericRequest $request): JsonResponse
|
||||
{
|
||||
$accounts = $request->getAssetAccounts();
|
||||
$start = $request->getStart();
|
||||
$end = $request->getEnd();
|
||||
$response = [];
|
||||
$accounts = $request->getAssetAccounts();
|
||||
$start = $request->getStart();
|
||||
$end = $request->getEnd();
|
||||
$convertToNative = Amount::convertToNative();
|
||||
$default = Amount::getDefaultCurrency();
|
||||
$response = [];
|
||||
|
||||
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts);
|
||||
$collector->withoutBill();
|
||||
|
||||
$genericSet = $collector->getExtractedJournals();
|
||||
$genericSet = $collector->getExtractedJournals();
|
||||
|
||||
foreach ($genericSet as $journal) {
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$foreignCurrencyId = (int) $journal['foreign_currency_id'];
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$currencyCode = $journal['currency_code'];
|
||||
$field = 'amount';
|
||||
|
||||
// use the native amount if the user wants to convert to native currency
|
||||
if ($convertToNative && $currencyId !== $default->id) {
|
||||
$currencyId = $default->id;
|
||||
$currencyCode = $default->code;
|
||||
$field = 'native_amount';
|
||||
}
|
||||
// use foreign amount when the foreign currency IS the default currency.
|
||||
if ($convertToNative && $journal['currency_id'] !== $default->id && $default->id === $journal['foreign_currency_id']) {
|
||||
$field = 'foreign_amount';
|
||||
}
|
||||
Log::debug(sprintf('Journal #%d will use %s (%s %s)', $journal['transaction_group_id'], $field, $currencyCode, $journal[$field] ?? '0'));
|
||||
|
||||
if (0 !== $currencyId) {
|
||||
$response[$currencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $journal['currency_code'],
|
||||
'currency_code' => $currencyCode,
|
||||
];
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']);
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], (string) ($journal[$field] ?? '0'));
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // intentional float
|
||||
}
|
||||
if (0 !== $foreignCurrencyId) {
|
||||
$response[$foreignCurrencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $foreignCurrencyId,
|
||||
'currency_code' => $journal['foreign_currency_code'],
|
||||
];
|
||||
$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']);
|
||||
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; // intentional float
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json(array_values($response));
|
||||
|
||||
@@ -28,7 +28,9 @@ use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class PeriodController
|
||||
@@ -41,39 +43,49 @@ class PeriodController extends Controller
|
||||
*/
|
||||
public function total(GenericRequest $request): JsonResponse
|
||||
{
|
||||
$accounts = $request->getAssetAccounts();
|
||||
$start = $request->getStart();
|
||||
$end = $request->getEnd();
|
||||
$response = [];
|
||||
$accounts = $request->getAssetAccounts();
|
||||
$start = $request->getStart();
|
||||
$end = $request->getEnd();
|
||||
$response = [];
|
||||
$convertToNative = Amount::convertToNative();
|
||||
$default = Amount::getDefaultCurrency();
|
||||
|
||||
// collect all expenses in this period (regardless of type)
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts);
|
||||
$genericSet = $collector->getExtractedJournals();
|
||||
$genericSet = $collector->getExtractedJournals();
|
||||
foreach ($genericSet as $journal) {
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$foreignCurrencyId = (int) $journal['foreign_currency_id'];
|
||||
// same code as many other sumExpense methods. I think this needs some kind of generic method.
|
||||
$amount = '0';
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$currencyCode = $journal['currency_code'];
|
||||
if ($convertToNative) {
|
||||
$amount = Amount::getAmountFromJournal($journal);
|
||||
if ($default->id !== (int) $journal['currency_id'] && $default->id !== (int) $journal['foreign_currency_id']) {
|
||||
$currencyId = $default->id;
|
||||
$currencyCode = $default->code;
|
||||
}
|
||||
if ($default->id !== (int) $journal['currency_id'] && $default->id === (int) $journal['foreign_currency_id']) {
|
||||
$currencyId = $journal['foreign_currency_id'];
|
||||
$currencyCode = $journal['foreign_currency_code'];
|
||||
}
|
||||
Log::debug(sprintf('[a] Add amount %s %s', $currencyCode, $amount));
|
||||
}
|
||||
if (!$convertToNative) {
|
||||
// ignore the amount in foreign currency.
|
||||
Log::debug(sprintf('[b] Add amount %s %s', $currencyCode, $journal['amount']));
|
||||
$amount = $journal['amount'];
|
||||
}
|
||||
|
||||
if (0 !== $currencyId) {
|
||||
$response[$currencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']);
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // intentional float
|
||||
}
|
||||
if (0 !== $foreignCurrencyId) {
|
||||
$response[$foreignCurrencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $foreignCurrencyId,
|
||||
'currency_code' => $journal['foreign_currency_code'],
|
||||
];
|
||||
$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']);
|
||||
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; // intentional float
|
||||
}
|
||||
|
||||
$response[$currencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $currencyCode,
|
||||
];
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $amount);
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // intentional float
|
||||
}
|
||||
|
||||
return response()->json(array_values($response));
|
||||
|
||||
@@ -29,7 +29,9 @@ use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class TagController
|
||||
@@ -62,42 +64,51 @@ class TagController extends Controller
|
||||
*/
|
||||
public function noTag(GenericRequest $request): JsonResponse
|
||||
{
|
||||
$accounts = $request->getAssetAccounts();
|
||||
$start = $request->getStart();
|
||||
$end = $request->getEnd();
|
||||
$response = [];
|
||||
$accounts = $request->getAssetAccounts();
|
||||
$start = $request->getStart();
|
||||
$end = $request->getEnd();
|
||||
$response = [];
|
||||
$convertToNative = Amount::convertToNative();
|
||||
$default = Amount::getDefaultCurrency();
|
||||
|
||||
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts);
|
||||
$collector->withoutTags();
|
||||
|
||||
$genericSet = $collector->getExtractedJournals();
|
||||
$genericSet = $collector->getExtractedJournals();
|
||||
|
||||
foreach ($genericSet as $journal) {
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$foreignCurrencyId = (int) $journal['foreign_currency_id'];
|
||||
// same code as many other sumExpense methods. I think this needs some kind of generic method.
|
||||
$amount = '0';
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$currencyCode = $journal['currency_code'];
|
||||
if ($convertToNative) {
|
||||
$amount = Amount::getAmountFromJournal($journal);
|
||||
if ($default->id !== (int) $journal['currency_id'] && $default->id !== (int) $journal['foreign_currency_id']) {
|
||||
$currencyId = $default->id;
|
||||
$currencyCode = $default->code;
|
||||
}
|
||||
if ($default->id !== (int) $journal['currency_id'] && $default->id === (int) $journal['foreign_currency_id']) {
|
||||
$currencyId = $journal['foreign_currency_id'];
|
||||
$currencyCode = $journal['foreign_currency_code'];
|
||||
}
|
||||
Log::debug(sprintf('[a] Add amount %s %s', $currencyCode, $amount));
|
||||
}
|
||||
if (!$convertToNative) {
|
||||
// ignore the amount in foreign currency.
|
||||
Log::debug(sprintf('[b] Add amount %s %s', $currencyCode, $journal['amount']));
|
||||
$amount = $journal['amount'];
|
||||
}
|
||||
|
||||
if (0 !== $currencyId) {
|
||||
$response[$currencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']);
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // float but on purpose.
|
||||
}
|
||||
if (0 !== $foreignCurrencyId) {
|
||||
$response[$foreignCurrencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $foreignCurrencyId,
|
||||
'currency_code' => $journal['foreign_currency_code'],
|
||||
];
|
||||
$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']);
|
||||
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; // float but on purpose.
|
||||
}
|
||||
$response[$currencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $currencyCode,
|
||||
];
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $amount);
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // float but on purpose.
|
||||
}
|
||||
|
||||
return response()->json(array_values($response));
|
||||
|
||||
@@ -73,6 +73,7 @@ class AccountController extends Controller
|
||||
$start = $request->getStart();
|
||||
$end = $request->getEnd();
|
||||
$assetAccounts = $request->getAssetAccounts();
|
||||
|
||||
$income = $this->opsRepository->sumIncomeByDestination($start, $end, $assetAccounts);
|
||||
$result = [];
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
@@ -41,42 +42,41 @@ class PeriodController extends Controller
|
||||
*/
|
||||
public function total(GenericRequest $request): JsonResponse
|
||||
{
|
||||
$accounts = $request->getAssetAccounts();
|
||||
$start = $request->getStart();
|
||||
$end = $request->getEnd();
|
||||
$response = [];
|
||||
$accounts = $request->getAssetAccounts();
|
||||
$start = $request->getStart();
|
||||
$end = $request->getEnd();
|
||||
$response = [];
|
||||
$convertToNative = Amount::convertToNative();
|
||||
$default = Amount::getDefaultCurrency();
|
||||
|
||||
// collect all expenses in this period (regardless of type)
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setTypes([TransactionTypeEnum::DEPOSIT->value])->setRange($start, $end)->setDestinationAccounts($accounts);
|
||||
$genericSet = $collector->getExtractedJournals();
|
||||
$genericSet = $collector->getExtractedJournals();
|
||||
foreach ($genericSet as $journal) {
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$foreignCurrencyId = (int) $journal['foreign_currency_id'];
|
||||
// currency
|
||||
$currencyId = $journal['currency_id'];
|
||||
$currencyCode = $journal['currency_code'];
|
||||
$field = $convertToNative && $currencyId !== $default->id ? 'native_amount' : 'amount';
|
||||
|
||||
if (0 !== $currencyId) {
|
||||
$response[$currencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // float but on purpose.
|
||||
// perhaps use default currency instead?
|
||||
if ($convertToNative && $journal['currency_id'] !== $default->id) {
|
||||
$currencyId = $default->id;
|
||||
$currencyCode = $default->code;
|
||||
}
|
||||
if (0 !== $foreignCurrencyId) {
|
||||
$response[$foreignCurrencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $foreignCurrencyId,
|
||||
'currency_code' => $journal['foreign_currency_code'],
|
||||
];
|
||||
$response[$foreignCurrencyId]['difference'] = bcadd(
|
||||
$response[$foreignCurrencyId]['difference'],
|
||||
app('steam')->positive($journal['foreign_amount'])
|
||||
);
|
||||
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; // float but on purpose.
|
||||
// use foreign amount when the foreign currency IS the default currency.
|
||||
if ($convertToNative && $journal['currency_id'] !== $default->id && $default->id === $journal['foreign_currency_id']) {
|
||||
$field = 'foreign_amount';
|
||||
}
|
||||
|
||||
$response[$currencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $currencyCode,
|
||||
];
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal[$field]));
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // float but on purpose.
|
||||
}
|
||||
|
||||
return response()->json(array_values($response));
|
||||
|
||||
@@ -29,6 +29,7 @@ use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
@@ -63,45 +64,45 @@ class TagController extends Controller
|
||||
*/
|
||||
public function noTag(GenericRequest $request): JsonResponse
|
||||
{
|
||||
$accounts = $request->getAssetAccounts();
|
||||
$start = $request->getStart();
|
||||
$end = $request->getEnd();
|
||||
$response = [];
|
||||
$accounts = $request->getAssetAccounts();
|
||||
$start = $request->getStart();
|
||||
$end = $request->getEnd();
|
||||
$response = [];
|
||||
$convertToNative = Amount::convertToNative();
|
||||
$default = Amount::getDefaultCurrency();
|
||||
|
||||
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setTypes([TransactionTypeEnum::DEPOSIT->value])->setRange($start, $end)->setDestinationAccounts($accounts);
|
||||
$collector->withoutTags();
|
||||
|
||||
$genericSet = $collector->getExtractedJournals();
|
||||
$genericSet = $collector->getExtractedJournals();
|
||||
|
||||
foreach ($genericSet as $journal) {
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$foreignCurrencyId = (int) $journal['foreign_currency_id'];
|
||||
// currency
|
||||
$currencyId = $journal['currency_id'];
|
||||
$currencyCode = $journal['currency_code'];
|
||||
$field = $convertToNative && $currencyId !== $default->id ? 'native_amount' : 'amount';
|
||||
|
||||
if (0 !== $currencyId) {
|
||||
$response[$currencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
|
||||
// perhaps use default currency instead?
|
||||
if ($convertToNative && $journal['currency_id'] !== $default->id) {
|
||||
$currencyId = $default->id;
|
||||
$currencyCode = $default->code;
|
||||
}
|
||||
if (0 !== $foreignCurrencyId) {
|
||||
$response[$foreignCurrencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $foreignCurrencyId,
|
||||
'currency_code' => $journal['foreign_currency_code'],
|
||||
];
|
||||
$response[$foreignCurrencyId]['difference'] = bcadd(
|
||||
$response[$foreignCurrencyId]['difference'],
|
||||
app('steam')->positive($journal['foreign_amount'])
|
||||
);
|
||||
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference'];
|
||||
// use foreign amount when the foreign currency IS the default currency.
|
||||
if ($convertToNative && $journal['currency_id'] !== $default->id && $default->id === $journal['foreign_currency_id']) {
|
||||
$field = 'foreign_amount';
|
||||
}
|
||||
|
||||
$response[$currencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $currencyCode,
|
||||
];
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal[$field]));
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
|
||||
|
||||
}
|
||||
|
||||
return response()->json(array_values($response));
|
||||
|
||||
@@ -28,6 +28,7 @@ use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
@@ -41,42 +42,42 @@ class PeriodController extends Controller
|
||||
*/
|
||||
public function total(GenericRequest $request): JsonResponse
|
||||
{
|
||||
$accounts = $request->getAssetAccounts();
|
||||
$start = $request->getStart();
|
||||
$end = $request->getEnd();
|
||||
$response = [];
|
||||
$accounts = $request->getAssetAccounts();
|
||||
$start = $request->getStart();
|
||||
$end = $request->getEnd();
|
||||
$response = [];
|
||||
$convertToNative = Amount::convertToNative();
|
||||
$default = Amount::getDefaultCurrency();
|
||||
|
||||
// collect all expenses in this period (regardless of type)
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setTypes([TransactionType::TRANSFER])->setRange($start, $end)->setDestinationAccounts($accounts);
|
||||
$genericSet = $collector->getExtractedJournals();
|
||||
$genericSet = $collector->getExtractedJournals();
|
||||
foreach ($genericSet as $journal) {
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$foreignCurrencyId = (int) $journal['foreign_currency_id'];
|
||||
// currency
|
||||
$currencyId = $journal['currency_id'];
|
||||
$currencyCode = $journal['currency_code'];
|
||||
$field = $convertToNative && $currencyId !== $default->id ? 'native_amount' : 'amount';
|
||||
|
||||
if (0 !== $currencyId) {
|
||||
$response[$currencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
|
||||
// perhaps use default currency instead?
|
||||
if ($convertToNative && $journal['currency_id'] !== $default->id) {
|
||||
$currencyId = $default->id;
|
||||
$currencyCode = $default->code;
|
||||
}
|
||||
if (0 !== $foreignCurrencyId) {
|
||||
$response[$foreignCurrencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $foreignCurrencyId,
|
||||
'currency_code' => $journal['foreign_currency_code'],
|
||||
];
|
||||
$response[$foreignCurrencyId]['difference'] = bcadd(
|
||||
$response[$foreignCurrencyId]['difference'],
|
||||
app('steam')->positive($journal['foreign_amount'])
|
||||
);
|
||||
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference'];
|
||||
// use foreign amount when the foreign currency IS the default currency.
|
||||
if ($convertToNative && $journal['currency_id'] !== $default->id && $default->id === $journal['foreign_currency_id']) {
|
||||
$field = 'foreign_amount';
|
||||
}
|
||||
|
||||
$response[$currencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $currencyCode,
|
||||
];
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal[$field]));
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
|
||||
|
||||
}
|
||||
|
||||
return response()->json(array_values($response));
|
||||
|
||||
@@ -29,6 +29,7 @@ use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
@@ -61,45 +62,46 @@ class TagController extends Controller
|
||||
*/
|
||||
public function noTag(GenericRequest $request): JsonResponse
|
||||
{
|
||||
$accounts = $request->getAssetAccounts();
|
||||
$start = $request->getStart();
|
||||
$end = $request->getEnd();
|
||||
$response = [];
|
||||
$accounts = $request->getAssetAccounts();
|
||||
$start = $request->getStart();
|
||||
$end = $request->getEnd();
|
||||
$response = [];
|
||||
$convertToNative = Amount::convertToNative();
|
||||
$default = Amount::getDefaultCurrency();
|
||||
|
||||
|
||||
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setTypes([TransactionType::TRANSFER])->setRange($start, $end)->setDestinationAccounts($accounts);
|
||||
$collector->withoutTags();
|
||||
|
||||
$genericSet = $collector->getExtractedJournals();
|
||||
$genericSet = $collector->getExtractedJournals();
|
||||
|
||||
foreach ($genericSet as $journal) {
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$foreignCurrencyId = (int) $journal['foreign_currency_id'];
|
||||
// currency
|
||||
$currencyId = $journal['currency_id'];
|
||||
$currencyCode = $journal['currency_code'];
|
||||
$field = $convertToNative && $currencyId !== $default->id ? 'native_amount' : 'amount';
|
||||
|
||||
if (0 !== $currencyId) {
|
||||
$response[$currencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
|
||||
// perhaps use default currency instead?
|
||||
if ($convertToNative && $journal['currency_id'] !== $default->id) {
|
||||
$currencyId = $default->id;
|
||||
$currencyCode = $default->code;
|
||||
}
|
||||
if (0 !== $foreignCurrencyId) {
|
||||
$response[$foreignCurrencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $foreignCurrencyId,
|
||||
'currency_code' => $journal['foreign_currency_code'],
|
||||
];
|
||||
$response[$foreignCurrencyId]['difference'] = bcadd(
|
||||
$response[$foreignCurrencyId]['difference'],
|
||||
app('steam')->positive($journal['foreign_amount'])
|
||||
);
|
||||
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference'];
|
||||
// use foreign amount when the foreign currency IS the default currency.
|
||||
if ($convertToNative && $journal['currency_id'] !== $default->id && $default->id === $journal['foreign_currency_id']) {
|
||||
$field = 'foreign_amount';
|
||||
}
|
||||
|
||||
$response[$currencyId] ??= [
|
||||
'difference' => '0',
|
||||
'difference_float' => 0,
|
||||
'currency_id' => (string) $currencyId,
|
||||
'currency_code' => $currencyCode,
|
||||
];
|
||||
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal[$field]));
|
||||
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
|
||||
|
||||
}
|
||||
|
||||
return response()->json(array_values($response));
|
||||
|
||||
@@ -105,19 +105,18 @@ class ShowController extends Controller
|
||||
public function show(TransactionCurrency $currency): JsonResponse
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$manager = $this->getManager();
|
||||
$defaultCurrency = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup);
|
||||
$this->parameters->set('defaultCurrency', $defaultCurrency);
|
||||
$user = auth()->user();
|
||||
$manager = $this->getManager();
|
||||
$this->parameters->set('defaultCurrency', $this->defaultCurrency);
|
||||
|
||||
// update fields with user info.
|
||||
$currency->refreshForUser($user);
|
||||
|
||||
/** @var CurrencyTransformer $transformer */
|
||||
$transformer = app(CurrencyTransformer::class);
|
||||
$transformer = app(CurrencyTransformer::class);
|
||||
$transformer->setParameters($this->parameters);
|
||||
|
||||
$resource = new Item($currency, $transformer, 'currencies');
|
||||
$resource = new Item($currency, $transformer, 'currencies');
|
||||
|
||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||
}
|
||||
@@ -135,7 +134,7 @@ class ShowController extends Controller
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$manager = $this->getManager();
|
||||
$currency = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup);
|
||||
$currency = $this->defaultCurrency;
|
||||
|
||||
// update fields with user info.
|
||||
$currency->refreshForUser($user);
|
||||
|
||||
@@ -27,19 +27,21 @@ namespace FireflyIII\Api\V1\Controllers\Summary;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Data\DateRequest;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Helpers\Report\NetWorthInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\AvailableBudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class BasicController
|
||||
@@ -101,10 +103,10 @@ class BasicController extends Controller
|
||||
$billData = $this->getBillInformation($start, $end);
|
||||
$spentData = $this->getLeftToSpendInfo($start, $end);
|
||||
$netWorthData = $this->getNetWorthInfo($start, $end);
|
||||
// $balanceData = [];
|
||||
// $billData = [];
|
||||
// $spentData = [];
|
||||
// $netWorthData = [];
|
||||
// $balanceData = [];
|
||||
// $billData = [];
|
||||
// $spentData = [];
|
||||
// $netWorthData = [];
|
||||
$total = array_merge($balanceData, $billData, $spentData, $netWorthData);
|
||||
|
||||
// give new keys
|
||||
@@ -120,48 +122,53 @@ class BasicController extends Controller
|
||||
|
||||
private function getBalanceInformation(Carbon $start, Carbon $end): array
|
||||
{
|
||||
// some config settings
|
||||
$convertToNative = Amount::convertToNative();
|
||||
$default = Amount::getDefaultCurrency();
|
||||
// prep some arrays:
|
||||
$incomes = [];
|
||||
$expenses = [];
|
||||
$sums = [];
|
||||
$return = [];
|
||||
$incomes = [];
|
||||
$expenses = [];
|
||||
$sums = [];
|
||||
$return = [];
|
||||
|
||||
// collect income of user using the new group collector.
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setRange($start, $end)->setPage($this->parameters->get('page'))->setTypes([TransactionTypeEnum::DEPOSIT->value]);
|
||||
|
||||
$set = $collector->getExtractedJournals();
|
||||
$set = $collector->getExtractedJournals();
|
||||
|
||||
/** @var array $transactionJournal */
|
||||
foreach ($set as $transactionJournal) {
|
||||
$currencyId = (int) $transactionJournal['currency_id'];
|
||||
/** @var array $journal */
|
||||
foreach ($set as $journal) {
|
||||
$currencyId = $convertToNative ? $default->id : (int) $journal['currency_id'];
|
||||
$amount = Amount::getAmountFromJournal($journal);
|
||||
$incomes[$currencyId] ??= '0';
|
||||
$incomes[$currencyId] = bcadd(
|
||||
$incomes[$currencyId],
|
||||
bcmul($transactionJournal['amount'], '-1')
|
||||
bcmul($amount, '-1')
|
||||
);
|
||||
$sums[$currencyId] ??= '0';
|
||||
$sums[$currencyId] = bcadd($sums[$currencyId], bcmul($transactionJournal['amount'], '-1'));
|
||||
$sums[$currencyId] = bcadd($sums[$currencyId], bcmul($amount, '-1'));
|
||||
}
|
||||
|
||||
// collect expenses of user using the new group collector.
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setRange($start, $end)->setPage($this->parameters->get('page'))->setTypes([TransactionTypeEnum::WITHDRAWAL->value]);
|
||||
$set = $collector->getExtractedJournals();
|
||||
$set = $collector->getExtractedJournals();
|
||||
|
||||
/** @var array $transactionJournal */
|
||||
foreach ($set as $transactionJournal) {
|
||||
$currencyId = (int) $transactionJournal['currency_id'];
|
||||
/** @var array $journal */
|
||||
foreach ($set as $journal) {
|
||||
$currencyId = $convertToNative ? $default->id : (int) $journal['currency_id'];
|
||||
$amount = Amount::getAmountFromJournal($journal);
|
||||
$expenses[$currencyId] ??= '0';
|
||||
$expenses[$currencyId] = bcadd($expenses[$currencyId], $transactionJournal['amount']);
|
||||
$expenses[$currencyId] = bcadd($expenses[$currencyId], $amount);
|
||||
$sums[$currencyId] ??= '0';
|
||||
$sums[$currencyId] = bcadd($sums[$currencyId], $transactionJournal['amount']);
|
||||
$sums[$currencyId] = bcadd($sums[$currencyId], $amount);
|
||||
}
|
||||
|
||||
// format amounts:
|
||||
$keys = array_keys($sums);
|
||||
$keys = array_keys($sums);
|
||||
foreach ($keys as $currencyId) {
|
||||
$currency = $this->currencyRepos->find($currencyId);
|
||||
if (null === $currency) {
|
||||
@@ -269,24 +276,27 @@ class BasicController extends Controller
|
||||
*/
|
||||
private function getLeftToSpendInfo(Carbon $start, Carbon $end): array
|
||||
{
|
||||
Log::debug(sprintf('Now in getLeftToSpendInfo("%s", "%s")', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
$return = [];
|
||||
$today = today(config('app.timezone'));
|
||||
$available = $this->abRepository->getAvailableBudgetWithCurrency($start, $end);
|
||||
$budgets = $this->budgetRepository->getActiveBudgets();
|
||||
$spent = $this->opsRepository->sumExpenses($start, $end, null, $budgets);
|
||||
$days = (int) $today->diffInDays($end, true) + 1;
|
||||
|
||||
foreach ($spent as $row) {
|
||||
// either an amount was budgeted or 0 is available.
|
||||
$amount = (string) ($available[$row['currency_id']] ?? '0');
|
||||
$currencyId = $row['currency_id'];
|
||||
$amount = (string) ($available[$currencyId] ?? '0');
|
||||
$spentInCurrency = $row['sum'];
|
||||
$leftToSpend = bcadd($amount, $spentInCurrency);
|
||||
|
||||
$days = (int) $today->diffInDays($end, true) + 1;
|
||||
$perDay = '0';
|
||||
if (0 !== $days && bccomp($leftToSpend, '0') > -1) {
|
||||
$perDay = bcdiv($leftToSpend, (string) $days);
|
||||
}
|
||||
|
||||
Log::debug(sprintf('Spent %s %s', $row['currency_code'], $row['sum']));
|
||||
|
||||
$return[] = [
|
||||
'key' => sprintf('left-to-spend-in-%s', $row['currency_code']),
|
||||
'title' => trans('firefly.box_left_to_spend_in_currency', ['currency' => $row['currency_symbol']]),
|
||||
@@ -311,9 +321,11 @@ class BasicController extends Controller
|
||||
|
||||
private function getNetWorthInfo(Carbon $start, Carbon $end): array
|
||||
{
|
||||
Log::debug('getNetWorthInfo');
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$date = today(config('app.timezone'))->startOfDay();
|
||||
$date = now(config('app.timezone'));
|
||||
// start and end in the future? use $end
|
||||
if ($this->notInDateRange($date, $start, $end)) {
|
||||
/** @var Carbon $date */
|
||||
@@ -323,9 +335,7 @@ class BasicController extends Controller
|
||||
/** @var NetWorthInterface $netWorthHelper */
|
||||
$netWorthHelper = app(NetWorthInterface::class);
|
||||
$netWorthHelper->setUser($user);
|
||||
$allAccounts = $this->accountRepository->getActiveAccountsByType(
|
||||
[AccountType::ASSET, AccountType::DEFAULT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::DEBT]
|
||||
);
|
||||
$allAccounts = $this->accountRepository->getActiveAccountsByType([AccountTypeEnum::ASSET->value, AccountTypeEnum::DEFAULT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::DEBT->value]);
|
||||
|
||||
// filter list on preference of being included.
|
||||
$filtered = $allAccounts->filter(
|
||||
@@ -360,6 +370,7 @@ class BasicController extends Controller
|
||||
'sub_title' => '',
|
||||
];
|
||||
}
|
||||
Log::debug('End of getNetWorthInfo');
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ class AccountController extends Controller
|
||||
'native_entries' => [],
|
||||
];
|
||||
$currentStart = clone $params['start'];
|
||||
$range = app('steam')->finalAccountBalanceInRange($account, $params['start'], clone $params['end'], $currency);
|
||||
$range = app('steam')->finalAccountBalanceInRange($account, $params['start'], clone $params['end'], $this->convertToNative);
|
||||
|
||||
$previous = array_values($range)[0]['balance'];
|
||||
$previousNative = array_values($range)[0]['native_balance'];
|
||||
|
||||
@@ -54,9 +54,10 @@ class Controller extends BaseController
|
||||
{
|
||||
use ValidatesUserGroupTrait;
|
||||
|
||||
protected const string CONTENT_TYPE = 'application/vnd.api+json';
|
||||
protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
|
||||
protected const string CONTENT_TYPE = 'application/vnd.api+json';
|
||||
protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
|
||||
protected ParameterBag $parameters;
|
||||
protected bool $convertToNative = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* AccountController.php
|
||||
* Copyright (c) 2024 james@firefly-iii.org.
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V2\Controllers\JsonApi;
|
||||
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\JsonApi\V2\Accounts\AccountCollectionQuery;
|
||||
use FireflyIII\JsonApi\V2\Accounts\AccountSchema;
|
||||
use FireflyIII\JsonApi\V2\Accounts\AccountSingleQuery;
|
||||
use FireflyIII\Models\Account;
|
||||
use Illuminate\Contracts\Support\Responsable;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use LaravelJsonApi\Core\Responses\DataResponse;
|
||||
use LaravelJsonApi\Laravel\Http\Controllers\Actions;
|
||||
|
||||
/**
|
||||
* Class AccountController
|
||||
*
|
||||
* This class handles api/v2 requests for accounts.
|
||||
* Most stuff is default stuff.
|
||||
*/
|
||||
class AccountController extends Controller
|
||||
{
|
||||
use Actions\AttachRelationship;
|
||||
use Actions\Destroy;
|
||||
use Actions\DetachRelationship;
|
||||
|
||||
use Actions\FetchMany;
|
||||
|
||||
// use Actions\FetchOne;
|
||||
use Actions\FetchRelated;
|
||||
use Actions\FetchRelationship;
|
||||
use Actions\Store;
|
||||
use Actions\Update;
|
||||
use Actions\UpdateRelationship;
|
||||
|
||||
/**
|
||||
* Fetch zero to many JSON API resources.
|
||||
*
|
||||
* @return Responsable|Response
|
||||
*/
|
||||
public function index(AccountSchema $schema, AccountCollectionQuery $request)
|
||||
{
|
||||
Log::debug(__METHOD__);
|
||||
$models = $schema
|
||||
->repository()
|
||||
->queryAll()
|
||||
->withRequest($request)
|
||||
->get()
|
||||
;
|
||||
|
||||
// do something custom...
|
||||
|
||||
return new DataResponse($models);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch zero to one JSON API resource by id.
|
||||
*
|
||||
* @return Responsable|Response
|
||||
*/
|
||||
public function show(AccountSchema $schema, AccountSingleQuery $request, Account $account)
|
||||
{
|
||||
Log::debug(__METHOD__);
|
||||
$model = $schema->repository()
|
||||
->queryOne($account)
|
||||
->withRequest($request)
|
||||
->first()
|
||||
;
|
||||
Log::debug(sprintf('%s again!', __METHOD__));
|
||||
|
||||
// do something custom...
|
||||
|
||||
return new DataResponse($model);
|
||||
}
|
||||
|
||||
// public function readAccountBalances(AnonymousQuery $query, AccountBalanceSchema $schema, Account $account): Responsable
|
||||
// {
|
||||
// $schema = JsonApi::server()->schemas()->schemaFor('account-balances');
|
||||
//
|
||||
// $models = $schema
|
||||
// ->repository()
|
||||
// ->queryAll()
|
||||
// ->withRequest($query)
|
||||
// ->withAccount($account)
|
||||
// ->get()
|
||||
// ;
|
||||
//
|
||||
// return DataResponse::make($models);
|
||||
// }
|
||||
}
|
||||
@@ -1,5 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* ConvertsDatesToUTC.php
|
||||
* Copyright (c) 2024 james@firefly-iii.org.
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* ConvertDatesToUTC.php
|
||||
@@ -21,7 +41,7 @@ declare(strict_types=1);
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Console\Commands\Integrity;
|
||||
namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
@@ -31,7 +51,7 @@ use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ConvertDatesToUTC extends Command
|
||||
class ConvertsDatesToUTC extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -47,13 +67,17 @@ class ConvertDatesToUTC extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly-iii:migrate-to-utc';
|
||||
protected $signature = 'correction:convert-to-utc';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->friendlyWarning('Please do not use this command.');
|
||||
|
||||
return 0;
|
||||
|
||||
/**
|
||||
* @var string $model
|
||||
* @var array $fields
|
||||
@@ -4,10 +4,6 @@ namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class CorrectionSkeleton
|
||||
* TODO DONT FORGET TO ADD THIS TO THE DOCKER BUILD
|
||||
*/
|
||||
class CorrectionSkeleton extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -29,15 +29,12 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class FixAccountOrder
|
||||
*/
|
||||
class FixAccountOrder extends Command
|
||||
class CorrectsAccountOrder extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Make sure account order is correct.';
|
||||
protected $signature = 'firefly-iii:fix-account-order';
|
||||
protected $signature = 'correction:account-order';
|
||||
|
||||
private AccountRepositoryInterface $repository;
|
||||
|
||||
@@ -54,8 +51,6 @@ class FixAccountOrder extends Command
|
||||
$this->repository->resetAccountOrder();
|
||||
}
|
||||
|
||||
$this->friendlyPositive('All accounts are ordered correctly');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -36,15 +36,12 @@ use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
|
||||
/**
|
||||
* Class FixAccountTypes
|
||||
*/
|
||||
class FixAccountTypes extends Command
|
||||
class CorrectsAccountTypes extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Make sure all journals have the correct from/to account types.';
|
||||
protected $signature = 'firefly-iii:fix-account-types';
|
||||
protected $signature = 'correction:account-types';
|
||||
private int $count;
|
||||
private array $expected;
|
||||
private AccountFactory $factory;
|
||||
@@ -120,9 +117,6 @@ class FixAccountTypes extends Command
|
||||
}
|
||||
}
|
||||
}
|
||||
if (0 === $this->count) {
|
||||
$this->friendlyPositive('All account types are OK');
|
||||
}
|
||||
if (0 !== $this->count) {
|
||||
app('log')->debug(sprintf('%d journals had to be fixed.', $this->count));
|
||||
$this->friendlyInfo(sprintf('Acted on %d transaction(s)', $this->count));
|
||||
@@ -36,15 +36,12 @@ use FireflyIII\Models\RuleTrigger;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Class ReportSkeleton
|
||||
*/
|
||||
class CorrectAmounts extends Command
|
||||
class CorrectsAmounts extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'This command makes sure positive and negative amounts are recorded correctly.';
|
||||
protected $signature = 'firefly-iii:fix-amount-pos-neg';
|
||||
protected $signature = 'correction:amounts';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
@@ -72,7 +69,6 @@ class CorrectAmounts extends Command
|
||||
{
|
||||
$count = AutoBudget::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]);
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('All auto budget amounts are positive.');
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -83,7 +79,6 @@ class CorrectAmounts extends Command
|
||||
{
|
||||
$count = AvailableBudget::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]);
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('All available budget amounts are positive.');
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -96,7 +91,6 @@ class CorrectAmounts extends Command
|
||||
$count += Bill::where('amount_max', '<', 0)->update(['amount_max' => DB::raw('amount_max * -1')]);
|
||||
$count += Bill::where('amount_min', '<', 0)->update(['amount_min' => DB::raw('amount_min * -1')]);
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('All bill amounts are positive.');
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -107,7 +101,6 @@ class CorrectAmounts extends Command
|
||||
{
|
||||
$count = BudgetLimit::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]);
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('All budget limit amounts are positive.');
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -118,7 +111,6 @@ class CorrectAmounts extends Command
|
||||
{
|
||||
$count = CurrencyExchangeRate::where('rate', '<', 0)->update(['rate' => DB::raw('rate * -1')]);
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('All currency exchange rates are positive.');
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -129,7 +121,6 @@ class CorrectAmounts extends Command
|
||||
{
|
||||
$count = PiggyBank::where('target_amount', '<', 0)->update(['target_amount' => DB::raw('target_amount * -1')]);
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('All piggy bank amounts are positive.');
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -142,7 +133,6 @@ class CorrectAmounts extends Command
|
||||
$count += RecurrenceTransaction::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]);
|
||||
$count += RecurrenceTransaction::where('foreign_amount', '<', 0)->update(['foreign_amount' => DB::raw('foreign_amount * -1')]);
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('All recurring transaction amounts are positive.');
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -165,7 +155,6 @@ class CorrectAmounts extends Command
|
||||
}
|
||||
}
|
||||
if (0 === $fixed) {
|
||||
$this->friendlyPositive('All rule trigger amounts are positive.');
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -37,15 +37,12 @@ use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Symfony\Component\Console\Command\Command as CommandAlias;
|
||||
|
||||
/**
|
||||
* Class EnableCurrencies
|
||||
*/
|
||||
class EnableCurrencies extends Command
|
||||
class CorrectsCurrencies extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Enables all currencies in use.';
|
||||
protected $signature = 'firefly-iii:enable-currencies';
|
||||
protected $signature = 'correction:currencies';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -27,14 +27,11 @@ namespace FireflyIII\Console\Commands\Correction;
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class CorrectDatabase
|
||||
*/
|
||||
class CorrectDatabase extends Command
|
||||
class CorrectsDatabase extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Will correct the integrity of your database, if necessary.';
|
||||
protected $description = 'Will validate and correct the integrity of your database, if necessary.';
|
||||
protected $signature = 'firefly-iii:correct-database';
|
||||
|
||||
/**
|
||||
@@ -49,32 +46,36 @@ class CorrectDatabase extends Command
|
||||
return 1;
|
||||
}
|
||||
$commands = [
|
||||
'firefly-iii:fix-piggies',
|
||||
'firefly-iii:create-link-types',
|
||||
'firefly-iii:create-access-tokens',
|
||||
'firefly-iii:remove-bills',
|
||||
'firefly-iii:fix-amount-pos-neg',
|
||||
'firefly-iii:enable-currencies',
|
||||
'firefly-iii:fix-transfer-budgets',
|
||||
'firefly-iii:fix-uneven-amount',
|
||||
'firefly-iii:delete-zero-amount',
|
||||
'firefly-iii:delete-orphaned-transactions',
|
||||
'firefly-iii:delete-empty-journals',
|
||||
'firefly-iii:delete-empty-groups',
|
||||
'firefly-iii:fix-account-types',
|
||||
'firefly-iii:fix-ibans',
|
||||
'firefly-iii:fix-account-order',
|
||||
'firefly-iii:rename-meta-fields',
|
||||
'firefly-iii:fix-ob-currencies',
|
||||
'firefly-iii:fix-long-descriptions',
|
||||
'firefly-iii:fix-recurring-transactions',
|
||||
'firefly-iii:upgrade-group-information',
|
||||
// 'firefly-iii:fix-transaction-types', // very resource heavy.
|
||||
'firefly-iii:fix-frontpage-accounts',
|
||||
// new!
|
||||
'firefly-iii:unify-group-accounts',
|
||||
'firefly-iii:trigger-credit-recalculation',
|
||||
'firefly-iii:migrate-preferences',
|
||||
'correction:restore-oauth-keys',
|
||||
'correction:timezones',
|
||||
'correction:create-group-memberships',
|
||||
'correction:group-information',
|
||||
'correction:piggy-banks',
|
||||
'correction:link-types',
|
||||
'correction:access-tokens',
|
||||
'correction:bills',
|
||||
'correction:amounts',
|
||||
'correction:currencies',
|
||||
'correction:transfer-budgets',
|
||||
'correction:uneven-amounts',
|
||||
'correction:zero-amounts',
|
||||
'correction:orphaned-transactions',
|
||||
'correction:empty-journals',
|
||||
'correction:empty-groups',
|
||||
'correction:account-types',
|
||||
'correction:ibans',
|
||||
'correction:account-order',
|
||||
'correction:meta-fields',
|
||||
'correction:opening-balance-currencies',
|
||||
'correction:long-descriptions',
|
||||
'correction:recurring-transactions',
|
||||
'correction:frontpage-accounts',
|
||||
'correction:group-accounts',
|
||||
'correction:recalculates-liabilities',
|
||||
'correction:preferences',
|
||||
// 'correction:transaction-types', // resource heavy, disabled.
|
||||
'correction:recalculate-native-amounts', // not necessary, disabled.
|
||||
'firefly-iii:report-integrity',
|
||||
];
|
||||
foreach ($commands as $command) {
|
||||
$this->friendlyLine(sprintf('Now executing command "%s"', $command));
|
||||
@@ -31,15 +31,12 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class FixFrontpageAccounts
|
||||
*/
|
||||
class FixFrontpageAccounts extends Command
|
||||
class CorrectsFrontpageAccounts extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Fixes a preference that may include deleted accounts or accounts of another type.';
|
||||
protected $signature = 'firefly-iii:fix-frontpage-accounts';
|
||||
protected $signature = 'correction:frontpage-accounts';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -55,7 +52,6 @@ class FixFrontpageAccounts extends Command
|
||||
$this->fixPreference($preference);
|
||||
}
|
||||
}
|
||||
$this->friendlyPositive('Account preferences are OK');
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -31,15 +31,12 @@ use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class FixGroupAccounts
|
||||
*/
|
||||
class FixGroupAccounts extends Command
|
||||
class CorrectsGroupAccounts extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Unify the source / destination accounts of split groups.';
|
||||
protected $signature = 'firefly-iii:unify-group-accounts';
|
||||
protected $signature = 'correction:group-accounts';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -64,8 +61,6 @@ class FixGroupAccounts extends Command
|
||||
$handler->unifyAccounts($event);
|
||||
}
|
||||
|
||||
$this->friendlyPositive('Updated possible inconsistent transaction groups.');
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* UpdateGroupInformation.php
|
||||
* Copyright (c) 2022 james@firefly-iii.org
|
||||
* CorrectsGroupInformation.php
|
||||
* Copyright (c) 2024 james@firefly-iii.org.
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
@@ -17,12 +17,12 @@
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands\Integrity;
|
||||
namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Models\Account;
|
||||
@@ -45,15 +45,12 @@ use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
/**
|
||||
* Class UpdateGroupInformation
|
||||
*/
|
||||
class UpdateGroupInformation extends Command
|
||||
class CorrectsGroupInformation extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Makes sure that every object is linked to a group';
|
||||
protected $signature = 'firefly-iii:upgrade-group-information';
|
||||
protected $signature = 'correction:group-information';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -30,15 +30,12 @@ use FireflyIII\Models\AccountType;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class FixIbans
|
||||
*/
|
||||
class FixIbans extends Command
|
||||
class CorrectsIbans extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Removes spaces from IBANs';
|
||||
protected $signature = 'firefly-iii:fix-ibans';
|
||||
protected $signature = 'correction:ibans';
|
||||
private int $count = 0;
|
||||
|
||||
/**
|
||||
@@ -49,9 +46,6 @@ class FixIbans extends Command
|
||||
$accounts = Account::whereNotNull('iban')->get();
|
||||
$this->filterIbans($accounts);
|
||||
$this->countAndCorrectIbans($accounts);
|
||||
if (0 === $this->count) {
|
||||
$this->friendlyPositive('All IBANs are valid.');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -28,24 +28,22 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Class FixLongDescriptions
|
||||
*/
|
||||
class FixLongDescriptions extends Command
|
||||
class CorrectsLongDescriptions extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
private const int MAX_LENGTH = 1000;
|
||||
protected $description = 'Fixes long descriptions in journals and groups.';
|
||||
protected $signature = 'firefly-iii:fix-long-descriptions';
|
||||
protected $signature = 'correction:long-descriptions';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$journals = TransactionJournal::get(['id', 'description']);
|
||||
$journals = TransactionJournal::where(DB::raw('LENGTH(description)'), '>', self::MAX_LENGTH)->get(['id', 'description']);
|
||||
$count = 0;
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
@@ -58,7 +56,7 @@ class FixLongDescriptions extends Command
|
||||
}
|
||||
}
|
||||
|
||||
$groups = TransactionGroup::get(['id', 'title']);
|
||||
$groups = TransactionGroup::where(DB::raw('LENGTH(title)'), '>', self::MAX_LENGTH)->get(['id', 'title']);
|
||||
|
||||
/** @var TransactionGroup $group */
|
||||
foreach ($groups as $group) {
|
||||
@@ -69,9 +67,6 @@ class FixLongDescriptions extends Command
|
||||
++$count;
|
||||
}
|
||||
}
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('All transaction group and journal title lengths are within bounds.');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -26,16 +26,14 @@ namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Class RenameMetaFields
|
||||
*/
|
||||
class RenameMetaFields extends Command
|
||||
class CorrectsMetaDataFields extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Rename changed meta fields.';
|
||||
protected $signature = 'firefly-iii:rename-meta-fields';
|
||||
protected $signature = 'correction:meta-fields';
|
||||
|
||||
private int $count = 0;
|
||||
|
||||
@@ -61,9 +59,6 @@ class RenameMetaFields extends Command
|
||||
foreach ($changes as $original => $update) {
|
||||
$this->rename($original, $update);
|
||||
}
|
||||
if (0 === $this->count) {
|
||||
$this->friendlyPositive('All meta fields are correct.');
|
||||
}
|
||||
if (0 !== $this->count) {
|
||||
$this->friendlyInfo(sprintf('Renamed %d meta field(s).', $this->count));
|
||||
}
|
||||
@@ -73,7 +68,7 @@ class RenameMetaFields extends Command
|
||||
|
||||
private function rename(string $original, string $update): void
|
||||
{
|
||||
$total = \DB::table('journal_meta')
|
||||
$total = DB::table('journal_meta')
|
||||
->where('name', '=', $original)
|
||||
->update(['name' => $update])
|
||||
;
|
||||
@@ -46,19 +46,24 @@ use Illuminate\Database\Query\Builder as DatabaseBuilder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class RecalculateNativeAmounts extends Command
|
||||
class CorrectsNativeAmounts extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Recalculate native amounts for all objects.';
|
||||
|
||||
protected $signature = 'firefly-iii:recalculate-native-amounts';
|
||||
protected $signature = 'correction:recalculate-native-amounts';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
if (!config('cer.enabled')) {
|
||||
$this->friendlyInfo('This command will not run because currency exchange rates are disabled.');
|
||||
|
||||
return 0;
|
||||
}
|
||||
Log::debug('Will update all native amounts. This may take some time.');
|
||||
$this->friendlyWarning('Recalculating native amounts for all objects. This may take some time!');
|
||||
|
||||
@@ -102,12 +107,13 @@ class RecalculateNativeAmounts extends Command
|
||||
foreach ($set as $account) {
|
||||
$account->touch();
|
||||
}
|
||||
Log::debug(sprintf('Recalculated %d accounts', $set->count()));
|
||||
Log::debug(sprintf('Recalculated %d accounts for user group #%d.', $set->count(), $userGroup->id));
|
||||
}
|
||||
|
||||
private function recalculatePiggyBanks(UserGroup $userGroup, TransactionCurrency $currency): void
|
||||
{
|
||||
$converter = new ExchangeRateConverter();
|
||||
$converter->setUserGroup($userGroup);
|
||||
$converter->setIgnoreSettings(true);
|
||||
$repository = app(PiggyBankRepositoryInterface::class);
|
||||
$repository->setUserGroup($userGroup);
|
||||
@@ -123,14 +129,14 @@ class RecalculateNativeAmounts extends Command
|
||||
|
||||
foreach ($piggyBank->accounts as $account) {
|
||||
$account->pivot->native_current_amount = null;
|
||||
if (0 !== bccomp($account->pivot->current_amount, '0')) {
|
||||
$account->pivot->native_current_amount = $converter->convert($piggyBank->transactionCurrency, $currency, today(), $account->pivot->current_amount);
|
||||
if (0 !== bccomp((string) $account->pivot->current_amount, '0')) {
|
||||
$account->pivot->native_current_amount = $converter->convert($piggyBank->transactionCurrency, $currency, today(), (string) $account->pivot->current_amount);
|
||||
}
|
||||
$account->pivot->save();
|
||||
}
|
||||
$this->recalculatePiggyBankEvents($piggyBank);
|
||||
}
|
||||
Log::debug(sprintf('Recalculated %d piggy banks.', $set->count()));
|
||||
Log::debug(sprintf('Recalculated %d piggy banks for user group #%d.', $set->count(), $userGroup->id));
|
||||
|
||||
}
|
||||
|
||||
@@ -167,7 +173,7 @@ class RecalculateNativeAmounts extends Command
|
||||
$limit->touch();
|
||||
Log::debug(sprintf('Done with touch BL #%d', $limit->id));
|
||||
}
|
||||
Log::debug(sprintf('Recalculated %d budget limits.', $set->count()));
|
||||
Log::debug(sprintf('Recalculated %d budget limits for budget #%d.', $set->count(), $budget->id));
|
||||
}
|
||||
|
||||
private function recalculateAutoBudgets(Budget $budget, TransactionCurrency $currency): void
|
||||
@@ -178,7 +184,7 @@ class RecalculateNativeAmounts extends Command
|
||||
foreach ($set as $autoBudget) {
|
||||
$autoBudget->touch();
|
||||
}
|
||||
Log::debug(sprintf('Recalculated %d auto budgets.', $set->count()));
|
||||
Log::debug(sprintf('Recalculated %d auto budgets for budget #%d.', $set->count(), $budget->id));
|
||||
}
|
||||
|
||||
private function recalculateAvailableBudgets(UserGroup $userGroup, TransactionCurrency $currency): void
|
||||
@@ -210,11 +216,19 @@ class RecalculateNativeAmounts extends Command
|
||||
$set = DB::table('transactions')
|
||||
->join('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->where('transaction_journals.user_group_id', $userGroup->id)
|
||||
->where(static function (DatabaseBuilder $q) use ($currency): void {
|
||||
$q->whereNot('transactions.transaction_currency_id', $currency->id)
|
||||
->orWhereNot('transactions.foreign_currency_id', $currency->id)
|
||||
;
|
||||
|
||||
->where(function (DatabaseBuilder $q1) use ($currency): void {
|
||||
$q1->where(function (DatabaseBuilder $q2) use ($currency): void {
|
||||
$q2->whereNot('transactions.transaction_currency_id', $currency->id)->whereNull('transactions.foreign_currency_id');
|
||||
})->orWhere(function (DatabaseBuilder $q3) use ($currency): void {
|
||||
$q3->whereNot('transactions.transaction_currency_id', $currency->id)->whereNot('transactions.foreign_currency_id', $currency->id);
|
||||
});
|
||||
})
|
||||
// ->where(static function (DatabaseBuilder $q) use ($currency): void {
|
||||
// $q->whereNot('transactions.transaction_currency_id', $currency->id)
|
||||
// ->whereNot('transactions.foreign_currency_id', $currency->id)
|
||||
// ;
|
||||
// })
|
||||
->get(['transactions.id'])
|
||||
;
|
||||
TransactionObserver::$recalculate = false;
|
||||
@@ -35,15 +35,12 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class CorrectOpeningBalanceCurrencies
|
||||
*/
|
||||
class CorrectOpeningBalanceCurrencies extends Command
|
||||
class CorrectsOpeningBalanceCurrencies extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Will make sure that opening balance transaction currencies match the account they\'re for.';
|
||||
protected $signature = 'firefly-iii:fix-ob-currencies';
|
||||
protected $signature = 'correction:opening-balance-currencies';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -62,10 +59,6 @@ class CorrectOpeningBalanceCurrencies extends Command
|
||||
$message = sprintf('Corrected %d opening balance transaction(s).', $count);
|
||||
$this->friendlyInfo($message);
|
||||
}
|
||||
if (0 === $count) {
|
||||
$message = 'There was nothing to fix in the opening balance transactions.';
|
||||
$this->friendlyPositive($message);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -29,17 +29,12 @@ use FireflyIII\Models\PiggyBankEvent;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Report (and fix) piggy banks.
|
||||
*
|
||||
* Class FixPiggies
|
||||
*/
|
||||
class FixPiggies extends Command
|
||||
class CorrectsPiggyBanks extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Fixes common issues with piggy banks.';
|
||||
protected $signature = 'firefly-iii:fix-piggies';
|
||||
protected $signature = 'correction:piggy-banks';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -66,9 +61,6 @@ class FixPiggies extends Command
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('All piggy bank events are OK.');
|
||||
}
|
||||
if (0 !== $count) {
|
||||
$this->friendlyInfo(sprintf('Fixed %d piggy bank event(s).', $count));
|
||||
}
|
||||
@@ -28,11 +28,11 @@ use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Command\Command as CommandAlias;
|
||||
|
||||
class MigratePreferences extends Command
|
||||
class CorrectsPreferences extends Command
|
||||
{
|
||||
protected $description = 'Give Firefly III preferences a user group ID so they can be made administration specific.';
|
||||
|
||||
protected $signature = 'firefly-iii:migrate-preferences';
|
||||
protected $signature = 'correction:preferences';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -50,7 +50,7 @@ class MigratePreferences extends Command
|
||||
if (null === $preference) {
|
||||
continue;
|
||||
}
|
||||
if (null !== $preference->user_group_id) {
|
||||
if (null === $preference->user_group_id) {
|
||||
$preference->user_group_id = $user->user_group_id;
|
||||
$preference->save();
|
||||
++$count;
|
||||
@@ -33,15 +33,12 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class FixRecurringTransactions
|
||||
*/
|
||||
class FixRecurringTransactions extends Command
|
||||
class CorrectsRecurringTransactions extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Fixes recurring transactions with the wrong transaction type.';
|
||||
protected $signature = 'firefly-iii:fix-recurring-transactions';
|
||||
protected $signature = 'correction:recurring-transactions';
|
||||
private int $count = 0;
|
||||
private RecurringRepositoryInterface $recurringRepos;
|
||||
private UserRepositoryInterface $userRepos;
|
||||
@@ -53,9 +50,6 @@ class FixRecurringTransactions extends Command
|
||||
{
|
||||
$this->stupidLaravel();
|
||||
$this->correctTransactions();
|
||||
if (0 === $this->count) {
|
||||
$this->friendlyPositive('All recurring transactions are OK.');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,5 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* CorrectsTimezoneInformation.php
|
||||
* Copyright (c) 2024 james@firefly-iii.org.
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* AddTimezonesToDates.php
|
||||
@@ -21,7 +41,7 @@ declare(strict_types=1);
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Console\Commands\Integrity;
|
||||
namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Models\AccountBalance;
|
||||
@@ -41,7 +61,7 @@ use Illuminate\Console\Command;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class AddTimezonesToDates extends Command
|
||||
class CorrectsTimezoneInformation extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -73,7 +93,7 @@ class AddTimezonesToDates extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly-iii:add-timezones-to-dates';
|
||||
protected $signature = 'correction:timezones';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -107,8 +127,6 @@ class AddTimezonesToDates extends Command
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive(sprintf('Timezone information is present in field "%s" of model "%s".', $field, $shortModel));
|
||||
|
||||
return;
|
||||
}
|
||||
$this->friendlyInfo(sprintf('Adding timezone information to field "%s" of model "%s".', $field, $shortModel));
|
||||
@@ -34,15 +34,12 @@ use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class FixTransactionTypes
|
||||
*/
|
||||
class FixTransactionTypes extends Command
|
||||
class CorrectsTransactionTypes extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Make sure all transactions are of the correct type, based on source + dest.';
|
||||
protected $signature = 'firefly-iii:fix-transaction-types';
|
||||
protected $signature = 'correction:transaction-types';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -29,15 +29,12 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class TransferBudgets
|
||||
*/
|
||||
class TransferBudgets extends Command
|
||||
class CorrectsTransferBudgets extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Removes budgets from transfers.';
|
||||
protected $signature = 'firefly-iii:fix-transfer-budgets';
|
||||
protected $signature = 'correction:transfer-budgets';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -60,10 +57,6 @@ class TransferBudgets extends Command
|
||||
$entry->budgets()->sync([]);
|
||||
++$count;
|
||||
}
|
||||
if (0 === $count) {
|
||||
$message = 'No invalid budget/journal entries.';
|
||||
$this->friendlyPositive($message);
|
||||
}
|
||||
if (0 !== $count) {
|
||||
$message = sprintf('Corrected %d invalid budget/journal entries (entry).', $count);
|
||||
app('log')->debug($message);
|
||||
@@ -33,15 +33,12 @@ use FireflyIII\Support\Models\AccountBalanceCalculator;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class FixUnevenAmount
|
||||
*/
|
||||
class FixUnevenAmount extends Command
|
||||
class CorrectsUnevenAmount extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Fix journals with uneven amounts.';
|
||||
protected $signature = 'firefly-iii:fix-uneven-amount';
|
||||
protected $signature = 'correction:uneven-amounts';
|
||||
private int $count;
|
||||
|
||||
/**
|
||||
@@ -118,11 +115,6 @@ class FixUnevenAmount extends Command
|
||||
++$count;
|
||||
}
|
||||
}
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('No "old style" foreign currency transfers.');
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private function fixUnevenAmounts(): void
|
||||
@@ -164,9 +156,6 @@ class FixUnevenAmount extends Command
|
||||
$this->fixJournal($entry->transaction_journal_id);
|
||||
}
|
||||
}
|
||||
if (0 === $this->count) {
|
||||
$this->friendlyPositive('Database amount integrity is OK');
|
||||
}
|
||||
}
|
||||
|
||||
private function fixJournal(int $param): void
|
||||
@@ -291,8 +280,6 @@ class FixUnevenAmount extends Command
|
||||
Log::debug(sprintf('Can skip foreign currency transfer #%d.', $journal->id));
|
||||
}
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('Journal currency integrity is OK');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -29,16 +29,13 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class CreateAccessTokens
|
||||
*/
|
||||
class CreateAccessTokens extends Command
|
||||
class CreatesAccessTokens extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Creates user access tokens which are used for command line access to personal data.';
|
||||
|
||||
protected $signature = 'firefly-iii:create-access-tokens';
|
||||
protected $signature = 'correction:access-tokens';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -64,9 +61,6 @@ class CreateAccessTokens extends Command
|
||||
++$count;
|
||||
}
|
||||
}
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('Verified access tokens.');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* CreateGroupMemberships.php
|
||||
* Copyright (c) 2023 james@firefly-iii.org
|
||||
* CreatesGroupMemberships.php
|
||||
* Copyright (c) 2024 james@firefly-iii.org.
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
@@ -17,12 +17,12 @@
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands\Integrity;
|
||||
namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
@@ -33,16 +33,13 @@ use FireflyIII\Models\UserRole;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class CreateGroupMemberships
|
||||
*/
|
||||
class CreateGroupMemberships extends Command
|
||||
class CreatesGroupMemberships extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
public const string CONFIG_NAME = '560_create_group_memberships';
|
||||
protected $description = 'Update group memberships';
|
||||
protected $signature = 'firefly-iii:create-group-memberships';
|
||||
protected $signature = 'correction:create-group-memberships';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -52,7 +49,6 @@ class CreateGroupMemberships extends Command
|
||||
public function handle(): int
|
||||
{
|
||||
$this->createGroupMemberships();
|
||||
$this->friendlyPositive('Validated group memberships');
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -28,16 +28,13 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Models\LinkType;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class CreateLinkTypes. Created all link types in case a migration hasn't fired.
|
||||
*/
|
||||
class CreateLinkTypes extends Command
|
||||
class CreatesLinkTypes extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Creates all link types.';
|
||||
|
||||
protected $signature = 'firefly-iii:create-link-types';
|
||||
protected $signature = 'correction:link-types';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -66,9 +63,6 @@ class CreateLinkTypes extends Command
|
||||
$link->editable = false;
|
||||
$link->save();
|
||||
}
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('All link types are OK');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -29,15 +29,12 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class RemoveBills
|
||||
*/
|
||||
class RemoveBills extends Command
|
||||
class RemovesBills extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Remove bills from transactions that shouldn\'t have one.';
|
||||
protected $signature = 'firefly-iii:remove-bills';
|
||||
protected $signature = 'correction:bills';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -60,7 +57,6 @@ class RemoveBills extends Command
|
||||
if ($journals->count() > 0) {
|
||||
$this->friendlyInfo('Fixed all transaction journals so they have correct bill information.');
|
||||
}
|
||||
$this->friendlyPositive('All bills and journals are OK');
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -29,15 +29,12 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class DeleteEmptyGroups
|
||||
*/
|
||||
class DeleteEmptyGroups extends Command
|
||||
class RemovesEmptyGroups extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Delete empty transaction groups.';
|
||||
protected $signature = 'firefly-iii:delete-empty-groups';
|
||||
protected $signature = 'correction:empty-groups';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -61,9 +58,6 @@ class DeleteEmptyGroups extends Command
|
||||
TransactionGroup::whereNull('deleted_at')->whereIn('id', $chunk)->delete();
|
||||
}
|
||||
}
|
||||
if (0 === $total) {
|
||||
$this->friendlyInfo('Verified there are no empty groups.');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -30,16 +30,13 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
/**
|
||||
* Class DeleteEmptyJournals
|
||||
*/
|
||||
class DeleteEmptyJournals extends Command
|
||||
class RemovesEmptyJournals extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Delete empty and uneven transaction journals.';
|
||||
|
||||
protected $signature = 'firefly-iii:delete-empty-journals';
|
||||
protected $signature = 'correction:empty-journals';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -82,9 +79,6 @@ class DeleteEmptyJournals extends Command
|
||||
++$total;
|
||||
}
|
||||
}
|
||||
if (0 === $total) {
|
||||
$this->friendlyPositive('No uneven transaction journals.');
|
||||
}
|
||||
}
|
||||
|
||||
private function deleteEmptyJournals(): void
|
||||
@@ -107,8 +101,5 @@ class DeleteEmptyJournals extends Command
|
||||
$this->friendlyInfo(sprintf('Deleted empty transaction journal #%d', $entry->id));
|
||||
++$count;
|
||||
}
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('No empty transaction journals.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,13 +32,13 @@ use Illuminate\Console\Command;
|
||||
/**
|
||||
* Deletes transactions where the journal has been deleted.
|
||||
*/
|
||||
class DeleteOrphanedTransactions extends Command
|
||||
class RemovesOrphanedTransactions extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Deletes orphaned transactions.';
|
||||
|
||||
protected $signature = 'firefly-iii:delete-orphaned-transactions';
|
||||
protected $signature = 'correction:orphaned-transactions';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -63,7 +63,7 @@ class DeleteOrphanedTransactions extends Command
|
||||
;
|
||||
$count = $set->count();
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('No orphaned journals.');
|
||||
// $this->friendlyPositive('No orphaned journals.');
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -116,9 +116,6 @@ class DeleteOrphanedTransactions extends Command
|
||||
++$count;
|
||||
}
|
||||
}
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('No orphaned transactions.');
|
||||
}
|
||||
}
|
||||
|
||||
private function deleteFromOrphanedAccounts(): void
|
||||
@@ -147,8 +144,5 @@ class DeleteOrphanedTransactions extends Command
|
||||
);
|
||||
++$count;
|
||||
}
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('No orphaned accounts.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,16 +29,13 @@ use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class DeleteZeroAmount
|
||||
*/
|
||||
class DeleteZeroAmount extends Command
|
||||
class RemovesZeroAmount extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Delete transactions with zero amount.';
|
||||
|
||||
protected $signature = 'firefly-iii:delete-zero-amount';
|
||||
protected $signature = 'correction:zero-amounts';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -56,9 +53,6 @@ class DeleteZeroAmount extends Command
|
||||
|
||||
Transaction::where('transaction_journal_id', $journal->id)->delete();
|
||||
}
|
||||
if (0 === $journals->count()) {
|
||||
$this->friendlyPositive('No zero-amount transaction journals.');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* RestoreOAuthKeys.php
|
||||
* Copyright (c) 2020 james@firefly-iii.org
|
||||
/*
|
||||
* RestoresOAuthKeys.php
|
||||
* Copyright (c) 2024 james@firefly-iii.org.
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
@@ -17,26 +17,23 @@
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands\Integrity;
|
||||
namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Support\System\OAuthKeys;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class RestoreOAuthKeys
|
||||
*/
|
||||
class RestoreOAuthKeys extends Command
|
||||
class RestoresOAuthKeys extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Will restore the OAuth keys generated for the system.';
|
||||
protected $signature = 'firefly-iii:restore-oauth-keys';
|
||||
protected $signature = 'correction:restore-oauth-keys';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -76,7 +73,6 @@ class RestoreOAuthKeys extends Command
|
||||
|
||||
return;
|
||||
}
|
||||
$this->friendlyPositive('OAuth keys are OK');
|
||||
}
|
||||
|
||||
private function keysInDatabase(): bool
|
||||
@@ -28,13 +28,10 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Services\Internal\Support\CreditRecalculateService;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class CorrectionSkeleton
|
||||
*/
|
||||
class TriggerCreditCalculation extends Command
|
||||
class TriggersCreditCalculation extends Command
|
||||
{
|
||||
protected $description = 'Triggers the credit recalculation service for liabilities.';
|
||||
protected $signature = 'firefly-iii:trigger-credit-recalculation';
|
||||
protected $signature = 'correction:recalculates-liabilities';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -36,10 +36,7 @@ use FireflyIII\Support\Export\ExportDataGenerator;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class ExportData
|
||||
*/
|
||||
class ExportData extends Command
|
||||
class ExportsData extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
use VerifiesAccessToken;
|
||||
@@ -4,10 +4,6 @@ namespace FireflyIII\Console\Commands\Integrity;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class ReportSkeleton
|
||||
* TODO DONT FORGET TO ADD THIS TO THE DOCKER BUILD
|
||||
*/
|
||||
class ReportSkeleton extends Command
|
||||
{
|
||||
|
||||
|
||||
@@ -31,16 +31,13 @@ use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\Tag;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class ReportEmptyObjects
|
||||
*/
|
||||
class ReportEmptyObjects extends Command
|
||||
class ReportsEmptyObjects extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Reports on empty database objects.';
|
||||
|
||||
protected $signature = 'firefly-iii:report-empty-objects';
|
||||
protected $signature = 'integrity:empty-objects';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -27,10 +27,7 @@ namespace FireflyIII\Console\Commands\Integrity;
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class ReportIntegrity
|
||||
*/
|
||||
class ReportIntegrity extends Command
|
||||
class ReportsIntegrity extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -48,11 +45,8 @@ class ReportIntegrity extends Command
|
||||
return 1;
|
||||
}
|
||||
$commands = [
|
||||
'firefly-iii:add-timezones-to-dates',
|
||||
'firefly-iii:create-group-memberships',
|
||||
'firefly-iii:report-empty-objects',
|
||||
'firefly-iii:report-sum',
|
||||
'firefly-iii:upgrade-group-information',
|
||||
'integrity:empty-objects',
|
||||
'integrity:total-sums',
|
||||
];
|
||||
foreach ($commands as $command) {
|
||||
$this->friendlyLine(sprintf('Now executing %s', $command));
|
||||
@@ -29,15 +29,12 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class ReportSkeleton
|
||||
*/
|
||||
class ReportSum extends Command
|
||||
class ReportsSums extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Report on the total sum of transactions. Must be 0.';
|
||||
protected $signature = 'firefly-iii:report-sum';
|
||||
protected $signature = 'integrity:total-sums';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -28,7 +28,7 @@ use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Symfony\Component\Console\Command\Command as CommandAlias;
|
||||
|
||||
class LaravelPassportKeys extends Command
|
||||
class CallsLaravelPassportKeys extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -28,10 +28,7 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* Class CreateDatabase
|
||||
*/
|
||||
class CreateDatabase extends Command
|
||||
class CreatesDatabase extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -29,16 +29,13 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
/**
|
||||
* Class CreateFirstUser
|
||||
*/
|
||||
class CreateFirstUser extends Command
|
||||
class CreatesFirstUser extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Creates a new user and gives admin rights. Outputs the password on the command line. Strictly for testing.';
|
||||
|
||||
protected $signature = 'firefly-iii:create-first-user {email}';
|
||||
protected $signature = 'system:create-first-user {email}';
|
||||
private UserRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
@@ -44,13 +44,11 @@ use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Class ForceDecimalSize
|
||||
*
|
||||
* This command was inspired by https://github.com/elliot-gh. It will check all amount fields
|
||||
* and their values and correct them to the correct number of decimal places. This fixes issues where
|
||||
* Firefly III would store 0.01 as 0.01000000000000000020816681711721685132943093776702880859375.
|
||||
*/
|
||||
class ForceDecimalSize extends Command
|
||||
class ForcesDecimalSize extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -33,10 +33,7 @@ use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Class ForceMigration
|
||||
*/
|
||||
class ForceMigration extends Command
|
||||
class ForcesMigrations extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
use VerifiesAccessToken;
|
||||
@@ -27,16 +27,13 @@ namespace FireflyIII\Console\Commands\System;
|
||||
use FireflyIII\Support\System\GeneratesInstallationId;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class UpgradeFireflyInstructions.
|
||||
*/
|
||||
class UpgradeFireflyInstructions extends Command
|
||||
class OutputsInstructions extends Command
|
||||
{
|
||||
use GeneratesInstallationId;
|
||||
|
||||
protected $description = 'Instructions in case of upgrade trouble.';
|
||||
|
||||
protected $signature = 'firefly:instructions {task}';
|
||||
protected $signature = 'firefly-iii:instructions {task=install}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -79,7 +76,7 @@ class UpgradeFireflyInstructions extends Command
|
||||
}
|
||||
|
||||
$prefix = 'v';
|
||||
if (str_starts_with($version, 'develop')) {
|
||||
if (str_starts_with($version, 'develop') || str_starts_with($version, 'branch')) {
|
||||
$prefix = '';
|
||||
}
|
||||
|
||||
@@ -94,6 +91,8 @@ class UpgradeFireflyInstructions extends Command
|
||||
$this->boxedInfo('There are no extra upgrade instructions.');
|
||||
$this->boxed('Firefly III should be ready for use.');
|
||||
$this->boxed('');
|
||||
$this->donationText();
|
||||
$this->boxed('');
|
||||
$this->showLine();
|
||||
|
||||
return;
|
||||
@@ -102,6 +101,8 @@ class UpgradeFireflyInstructions extends Command
|
||||
$this->boxed(sprintf('Thank you for updating to Firefly III, %s%s!', $prefix, $version));
|
||||
$this->boxedInfo($text);
|
||||
$this->boxed('');
|
||||
$this->donationText();
|
||||
$this->boxed('');
|
||||
$this->showLine();
|
||||
}
|
||||
|
||||
@@ -213,6 +214,8 @@ class UpgradeFireflyInstructions extends Command
|
||||
$this->boxedInfo('There are no extra installation instructions.');
|
||||
$this->boxed('Firefly III should be ready for use.');
|
||||
$this->boxed('');
|
||||
$this->donationText();
|
||||
$this->boxed('');
|
||||
$this->showLine();
|
||||
|
||||
return;
|
||||
@@ -221,6 +224,15 @@ class UpgradeFireflyInstructions extends Command
|
||||
$this->boxed(sprintf('Thank you for installing Firefly III, %s%s!', $prefix, $version));
|
||||
$this->boxedInfo($text);
|
||||
$this->boxed('');
|
||||
$this->donationText();
|
||||
$this->boxed('');
|
||||
$this->showLine();
|
||||
}
|
||||
|
||||
private function donationText(): void
|
||||
{
|
||||
$this->boxed('Did you know you can support the development of Firefly III?');
|
||||
$this->boxed('You can donate in many ways, like GitHub Sponsors or Patreon.');
|
||||
$this->boxed('For more information, please visit https://bit.ly/donate-to-Firefly-III');
|
||||
}
|
||||
}
|
||||
@@ -26,10 +26,7 @@ namespace FireflyIII\Console\Commands\System;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class OutputVersion
|
||||
*/
|
||||
class OutputVersion extends Command
|
||||
class OutputsVersion extends Command
|
||||
{
|
||||
protected $description = 'Outputs the Firefly III version';
|
||||
|
||||
@@ -29,10 +29,7 @@ use FireflyIII\Models\Attachment;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
|
||||
/**
|
||||
* Class ScanAttachments.
|
||||
*/
|
||||
class ScanAttachments extends Command
|
||||
class ScansAttachments extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -27,10 +27,7 @@ namespace FireflyIII\Console\Commands\System;
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class SetLatestVersion
|
||||
*/
|
||||
class SetLatestVersion extends Command
|
||||
class SetsLatestVersion extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -29,9 +29,6 @@ use Illuminate\Console\Command;
|
||||
use Illuminate\Database\QueryException;
|
||||
use League\Flysystem\FilesystemException;
|
||||
|
||||
/**
|
||||
* Class VerifySecurityAlerts
|
||||
*/
|
||||
class VerifySecurityAlerts extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -40,9 +40,6 @@ use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class ApplyRules
|
||||
*/
|
||||
class ApplyRules extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -34,9 +34,6 @@ use FireflyIII\Support\Cronjobs\RecurringCronjob;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class Cron
|
||||
*/
|
||||
class Cron extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -32,16 +32,13 @@ use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
/**
|
||||
* Class TransactionIdentifier
|
||||
*/
|
||||
class TransactionIdentifier extends Command
|
||||
class AddsTransactionIdentifiers extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
public const string CONFIG_NAME = '480_transaction_identifier';
|
||||
protected $description = 'Fixes transaction identifiers.';
|
||||
protected $signature = 'firefly-iii:transaction-identifiers {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:480-transaction-identifiers {--F|force : Force the execution of this command.}';
|
||||
private JournalCLIRepositoryInterface $cliRepository;
|
||||
private int $count;
|
||||
|
||||
@@ -79,9 +76,6 @@ class TransactionIdentifier extends Command
|
||||
$this->updateJournalIdentifiers($journal);
|
||||
}
|
||||
|
||||
if (0 === $this->count) {
|
||||
$this->friendlyPositive('All split journal transaction identifiers are OK.');
|
||||
}
|
||||
if (0 !== $this->count) {
|
||||
$this->friendlyInfo(sprintf('Fixed %d split journal transaction identifier(s).', $this->count));
|
||||
}
|
||||
@@ -30,15 +30,12 @@ use FireflyIII\Models\Preference;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
|
||||
/**
|
||||
* Class DecryptDatabase
|
||||
*/
|
||||
class DecryptDatabase extends Command
|
||||
class RemovesDatabaseDecryption extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Decrypts the database.';
|
||||
protected $signature = 'firefly-iii:decrypt-all';
|
||||
protected $signature = 'upgrade:480-decrypt-all';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -73,7 +70,6 @@ class DecryptDatabase extends Command
|
||||
private function decryptTable(string $table, array $fields): void
|
||||
{
|
||||
if ($this->isDecrypted($table)) {
|
||||
$this->friendlyInfo(sprintf('No decryption required for table "%s".', $table));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -28,16 +28,13 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Support\Models\AccountBalanceCalculator;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class CorrectionSkeleton
|
||||
*/
|
||||
class CorrectAccountBalance extends Command
|
||||
class RepairsAccountBalances extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
public const string CONFIG_NAME = '610_correct_balances';
|
||||
protected $description = 'Recalculate all account balance amounts';
|
||||
protected $signature = 'firefly-iii:correct-account-balance {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:610-account-balances {--F|force : Force the execution of this command.}';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
@@ -27,16 +27,13 @@ namespace FireflyIII\Console\Commands\Upgrade;
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class FixPostgresSequences
|
||||
*/
|
||||
class FixPostgresSequences extends Command
|
||||
class RepairsPostgresSequences extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
protected $description = 'Fixes issues with PostgreSQL sequences.';
|
||||
|
||||
protected $signature = 'firefly-iii:fix-pgsql-sequences';
|
||||
protected $signature = 'upgrade:600-pgsql-sequences';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -4,9 +4,6 @@ namespace FireflyIII\Console\Commands\Upgrade;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class UpgradeSkeleton.
|
||||
*/
|
||||
class UpgradeSkeleton extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
@@ -14,7 +11,7 @@ class UpgradeSkeleton extends Command
|
||||
|
||||
protected $description = 'SOME DESCRIPTION';
|
||||
|
||||
protected $signature = 'firefly-iii:UPGRSKELETON {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:UPGRSKELETON {--F|force : Force the execution of this command.}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
|
||||
@@ -36,17 +36,14 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class AccountCurrencies
|
||||
*/
|
||||
class AccountCurrencies extends Command
|
||||
class UpgradesAccountCurrencies extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
public const string CONFIG_NAME = '480_account_currencies';
|
||||
|
||||
protected $description = 'Give all accounts proper currency info.';
|
||||
protected $signature = 'firefly-iii:account-currencies {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:480-account-currencies {--F|force : Force the execution of this command.}';
|
||||
private AccountRepositoryInterface $accountRepos;
|
||||
private int $count;
|
||||
private UserRepositoryInterface $userRepos;
|
||||
@@ -65,9 +62,6 @@ class AccountCurrencies extends Command
|
||||
}
|
||||
$this->updateAccountCurrencies();
|
||||
|
||||
if (0 === $this->count) {
|
||||
$this->friendlyPositive('All account currencies are OK.');
|
||||
}
|
||||
if (0 !== $this->count) {
|
||||
$this->friendlyInfo(sprintf('Corrected %d account(s).', $this->count));
|
||||
}
|
||||
@@ -29,10 +29,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\AccountMeta;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class RenameAccountMeta
|
||||
*/
|
||||
class RenameAccountMeta extends Command
|
||||
class UpgradesAccountMetaData extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -40,7 +37,7 @@ class RenameAccountMeta extends Command
|
||||
|
||||
protected $description = 'Rename account meta-data to new format.';
|
||||
|
||||
protected $signature = 'firefly-iii:rename-account-meta {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:480-account-meta {--F|force : Force the execution of this command.}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -76,9 +73,6 @@ class RenameAccountMeta extends Command
|
||||
|
||||
$this->markAsExecuted();
|
||||
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('All account meta is OK.');
|
||||
}
|
||||
if (0 !== $count) {
|
||||
$this->friendlyInfo(sprintf('Renamed %d account meta entries (entry).', $count));
|
||||
}
|
||||
@@ -30,10 +30,7 @@ use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\Note;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class MigrateAttachments
|
||||
*/
|
||||
class MigrateAttachments extends Command
|
||||
class UpgradesAttachments extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -41,7 +38,7 @@ class MigrateAttachments extends Command
|
||||
|
||||
protected $description = 'Migrates attachment meta-data.';
|
||||
|
||||
protected $signature = 'firefly-iii:migrate-attachments {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:480-attachments {--F|force : Force the execution of this command.}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -82,9 +79,6 @@ class MigrateAttachments extends Command
|
||||
++$count;
|
||||
}
|
||||
}
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('All attachments are OK.');
|
||||
}
|
||||
if (0 !== $count) {
|
||||
$this->friendlyInfo(sprintf('Updated %d attachment(s).', $count));
|
||||
}
|
||||
@@ -36,10 +36,7 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class MigrateToRules
|
||||
*/
|
||||
class MigrateToRules extends Command
|
||||
class UpgradesBillsToRules extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -47,7 +44,7 @@ class MigrateToRules extends Command
|
||||
|
||||
protected $description = 'Migrate bills to rules.';
|
||||
|
||||
protected $signature = 'firefly-iii:bills-to-rules {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:480-bills-to-rules {--F|force : Force the execution of this command.}';
|
||||
private BillRepositoryInterface $billRepository;
|
||||
private int $count;
|
||||
private RuleGroupRepositoryInterface $ruleGroupRepository;
|
||||
@@ -76,9 +73,6 @@ class MigrateToRules extends Command
|
||||
$this->migrateUser($user);
|
||||
}
|
||||
|
||||
if (0 === $this->count) {
|
||||
$this->friendlyPositive('All bills are OK.');
|
||||
}
|
||||
if (0 !== $this->count) {
|
||||
$this->friendlyInfo(sprintf('Verified and fixed %d bill(s).', $this->count));
|
||||
}
|
||||
@@ -28,10 +28,7 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class AppendBudgetLimitPeriods
|
||||
*/
|
||||
class AppendBudgetLimitPeriods extends Command
|
||||
class UpgradesBudgetLimitPeriods extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -39,7 +36,7 @@ class AppendBudgetLimitPeriods extends Command
|
||||
|
||||
protected $description = 'Append budget limits with their (estimated) timeframe.';
|
||||
|
||||
protected $signature = 'firefly-iii:budget-limit-periods {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:550-budget-limit-periods {--F|force : Force the execution of this command.}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -31,10 +31,7 @@ use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class BudgetLimitCurrency
|
||||
*/
|
||||
class BudgetLimitCurrency extends Command
|
||||
class UpgradesBudgetLimits extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -42,7 +39,7 @@ class BudgetLimitCurrency extends Command
|
||||
|
||||
protected $description = 'Give budget limits a currency';
|
||||
|
||||
protected $signature = 'firefly-iii:bl-currency {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:480-budget-limit-currencies {--F|force : Force the execution of this command.}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -80,9 +77,6 @@ class BudgetLimitCurrency extends Command
|
||||
}
|
||||
}
|
||||
}
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('All budget limits are OK.');
|
||||
}
|
||||
$this->markAsExecuted();
|
||||
|
||||
return 0;
|
||||
@@ -31,16 +31,13 @@ use FireflyIII\Models\AccountType;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class CCLiabilities
|
||||
*/
|
||||
class CCLiabilities extends Command
|
||||
class UpgradesCreditCardLiabilities extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
public const string CONFIG_NAME = '480_cc_liabilities';
|
||||
protected $description = 'Convert old credit card liabilities.';
|
||||
protected $signature = 'firefly-iii:cc-liabilities {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:480-cc-liabilities {--F|force : Force the execution of this command.}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -58,7 +55,6 @@ class CCLiabilities extends Command
|
||||
$ccType = AccountType::where('type', AccountType::CREDITCARD)->first();
|
||||
$debtType = AccountType::where('type', AccountType::DEBT)->first();
|
||||
if (null === $ccType || null === $debtType) {
|
||||
$this->friendlyPositive('No incorrectly stored credit card liabilities.');
|
||||
$this->markAsExecuted();
|
||||
|
||||
return 0;
|
||||
@@ -76,9 +72,6 @@ class CCLiabilities extends Command
|
||||
'Credit card liability types are no longer supported and have been converted to generic debts. See: https://bit.ly/FF3-credit-cards'
|
||||
);
|
||||
}
|
||||
if (0 === $accounts->count()) {
|
||||
$this->friendlyPositive('No incorrectly stored credit card liabilities.');
|
||||
}
|
||||
$this->markAsExecuted();
|
||||
|
||||
return 0;
|
||||
@@ -32,10 +32,7 @@ use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class UpgradeCurrencyPreferences
|
||||
*/
|
||||
class UpgradeCurrencyPreferences extends Command
|
||||
class UpgradesCurrencyPreferences extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -43,7 +40,7 @@ class UpgradeCurrencyPreferences extends Command
|
||||
|
||||
protected $description = 'Upgrade user currency preferences';
|
||||
|
||||
protected $signature = 'firefly-iii:upgrade-currency-preferences {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:610-currency-preferences {--F|force : Force the execution of this command.}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -29,10 +29,7 @@ set_time_limit(0);
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class UpgradeDatabase
|
||||
*/
|
||||
class UpgradeDatabase extends Command
|
||||
class UpgradesDatabase extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -46,33 +43,29 @@ class UpgradeDatabase extends Command
|
||||
{
|
||||
$this->callInitialCommands();
|
||||
$commands = [
|
||||
'firefly-iii:transaction-identifiers',
|
||||
'firefly-iii:migrate-to-groups',
|
||||
'firefly-iii:account-currencies',
|
||||
'firefly-iii:transfer-currencies',
|
||||
'firefly-iii:other-currencies',
|
||||
'firefly-iii:migrate-notes',
|
||||
'firefly-iii:migrate-attachments',
|
||||
'firefly-iii:bills-to-rules',
|
||||
'firefly-iii:bl-currency',
|
||||
'firefly-iii:cc-liabilities',
|
||||
'firefly-iii:back-to-journals',
|
||||
'firefly-iii:rename-account-meta',
|
||||
'firefly-iii:migrate-recurrence-meta',
|
||||
'firefly-iii:migrate-tag-locations',
|
||||
'firefly-iii:migrate-recurrence-type',
|
||||
'firefly-iii:upgrade-liabilities',
|
||||
'firefly-iii:liabilities-600',
|
||||
'firefly-iii:budget-limit-periods',
|
||||
'firefly-iii:migrate-rule-actions',
|
||||
'firefly-iii:restore-oauth-keys',
|
||||
'firefly-iii:correct-account-balance',
|
||||
// also just in case, some integrity commands:
|
||||
'firefly-iii:add-timezones-to-dates',
|
||||
'firefly-iii:create-group-memberships',
|
||||
'firefly-iii:upgrade-group-information',
|
||||
'firefly-iii:upgrade-currency-preferences',
|
||||
'firefly-iii:upgrade-multi-piggies',
|
||||
'upgrade:480-transaction-identifiers',
|
||||
'upgrade:480-migrate-to-groups',
|
||||
'upgrade:480-account-currencies',
|
||||
'upgrade:480-transfer-currencies',
|
||||
'upgrade:480-currency-information',
|
||||
'upgrade:480-notes',
|
||||
'upgrade:480-attachments',
|
||||
'upgrade:480-bills-to-rules',
|
||||
'upgrade:480-budget-limit-currencies',
|
||||
'upgrade:480-cc-liabilities',
|
||||
'upgrade:480-journal-meta-data',
|
||||
'upgrade:480-account-meta',
|
||||
'upgrade:481-recurrence-meta',
|
||||
'upgrade:500-tag-locations',
|
||||
'upgrade:560-liabilities',
|
||||
'upgrade:600-liabilities',
|
||||
'upgrade:550-budget-limit-periods',
|
||||
'upgrade:600-rule-actions',
|
||||
'upgrade:610-account-balance',
|
||||
'upgrade:610-currency-preferences',
|
||||
'upgrade:610-currency-preferences',
|
||||
'upgrade:620-piggy-banks',
|
||||
'upgrade:620-native-amounts',
|
||||
'firefly-iii:correct-database',
|
||||
];
|
||||
$args = [];
|
||||
@@ -94,7 +87,7 @@ class UpgradeDatabase extends Command
|
||||
private function callInitialCommands(): void
|
||||
{
|
||||
$this->call('migrate', ['--seed' => true, '--force' => true, '--no-interaction' => true]);
|
||||
$this->call('firefly-iii:fix-pgsql-sequences');
|
||||
$this->call('firefly-iii:decrypt-all');
|
||||
$this->call('upgrade:600-pgsql-sequences');
|
||||
$this->call('upgrade:480-decrypt-all');
|
||||
}
|
||||
}
|
||||
@@ -32,10 +32,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class BackToJournals
|
||||
*/
|
||||
class BackToJournals extends Command
|
||||
class UpgradesJournalMetaData extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -43,7 +40,7 @@ class BackToJournals extends Command
|
||||
|
||||
protected $description = 'Move meta data back to journals, not individual transactions.';
|
||||
|
||||
protected $signature = 'firefly-iii:back-to-journals {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:480-journal-meta-data {--F|force : Force the execution of this command.}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -71,7 +68,7 @@ class BackToJournals extends Command
|
||||
|
||||
private function isMigrated(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(MigrateToGroups::CONFIG_NAME, false);
|
||||
$configVar = app('fireflyconfig')->get(UpgradesToGroups::CONFIG_NAME, false);
|
||||
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
@@ -29,10 +29,7 @@ use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\TransactionJournalMeta;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class MigrateJournalNotes
|
||||
*/
|
||||
class MigrateJournalNotes extends Command
|
||||
class UpgradesJournalNotes extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -40,7 +37,7 @@ class MigrateJournalNotes extends Command
|
||||
|
||||
protected $description = 'Migrate notes for transaction journals.';
|
||||
|
||||
protected $signature = 'firefly-iii:migrate-notes {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:480-notes {--F|force : Force the execution of this command.}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -75,9 +72,6 @@ class MigrateJournalNotes extends Command
|
||||
++$count;
|
||||
}
|
||||
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('No notes to migrate.');
|
||||
}
|
||||
if (0 !== $count) {
|
||||
$this->friendlyInfo(sprintf('Migrated %d note(s).', $count));
|
||||
}
|
||||
@@ -34,16 +34,13 @@ use FireflyIII\Services\Internal\Support\CreditRecalculateService;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class UpgradeLiabilities
|
||||
*/
|
||||
class UpgradeLiabilities extends Command
|
||||
class UpgradesLiabilities extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
public const string CONFIG_NAME = '560_upgrade_liabilities';
|
||||
protected $description = 'Upgrade liabilities to new 5.6.0 structure.';
|
||||
protected $signature = 'firefly-iii:upgrade-liabilities {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:560-liabilities {--F|force : Force the execution of this command.}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -35,16 +35,13 @@ use FireflyIII\Services\Internal\Support\CreditRecalculateService;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class UpgradeLiabilitiesEight
|
||||
*/
|
||||
class UpgradeLiabilitiesEight extends Command
|
||||
class UpgradesLiabilitiesEight extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
public const string CONFIG_NAME = '600_upgrade_liabilities';
|
||||
protected $description = 'Upgrade liabilities to new 6.0.0 structure.';
|
||||
protected $signature = 'firefly-iii:liabilities-600 {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:600-liabilities {--F|force : Force the execution of this command.}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -201,32 +198,9 @@ class UpgradeLiabilitiesEight extends Command
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($journals as $journal) {
|
||||
// $delete = false;
|
||||
// /** @var Transaction $source */
|
||||
// $source = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
// /** @var Transaction $dest */
|
||||
// $dest = $journal->transactions()->where('amount', '>', 0)->first();
|
||||
|
||||
/**
|
||||
* // if source is this liability and destination is expense, remove transaction.
|
||||
* // if source is revenue and destination is liability, remove transaction.
|
||||
* if ($source->account_id === $account->id && $dest->account->accountType->type === AccountType::EXPENSE) {
|
||||
* $delete = true;
|
||||
* }
|
||||
* if ($dest->account_id === $account->id && $source->account->accountType->type === AccountType::REVENUE) {
|
||||
* $delete = true;
|
||||
* }
|
||||
*
|
||||
* // overruled. No transaction will be deleted, ever.
|
||||
* // code is kept in place, so I can revisit my reasoning.
|
||||
* $delete = false;
|
||||
*/
|
||||
|
||||
// if ($delete) {
|
||||
$service = app(TransactionGroupDestroyService::class);
|
||||
$service->destroy($journal->transactionGroup);
|
||||
++$count;
|
||||
// }
|
||||
}
|
||||
|
||||
return $count;
|
||||
@@ -30,15 +30,15 @@ use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpgradeMultiPiggyBanks extends Command
|
||||
class UpgradesMultiPiggyBanks extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
public const string CONFIG_NAME = '620_make_multi_piggies';
|
||||
|
||||
protected $description = 'Upgrade piggybanks so they can use multiple accounts.';
|
||||
protected $description = 'Upgrade piggy banks so they can use multiple accounts.';
|
||||
|
||||
protected $signature = 'firefly-iii:upgrade-multi-piggies {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:620-piggy-banks {--F|force : Force the execution of this command.}';
|
||||
private AccountRepositoryInterface $accountRepository;
|
||||
private PiggyBankRepositoryInterface $repository;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* MigrateRecurrenceType.php
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
* UpgradesNativeAmounts.php
|
||||
* Copyright (c) 2024 james@firefly-iii.org.
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
@@ -17,28 +18,23 @@
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands\Upgrade;
|
||||
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
/**
|
||||
* Class MigrateRecurrenceType
|
||||
*/
|
||||
class MigrateRecurrenceType extends Command
|
||||
class UpgradesNativeAmounts extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
public const string CONFIG_NAME = '620_native_amounts';
|
||||
|
||||
public const string CONFIG_NAME = '550_migrate_recurrence_type';
|
||||
protected $description = 'Runs the native amounts calculations.';
|
||||
|
||||
protected $description = 'Migrate transaction type of recurring transaction.';
|
||||
|
||||
protected $signature = 'firefly-iii:migrate-recurrence-type {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:620-native-amounts {--F|force : Force the execution of this command.}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -50,17 +46,23 @@ class MigrateRecurrenceType extends Command
|
||||
|
||||
return 0;
|
||||
}
|
||||
$this->friendlyWarning('This command has been disabled.');
|
||||
|
||||
Artisan::call('correction:recalculate-native-amounts');
|
||||
|
||||
$this->markAsExecuted();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return (bool) $configVar?->data;
|
||||
return false;
|
||||
}
|
||||
|
||||
private function markAsExecuted(): void
|
||||
@@ -30,10 +30,7 @@ use FireflyIII\Models\RecurrenceMeta;
|
||||
use FireflyIII\Models\RecurrenceTransactionMeta;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class MigrateRecurrenceMeta
|
||||
*/
|
||||
class MigrateRecurrenceMeta extends Command
|
||||
class UpgradesRecurrenceMetaData extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -41,7 +38,7 @@ class MigrateRecurrenceMeta extends Command
|
||||
|
||||
protected $description = 'Migrate recurrence meta data';
|
||||
|
||||
protected $signature = 'firefly-iii:migrate-recurrence-meta {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:481-recurrence-meta {--F|force : Force the execution of this command.}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -55,9 +52,6 @@ class MigrateRecurrenceMeta extends Command
|
||||
}
|
||||
$count = $this->migrateMetaData();
|
||||
|
||||
if (0 === $count) {
|
||||
$this->friendlyPositive('No recurrence meta data migrated.');
|
||||
}
|
||||
if ($count > 0) {
|
||||
$this->friendlyInfo(sprintf('Migrated %d meta data entries', $count));
|
||||
}
|
||||
@@ -27,7 +27,7 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class MigrateRuleActions extends Command
|
||||
class UpgradesRuleActions extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -35,7 +35,7 @@ class MigrateRuleActions extends Command
|
||||
|
||||
protected $description = 'Migrate rule actions away from expression engine';
|
||||
|
||||
protected $signature = 'firefly-iii:migrate-rule-actions {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:600-rule-actions {--F|force : Force the execution of this command.}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -29,10 +29,7 @@ use FireflyIII\Models\Location;
|
||||
use FireflyIII\Models\Tag;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class MigrateTagLocations
|
||||
*/
|
||||
class MigrateTagLocations extends Command
|
||||
class UpgradesTagLocations extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
@@ -40,7 +37,7 @@ class MigrateTagLocations extends Command
|
||||
|
||||
protected $description = 'Migrate tag locations.';
|
||||
|
||||
protected $signature = 'firefly-iii:migrate-tag-locations {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:500-tag-locations {--F|force : Force the execution of this command.}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -36,20 +36,13 @@ use FireflyIII\Services\Internal\Destroy\JournalDestroyService;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* This command will take split transactions and migrate them to "transaction groups".
|
||||
*
|
||||
* It will only run once, but can be forced to run again.
|
||||
*
|
||||
* Class MigrateToGroups
|
||||
*/
|
||||
class MigrateToGroups extends Command
|
||||
class UpgradesToGroups extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
public const string CONFIG_NAME = '480_migrated_to_groups';
|
||||
protected $description = 'Migrates a pre-4.7.8 transaction structure to the 4.7.8+ transaction structure.';
|
||||
protected $signature = 'firefly-iii:migrate-to-groups {--F|force : Force the migration, even if it fired before.}';
|
||||
protected $signature = 'upgrade:480-migrate-to-groups {--F|force : Force the migration, even if it fired before.}';
|
||||
private JournalCLIRepositoryInterface $cliRepository;
|
||||
private int $count;
|
||||
private TransactionGroupFactory $groupFactory;
|
||||
@@ -79,9 +72,6 @@ class MigrateToGroups extends Command
|
||||
if (0 !== $this->count) {
|
||||
$this->friendlyInfo(sprintf('Migrated %d transaction journal(s).', $this->count));
|
||||
}
|
||||
if (0 === $this->count) {
|
||||
$this->friendlyPositive('No journals to migrate to groups.');
|
||||
}
|
||||
$this->markAsMigrated();
|
||||
|
||||
return 0;
|
||||
@@ -370,9 +360,6 @@ class MigrateToGroups extends Command
|
||||
$this->giveGroup($array);
|
||||
}
|
||||
}
|
||||
if (0 === $total) {
|
||||
$this->friendlyPositive('No need to convert transaction journals.');
|
||||
}
|
||||
}
|
||||
|
||||
private function giveGroup(array $array): void
|
||||
@@ -34,16 +34,13 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class TransferCurrenciesCorrections
|
||||
*/
|
||||
class TransferCurrenciesCorrections extends Command
|
||||
class UpgradesTransferCurrencies extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
public const string CONFIG_NAME = '480_transfer_currencies';
|
||||
protected $description = 'Updates transfer currency information.';
|
||||
protected $signature = 'firefly-iii:transfer-currencies {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:480-transfer-currencies {--F|force : Force the execution of this command.}';
|
||||
private array $accountCurrencies;
|
||||
private AccountRepositoryInterface $accountRepos;
|
||||
private JournalCLIRepositoryInterface $cliRepos;
|
||||
@@ -71,15 +68,10 @@ class TransferCurrenciesCorrections extends Command
|
||||
|
||||
$this->startUpdateRoutine();
|
||||
$this->markAsExecuted();
|
||||
|
||||
if (0 === $this->count) {
|
||||
$this->friendlyPositive('All transfers have correct currency information.');
|
||||
|
||||
return 0;
|
||||
if ($this->count > 0) {
|
||||
$this->friendlyInfo(sprintf('Verified currency information of %d transfer(s).', $this->count));
|
||||
}
|
||||
|
||||
$this->friendlyInfo(sprintf('Verified currency information of %d transfer(s).', $this->count));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -36,16 +36,13 @@ use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class OtherCurrenciesCorrections
|
||||
*/
|
||||
class OtherCurrenciesCorrections extends Command
|
||||
class UpgradesVariousCurrencyInformation extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
public const string CONFIG_NAME = '480_other_currencies';
|
||||
protected $description = 'Update all journal currency information.';
|
||||
protected $signature = 'firefly-iii:other-currencies {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'upgrade:480-currency-information {--F|force : Force the execution of this command.}';
|
||||
private array $accountCurrencies;
|
||||
private AccountRepositoryInterface $accountRepos;
|
||||
private JournalCLIRepositoryInterface $cliRepos;
|
||||
@@ -36,8 +36,6 @@ use Illuminate\Session\TokenMismatchException;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Validation\ValidationException as LaravelValidationException;
|
||||
use Laravel\Passport\Exceptions\OAuthServerException as LaravelOAuthException;
|
||||
use LaravelJsonApi\Core\Exceptions\JsonApiException;
|
||||
use LaravelJsonApi\Exceptions\ExceptionParser;
|
||||
use League\OAuth2\Server\Exception\OAuthServerException;
|
||||
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -65,18 +63,12 @@ class Handler extends ExceptionHandler
|
||||
HttpException::class,
|
||||
SuspiciousOperationException::class,
|
||||
BadHttpHeaderException::class,
|
||||
JsonApiException::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->renderable(
|
||||
ExceptionParser::make()->renderable()
|
||||
);
|
||||
}
|
||||
public function register(): void {}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response. It's complex but lucky for us, we never use it because
|
||||
|
||||
@@ -43,11 +43,11 @@ class PiggyBankFactory
|
||||
|
||||
public User $user {
|
||||
set(User $value) {
|
||||
$this->user = $value;
|
||||
$this->currencyRepository->setUser($value);
|
||||
$this->accountRepository->setUser($value);
|
||||
$this->piggyBankRepository->setUser($value);
|
||||
}
|
||||
$this->user = $value;
|
||||
$this->currencyRepository->setUser($value);
|
||||
$this->accountRepository->setUser($value);
|
||||
$this->piggyBankRepository->setUser($value);
|
||||
}
|
||||
}
|
||||
private AccountRepositoryInterface $accountRepository;
|
||||
private CurrencyRepositoryInterface $currencyRepository;
|
||||
@@ -62,15 +62,11 @@ class PiggyBankFactory
|
||||
|
||||
/**
|
||||
* Store a piggy bank or come back with an exception.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return PiggyBank
|
||||
*/
|
||||
public function store(array $data): PiggyBank
|
||||
{
|
||||
|
||||
$piggyBankData = $data;
|
||||
$piggyBankData = $data;
|
||||
|
||||
// unset some fields
|
||||
unset($piggyBankData['object_group_title'], $piggyBankData['transaction_currency_code'], $piggyBankData['transaction_currency_id'], $piggyBankData['accounts'], $piggyBankData['object_group_id'], $piggyBankData['notes']);
|
||||
@@ -94,11 +90,11 @@ class PiggyBankFactory
|
||||
|
||||
throw new FireflyException('400005: Could not store new piggy bank.', 0, $e);
|
||||
}
|
||||
$piggyBank = $this->setOrder($piggyBank, $data);
|
||||
$piggyBank = $this->setOrder($piggyBank, $data);
|
||||
$this->linkToAccountIds($piggyBank, $data['accounts']);
|
||||
$this->piggyBankRepository->updateNote($piggyBank, $data['notes']);
|
||||
|
||||
$objectGroupTitle = $data['object_group_title'] ?? '';
|
||||
$objectGroupTitle = $data['object_group_title'] ?? '';
|
||||
if ('' !== $objectGroupTitle) {
|
||||
$objectGroup = $this->findOrCreateObjectGroup($objectGroupTitle);
|
||||
if (null !== $objectGroup) {
|
||||
@@ -106,7 +102,7 @@ class PiggyBankFactory
|
||||
}
|
||||
}
|
||||
// try also with ID
|
||||
$objectGroupId = (int) ($data['object_group_id'] ?? 0);
|
||||
$objectGroupId = (int) ($data['object_group_id'] ?? 0);
|
||||
if (0 !== $objectGroupId) {
|
||||
$objectGroup = $this->findObjectGroupById($objectGroupId);
|
||||
if (null !== $objectGroup) {
|
||||
@@ -114,9 +110,10 @@ class PiggyBankFactory
|
||||
}
|
||||
}
|
||||
Log::debug('Touch piggy bank');
|
||||
$piggyBank->encrypted = false;
|
||||
$piggyBank->encrypted = false;
|
||||
$piggyBank->save();
|
||||
$piggyBank->touch();
|
||||
|
||||
return $piggyBank;
|
||||
}
|
||||
|
||||
@@ -132,6 +129,7 @@ class PiggyBankFactory
|
||||
$currency = $this->currencyRepository->find((int) ($data['transaction_currency_id'] ?? 0));
|
||||
}
|
||||
$currency ??= $defaultCurrency;
|
||||
|
||||
return $currency;
|
||||
}
|
||||
|
||||
@@ -144,12 +142,12 @@ class PiggyBankFactory
|
||||
}
|
||||
// first find by ID:
|
||||
if ($piggyBankId > 0) {
|
||||
$piggyBank = PiggyBank
|
||||
::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
|
||||
$piggyBank = PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
|
||||
->where('accounts.user_id', $this->user->id)
|
||||
->where('piggy_banks.id', $piggyBankId)
|
||||
->first(['piggy_banks.*']);
|
||||
->first(['piggy_banks.*'])
|
||||
;
|
||||
if (null !== $piggyBank) {
|
||||
return $piggyBank;
|
||||
}
|
||||
@@ -169,23 +167,24 @@ class PiggyBankFactory
|
||||
|
||||
public function findByName(string $name): ?PiggyBank
|
||||
{
|
||||
return PiggyBank
|
||||
::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
|
||||
return PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
|
||||
->where('accounts.user_id', $this->user->id)
|
||||
->where('piggy_banks.name', $name)
|
||||
->first(['piggy_banks.*']);
|
||||
->first(['piggy_banks.*'])
|
||||
;
|
||||
}
|
||||
|
||||
private function setOrder(PiggyBank $piggyBank, array $data): PiggyBank
|
||||
{
|
||||
$this->resetOrder();
|
||||
$order = $this->getMaxOrder() + 1;
|
||||
$order = $this->getMaxOrder() + 1;
|
||||
if (array_key_exists('order', $data)) {
|
||||
$order = $data['order'];
|
||||
}
|
||||
$piggyBank->order = $order;
|
||||
$piggyBank->saveQuietly();
|
||||
|
||||
return $piggyBank;
|
||||
|
||||
}
|
||||
@@ -193,8 +192,7 @@ class PiggyBankFactory
|
||||
public function resetOrder(): void
|
||||
{
|
||||
// TODO duplicate code
|
||||
$set = PiggyBank
|
||||
::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
|
||||
$set = PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
|
||||
->where('accounts.user_id', $this->user->id)
|
||||
->with(
|
||||
@@ -202,7 +200,8 @@ class PiggyBankFactory
|
||||
'objectGroups',
|
||||
]
|
||||
)
|
||||
->orderBy('piggy_banks.order', 'ASC')->get(['piggy_banks.*']);
|
||||
->orderBy('piggy_banks.order', 'ASC')->get(['piggy_banks.*'])
|
||||
;
|
||||
$current = 1;
|
||||
foreach ($set as $piggyBank) {
|
||||
if ($piggyBank->order !== $current) {
|
||||
@@ -214,7 +213,6 @@ class PiggyBankFactory
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function getMaxOrder(): int
|
||||
{
|
||||
return (int) $this->piggyBankRepository->getPiggyBanks()->max('order');
|
||||
@@ -231,8 +229,8 @@ class PiggyBankFactory
|
||||
foreach ($accounts as $info) {
|
||||
if ($account->id === $info['account_id']) {
|
||||
if (array_key_exists($account->id, $accounts)) {
|
||||
$toBeLinked[$account->id] = ['current_amount' => $account->pivot->current_amount];
|
||||
Log::debug(sprintf('Prefilled for account #%d with amount %s', $account->id, $account->pivot->current_amount));
|
||||
$toBeLinked[$account->id] = ['current_amount' => $account->pivot?->current_amount ?? '0'];
|
||||
Log::debug(sprintf('Prefilled for account #%d with amount %s', $account->id, $account->pivot?->current_amount ?? '0'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -247,7 +245,7 @@ class PiggyBankFactory
|
||||
}
|
||||
if (array_key_exists('current_amount', $info)) {
|
||||
$toBeLinked[$account->id] = ['current_amount' => $info['current_amount']];
|
||||
Log::debug(sprintf('Will link account #%d with amount %s', $account->id, $account->pivot->current_amount));
|
||||
Log::debug(sprintf('Will link account #%d with amount %s', $account->id, $account->pivot?->current_amount ?? '0'));
|
||||
}
|
||||
if (!array_key_exists('current_amount', $info)) {
|
||||
$toBeLinked[$account->id] ??= [];
|
||||
|
||||
@@ -83,6 +83,9 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
'create_date',
|
||||
'update_date',
|
||||
|
||||
// more
|
||||
'notes',
|
||||
|
||||
// date fields.
|
||||
'interest_date',
|
||||
'book_date',
|
||||
@@ -126,7 +129,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setAccounts(new Collection([$account]))->setRange($this->start, $this->end)->withAccountInformation()
|
||||
->withBudgetInformation()->withCategoryInformation()->withBillInformation()
|
||||
->withBudgetInformation()->withCategoryInformation()->withBillInformation()->withNotes()
|
||||
;
|
||||
$journals = $collector->getExtractedJournals();
|
||||
$journals = array_reverse($journals, true);
|
||||
|
||||
@@ -32,6 +32,7 @@ use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Spatie\Period\Boundaries;
|
||||
@@ -45,20 +46,20 @@ class BudgetLimitHandler
|
||||
{
|
||||
public function created(Created $event): void
|
||||
{
|
||||
app('log')->debug(sprintf('BudgetLimitHandler::created(#%s)', $event->budgetLimit->id));
|
||||
Log::debug(sprintf('BudgetLimitHandler::created(#%s)', $event->budgetLimit->id));
|
||||
$this->updateAvailableBudget($event->budgetLimit);
|
||||
}
|
||||
|
||||
private function updateAvailableBudget(BudgetLimit $budgetLimit): void
|
||||
{
|
||||
app('log')->debug(sprintf('Now in updateAvailableBudget(#%d)', $budgetLimit->id));
|
||||
Log::debug(sprintf('Now in updateAvailableBudget(limit #%d)', $budgetLimit->id));
|
||||
$budget = Budget::find($budgetLimit->budget_id);
|
||||
if (null === $budget) {
|
||||
app('log')->warning('Budget is null, probably deleted, find deleted version.');
|
||||
Log::warning('Budget is null, probably deleted, find deleted version.');
|
||||
$budget = Budget::withTrashed()->find($budgetLimit->budget_id);
|
||||
}
|
||||
if (null === $budget) {
|
||||
app('log')->warning('Budget is still null, cannot continue, will delete budget limit.');
|
||||
Log::warning('Budget is still null, cannot continue, will delete budget limit.');
|
||||
$budgetLimit->forceDelete();
|
||||
|
||||
return;
|
||||
@@ -69,7 +70,7 @@ class BudgetLimitHandler
|
||||
|
||||
// sanity check. It happens when the budget has been deleted so the original user is unknown.
|
||||
if (null === $user) {
|
||||
app('log')->warning('User is null, cannot continue.');
|
||||
Log::warning('User is null, cannot continue.');
|
||||
$budgetLimit->forceDelete();
|
||||
|
||||
return;
|
||||
@@ -82,7 +83,7 @@ class BudgetLimitHandler
|
||||
try {
|
||||
$viewRange = app('preferences')->getForUser($user, 'viewRange', '1M')->data;
|
||||
} catch (ContainerExceptionInterface|NotFoundExceptionInterface $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
Log::error($e->getMessage());
|
||||
$viewRange = '1M';
|
||||
}
|
||||
// safety catch
|
||||
@@ -97,7 +98,7 @@ class BudgetLimitHandler
|
||||
|
||||
// limit period in total is:
|
||||
$limitPeriod = Period::make($start, $end, precision: Precision::DAY(), boundaries: Boundaries::EXCLUDE_NONE());
|
||||
app('log')->debug(sprintf('Limit period is from %s to %s', $start->format('Y-m-d'), $end->format('Y-m-d')));
|
||||
Log::debug(sprintf('Limit period is from %s to %s', $start->format('Y-m-d'), $end->format('Y-m-d')));
|
||||
|
||||
// from the start until the end of the budget limit, need to loop!
|
||||
$current = clone $start;
|
||||
@@ -106,16 +107,14 @@ class BudgetLimitHandler
|
||||
|
||||
// create or find AB for this particular period, and set the amount accordingly.
|
||||
/** @var null|AvailableBudget $availableBudget */
|
||||
$availableBudget = $user->availableBudgets()->where('start_date', $current->format('Y-m-d'))->where(
|
||||
'end_date',
|
||||
$currentEnd->format('Y-m-d')
|
||||
)->where('transaction_currency_id', $budgetLimit->transaction_currency_id)->first();
|
||||
$availableBudget = $user->availableBudgets()->where('start_date', $current->format('Y-m-d'))->where('end_date', $currentEnd->format('Y-m-d'))->where('transaction_currency_id', $budgetLimit->transaction_currency_id)->first();
|
||||
|
||||
if (null !== $availableBudget) {
|
||||
app('log')->debug('Found 1 AB, will update.');
|
||||
Log::debug('Found 1 AB, will update.');
|
||||
$this->calculateAmount($availableBudget);
|
||||
}
|
||||
if (null === $availableBudget) {
|
||||
Log::debug('No AB found, will create.');
|
||||
// if not exists:
|
||||
$currentPeriod = Period::make($current, $currentEnd, precision: Precision::DAY(), boundaries: Boundaries::EXCLUDE_NONE());
|
||||
$daily = $this->getDailyAmount($budgetLimit);
|
||||
@@ -126,10 +125,10 @@ class BudgetLimitHandler
|
||||
$amount = 0 === $budgetLimit->id ? '0' : $budgetLimit->amount;
|
||||
}
|
||||
if (0 === bccomp($amount, '0')) {
|
||||
app('log')->debug('Amount is zero, will not create AB.');
|
||||
Log::debug('Amount is zero, will not create AB.');
|
||||
}
|
||||
if (0 !== bccomp($amount, '0')) {
|
||||
app('log')->debug(sprintf('Will create AB for period %s to %s', $current->format('Y-m-d'), $currentEnd->format('Y-m-d')));
|
||||
Log::debug(sprintf('Will create AB for period %s to %s', $current->format('Y-m-d'), $currentEnd->format('Y-m-d')));
|
||||
$availableBudget = new AvailableBudget(
|
||||
[
|
||||
'user_id' => $user->id,
|
||||
@@ -143,7 +142,7 @@ class BudgetLimitHandler
|
||||
]
|
||||
);
|
||||
$availableBudget->save();
|
||||
app('log')->debug(sprintf('ID of new AB is #%d', $availableBudget->id));
|
||||
Log::debug(sprintf('ID of new AB is #%d', $availableBudget->id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +157,7 @@ class BudgetLimitHandler
|
||||
$repository->setUser($availableBudget->user);
|
||||
$newAmount = '0';
|
||||
$abPeriod = Period::make($availableBudget->start_date, $availableBudget->end_date, Precision::DAY());
|
||||
app('log')->debug(
|
||||
Log::debug(
|
||||
sprintf(
|
||||
'Now at AB #%d, ("%s" to "%s")',
|
||||
$availableBudget->id,
|
||||
@@ -168,11 +167,11 @@ class BudgetLimitHandler
|
||||
);
|
||||
// have to recalculate everything just in case.
|
||||
$set = $repository->getAllBudgetLimitsByCurrency($availableBudget->transactionCurrency, $availableBudget->start_date, $availableBudget->end_date);
|
||||
app('log')->debug(sprintf('Found %d interesting budget limit(s).', $set->count()));
|
||||
Log::debug(sprintf('Found %d interesting budget limit(s).', $set->count()));
|
||||
|
||||
/** @var BudgetLimit $budgetLimit */
|
||||
foreach ($set as $budgetLimit) {
|
||||
app('log')->debug(
|
||||
Log::debug(
|
||||
sprintf(
|
||||
'Found interesting budget limit #%d ("%s" to "%s")',
|
||||
$budgetLimit->id,
|
||||
@@ -189,16 +188,16 @@ class BudgetLimitHandler
|
||||
);
|
||||
// if both equal each other, amount from this BL must be added to the AB
|
||||
if ($limitPeriod->equals($abPeriod)) {
|
||||
app('log')->debug('This budget limit is equal to the available budget period.');
|
||||
Log::debug('This budget limit is equal to the available budget period.');
|
||||
$newAmount = bcadd($newAmount, $budgetLimit->amount);
|
||||
}
|
||||
// if budget limit period is inside AB period, it can be added in full.
|
||||
if (!$limitPeriod->equals($abPeriod) && $abPeriod->contains($limitPeriod)) {
|
||||
app('log')->debug('This budget limit is smaller than the available budget period.');
|
||||
Log::debug('This budget limit is smaller than the available budget period.');
|
||||
$newAmount = bcadd($newAmount, $budgetLimit->amount);
|
||||
}
|
||||
if (!$limitPeriod->equals($abPeriod) && !$abPeriod->contains($limitPeriod) && $abPeriod->overlapsWith($limitPeriod)) {
|
||||
app('log')->debug('This budget limit is something else entirely!');
|
||||
Log::debug('This budget limit is something else entirely!');
|
||||
$overlap = $abPeriod->overlap($limitPeriod);
|
||||
if (null !== $overlap) {
|
||||
$length = $overlap->length();
|
||||
@@ -208,12 +207,12 @@ class BudgetLimitHandler
|
||||
}
|
||||
}
|
||||
if (0 === bccomp('0', $newAmount)) {
|
||||
app('log')->debug('New amount is zero, deleting AB.');
|
||||
Log::debug('New amount is zero, deleting AB.');
|
||||
$availableBudget->delete();
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->debug(sprintf('Concluded new amount for this AB must be %s', $newAmount));
|
||||
Log::debug(sprintf('Concluded new amount for this AB must be %s', $newAmount));
|
||||
$availableBudget->amount = app('steam')->bcround($newAmount, $availableBudget->transactionCurrency->decimal_places);
|
||||
$availableBudget->save();
|
||||
}
|
||||
@@ -231,7 +230,7 @@ class BudgetLimitHandler
|
||||
);
|
||||
$days = $limitPeriod->length();
|
||||
$amount = bcdiv($budgetLimit->amount, (string) $days, 12);
|
||||
app('log')->debug(
|
||||
Log::debug(
|
||||
sprintf('Total amount for budget limit #%d is %s. Nr. of days is %d. Amount per day is %s', $budgetLimit->id, $budgetLimit->amount, $days, $amount)
|
||||
);
|
||||
|
||||
@@ -240,7 +239,7 @@ class BudgetLimitHandler
|
||||
|
||||
public function deleted(Deleted $event): void
|
||||
{
|
||||
app('log')->debug(sprintf('BudgetLimitHandler::deleted(#%s)', $event->budgetLimit->id));
|
||||
Log::debug(sprintf('BudgetLimitHandler::deleted(#%s)', $event->budgetLimit->id));
|
||||
$budgetLimit = $event->budgetLimit;
|
||||
$budgetLimit->id = 0;
|
||||
$this->updateAvailableBudget($event->budgetLimit);
|
||||
@@ -248,7 +247,7 @@ class BudgetLimitHandler
|
||||
|
||||
public function updated(Updated $event): void
|
||||
{
|
||||
app('log')->debug(sprintf('BudgetLimitHandler::updated(#%s)', $event->budgetLimit->id));
|
||||
Log::debug(sprintf('BudgetLimitHandler::updated(#%s)', $event->budgetLimit->id));
|
||||
$this->updateAvailableBudget($event->budgetLimit);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user