Compare commits

..

112 Commits

Author SHA1 Message Date
github-actions[bot]
9685b47126 Merge pull request #11578 from firefly-iii/release-1769177668
🤖 Automatically merge the PR into the develop branch.
2026-01-23 15:14:37 +01:00
JC5
eeeba86d38 🤖 Auto commit for release 'develop' on 2026-01-23 2026-01-23 15:14:29 +01:00
James Cole
8f15a32bd6 Autoformat lol 2026-01-23 15:09:50 +01:00
James Cole
ae1347c550 Auto fix issues. 2026-01-23 15:09:36 +01:00
James Cole
e215d550b5 More refactoring for #11544 2026-01-23 15:06:35 +01:00
James Cole
203a80147a Refactor a bunch of events for #11544 2026-01-23 14:53:54 +01:00
James Cole
fa6c7e77bc Refactor events for #11544 2026-01-23 13:58:57 +01:00
James Cole
c47be06043 Remove overflow. 2026-01-22 19:56:36 +01:00
James Cole
eb4b6cbfc5 Remove duplicates 2026-01-22 19:56:27 +01:00
github-actions[bot]
1c844bab23 Merge pull request #11571 from firefly-iii/release-1769021222
🤖 Automatically merge the PR into the develop branch.
2026-01-21 19:47:11 +01:00
JC5
b3ee8dccd5 🤖 Auto commit for release 'develop' on 2026-01-21 2026-01-21 19:47:02 +01:00
James Cole
41108e81a0 Remove unexpected exit call. 2026-01-21 19:42:27 +01:00
James Cole
8dba928dca Add autocomplete=off 2026-01-21 11:35:01 +01:00
James Cole
0955daf21f Merge pull request #11569 from gian21391/develop
Fix layout overflow issues with long content in v1 and v2 layouts
2026-01-21 11:31:48 +01:00
Gianluca Martino
de79a757cb Adding CSS properties to v1 and v2 layouts. 2026-01-20 23:31:40 -08:00
github-actions[bot]
39531a2132 Merge pull request #11567 from firefly-iii/release-1768973599
🤖 Automatically merge the PR into the develop branch.
2026-01-21 06:33:28 +01:00
JC5
90b546e2eb 🤖 Auto commit for release 'develop' on 2026-01-21 2026-01-21 06:33:19 +01:00
James Cole
b535c5b6a1 Back to jquery 3.x 2026-01-21 06:28:26 +01:00
James Cole
54f1ef0e21 Update view and audit logs for #11399 2026-01-21 06:26:48 +01:00
github-actions[bot]
e1ada04d07 Merge pull request #11566 from firefly-iii/release-1768939586
🤖 Automatically merge the PR into the develop branch.
2026-01-20 21:06:33 +01:00
JC5
61cc480c03 🤖 Auto commit for release 'develop' on 2026-01-20 2026-01-20 21:06:26 +01:00
James Cole
889b25e85d Merge branch 'main' into develop 2026-01-20 21:02:06 +01:00
James Cole
f9f365153a Update build job. 2026-01-20 21:01:37 +01:00
github-actions[bot]
62c676157f Merge pull request #11565 from firefly-iii/release-1768939166
🤖 Automatically merge the PR into the develop branch.
2026-01-20 20:59:34 +01:00
JC5
24df659ecb 🤖 Auto commit for release 'develop' on 2026-01-20 2026-01-20 20:59:26 +01:00
James Cole
9180cdbc66 Add error box. 2026-01-20 20:55:35 +01:00
github-actions[bot]
7a6245f246 Merge pull request #11564 from firefly-iii/release-1768934499
🤖 Automatically merge the PR into the develop branch.
2026-01-20 19:41:46 +01:00
JC5
e156a4eedc 🤖 Auto commit for release 'develop' on 2026-01-20 2026-01-20 19:41:39 +01:00
James Cole
c63fead216 Add jquery. 2026-01-20 19:37:11 +01:00
github-actions[bot]
d9c09fe566 Merge pull request #11562 from firefly-iii/release-1768885025
🤖 Automatically merge the PR into the develop branch.
2026-01-20 05:57:12 +01:00
JC5
0686d86ef8 🤖 Auto commit for release 'develop' on 2026-01-20 2026-01-20 05:57:05 +01:00
James Cole
7c2aea31fe Update jquery 2026-01-20 05:49:14 +01:00
James Cole
bb0af2396e Merge pull request #11551 from firefly-iii/dependabot/npm_and_yarn/develop/i18next-chained-backend-5.0.0 2026-01-20 05:08:52 +01:00
Gianluca Martino
417a97c26c Avoiding the overflow of the content in the transaction list when a very long description is present. 2026-01-19 15:29:41 -08:00
mergify[bot]
4718ee9723 Merge branch 'develop' into dependabot/npm_and_yarn/develop/i18next-chained-backend-5.0.0 2026-01-19 19:24:23 +00:00
github-actions[bot]
55c762d55a Merge pull request #11558 from firefly-iii/release-1768850616
🤖 Automatically merge the PR into the develop branch.
2026-01-19 20:23:44 +01:00
JC5
734df18f4e 🤖 Auto commit for release 'develop' on 2026-01-19 2026-01-19 20:23:36 +01:00
mergify[bot]
11537c4922 Merge branch 'develop' into dependabot/npm_and_yarn/develop/i18next-chained-backend-5.0.0 2026-01-19 19:20:14 +00:00
James Cole
30205d828a Merge pull request #11552 from firefly-iii/dependabot/npm_and_yarn/develop/jquery-4.0.0
Bump jquery from 3.7.1 to 4.0.0
2026-01-19 20:19:30 +01:00
mergify[bot]
6b2d724a5b Merge branch 'develop' into dependabot/npm_and_yarn/develop/i18next-chained-backend-5.0.0 2026-01-19 19:18:17 +00:00
mergify[bot]
9c0eb8a028 Merge branch 'develop' into dependabot/npm_and_yarn/develop/jquery-4.0.0 2026-01-19 19:18:01 +00:00
James Cole
103a6d1b15 Expand events for #11544 2026-01-19 20:17:16 +01:00
mergify[bot]
99403ab9f6 Merge branch 'develop' into dependabot/npm_and_yarn/develop/jquery-4.0.0 2026-01-19 19:11:10 +00:00
mergify[bot]
5980ac0b64 Merge branch 'develop' into dependabot/npm_and_yarn/develop/i18next-chained-backend-5.0.0 2026-01-19 19:11:07 +00:00
James Cole
b9e5851e38 Remove unused class #11411 2026-01-19 20:09:53 +01:00
mergify[bot]
6da02065b7 Merge branch 'develop' into dependabot/npm_and_yarn/develop/i18next-chained-backend-5.0.0 2026-01-19 19:08:57 +00:00
mergify[bot]
eab18ed2f2 Merge branch 'develop' into dependabot/npm_and_yarn/develop/jquery-4.0.0 2026-01-19 19:08:53 +00:00
James Cole
67d18e4b62 Clean up latest MFA handler #11455 2026-01-19 20:08:15 +01:00
mergify[bot]
41da3a014f Merge branch 'develop' into dependabot/npm_and_yarn/develop/i18next-chained-backend-5.0.0 2026-01-19 19:02:51 +00:00
mergify[bot]
71774905b0 Merge branch 'develop' into dependabot/npm_and_yarn/develop/jquery-4.0.0 2026-01-19 19:02:47 +00:00
James Cole
48f886d17c Replace multiple failures alert #11544 2026-01-19 20:02:20 +01:00
James Cole
e28df272b5 Replace multiple failures alert #11544 2026-01-19 20:02:08 +01:00
mergify[bot]
c7f4c40435 Merge branch 'develop' into dependabot/npm_and_yarn/develop/i18next-chained-backend-5.0.0 2026-01-19 18:57:51 +00:00
mergify[bot]
95e98cfeca Merge branch 'develop' into dependabot/npm_and_yarn/develop/jquery-4.0.0 2026-01-19 18:57:47 +00:00
James Cole
095d31fbe1 Replace multiple failures alert #11544 2026-01-19 19:57:09 +01:00
mergify[bot]
8db08cc623 Merge branch 'develop' into dependabot/npm_and_yarn/develop/i18next-chained-backend-5.0.0 2026-01-19 18:50:19 +00:00
mergify[bot]
27044aeecf Merge branch 'develop' into dependabot/npm_and_yarn/develop/jquery-4.0.0 2026-01-19 18:50:15 +00:00
James Cole
8bd7752e2b Clean up more MFA event handlers #11544 2026-01-19 19:49:50 +01:00
James Cole
ee24d55554 Clean up more MFA event handlers #11544 2026-01-19 19:49:34 +01:00
mergify[bot]
8e8e0ab67d Merge branch 'develop' into dependabot/npm_and_yarn/develop/i18next-chained-backend-5.0.0 2026-01-19 18:43:54 +00:00
mergify[bot]
740a14972a Merge branch 'develop' into dependabot/npm_and_yarn/develop/jquery-4.0.0 2026-01-19 18:43:44 +00:00
James Cole
c6667c2293 Continued. #11544 2026-01-19 19:43:23 +01:00
James Cole
8327a3d670 Enabled MFA notifications #11544 2026-01-19 19:43:06 +01:00
mergify[bot]
4278d59d05 Merge branch 'develop' into dependabot/npm_and_yarn/develop/i18next-chained-backend-5.0.0 2026-01-19 18:37:08 +00:00
mergify[bot]
5534bedde0 Merge branch 'develop' into dependabot/npm_and_yarn/develop/jquery-4.0.0 2026-01-19 18:37:02 +00:00
James Cole
83fe7f6f6d MFA disabled #11544 2026-01-19 19:36:21 +01:00
mergify[bot]
669bb20228 Merge branch 'develop' into dependabot/npm_and_yarn/develop/i18next-chained-backend-5.0.0 2026-01-19 18:33:07 +00:00
mergify[bot]
e41dbdc3a7 Merge branch 'develop' into dependabot/npm_and_yarn/develop/jquery-4.0.0 2026-01-19 18:33:03 +00:00
James Cole
670f98eb66 Merge branch 'main' into develop 2026-01-19 19:32:21 +01:00
mergify[bot]
3229011035 Merge branch 'develop' into dependabot/npm_and_yarn/develop/i18next-chained-backend-5.0.0 2026-01-19 06:56:35 +00:00
mergify[bot]
7e02bee90b Merge branch 'develop' into dependabot/npm_and_yarn/develop/jquery-4.0.0 2026-01-19 06:56:31 +00:00
github-actions[bot]
be6801654f Merge pull request #11555 from firefly-iii/release-1768805748
🤖 Automatically merge the PR into the develop branch.
2026-01-19 07:55:56 +01:00
JC5
93fe1f5558 🤖 Auto commit for release 'develop' on 2026-01-19 2026-01-19 07:55:48 +01:00
James Cole
d12fd40a57 Merge pull request #11554 from firefly-iii/JC5-patch-2
Update PHP version setup in release workflow
2026-01-19 07:52:00 +01:00
James Cole
4405b2ac8f Update PHP version setup in release workflow
Set default PHP version to 8.4 if not provided.

Signed-off-by: James Cole <james@firefly-iii.org>
2026-01-19 07:51:49 +01:00
mergify[bot]
cc99abefac Merge branch 'develop' into dependabot/npm_and_yarn/develop/i18next-chained-backend-5.0.0 2026-01-19 06:03:18 +00:00
mergify[bot]
bbbc8492db Merge branch 'develop' into dependabot/npm_and_yarn/develop/jquery-4.0.0 2026-01-19 06:03:13 +00:00
James Cole
ba5b6ff694 Merge pull request #11550 from firefly-iii/dependabot/composer/develop/larastan/larastan-3.9.0 2026-01-19 07:02:34 +01:00
dependabot[bot]
edb8f811af Bump jquery from 3.7.1 to 4.0.0
Bumps [jquery](https://github.com/jquery/jquery) from 3.7.1 to 4.0.0.
- [Release notes](https://github.com/jquery/jquery/releases)
- [Changelog](https://github.com/jquery/jquery/blob/main/changelog.md)
- [Commits](https://github.com/jquery/jquery/compare/3.7.1...4.0.0)

---
updated-dependencies:
- dependency-name: jquery
  dependency-version: 4.0.0
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-19 04:09:35 +00:00
dependabot[bot]
d79d1a3317 Bump i18next-chained-backend from 4.6.3 to 5.0.0
Bumps [i18next-chained-backend](https://github.com/i18next/i18next-chained-backend) from 4.6.3 to 5.0.0.
- [Changelog](https://github.com/i18next/i18next-chained-backend/blob/master/CHANGELOG.md)
- [Commits](https://github.com/i18next/i18next-chained-backend/compare/v4.6.3...v5.0.0)

---
updated-dependencies:
- dependency-name: i18next-chained-backend
  dependency-version: 5.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-19 04:09:22 +00:00
dependabot[bot]
492aec0652 Bump larastan/larastan from 3.8.1 to 3.9.0
Bumps [larastan/larastan](https://github.com/larastan/larastan) from 3.8.1 to 3.9.0.
- [Release notes](https://github.com/larastan/larastan/releases)
- [Changelog](https://github.com/larastan/larastan/blob/3.x/RELEASE.md)
- [Commits](https://github.com/larastan/larastan/compare/v3.8.1...v3.9.0)

---
updated-dependencies:
- dependency-name: larastan/larastan
  dependency-version: 3.9.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-19 04:09:13 +00:00
James Cole
c81bb44552 Fix #11546 2026-01-18 13:32:05 +01:00
James Cole
0431c95b49 Move rule actions for rule events. #11544 2026-01-18 12:13:11 +01:00
James Cole
6408db5414 Remove unused class #11544 2026-01-18 12:08:05 +01:00
James Cole
5de88a70f8 Remove piggy bank event handler and replace name event. #11544 2026-01-18 12:07:03 +01:00
James Cole
968da83c67 Migrate PiggyBankAmountIsChanged handler to listener #11544 2026-01-18 12:00:41 +01:00
James Cole
e77b4ee4a6 Rename to PiggyBankAmountIsChanged for #11544 2026-01-18 11:58:20 +01:00
James Cole
a36c775bd2 Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop 2026-01-18 11:57:23 +01:00
James Cole
7773862eb9 Remove unused class. #11544 2026-01-18 11:57:17 +01:00
github-actions[bot]
ae107b1776 Merge pull request #11545 from firefly-iii/release-1768729993
🤖 Automatically merge the PR into the develop branch.
2026-01-18 10:53:20 +01:00
JC5
d1b167447b 🤖 Auto commit for release 'develop' on 2026-01-18 2026-01-18 10:53:13 +01:00
James Cole
a08ba43c23 For multiple subscriptions payment missed warning #11544 2026-01-18 10:17:50 +01:00
James Cole
64325fbce7 Remove unused class #11544 2026-01-18 10:12:39 +01:00
James Cole
aeac59e851 Subscription reminder for extension or ending. https://github.com/firefly-iii/firefly-iii/issues/11544 2026-01-18 10:11:26 +01:00
James Cole
151be7df8a Fix #11541 2026-01-18 06:07:50 +01:00
github-actions[bot]
040bd0f6e3 Merge pull request #11540 from firefly-iii/release-1768662669
🤖 Automatically merge the PR into the develop branch.
2026-01-17 16:11:15 +01:00
JC5
a859ca4e38 🤖 Auto commit for release 'develop' on 2026-01-17 2026-01-17 16:11:09 +01:00
James Cole
95c62d783a Fix https://github.com/orgs/firefly-iii/discussions/11538 2026-01-17 16:02:59 +01:00
github-actions[bot]
e7b67bc85e Merge pull request #11536 from firefly-iii/develop
🤖 Automatically merge the PR into the main branch.
2026-01-17 08:54:06 +01:00
github-actions[bot]
208f13ee75 Merge pull request #11535 from firefly-iii/release-1768636434
🤖 Automatically merge the PR into the develop branch.
2026-01-17 08:54:01 +01:00
JC5
437eecc1c9 🤖 Auto commit for release 'v6.4.16' on 2026-01-17 2026-01-17 08:53:54 +01:00
James Cole
1d34d81389 Remove double line from changelog. 2026-01-17 07:22:40 +01:00
github-actions[bot]
30844e99d4 Merge pull request #11534 from firefly-iii/release-1768630688
🤖 Automatically merge the PR into the develop branch.
2026-01-17 07:18:14 +01:00
JC5
d734449f63 🤖 Auto commit for release 'develop' on 2026-01-17 2026-01-17 07:18:08 +01:00
James Cole
69a9e3a198 Clean up account deletion and balance recalculation. 2026-01-17 07:12:14 +01:00
James Cole
3ad2f8c750 Expand changelog. 2026-01-17 07:03:29 +01:00
James Cole
2166839768 Fix #11475 2026-01-17 07:03:18 +01:00
James Cole
8ecb9d7774 Fix #11508 2026-01-17 06:58:33 +01:00
James Cole
8814fb0806 Fix https://github.com/orgs/firefly-iii/discussions/11509 2026-01-16 09:02:37 +01:00
James Cole
7481c8d4c0 Fix https://github.com/firefly-iii/firefly-iii/issues/11531 2026-01-16 07:34:20 +01:00
James Cole
1e618fbf6d Sort alphabetically https://github.com/orgs/firefly-iii/discussions/11524 2026-01-15 05:59:33 +01:00
James Cole
8b322dc903 Sort alphabetically https://github.com/orgs/firefly-iii/discussions/11524 2026-01-15 05:56:18 +01:00
995 changed files with 15602 additions and 15316 deletions

View File

@@ -14,7 +14,15 @@ SITE_OWNER=mail@example.com
# Change it to a string of exactly 32 chars or use something like `php artisan key:generate` to generate it.
# If you use Docker or similar, you can set this variable from a file by using APP_KEY_FILE
#
# Avoid the "#" character in your APP_KEY, it may break things.
# Try to avoid special characters like #, < and > in your app key. This string does not need full entropy
# When in doubt, follow the link below and pick one.
#
# https://www.random.org/strings/?num=5&len=32&digits=on&upperalpha=on&loweralpha=on&unique=on&format=html&rnd=new
#
# If you are a fancy linux nerd like me, use this command:
#
# head /dev/urandom | LC_ALL=C tr -dc 'A-Za-z0-9' | head -c 32 && echo
#
#
APP_KEY=SomeRandomStringOf32CharsExactly

View File

@@ -42,7 +42,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ github.event.inputs.phpversion }}
php-version: ${{ github.event.inputs.phpversion || '8.4' }}
extensions: mbstring, intl, zip, bcmath
- name: Switch and pull
run: |
@@ -170,10 +170,15 @@ jobs:
npm run prod --workspace=v1
npm run build --workspace=v2
npm update
- name: Setup Mago
uses: nhedger/setup-mago@v1
- name: Run CI
run: |
rm -rf vendor composer.lock
composer update --no-dev --no-scripts --no-plugins -q
composer update --no-scripts --no-plugins -q
mago format --dry-run || true
mago lint --reporting-format=github || true
mago analyze --reporting-format=github || true
sudo chown -R runner:docker resources/lang
.ci/phpcs.sh || true
- name: Calculate variables

View File

@@ -4,6 +4,7 @@ Over time, many people have contributed to Firefly III. Their efforts are not al
Please find below all the people who contributed to the Firefly III code. Their names are mentioned in the year of their first contribution.
## 2026
- Gianluca Martino
- embedded
## 2025

View File

@@ -82,6 +82,7 @@ class PiggyBankController extends Controller
'currency_decimal_places' => $currency->decimal_places,
'object_group_id' => null === $objectGroup ? null : (string) $objectGroup->id,
'object_group_title' => $objectGroup?->title,
'object_group_order' => $objectGroup?->order,
];
}

View File

@@ -24,13 +24,13 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Data\Bulk;
use Illuminate\Http\Request;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Data\Bulk\TransactionRequest;
use FireflyIII\Enums\UserRoleEnum;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Services\Internal\Destroy\AccountDestroyService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
/**
* Class TransactionController
@@ -51,16 +51,14 @@ class TransactionController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function (Request $request, $next) {
$this->validateUserGroup($request);
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUserGroup($this->userGroup);
$this->repository->setUser($this->user);
$this->middleware(function (Request $request, $next) {
$this->validateUserGroup($request);
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUserGroup($this->userGroup);
$this->repository->setUser($this->user);
return $next($request);
}
);
return $next($request);
});
}
public function update(TransactionRequest $request): JsonResponse

View File

@@ -24,12 +24,12 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Data\Export;
use Illuminate\Http\Request;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Data\Export\ExportRequest;
use FireflyIII\Enums\UserRoleEnum;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Support\Export\ExportDataGenerator;
use Illuminate\Http\Request;
use Illuminate\Http\Response as LaravelResponse;
use Safe\Exceptions\DatetimeException;
@@ -49,16 +49,14 @@ class ExportController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function (Request $request, $next) {
$this->validateUserGroup($request);
$this->exporter = app(ExportDataGenerator::class);
$this->exporter->setUserGroup($this->userGroup);
$this->exporter->setUser($this->user);
$this->middleware(function (Request $request, $next) {
$this->validateUserGroup($request);
$this->exporter = app(ExportDataGenerator::class);
$this->exporter->setUserGroup($this->userGroup);
$this->exporter->setUser($this->user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -42,7 +42,7 @@ class AccountController extends Controller
use ApiSupport;
private OperationsRepositoryInterface $opsRepository;
private AccountRepositoryInterface $repository;
private AccountRepositoryInterface $repository;
/**
* AccountController constructor.
@@ -50,18 +50,16 @@ class AccountController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$user = auth()->user();
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
$user = auth()->user();
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser($user);
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->opsRepository->setUser($user);
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->opsRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
public function asset(GenericRequest $request): JsonResponse

View File

@@ -46,15 +46,13 @@ class BillController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$user = auth()->user();
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
$user = auth()->user();
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -97,7 +95,14 @@ class BillController extends Controller
if ($convertToPrimary && $journal['currency_id'] !== $primary->id && $primary->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'));
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);

View File

@@ -38,9 +38,9 @@ use Illuminate\Support\Collection;
*/
class BudgetController extends Controller
{
private NoBudgetRepositoryInterface $noRepository;
private NoBudgetRepositoryInterface $noRepository;
private OperationsRepositoryInterface $opsRepository;
private BudgetRepositoryInterface $repository;
private BudgetRepositoryInterface $repository;
/**
* AccountController constructor.
@@ -48,19 +48,17 @@ class BudgetController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(BudgetRepositoryInterface::class);
$this->noRepository = app(NoBudgetRepositoryInterface::class);
$user = auth()->user();
$this->opsRepository->setUser($user);
$this->repository->setUser($user);
$this->noRepository->setUser($user);
$this->middleware(function ($request, $next) {
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(BudgetRepositoryInterface::class);
$this->noRepository = app(NoBudgetRepositoryInterface::class);
$user = auth()->user();
$this->opsRepository->setUser($user);
$this->repository->setUser($user);
$this->noRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
public function budget(GenericRequest $request): JsonResponse

View File

@@ -40,7 +40,7 @@ class CategoryController extends Controller
{
private NoCategoryRepositoryInterface $noRepository;
private OperationsRepositoryInterface $opsRepository;
private CategoryRepositoryInterface $repository;
private CategoryRepositoryInterface $repository;
/**
* AccountController constructor.
@@ -48,19 +48,17 @@ class CategoryController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(CategoryRepositoryInterface::class);
$this->noRepository = app(NoCategoryRepositoryInterface::class);
$user = auth()->user();
$this->opsRepository->setUser($user);
$this->repository->setUser($user);
$this->noRepository->setUser($user);
$this->middleware(function ($request, $next) {
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(CategoryRepositoryInterface::class);
$this->noRepository = app(NoCategoryRepositoryInterface::class);
$user = auth()->user();
$this->opsRepository->setUser($user);
$this->repository->setUser($user);
$this->noRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
public function category(GenericRequest $request): JsonResponse

View File

@@ -73,7 +73,6 @@ class PeriodController extends Controller
$amount = $journal['amount'];
}
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,

View File

@@ -46,14 +46,12 @@ class TagController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -42,7 +42,7 @@ class AccountController extends Controller
use ApiSupport;
private OperationsRepositoryInterface $opsRepository;
private AccountRepositoryInterface $repository;
private AccountRepositoryInterface $repository;
/**
* AccountController constructor.
@@ -50,18 +50,16 @@ class AccountController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$user = auth()->user();
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
$user = auth()->user();
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser($user);
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->opsRepository->setUser($user);
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->opsRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
public function asset(GenericRequest $request): JsonResponse

View File

@@ -40,7 +40,7 @@ class CategoryController extends Controller
{
private NoCategoryRepositoryInterface $noRepository;
private OperationsRepositoryInterface $opsRepository;
private CategoryRepositoryInterface $repository;
private CategoryRepositoryInterface $repository;
/**
* AccountController constructor.
@@ -48,19 +48,17 @@ class CategoryController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(CategoryRepositoryInterface::class);
$this->noRepository = app(NoCategoryRepositoryInterface::class);
$user = auth()->user();
$this->opsRepository->setUser($user);
$this->repository->setUser($user);
$this->noRepository->setUser($user);
$this->middleware(function ($request, $next) {
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(CategoryRepositoryInterface::class);
$this->noRepository = app(NoCategoryRepositoryInterface::class);
$user = auth()->user();
$this->opsRepository->setUser($user);
$this->repository->setUser($user);
$this->noRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
public function category(GenericRequest $request): JsonResponse

View File

@@ -46,15 +46,13 @@ class TagController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
$user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -100,7 +98,6 @@ class TagController extends Controller
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], Steam::positive($journal[$field]));
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
}
return response()->json(array_values($response));

View File

@@ -45,15 +45,13 @@ class AccountController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$user = auth()->user();
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->opsRepository->setUser($user);
$this->middleware(function ($request, $next) {
$user = auth()->user();
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->opsRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
public function asset(GenericRequest $request): JsonResponse

View File

@@ -40,7 +40,7 @@ class CategoryController extends Controller
{
private NoCategoryRepositoryInterface $noRepository;
private OperationsRepositoryInterface $opsRepository;
private CategoryRepositoryInterface $repository;
private CategoryRepositoryInterface $repository;
/**
* AccountController constructor.
@@ -48,19 +48,17 @@ class CategoryController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(CategoryRepositoryInterface::class);
$this->noRepository = app(NoCategoryRepositoryInterface::class);
$user = auth()->user();
$this->opsRepository->setUser($user);
$this->repository->setUser($user);
$this->noRepository->setUser($user);
$this->middleware(function ($request, $next) {
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(CategoryRepositoryInterface::class);
$this->noRepository = app(NoCategoryRepositoryInterface::class);
$user = auth()->user();
$this->opsRepository->setUser($user);
$this->repository->setUser($user);
$this->noRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
public function category(GenericRequest $request): JsonResponse

View File

@@ -74,7 +74,6 @@ class PeriodController extends Controller
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], Steam::positive($journal[$field]));
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
}
return response()->json(array_values($response));

View File

@@ -46,15 +46,13 @@ class TagController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
$user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
public function noTag(GenericRequest $request): JsonResponse
@@ -66,7 +64,6 @@ class TagController extends Controller
$convertToPrimary = Amount::convertToPrimary();
$primary = Amount::getPrimaryCurrency();
// collect all expenses in this period (regardless of type) by the given bills and accounts.
$collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::TRANSFER->value])->setRange($start, $end)->setDestinationAccounts($accounts);
@@ -98,7 +95,6 @@ class TagController extends Controller
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], Steam::positive($journal[$field]));
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
}
return response()->json(array_values($response));
@@ -159,10 +155,7 @@ class TagController extends Controller
'currency_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignKey]['difference'] = bcadd(
(string) $response[$foreignKey]['difference'],
Steam::positive($journal['foreign_amount'])
);
$response[$foreignKey]['difference'] = bcadd((string) $response[$foreignKey]['difference'], Steam::positive($journal['foreign_amount']));
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // intentional float
}
}

View File

@@ -45,14 +45,12 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -60,37 +60,31 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
public function attachments(PaginationRequest $request, Account $account): JsonResponse
{
$manager = $this->getManager();
[
'limit' => $limit,
'offset' => $offset,
'page' => $page,
] = $request->attributes->all();
$collection = $this->repository->getAttachments($account);
$manager = $this->getManager();
['limit' => $limit, 'offset' => $offset, 'page' => $page] = $request->attributes->all();
$collection = $this->repository->getAttachments($account);
$count = $collection->count();
$attachments = $collection->slice($offset, $limit);
$count = $collection->count();
$attachments = $collection->slice($offset, $limit);
// make paginator:
$paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
$paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
$paginator->setPath(route('api.v1.accounts.attachments', [$account->id]).$this->buildParams());
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
$transformer = app(AttachmentTransformer::class);
$resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -99,35 +93,31 @@ class ListController extends Controller
public function piggyBanks(PaginationRequest $request, Account $account): JsonResponse
{
// create some objects:
$manager = $this->getManager();
$manager = $this->getManager();
[
'limit' => $limit,
'offset' => $offset,
'page' => $page,
] = $request->attributes->all();
['limit' => $limit, 'offset' => $offset, 'page' => $page] = $request->attributes->all();
// get list of piggy banks. Count it and split it.
$collection = $this->repository->getPiggyBanks($account);
$count = $collection->count();
$piggyBanks = $collection->slice($offset, $limit);
$collection = $this->repository->getPiggyBanks($account);
$count = $collection->count();
$piggyBanks = $collection->slice($offset, $limit);
// enrich
/** @var User $admin */
$admin = auth()->user();
$enrichment = new PiggyBankEnrichment();
$admin = auth()->user();
$enrichment = new PiggyBankEnrichment();
$enrichment->setUser($admin);
$piggyBanks = $enrichment->enrich($piggyBanks);
$piggyBanks = $enrichment->enrich($piggyBanks);
// make paginator:
$paginator = new LengthAwarePaginator($piggyBanks, $count, $limit, $page);
$paginator = new LengthAwarePaginator($piggyBanks, $count, $limit, $page);
$paginator->setPath(route('api.v1.accounts.piggy-banks', [$account->id]).$this->buildParams());
/** @var PiggyBankTransformer $transformer */
$transformer = app(PiggyBankTransformer::class);
$transformer = app(PiggyBankTransformer::class);
// $transformer->setParameters($this->parameters);
$resource = new FractalCollection($piggyBanks, $transformer, 'piggy-banks');
$resource = new FractalCollection($piggyBanks, $transformer, 'piggy-banks');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -138,21 +128,15 @@ class ListController extends Controller
*/
public function transactions(PaginationDateRangeRequest $request, Account $account): JsonResponse
{
[
'limit' => $limit,
'page' => $page,
'start' => $start,
'end' => $end,
'types' => $types,
] = $request->attributes->all();
$manager = $this->getManager();
['limit' => $limit, 'page' => $page, 'start' => $start, 'end' => $end, 'types' => $types] = $request->attributes->all();
$manager = $this->getManager();
/** @var User $admin */
$admin = auth()->user();
$admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector = app(GroupCollectorInterface::class);
$collector->setUser($admin)->setAccounts(new Collection()->push($account))->withAPIInformation()->setLimit($limit)->setPage($page)->setTypes($types);
if (null !== $start) {
$collector->setStart($start);
@@ -161,18 +145,18 @@ class ListController extends Controller
$collector->setEnd($end);
}
$paginator = $collector->getPaginatedGroups();
$paginator = $collector->getPaginatedGroups();
$paginator->setPath(route('api.v1.accounts.transactions', [$account->id]).$this->buildParams());
// enrich
$enrichment = new TransactionGroupEnrichment();
$enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
$transactions = $enrichment->enrich($paginator->getCollection());
$transactions = $enrichment->enrich($paginator->getCollection());
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
$transformer = app(TransactionGroupTransformer::class);
$resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);

View File

@@ -55,14 +55,12 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -80,8 +78,7 @@ class ShowController extends Controller
'start' => $start,
'end' => $end,
'date' => $date,
]
= $request->attributes->all();
] = $request->attributes->all();
// get list of accounts. Count it and split it.
$this->repository->resetAccountOrder();
$collection = $this->repository->getAccountsByType($types, $sort);
@@ -127,25 +124,22 @@ class ShowController extends Controller
// get list of accounts. Count it and split it.
$this->repository->resetAccountOrder();
$account->refresh();
$manager = $this->getManager();
['start' => $start,
'end' => $end,
'date' => $date,] = $request->attributes->all();
$manager = $this->getManager();
['start' => $start, 'end' => $end, 'date' => $date] = $request->attributes->all();
// enrich
/** @var User $admin */
$admin = auth()->user();
$enrichment = new AccountEnrichment();
$admin = auth()->user();
$enrichment = new AccountEnrichment();
$enrichment->setDate($date);
$enrichment->setStart($start);
$enrichment->setEnd($end);
$enrichment->setUser($admin);
$account = $enrichment->enrichSingle($account);
$account = $enrichment->enrichSingle($account);
/** @var AccountTransformer $transformer */
$transformer = app(AccountTransformer::class);
$resource = new Item($account, $transformer, self::RESOURCE_KEY);
$transformer = app(AccountTransformer::class);
$resource = new Item($account, $transformer, self::RESOURCE_KEY);
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}

View File

@@ -48,14 +48,12 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -51,14 +51,12 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -48,16 +48,14 @@ class DestroyController extends Controller
{
parent::__construct();
$this->middleware(ApiDemoUser::class)->except(['delete', 'download', 'show', 'index']);
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -55,16 +55,14 @@ class ShowController extends Controller
{
parent::__construct();
$this->middleware(ApiDemoUser::class)->except(['delete', 'download', 'show', 'index']);
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -123,11 +121,7 @@ class ShowController extends Controller
*/
public function index(PaginationRequest $request): JsonResponse
{
[
'limit' => $limit,
'offset' => $offset,
'page' => $page,
] = $request->attributes->all();
['limit' => $limit, 'offset' => $offset, 'page' => $page] = $request->attributes->all();
if (true === auth()->user()->hasRole('demo')) {
Log::channel('audit')->warning(sprintf('Demo user tries to access attachment API in %s', __METHOD__));
@@ -135,21 +129,21 @@ class ShowController extends Controller
throw new NotFoundHttpException();
}
$manager = $this->getManager();
$manager = $this->getManager();
// get list of attachments. Count it and split it.
$collection = $this->repository->get();
$count = $collection->count();
$attachments = $collection->slice($offset, $limit);
$collection = $this->repository->get();
$count = $collection->count();
$attachments = $collection->slice($offset, $limit);
// make paginator:
$paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
$paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
$paginator->setPath(route('api.v1.attachments.index').$this->buildParams());
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
$transformer = app(AttachmentTransformer::class);
$resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);

View File

@@ -53,16 +53,14 @@ class StoreController extends Controller
{
parent::__construct();
$this->middleware(ApiDemoUser::class)->except(['delete', 'download', 'show', 'index']);
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -50,16 +50,14 @@ class UpdateController extends Controller
{
parent::__construct();
$this->middleware(ApiDemoUser::class)->except(['delete', 'download', 'show', 'index']);
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -50,16 +50,14 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->abRepository = app(AvailableBudgetRepositoryInterface::class);
$this->abRepository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->abRepository = app(AvailableBudgetRepositoryInterface::class);
$this->abRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -70,35 +68,29 @@ class ShowController extends Controller
*/
public function index(PaginationDateRangeRequest $request): JsonResponse
{
$manager = $this->getManager();
[
'limit' => $limit,
'offset' => $offset,
'page' => $page,
'start' => $start,
'end' => $end,
] = $request->attributes->all();
$manager = $this->getManager();
['limit' => $limit, 'offset' => $offset, 'page' => $page, 'start' => $start, 'end' => $end] = $request->attributes->all();
// get list of available budgets. Count it and split it.
$collection = $this->abRepository->getAvailableBudgetsByDate($start, $end);
$count = $collection->count();
$availableBudgets = $collection->slice($offset, $limit);
$collection = $this->abRepository->getAvailableBudgetsByDate($start, $end);
$count = $collection->count();
$availableBudgets = $collection->slice($offset, $limit);
// enrich
/** @var User $admin */
$admin = auth()->user();
$enrichment = new AvailableBudgetEnrichment();
$admin = auth()->user();
$enrichment = new AvailableBudgetEnrichment();
$enrichment->setUser($admin);
$availableBudgets = $enrichment->enrich($availableBudgets);
$availableBudgets = $enrichment->enrich($availableBudgets);
// make paginator:
$paginator = new LengthAwarePaginator($availableBudgets, $count, $limit, $page);
$paginator = new LengthAwarePaginator($availableBudgets, $count, $limit, $page);
$paginator->setPath(route('api.v1.available-budgets.index').$this->buildParams());
/** @var AvailableBudgetTransformer $transformer */
$transformer = app(AvailableBudgetTransformer::class);
$transformer = app(AvailableBudgetTransformer::class);
$resource = new FractalCollection($availableBudgets, $transformer, 'available_budgets');
$resource = new FractalCollection($availableBudgets, $transformer, 'available_budgets');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -126,7 +118,6 @@ class ShowController extends Controller
$enrichment->setUser($admin);
$availableBudget = $enrichment->enrichSingle($availableBudget);
$resource = new Item($availableBudget, $transformer, 'available_budgets');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);

View File

@@ -43,14 +43,12 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -56,14 +56,12 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -74,25 +72,21 @@ class ListController extends Controller
*/
public function attachments(PaginationRequest $request, Bill $bill): JsonResponse
{
[
'limit' => $limit,
'offset' => $offset,
'page' => $page,
] = $request->attributes->all();
$manager = $this->getManager();
$collection = $this->repository->getAttachments($bill);
['limit' => $limit, 'offset' => $offset, 'page' => $page] = $request->attributes->all();
$manager = $this->getManager();
$collection = $this->repository->getAttachments($bill);
$count = $collection->count();
$attachments = $collection->slice($offset, $limit);
$count = $collection->count();
$attachments = $collection->slice($offset, $limit);
// make paginator:
$paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
$paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
$paginator->setPath(route('api.v1.bills.attachments', [$bill->id]).$this->buildParams());
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
$transformer = app(AttachmentTransformer::class);
$resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -106,24 +100,20 @@ class ListController extends Controller
*/
public function rules(PaginationRequest $request, Bill $bill): JsonResponse
{
[
'limit' => $limit,
'offset' => $offset,
'page' => $page,
] = $request->attributes->all();
['limit' => $limit, 'offset' => $offset, 'page' => $page] = $request->attributes->all();
$manager = $this->getManager();
$collection = $this->repository->getRulesForBill($bill);
$count = $collection->count();
$rules = $collection->slice($offset, $limit);
$manager = $this->getManager();
$collection = $this->repository->getRulesForBill($bill);
$count = $collection->count();
$rules = $collection->slice($offset, $limit);
// make paginator:
$paginator = new LengthAwarePaginator($rules, $count, $limit, $page);
$paginator = new LengthAwarePaginator($rules, $count, $limit, $page);
$paginator->setPath(route('api.v1.bills.rules', [$bill->id]).$this->buildParams());
/** @var RuleTransformer $transformer */
$transformer = app(RuleTransformer::class);
$resource = new FractalCollection($rules, $transformer, 'rules');
$transformer = app(RuleTransformer::class);
$resource = new FractalCollection($rules, $transformer, 'rules');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -137,22 +127,16 @@ class ListController extends Controller
*/
public function transactions(PaginationDateRangeRequest $request, Bill $bill): JsonResponse
{
[
'limit' => $limit,
'page' => $page,
'types' => $types,
'start' => $start,
'end' => $end,
] = $request->attributes->all();
['limit' => $limit, 'page' => $page, 'types' => $types, 'start' => $start, 'end' => $end] = $request->attributes->all();
$manager = $this->getManager();
$manager = $this->getManager();
/** @var User $admin */
$admin = auth()->user();
$admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector = app(GroupCollectorInterface::class);
$collector
->setUser($admin)
// include source + destination account name and type.
@@ -175,18 +159,18 @@ class ListController extends Controller
}
// get paginator.
$paginator = $collector->getPaginatedGroups();
$paginator = $collector->getPaginatedGroups();
$paginator->setPath(route('api.v1.bills.transactions', [$bill->id]).$this->buildParams());
// enrich
$enrichment = new TransactionGroupEnrichment();
$enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
$transactions = $enrichment->enrich($paginator->getCollection());
$transactions = $enrichment->enrich($paginator->getCollection());
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
$transformer = app(TransactionGroupTransformer::class);
$resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);

View File

@@ -51,14 +51,12 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -69,34 +67,28 @@ class ShowController extends Controller
*/
public function index(PaginationDateRangeRequest $request): JsonResponse
{
[
'limit' => $limit,
'offset' => $offset,
'start' => $start,
'end' => $end,
'page' => $page,
] = $request->attributes->all();
['limit' => $limit, 'offset' => $offset, 'start' => $start, 'end' => $end, 'page' => $page] = $request->attributes->all();
$this->repository->correctOrder();
$bills = $this->repository->getBills();
$manager = $this->getManager();
$count = $bills->count();
$bills = $bills->slice($offset, $limit);
$paginator = new LengthAwarePaginator($bills, $count, $limit, $page);
$bills = $this->repository->getBills();
$manager = $this->getManager();
$count = $bills->count();
$bills = $bills->slice($offset, $limit);
$paginator = new LengthAwarePaginator($bills, $count, $limit, $page);
// enrich
/** @var User $admin */
$admin = auth()->user();
$enrichment = new SubscriptionEnrichment();
$admin = auth()->user();
$enrichment = new SubscriptionEnrichment();
$enrichment->setUser($admin);
$enrichment->setStart($start);
$enrichment->setEnd($end);
$bills = $enrichment->enrich($bills);
$bills = $enrichment->enrich($bills);
/** @var BillTransformer $transformer */
$transformer = app(BillTransformer::class);
$transformer = app(BillTransformer::class);
$resource = new FractalCollection($bills, $transformer, 'bills');
$resource = new FractalCollection($bills, $transformer, 'bills');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -110,26 +102,23 @@ class ShowController extends Controller
*/
public function show(DateRangeRequest $request, Bill $bill): JsonResponse
{
[
'start' => $start,
'end' => $end,
] = $request->attributes->all();
['start' => $start, 'end' => $end] = $request->attributes->all();
$manager = $this->getManager();
$manager = $this->getManager();
// enrich
/** @var User $admin */
$admin = auth()->user();
$enrichment = new SubscriptionEnrichment();
$admin = auth()->user();
$enrichment = new SubscriptionEnrichment();
$enrichment->setUser($admin);
$enrichment->setStart($start);
$enrichment->setEnd($end);
$bill = $enrichment->enrichSingle($bill);
$bill = $enrichment->enrichSingle($bill);
/** @var BillTransformer $transformer */
$transformer = app(BillTransformer::class);
$transformer = app(BillTransformer::class);
$resource = new Item($bill, $transformer, 'bills');
$resource = new Item($bill, $transformer, 'bills');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}

View File

@@ -50,14 +50,12 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -47,14 +47,12 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -43,14 +43,12 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -49,7 +49,7 @@ class ListController extends Controller
use TransactionFilter;
private BudgetLimitRepositoryInterface $blRepository;
private BudgetRepositoryInterface $repository;
private BudgetRepositoryInterface $repository;
/**
* ListController constructor.
@@ -57,16 +57,14 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->blRepository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->blRepository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -120,7 +118,6 @@ class ListController extends Controller
$enrichment->setUser($admin);
$budgetLimits = $enrichment->enrich($budgetLimits);
/** @var BudgetLimitTransformer $transformer */
$transformer = app(BudgetLimitTransformer::class);
$transformer->setParameters($this->parameters);

View File

@@ -43,7 +43,7 @@ use League\Fractal\Resource\Item;
class ShowController extends Controller
{
private BudgetLimitRepositoryInterface $blRepository;
private BudgetRepositoryInterface $repository;
private BudgetRepositoryInterface $repository;
/**
* ListController constructor.
@@ -51,16 +51,14 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->blRepository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->blRepository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -47,14 +47,12 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -47,14 +47,12 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
public function update(UpdateRequest $request, Budget $budget): JsonResponse

View File

@@ -46,16 +46,14 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->blRepository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->blRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -47,7 +47,7 @@ use League\Fractal\Resource\Item;
class ShowController extends Controller
{
private BudgetLimitRepositoryInterface $blRepository;
private BudgetRepositoryInterface $repository;
private BudgetRepositoryInterface $repository;
/**
* BudgetLimitController constructor.
@@ -55,18 +55,16 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(BudgetRepositoryInterface::class);
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->repository->setUser($user);
$this->blRepository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(BudgetRepositoryInterface::class);
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->repository->setUser($user);
$this->blRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -88,7 +86,6 @@ class ShowController extends Controller
/** @var Budget $budget */
$budget = $enrichment->enrichSingle($budget);
$manager = $this->getManager();
$manager->parseIncludes('budget');
$pageSize = $this->parameters->get('limit');

View File

@@ -47,16 +47,14 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->blRepository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->blRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -52,16 +52,14 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->blRepository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->blRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -43,14 +43,12 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -54,14 +54,12 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -49,14 +49,12 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -47,14 +47,12 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -47,14 +47,12 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\CurrencyExchangeRate;
use Illuminate\Http\Request;
use Carbon\Carbon;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate\DestroyRequest;
@@ -35,26 +34,26 @@ use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\ExchangeRate\ExchangeRateRepositoryInterface;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class DestroyController extends Controller
{
use ValidatesUserGroupTrait;
public const string RESOURCE_KEY = 'exchange-rates';
protected array $acceptedRoles = [UserRoleEnum::OWNER];
private ExchangeRateRepositoryInterface $repository;
public function __construct()
{
parent::__construct();
$this->middleware(
function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
$this->middleware(function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
return $next($request);
}
);
return $next($request);
});
}
public function destroy(DestroyRequest $request, TransactionCurrency $from, TransactionCurrency $to): JsonResponse

View File

@@ -24,13 +24,13 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\CurrencyExchangeRate;
use Illuminate\Http\Request;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Enums\UserRoleEnum;
use FireflyIII\Repositories\ExchangeRate\ExchangeRateRepositoryInterface;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use FireflyIII\Transformers\ExchangeRateTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
/**
@@ -41,20 +41,19 @@ class IndexController extends Controller
use ValidatesUserGroupTrait;
public const string RESOURCE_KEY = 'exchange-rates';
protected array $acceptedRoles = [UserRoleEnum::OWNER];
private ExchangeRateRepositoryInterface $repository;
public function __construct()
{
parent::__construct();
$this->middleware(
function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
$this->middleware(function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
return $next($request);
}
);
return $next($request);
});
}
public function index(): JsonResponse
@@ -67,9 +66,6 @@ class IndexController extends Controller
$transformer = new ExchangeRateTransformer();
$transformer->setParameters($this->parameters); // give params to transformer
return response()
->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))
->header('Content-Type', self::CONTENT_TYPE)
;
return response()->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\CurrencyExchangeRate;
use Illuminate\Http\Request;
use Carbon\Carbon;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Enums\UserRoleEnum;
@@ -34,6 +33,7 @@ use FireflyIII\Repositories\ExchangeRate\ExchangeRateRepositoryInterface;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use FireflyIII\Transformers\ExchangeRateTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -45,20 +45,19 @@ class ShowController extends Controller
use ValidatesUserGroupTrait;
public const string RESOURCE_KEY = 'exchange-rates';
protected array $acceptedRoles = [UserRoleEnum::OWNER];
private ExchangeRateRepositoryInterface $repository;
public function __construct()
{
parent::__construct();
$this->middleware(
function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
$this->middleware(function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
return $next($request);
}
);
return $next($request);
});
}
public function show(TransactionCurrency $from, TransactionCurrency $to): JsonResponse
@@ -73,10 +72,7 @@ class ShowController extends Controller
$transformer = new ExchangeRateTransformer();
$transformer->setParameters($this->parameters); // give params to transformer
return response()
->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))
->header('Content-Type', self::CONTENT_TYPE)
;
return response()->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
public function showSingleById(CurrencyExchangeRate $exchangeRate): JsonResponse
@@ -84,10 +80,7 @@ class ShowController extends Controller
$transformer = new ExchangeRateTransformer();
$transformer->setParameters($this->parameters);
return response()
->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))
->header('Content-Type', self::CONTENT_TYPE)
;
return response()->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
public function showSingleByDate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): JsonResponse
@@ -100,9 +93,6 @@ class ShowController extends Controller
throw new NotFoundHttpException();
}
return response()
->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))
->header('Content-Type', self::CONTENT_TYPE)
;
return response()->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\CurrencyExchangeRate;
use Illuminate\Http\Request;
use Carbon\Carbon;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate\StoreByCurrenciesRequest;
@@ -38,6 +37,7 @@ use FireflyIII\Support\Facades\Amount;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use FireflyIII\Transformers\ExchangeRateTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
@@ -45,26 +45,24 @@ class StoreController extends Controller
{
use ValidatesUserGroupTrait;
public const string RESOURCE_KEY = 'exchange-rates';
protected array $acceptedRoles = [UserRoleEnum::OWNER];
public const string RESOURCE_KEY = 'exchange-rates';
protected array $acceptedRoles = [UserRoleEnum::OWNER];
private ExchangeRateRepositoryInterface $repository;
public function __construct()
{
parent::__construct();
$this->middleware(
function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
$this->middleware(function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
return $next($request);
}
);
return $next($request);
});
}
public function storeByCurrencies(StoreByCurrenciesRequest $request, TransactionCurrency $from, TransactionCurrency $to): JsonResponse
{
$data = $request->getAll();
$collection = new Collection();
@@ -87,15 +85,11 @@ class StoreController extends Controller
$transformer = new ExchangeRateTransformer();
$transformer->setParameters($this->parameters); // give params to transformer
return response()
->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))
->header('Content-Type', self::CONTENT_TYPE)
;
return response()->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
public function storeByDate(StoreByDateRequest $request, Carbon $date): JsonResponse
{
$data = $request->getAll();
$from = $request->getFromCurrency();
$collection = new Collection();
@@ -118,10 +112,7 @@ class StoreController extends Controller
$transformer = new ExchangeRateTransformer();
$transformer->setParameters($this->parameters); // give params to transformer
return response()
->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))
->header('Content-Type', self::CONTENT_TYPE)
;
return response()->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
public function store(StoreRequest $request): JsonResponse
@@ -145,9 +136,6 @@ class StoreController extends Controller
$transformer = new ExchangeRateTransformer();
$transformer->setParameters($this->parameters);
return response()
->api($this->jsonApiObject(self::RESOURCE_KEY, $rate, $transformer))
->header('Content-Type', self::CONTENT_TYPE)
;
return response()->api($this->jsonApiObject(self::RESOURCE_KEY, $rate, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\CurrencyExchangeRate;
use Illuminate\Http\Request;
use Carbon\Carbon;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate\UpdateRequest;
@@ -35,27 +34,27 @@ use FireflyIII\Repositories\ExchangeRate\ExchangeRateRepositoryInterface;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use FireflyIII\Transformers\ExchangeRateTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class UpdateController extends Controller
{
use ValidatesUserGroupTrait;
public const string RESOURCE_KEY = 'exchange-rates';
protected array $acceptedRoles = [UserRoleEnum::OWNER];
public const string RESOURCE_KEY = 'exchange-rates';
protected array $acceptedRoles = [UserRoleEnum::OWNER];
private ExchangeRateRepositoryInterface $repository;
public function __construct()
{
parent::__construct();
$this->middleware(
function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
$this->middleware(function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
return $next($request);
}
);
return $next($request);
});
}
public function updateById(UpdateRequest $request, CurrencyExchangeRate $exchangeRate): JsonResponse
@@ -66,10 +65,7 @@ class UpdateController extends Controller
$transformer = new ExchangeRateTransformer();
$transformer->setParameters($this->parameters);
return response()
->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))
->header('Content-Type', self::CONTENT_TYPE)
;
return response()->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
public function updateByDate(UpdateRequest $request, TransactionCurrency $from, TransactionCurrency $to, Carbon $date): JsonResponse
@@ -84,9 +80,6 @@ class UpdateController extends Controller
$transformer = new ExchangeRateTransformer();
return response()
->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))
->header('Content-Type', self::CONTENT_TYPE)
;
return response()->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -44,16 +44,14 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -50,16 +50,14 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -48,16 +48,14 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -46,16 +46,14 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -43,14 +43,12 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -51,14 +51,12 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -49,14 +49,12 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -114,7 +112,6 @@ class ShowController extends Controller
$enrichment->setUser($admin);
$piggyBank = $enrichment->enrichSingle($piggyBank);
/** @var PiggyBankTransformer $transformer */
$transformer = app(PiggyBankTransformer::class);
$transformer->setParameters($this->parameters);

View File

@@ -47,14 +47,12 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -47,14 +47,12 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -43,14 +43,12 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -52,14 +52,12 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -49,14 +49,12 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -47,14 +47,12 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -1,6 +1,7 @@
<?php
declare(strict_types=1);
/*
* TriggerController.php
* Copyright (c) 2025 james@firefly-iii.org
@@ -50,14 +51,12 @@ class TriggerController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
public function trigger(SingleDateRequest $request, Recurrence $recurrence): JsonResponse
@@ -95,11 +94,7 @@ class TriggerController extends Controller
// use new group collector:
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector
->setUser($admin)
->setIds($groups->pluck('id')->toArray())
->withAPIInformation()
;
$collector->setUser($admin)->setIds($groups->pluck('id')->toArray())->withAPIInformation();
$paginator = $collector->getPaginatedGroups();
}

View File

@@ -47,14 +47,12 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -44,17 +44,15 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -41,8 +41,6 @@ class ExpressionController extends Controller
*/
public function validateExpression(ValidateExpressionRequest $request): JsonResponse
{
return response()->json([
'valid' => true,
]);
return response()->json(['valid' => true]);
}
}

View File

@@ -48,17 +48,15 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -45,17 +45,15 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -52,17 +52,15 @@ class TriggerController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -80,15 +78,15 @@ class TriggerController extends Controller
// overrule the rule(s) if necessary.
if (array_key_exists('start', $parameters) && null !== $parameters['start']) {
// add a range:
$ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]);
$ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]);
}
if (array_key_exists('end', $parameters) && null !== $parameters['end']) {
// add a range:
$ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]);
$ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]);
}
if (array_key_exists('accounts', $parameters) && '' !== $parameters['accounts']) {
$ruleEngine->addOperator(['type' => 'account_id', 'value' => implode(',', $parameters['accounts'])]);
$ruleEngine->addOperator(['type' => 'account_id', 'value' => implode(',', $parameters['accounts'])]);
}
// file the rule(s)
@@ -134,15 +132,15 @@ class TriggerController extends Controller
// overrule the rule(s) if necessary.
if (array_key_exists('start', $parameters) && null !== $parameters['start']) {
// add a range:
$ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]);
$ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]);
}
if (array_key_exists('end', $parameters) && null !== $parameters['end']) {
// add a range:
$ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]);
$ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]);
}
if (array_key_exists('accounts', $parameters) && is_array($parameters['accounts']) && count($parameters['accounts']) > 0) {
$ruleEngine->addOperator(['type' => 'account_id', 'value' => implode(',', $parameters['accounts'])]);
$ruleEngine->addOperator(['type' => 'account_id', 'value' => implode(',', $parameters['accounts'])]);
}
// fire the rule(s)

View File

@@ -46,17 +46,15 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -44,17 +44,15 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -47,17 +47,15 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -48,17 +48,15 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -38,7 +38,7 @@ use League\Fractal\Resource\Item;
*/
class StoreController extends Controller
{
private AccountRepositoryInterface $accountRepository;
private AccountRepositoryInterface $accountRepository;
private RuleGroupRepositoryInterface $ruleGroupRepository;
/**
@@ -47,20 +47,18 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
$this->accountRepository = app(AccountRepositoryInterface::class);
$this->accountRepository->setUser($user);
$this->accountRepository = app(AccountRepositoryInterface::class);
$this->accountRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -53,17 +53,15 @@ class TriggerController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -87,15 +85,15 @@ class TriggerController extends Controller
// overrule the rule(s) if necessary.
if (array_key_exists('start', $parameters) && null !== $parameters['start']) {
// add a range:
$ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]);
$ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]);
}
if (array_key_exists('end', $parameters) && null !== $parameters['end']) {
// add a range:
$ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]);
$ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]);
}
if (array_key_exists('accounts', $parameters) && '' !== $parameters['accounts']) {
$ruleEngine->addOperator(['type' => 'account_id', 'value' => implode(',', $parameters['accounts'])]);
$ruleEngine->addOperator(['type' => 'account_id', 'value' => implode(',', $parameters['accounts'])]);
}
// file the rule(s)
@@ -148,15 +146,15 @@ class TriggerController extends Controller
// overrule the rule(s) if necessary.
if (array_key_exists('start', $parameters) && null !== $parameters['start']) {
// add a range:
$ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]);
$ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]);
}
if (array_key_exists('end', $parameters) && null !== $parameters['end']) {
// add a range:
$ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]);
$ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]);
}
if (array_key_exists('accounts', $parameters) && is_array($parameters['accounts']) && count($parameters['accounts']) > 0) {
$ruleEngine->addOperator(['type' => 'account_id', 'value' => implode(',', $parameters['accounts'])]);
$ruleEngine->addOperator(['type' => 'account_id', 'value' => implode(',', $parameters['accounts'])]);
}
// file the rule(s)

View File

@@ -46,17 +46,15 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -44,17 +44,15 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -54,17 +54,15 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -143,7 +141,6 @@ class ListController extends Controller
$enrichment->setUser($admin);
$transactions = $enrichment->enrich($paginator->getCollection());
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);

View File

@@ -48,17 +48,15 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -45,17 +45,15 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -46,17 +46,15 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -51,20 +51,18 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $admin */
$admin = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $admin */
$admin = auth()->user();
$this->repository = app(JournalRepositoryInterface::class);
$this->repository->setUser($admin);
$this->repository = app(JournalRepositoryInterface::class);
$this->repository->setUser($admin);
$this->groupRepository = app(TransactionGroupRepository::class);
$this->groupRepository->setUser($admin);
$this->groupRepository = app(TransactionGroupRepository::class);
$this->groupRepository->setUser($admin);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -52,17 +52,15 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $admin */
$admin = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $admin */
$admin = auth()->user();
$this->journalAPIRepository = app(JournalAPIRepositoryInterface::class);
$this->journalAPIRepository->setUser($admin);
$this->journalAPIRepository = app(JournalAPIRepositoryInterface::class);
$this->journalAPIRepository->setUser($admin);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -144,7 +144,6 @@ class ShowController extends Controller
$enrichment->setUser($admin);
$selectedGroup = $enrichment->enrichSingle($selectedGroup);
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\Transaction;
use Illuminate\Http\Request;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Models\Transaction\StoreRequest;
use FireflyIII\Enums\UserRoleEnum;
@@ -40,6 +39,7 @@ use FireflyIII\Support\JsonApi\Enrichments\TransactionGroupEnrichment;
use FireflyIII\Transformers\TransactionGroupTransformer;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationException;
@@ -63,19 +63,17 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function (Request $request, $next) {
/** @var User $admin */
$admin = auth()->user();
$userGroup = $this->validateUserGroup($request);
$this->middleware(function (Request $request, $next) {
/** @var User $admin */
$admin = auth()->user();
$userGroup = $this->validateUserGroup($request);
$this->groupRepository = app(TransactionGroupRepositoryInterface::class);
$this->groupRepository->setUser($admin);
$this->groupRepository->setUserGroup($userGroup);
$this->groupRepository = app(TransactionGroupRepositoryInterface::class);
$this->groupRepository->setUser($admin);
$this->groupRepository->setUserGroup($userGroup);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -93,7 +91,6 @@ class StoreController extends Controller
$data['user'] = auth()->user();
$data['user_group'] = $this->userGroup;
Log::channel('audit')->info('Store new transaction over API.', $data);
try {

View File

@@ -52,17 +52,15 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $admin */
$admin = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $admin */
$admin = auth()->user();
$this->groupRepository = app(TransactionGroupRepositoryInterface::class);
$this->groupRepository->setUser($admin);
$this->groupRepository = app(TransactionGroupRepositoryInterface::class);
$this->groupRepository->setUser($admin);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -41,7 +41,7 @@ use Illuminate\Validation\ValidationException;
class DestroyController extends Controller
{
private CurrencyRepositoryInterface $repository;
private UserRepositoryInterface $userRepository;
private UserRepositoryInterface $userRepository;
/**
* CurrencyRepository constructor.
@@ -49,15 +49,13 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(CurrencyRepositoryInterface::class);
$this->userRepository = app(UserRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(CurrencyRepositoryInterface::class);
$this->userRepository = app(UserRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -89,13 +89,11 @@ class ListController extends Controller
$unfiltered = $accountRepository->getAccountsByType($types);
// filter list on currency preference:
$collection = $unfiltered->filter(
static function (Account $account) use ($currency, $accountRepository): bool {
$currencyId = (int) $accountRepository->getMetaValue($account, 'currency_id');
$collection = $unfiltered->filter(static function (Account $account) use ($currency, $accountRepository): bool {
$currencyId = (int) $accountRepository->getMetaValue($account, 'currency_id');
return $currencyId === $currency->id;
}
);
return $currencyId === $currency->id;
});
$count = $collection->count();
$accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
@@ -177,9 +175,7 @@ class ListController extends Controller
$unfiltered = $billRepos->getBills();
// filter and paginate list:
$collection = $unfiltered->filter(
static fn (Bill $bill): bool => $bill->transaction_currency_id === $currency->id
);
$collection = $unfiltered->filter(static fn (Bill $bill): bool => $bill->transaction_currency_id === $currency->id);
$count = $collection->count();
$bills = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
@@ -260,15 +256,16 @@ class ListController extends Controller
$unfiltered = $recurringRepos->get();
// filter selection
$collection = $unfiltered->filter(
static function (Recurrence $recurrence) use ($currency): ?Recurrence { // @phpstan-ignore-line
if (array_any($recurrence->recurrenceTransactions, static fn ($transaction): bool => $transaction->transaction_currency_id === $currency->id || $transaction->foreign_currency_id === $currency->id)) {
return $recurrence;
}
return null;
$collection = $unfiltered->filter(static function (Recurrence $recurrence) use ($currency): null|Recurrence { // @phpstan-ignore-line
if (array_any(
$recurrence->recurrenceTransactions,
static fn ($transaction): bool => $transaction->transaction_currency_id === $currency->id || $transaction->foreign_currency_id === $currency->id
)) {
return $recurrence;
}
);
return null;
});
$count = $collection->count();
$recurrences = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
@@ -309,15 +306,16 @@ class ListController extends Controller
$ruleRepos = app(RuleRepositoryInterface::class);
$unfiltered = $ruleRepos->getAll();
$collection = $unfiltered->filter(
static function (Rule $rule) use ($currency): ?Rule { // @phpstan-ignore-line
if (array_any($rule->ruleTriggers, static fn ($trigger): bool => 'currency_is' === $trigger->trigger_type && $currency->name === $trigger->trigger_value)) {
return $rule;
}
return null;
$collection = $unfiltered->filter(static function (Rule $rule) use ($currency): null|Rule { // @phpstan-ignore-line
if (array_any(
$rule->ruleTriggers,
static fn ($trigger): bool => 'currency_is' === $trigger->trigger_type && $currency->name === $trigger->trigger_value
)) {
return $rule;
}
);
return null;
});
$count = $collection->count();
$rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);

View File

@@ -53,14 +53,12 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(CurrencyRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(CurrencyRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -51,14 +51,12 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(CurrencyRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(CurrencyRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -54,14 +54,12 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(CurrencyRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(CurrencyRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -44,18 +44,16 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->repository->setUser($user);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -49,18 +49,16 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->repository->setUser($user);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -43,7 +43,7 @@ class StoreController extends Controller
{
use TransactionFilter;
private JournalRepositoryInterface $journalRepository;
private JournalRepositoryInterface $journalRepository;
private LinkTypeRepositoryInterface $repository;
/**
@@ -52,20 +52,18 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->journalRepository = app(JournalRepositoryInterface::class);
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->journalRepository = app(JournalRepositoryInterface::class);
$this->repository->setUser($user);
$this->journalRepository->setUser($user);
$this->repository->setUser($user);
$this->journalRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -39,7 +39,7 @@ use League\Fractal\Resource\Item;
*/
class UpdateController extends Controller
{
private JournalRepositoryInterface $journalRepository;
private JournalRepositoryInterface $journalRepository;
private LinkTypeRepositoryInterface $repository;
/**
@@ -48,20 +48,18 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->journalRepository = app(JournalRepositoryInterface::class);
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->journalRepository = app(JournalRepositoryInterface::class);
$this->repository->setUser($user);
$this->journalRepository->setUser($user);
$this->repository->setUser($user);
$this->journalRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

View File

@@ -48,16 +48,14 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

Some files were not shown because too many files have changed in this diff Show More