From b717148058d49c250140a6f9163ff6d346b81c71 Mon Sep 17 00:00:00 2001 From: Philipp Lang Date: Fri, 28 Oct 2022 12:01:04 +0200 Subject: [PATCH] Add TeX Package --- .gitmodules | 3 + app/Efz/EfzDocument.php | 47 ++++++ app/Efz/ShowEfzDocumentAction.php | 24 +++ app/Member/Member.php | 12 ++ app/Pdf/MemberEfzController.php | 14 -- app/Pdf/Sender.php | 21 +++ composer.json | 6 +- composer.lock | 268 +++++++++++++++++------------- packages/tex | 1 + phpstan.neon | 1 + resources/views/tex/efz.tex | 8 +- routes/web.php | 4 +- tests/Feature/Pdf/EfzTest.php | 35 ++++ 13 files changed, 308 insertions(+), 136 deletions(-) create mode 100644 app/Efz/EfzDocument.php create mode 100644 app/Efz/ShowEfzDocumentAction.php delete mode 100644 app/Pdf/MemberEfzController.php create mode 100644 app/Pdf/Sender.php create mode 160000 packages/tex diff --git a/.gitmodules b/.gitmodules index 3d312a7c..2e1c3495 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "packages/laravel-nami"] path = packages/laravel-nami url = git@github.com:DPSGKoeln/laravel-nami.git +[submodule "packages/tex"] + path = packages/tex + url = git@zoomyboy.de:pille/tex.git diff --git a/app/Efz/EfzDocument.php b/app/Efz/EfzDocument.php new file mode 100644 index 00000000..43e2181f --- /dev/null +++ b/app/Efz/EfzDocument.php @@ -0,0 +1,47 @@ +name = $member->fullname; + $this->slug = $member->slug; + $this->secondLine = "geb. am {$member->birthday->format('d.m.Y')}, wohnhaft in {$member->location}"; + $this->now = now()->format('d.m.Y'); + $this->sender = $member->toSender(); + } + + public function basename(): string + { + return "efz-fuer-{$this->slug}"; + } + + public function getEngine(): Engine + { + return Engine::PDFLATEX; + } + + public function template(): Template + { + return Template::make('tex.templates.efz'); + } + + public function view(): string + { + return 'tex.efz'; + } +} diff --git a/app/Efz/ShowEfzDocumentAction.php b/app/Efz/ShowEfzDocumentAction.php new file mode 100644 index 00000000..c5e35dd0 --- /dev/null +++ b/app/Efz/ShowEfzDocumentAction.php @@ -0,0 +1,24 @@ +handle($member); + } +} diff --git a/app/Member/Member.php b/app/Member/Member.php index 623436c3..420e96a5 100644 --- a/app/Member/Member.php +++ b/app/Member/Member.php @@ -11,6 +11,7 @@ use App\Group; use App\Nationality; use App\Payment\Payment; use App\Payment\Subscription; +use App\Pdf\Sender; use App\Region; use App\Setting\NamiSettings; use App\Subactivity; @@ -24,6 +25,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Notifications\Notifiable; use Sabre\VObject\Component\VCard; use Sabre\VObject\Reader; +use Spatie\LaravelData\Lazy; use Zoomyboy\LaravelNami\Api; use Zoomyboy\LaravelNami\Data\MembershipEntry; @@ -446,4 +448,14 @@ class Member extends Model return $card; } + + public function toSender(): Sender + { + return Sender::from([ + 'name' => $this->fullname, + 'address' => $this->address, + 'zipLocation' => $this->zip.' '.$this->location, + 'mglnr' => Lazy::create(fn () => 'Mglnr.: '.$this->nami_id), + ]); + } } diff --git a/app/Pdf/MemberEfzController.php b/app/Pdf/MemberEfzController.php deleted file mode 100644 index e43e0e07..00000000 --- a/app/Pdf/MemberEfzController.php +++ /dev/null @@ -1,14 +0,0 @@ -setRepository($data)->render(); - } -} diff --git a/app/Pdf/Sender.php b/app/Pdf/Sender.php new file mode 100644 index 00000000..20aa7752 --- /dev/null +++ b/app/Pdf/Sender.php @@ -0,0 +1,21 @@ + + */ + public function values(): array + { + return array_values($this->include('mglnr')->toArray()); + } +} diff --git a/composer.json b/composer.json index cde85b10..e6d10321 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,8 @@ "laravel" ], "repositories": [ - { "type": "path", "url": "./packages/laravel-nami", "options": {"symlink": true} } + { "type": "path", "url": "./packages/laravel-nami", "options": {"symlink": true} }, + { "type": "path", "url": "./packages/tex", "options": {"symlink": true} } ], "license": "MIT", "require": { @@ -31,7 +32,8 @@ "spatie/laravel-medialibrary": "^10.0", "spatie/laravel-settings": "^2.2", "worksome/request-factories": "^2.5", - "zoomyboy/laravel-nami": "dev-master" + "zoomyboy/laravel-nami": "dev-master", + "zoomyboy/tex": "dev-main as 1.0" }, "require-dev": { "fakerphp/faker": "^1.9.1", diff --git a/composer.lock b/composer.lock index 29bbdc3b..1f536dfd 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "636d4f83830d3a56848cfaca9a395a8a", + "content-hash": "77a195281ef8e4e20e6e5f9a6d36c752", "packages": [ { "name": "beyondcode/laravel-dump-server", @@ -276,16 +276,16 @@ }, { "name": "dflydev/dot-access-data", - "version": "v3.0.1", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/dflydev/dflydev-dot-access-data.git", - "reference": "0992cc19268b259a39e86f296da5f0677841f42c" + "reference": "f41715465d65213d644d3141a6a93081be5d3549" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dflydev/dflydev-dot-access-data/zipball/0992cc19268b259a39e86f296da5f0677841f42c", - "reference": "0992cc19268b259a39e86f296da5f0677841f42c", + "url": "https://api.github.com/repos/dflydev/dflydev-dot-access-data/zipball/f41715465d65213d644d3141a6a93081be5d3549", + "reference": "f41715465d65213d644d3141a6a93081be5d3549", "shasum": "" }, "require": { @@ -296,7 +296,7 @@ "phpunit/phpunit": "^7.5 || ^8.5 || ^9.3", "scrutinizer/ocular": "1.6.0", "squizlabs/php_codesniffer": "^3.5", - "vimeo/psalm": "^3.14" + "vimeo/psalm": "^4.0.0" }, "type": "library", "extra": { @@ -345,9 +345,9 @@ ], "support": { "issues": "https://github.com/dflydev/dflydev-dot-access-data/issues", - "source": "https://github.com/dflydev/dflydev-dot-access-data/tree/v3.0.1" + "source": "https://github.com/dflydev/dflydev-dot-access-data/tree/v3.0.2" }, - "time": "2021-08-13T13:06:58+00:00" + "time": "2022-10-27T11:44:00+00:00" }, { "name": "doctrine/cache", @@ -444,23 +444,23 @@ }, { "name": "doctrine/dbal", - "version": "3.4.5", + "version": "3.5.1", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "a5a58773109c0abb13e658c8ccd92aeec8d07f9e" + "reference": "f38ee8aaca2d58ee88653cb34a6a3880c23f38a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/a5a58773109c0abb13e658c8ccd92aeec8d07f9e", - "reference": "a5a58773109c0abb13e658c8ccd92aeec8d07f9e", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/f38ee8aaca2d58ee88653cb34a6a3880c23f38a5", + "reference": "f38ee8aaca2d58ee88653cb34a6a3880c23f38a5", "shasum": "" }, "require": { "composer-runtime-api": "^2", "doctrine/cache": "^1.11|^2.0", "doctrine/deprecations": "^0.5.3|^1", - "doctrine/event-manager": "^1.0", + "doctrine/event-manager": "^1|^2", "php": "^7.4 || ^8.0", "psr/cache": "^1|^2|^3", "psr/log": "^1|^2|^3" @@ -468,14 +468,14 @@ "require-dev": { "doctrine/coding-standard": "10.0.0", "jetbrains/phpstorm-stubs": "2022.2", - "phpstan/phpstan": "1.8.3", - "phpstan/phpstan-strict-rules": "^1.3", - "phpunit/phpunit": "9.5.24", + "phpstan/phpstan": "1.8.10", + "phpstan/phpstan-strict-rules": "^1.4", + "phpunit/phpunit": "9.5.25", "psalm/plugin-phpunit": "0.17.0", "squizlabs/php_codesniffer": "3.7.1", "symfony/cache": "^5.4|^6.0", "symfony/console": "^4.4|^5.4|^6.0", - "vimeo/psalm": "4.27.0" + "vimeo/psalm": "4.29.0" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." @@ -535,7 +535,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/3.4.5" + "source": "https://github.com/doctrine/dbal/tree/3.5.1" }, "funding": [ { @@ -551,7 +551,7 @@ "type": "tidelift" } ], - "time": "2022-09-23T17:48:57+00:00" + "time": "2022-10-24T07:26:18+00:00" }, { "name": "doctrine/deprecations", @@ -598,30 +598,29 @@ }, { "name": "doctrine/event-manager", - "version": "1.2.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/event-manager.git", - "reference": "95aa4cb529f1e96576f3fda9f5705ada4056a520" + "reference": "750671534e0241a7c50ea5b43f67e23eb5c96f32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/event-manager/zipball/95aa4cb529f1e96576f3fda9f5705ada4056a520", - "reference": "95aa4cb529f1e96576f3fda9f5705ada4056a520", + "url": "https://api.github.com/repos/doctrine/event-manager/zipball/750671534e0241a7c50ea5b43f67e23eb5c96f32", + "reference": "750671534e0241a7c50ea5b43f67e23eb5c96f32", "shasum": "" }, "require": { - "doctrine/deprecations": "^0.5.3 || ^1", - "php": "^7.1 || ^8.0" + "php": "^8.1" }, "conflict": { "doctrine/common": "<2.9" }, "require-dev": { - "doctrine/coding-standard": "^9 || ^10", - "phpstan/phpstan": "~1.4.10 || ^1.8.8", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.24" + "doctrine/coding-standard": "^10", + "phpstan/phpstan": "^1.8.8", + "phpunit/phpunit": "^9.5", + "vimeo/psalm": "^4.28" }, "type": "library", "autoload": { @@ -670,7 +669,7 @@ ], "support": { "issues": "https://github.com/doctrine/event-manager/issues", - "source": "https://github.com/doctrine/event-manager/tree/1.2.0" + "source": "https://github.com/doctrine/event-manager/tree/2.0.0" }, "funding": [ { @@ -686,27 +685,27 @@ "type": "tidelift" } ], - "time": "2022-10-12T20:51:15+00:00" + "time": "2022-10-12T20:59:15+00:00" }, { "name": "doctrine/inflector", - "version": "2.0.5", + "version": "2.0.6", "source": { "type": "git", "url": "https://github.com/doctrine/inflector.git", - "reference": "ade2b3bbfb776f27f0558e26eed43b5d9fe1b392" + "reference": "d9d313a36c872fd6ee06d9a6cbcf713eaa40f024" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/ade2b3bbfb776f27f0558e26eed43b5d9fe1b392", - "reference": "ade2b3bbfb776f27f0558e26eed43b5d9fe1b392", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/d9d313a36c872fd6ee06d9a6cbcf713eaa40f024", + "reference": "d9d313a36c872fd6ee06d9a6cbcf713eaa40f024", "shasum": "" }, "require": { "php": "^7.2 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^9", + "doctrine/coding-standard": "^10", "phpstan/phpstan": "^1.8", "phpstan/phpstan-phpunit": "^1.1", "phpstan/phpstan-strict-rules": "^1.3", @@ -761,7 +760,7 @@ ], "support": { "issues": "https://github.com/doctrine/inflector/issues", - "source": "https://github.com/doctrine/inflector/tree/2.0.5" + "source": "https://github.com/doctrine/inflector/tree/2.0.6" }, "funding": [ { @@ -777,7 +776,7 @@ "type": "tidelift" } ], - "time": "2022-09-07T09:01:28+00:00" + "time": "2022-10-20T09:10:12+00:00" }, { "name": "doctrine/instantiator", @@ -1472,16 +1471,16 @@ }, { "name": "guzzlehttp/psr7", - "version": "2.4.1", + "version": "2.4.3", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "69568e4293f4fa993f3b0e51c9723e1e17c41379" + "reference": "67c26b443f348a51926030c83481b85718457d3d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/69568e4293f4fa993f3b0e51c9723e1e17c41379", - "reference": "69568e4293f4fa993f3b0e51c9723e1e17c41379", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/67c26b443f348a51926030c83481b85718457d3d", + "reference": "67c26b443f348a51926030c83481b85718457d3d", "shasum": "" }, "require": { @@ -1571,7 +1570,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.4.1" + "source": "https://github.com/guzzle/psr7/tree/2.4.3" }, "funding": [ { @@ -1587,7 +1586,7 @@ "type": "tidelift" } ], - "time": "2022-08-28T14:45:39+00:00" + "time": "2022-10-26T14:07:24+00:00" }, { "name": "inertiajs/inertia-laravel", @@ -1730,16 +1729,16 @@ }, { "name": "laravel/framework", - "version": "v9.36.3", + "version": "v9.37.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "80ba0561b3682b96743e1c152fde0698bbdb2412" + "reference": "0c9675abf6d966e834b2ebeca3319f524e07a330" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/80ba0561b3682b96743e1c152fde0698bbdb2412", - "reference": "80ba0561b3682b96743e1c152fde0698bbdb2412", + "url": "https://api.github.com/repos/laravel/framework/zipball/0c9675abf6d966e834b2ebeca3319f524e07a330", + "reference": "0c9675abf6d966e834b2ebeca3319f524e07a330", "shasum": "" }, "require": { @@ -1751,7 +1750,7 @@ "fruitcake/php-cors": "^1.2", "laravel/serializable-closure": "^1.2.2", "league/commonmark": "^2.2", - "league/flysystem": "^3.0.16", + "league/flysystem": "^3.8.0", "monolog/monolog": "^2.0", "nesbot/carbon": "^2.62.1", "nunomaduro/termwind": "^1.13", @@ -1912,20 +1911,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-10-19T13:23:53+00:00" + "time": "2022-10-25T15:43:46+00:00" }, { "name": "laravel/horizon", - "version": "v5.10.2", + "version": "v5.10.3", "source": { "type": "git", "url": "https://github.com/laravel/horizon.git", - "reference": "de84bf86ffee940fa92e29c54d41618048ec9b6f" + "reference": "22403726851d62c45051114c89106130c348decc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/horizon/zipball/de84bf86ffee940fa92e29c54d41618048ec9b6f", - "reference": "de84bf86ffee940fa92e29c54d41618048ec9b6f", + "url": "https://api.github.com/repos/laravel/horizon/zipball/22403726851d62c45051114c89106130c348decc", + "reference": "22403726851d62c45051114c89106130c348decc", "shasum": "" }, "require": { @@ -1987,9 +1986,9 @@ ], "support": { "issues": "https://github.com/laravel/horizon/issues", - "source": "https://github.com/laravel/horizon/tree/v5.10.2" + "source": "https://github.com/laravel/horizon/tree/v5.10.3" }, - "time": "2022-09-26T13:45:51+00:00" + "time": "2022-10-14T13:33:44+00:00" }, { "name": "laravel/serializable-closure", @@ -2053,16 +2052,16 @@ }, { "name": "laravel/telescope", - "version": "v4.9.4", + "version": "v4.9.5", "source": { "type": "git", "url": "https://github.com/laravel/telescope.git", - "reference": "ca8bec380ecef80d00ce6daecac2dc17c7e35ccd" + "reference": "a316d6d15793b559c51ccb4b5dc59b223da500e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/telescope/zipball/ca8bec380ecef80d00ce6daecac2dc17c7e35ccd", - "reference": "ca8bec380ecef80d00ce6daecac2dc17c7e35ccd", + "url": "https://api.github.com/repos/laravel/telescope/zipball/a316d6d15793b559c51ccb4b5dc59b223da500e5", + "reference": "a316d6d15793b559c51ccb4b5dc59b223da500e5", "shasum": "" }, "require": { @@ -2115,9 +2114,9 @@ ], "support": { "issues": "https://github.com/laravel/telescope/issues", - "source": "https://github.com/laravel/telescope/tree/v4.9.4" + "source": "https://github.com/laravel/telescope/tree/v4.9.5" }, - "time": "2022-10-03T14:55:50+00:00" + "time": "2022-10-06T14:01:10+00:00" }, { "name": "laravel/tinker", @@ -2438,16 +2437,16 @@ }, { "name": "league/flysystem", - "version": "3.9.0", + "version": "3.10.2", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "60f3760352fe08e918bc3b1acae4e91af092ebe1" + "reference": "b9bd194b016114d6ff6765c09d40c7d427e4e3f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/60f3760352fe08e918bc3b1acae4e91af092ebe1", - "reference": "60f3760352fe08e918bc3b1acae4e91af092ebe1", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/b9bd194b016114d6ff6765c09d40c7d427e4e3f6", + "reference": "b9bd194b016114d6ff6765c09d40c7d427e4e3f6", "shasum": "" }, "require": { @@ -2463,7 +2462,7 @@ }, "require-dev": { "async-aws/s3": "^1.5", - "async-aws/simple-s3": "^1.0", + "async-aws/simple-s3": "^1.1", "aws/aws-sdk-php": "^3.198.1", "composer/semver": "^3.0", "ext-fileinfo": "*", @@ -2509,7 +2508,7 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem/issues", - "source": "https://github.com/thephpleague/flysystem/tree/3.9.0" + "source": "https://github.com/thephpleague/flysystem/tree/3.10.2" }, "funding": [ { @@ -2525,7 +2524,7 @@ "type": "tidelift" } ], - "time": "2022-10-18T21:02:43+00:00" + "time": "2022-10-25T07:01:47+00:00" }, { "name": "league/glide", @@ -2650,25 +2649,26 @@ }, { "name": "lorisleiva/laravel-actions", - "version": "v2.4.0", + "version": "v2.4.1", "source": { "type": "git", "url": "https://github.com/lorisleiva/laravel-actions.git", - "reference": "4e60c9fbdfcea7d9977d882f3104c8996b43c169" + "reference": "6701206501fcb048f1bba33b84a5a174188cadb7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/lorisleiva/laravel-actions/zipball/4e60c9fbdfcea7d9977d882f3104c8996b43c169", - "reference": "4e60c9fbdfcea7d9977d882f3104c8996b43c169", + "url": "https://api.github.com/repos/lorisleiva/laravel-actions/zipball/6701206501fcb048f1bba33b84a5a174188cadb7", + "reference": "6701206501fcb048f1bba33b84a5a174188cadb7", "shasum": "" }, "require": { - "illuminate/contracts": "^8.15|^9.0", + "illuminate/contracts": "^8.15 || 9.0 - 9.34 || ^9.36", "lorisleiva/lody": "^0.3.0", "php": "^8.0" }, "require-dev": { - "orchestra/testbench": "^7.0", + "orchestra/testbench": "7.0.0", + "orchestra/testbench-core": "7.0.0", "pestphp/pest": "^1.2", "phpunit/phpunit": "^9.5" }, @@ -2713,7 +2713,7 @@ ], "support": { "issues": "https://github.com/lorisleiva/laravel-actions/issues", - "source": "https://github.com/lorisleiva/laravel-actions/tree/v2.4.0" + "source": "https://github.com/lorisleiva/laravel-actions/tree/v2.4.1" }, "funding": [ { @@ -2721,7 +2721,7 @@ "type": "github" } ], - "time": "2022-02-27T15:30:59+00:00" + "time": "2022-10-20T17:56:26+00:00" }, { "name": "lorisleiva/lody", @@ -5740,16 +5740,16 @@ }, { "name": "spatie/laravel-ignition", - "version": "1.5.2", + "version": "1.6.1", "source": { "type": "git", "url": "https://github.com/spatie/laravel-ignition.git", - "reference": "f2336fc79d99aab5cf27fa4aebe5e9c9ecf3808a" + "reference": "2b79cf6ed40946b64ac6713d7d2da8a9d87f612b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/f2336fc79d99aab5cf27fa4aebe5e9c9ecf3808a", - "reference": "f2336fc79d99aab5cf27fa4aebe5e9c9ecf3808a", + "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/2b79cf6ed40946b64ac6713d7d2da8a9d87f612b", + "reference": "2b79cf6ed40946b64ac6713d7d2da8a9d87f612b", "shasum": "" }, "require": { @@ -5826,20 +5826,20 @@ "type": "github" } ], - "time": "2022-10-14T12:24:21+00:00" + "time": "2022-10-26T17:39:54+00:00" }, { "name": "spatie/laravel-medialibrary", - "version": "10.5.2", + "version": "10.6.0", "source": { "type": "git", "url": "https://github.com/spatie/laravel-medialibrary.git", - "reference": "5872a4f9e5f72b9dd1a02ea5ab699f33ef1a1c75" + "reference": "2f7db874ecdb9c6a2b06db794f00fb2e487c91ee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-medialibrary/zipball/5872a4f9e5f72b9dd1a02ea5ab699f33ef1a1c75", - "reference": "5872a4f9e5f72b9dd1a02ea5ab699f33ef1a1c75", + "url": "https://api.github.com/repos/spatie/laravel-medialibrary/zipball/2f7db874ecdb9c6a2b06db794f00fb2e487c91ee", + "reference": "2f7db874ecdb9c6a2b06db794f00fb2e487c91ee", "shasum": "" }, "require": { @@ -5922,7 +5922,7 @@ ], "support": { "issues": "https://github.com/spatie/laravel-medialibrary/issues", - "source": "https://github.com/spatie/laravel-medialibrary/tree/10.5.2" + "source": "https://github.com/spatie/laravel-medialibrary/tree/10.6.0" }, "funding": [ { @@ -5934,7 +5934,7 @@ "type": "github" } ], - "time": "2022-09-30T09:48:56+00:00" + "time": "2022-10-21T14:20:02+00:00" }, { "name": "spatie/laravel-package-tools", @@ -8931,6 +8931,38 @@ "symlink": true, "relative": true } + }, + { + "name": "zoomyboy/tex", + "version": "dev-main", + "dist": { + "type": "path", + "url": "./packages/tex", + "reference": "48251272de62e3fea044a7ad31e1a411c15eb4c6" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Zoomyboy\\Tex\\TexServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Zoomyboy\\Tex\\": "src/" + } + }, + "authors": [ + { + "name": "Philipp Lang", + "email": "philipp@zoomyboy.de" + } + ], + "transport-options": { + "symlink": true, + "relative": true + } } ], "packages-dev": [ @@ -9085,16 +9117,16 @@ }, { "name": "composer/composer", - "version": "2.4.3", + "version": "2.4.4", "source": { "type": "git", "url": "https://github.com/composer/composer.git", - "reference": "b34c0e9a93f2cd688c62ce4dfcc69e13b6ce7aa4" + "reference": "e8d9087229bcdbc5867594d3098091412f1130cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/composer/zipball/b34c0e9a93f2cd688c62ce4dfcc69e13b6ce7aa4", - "reference": "b34c0e9a93f2cd688c62ce4dfcc69e13b6ce7aa4", + "url": "https://api.github.com/repos/composer/composer/zipball/e8d9087229bcdbc5867594d3098091412f1130cf", + "reference": "e8d9087229bcdbc5867594d3098091412f1130cf", "shasum": "" }, "require": { @@ -9177,7 +9209,7 @@ "support": { "irc": "ircs://irc.libera.chat:6697/composer", "issues": "https://github.com/composer/composer/issues", - "source": "https://github.com/composer/composer/tree/2.4.3" + "source": "https://github.com/composer/composer/tree/2.4.4" }, "funding": [ { @@ -9193,7 +9225,7 @@ "type": "tidelift" } ], - "time": "2022-10-14T14:56:41+00:00" + "time": "2022-10-27T12:39:29+00:00" }, { "name": "composer/metadata-minifier", @@ -10316,16 +10348,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.8.10", + "version": "1.8.11", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "0c4459dc42c568b818b3f25186589f3acddc1823" + "reference": "46e223dd68a620da18855c23046ddb00940b4014" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0c4459dc42c568b818b3f25186589f3acddc1823", - "reference": "0c4459dc42c568b818b3f25186589f3acddc1823", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/46e223dd68a620da18855c23046ddb00940b4014", + "reference": "46e223dd68a620da18855c23046ddb00940b4014", "shasum": "" }, "require": { @@ -10355,7 +10387,7 @@ ], "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.8.10" + "source": "https://github.com/phpstan/phpstan/tree/1.8.11" }, "funding": [ { @@ -10371,20 +10403,20 @@ "type": "tidelift" } ], - "time": "2022-10-17T14:23:35+00:00" + "time": "2022-10-24T15:45:13+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.17", + "version": "9.2.18", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8" + "reference": "12fddc491826940cf9b7e88ad9664cf51f0f6d0a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/aa94dc41e8661fe90c7316849907cba3007b10d8", - "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/12fddc491826940cf9b7e88ad9664cf51f0f6d0a", + "reference": "12fddc491826940cf9b7e88ad9664cf51f0f6d0a", "shasum": "" }, "require": { @@ -10440,7 +10472,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.17" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.18" }, "funding": [ { @@ -10448,7 +10480,7 @@ "type": "github" } ], - "time": "2022-08-30T12:24:04+00:00" + "time": "2022-10-27T13:35:33+00:00" }, { "name": "phpunit/php-file-iterator", @@ -10693,16 +10725,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.25", + "version": "9.5.26", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d" + "reference": "851867efcbb6a1b992ec515c71cdcf20d895e9d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d", - "reference": "3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/851867efcbb6a1b992ec515c71cdcf20d895e9d2", + "reference": "851867efcbb6a1b992ec515c71cdcf20d895e9d2", "shasum": "" }, "require": { @@ -10775,7 +10807,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.25" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.26" }, "funding": [ { @@ -10791,7 +10823,7 @@ "type": "tidelift" } ], - "time": "2022-09-25T03:44:45+00:00" + "time": "2022-10-28T06:00:21+00:00" }, { "name": "pimple/pimple", @@ -12601,10 +12633,18 @@ "time": "2022-09-08T15:44:55+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "zoomyboy/tex", + "version": "dev-main", + "alias": "1.0", + "alias_normalized": "1.0.0.0" + } + ], "minimum-stability": "dev", "stability-flags": { - "zoomyboy/laravel-nami": 20 + "zoomyboy/laravel-nami": 20, + "zoomyboy/tex": 20 }, "prefer-stable": true, "prefer-lowest": false, diff --git a/packages/tex b/packages/tex new file mode 160000 index 00000000..fb9d7a66 --- /dev/null +++ b/packages/tex @@ -0,0 +1 @@ +Subproject commit fb9d7a660c6e170eedf7a11b02f7cfeff14346ab diff --git a/phpstan.neon b/phpstan.neon index a6fb185d..91f73f14 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -7,6 +7,7 @@ parameters: - app - tests - database + - packages/tex/src # The level 8 is the highest level level: 6 diff --git a/resources/views/tex/efz.tex b/resources/views/tex/efz.tex index c5e0f076..e4a6e848 100644 --- a/resources/views/tex/efz.tex +++ b/resources/views/tex/efz.tex @@ -26,9 +26,9 @@ \coordinate (B) at ($(A)+(0mm,5mm)$); \coordinate (C) at (19mm,212mm); - \path (A) node[anchor=west,fill=white,text width=120mm,text height=2.5mm,inner xsep=0mm,inner ysep=1mm]{<<<$data->name>>>}; - \path (B) node[anchor=west,fill=white,text width=120mm,text height=2.5mm,inner xsep=0mm,inner ysep=1mm]{<<<$data->secondLine>>>}; - \path (C) node[anchor=west,fill=white,text width=120mm,text height=2.5mm,inner xsep=0mm,inner ysep=1mm]{Neuss, <<<$data->currentDate>>>}; + \path (A) node[anchor=west,fill=white,text width=120mm,text height=2.5mm,inner xsep=0mm,inner ysep=1mm]{<<<$name>>>}; + \path (B) node[anchor=west,fill=white,text width=120mm,text height=2.5mm,inner xsep=0mm,inner ysep=1mm]{<<<$secondLine>>>}; + \path (C) node[anchor=west,fill=white,text width=120mm,text height=2.5mm,inner xsep=0mm,inner ysep=1mm]{Neuss, <<<$now>>>}; \end{tikzpicture} \backgroundsetup{scale = 1, pages=some, angle = 0, opacity = 1, color=black, contents = {\includegraphics[width = \paperwidth, height = \paperheight] {bg-2.pdf}}} @@ -40,7 +40,7 @@ % \useasboundingbox (2.52,6.67) rectangle (18.47,12.85); % \fill[fill=white, opacity=0.9] (25mm,63mm) rectangle ++(160mm,62mm); - \node[anchor=north west,fill=white,text width=80mm,minimum height=30mm,inner sep=1mm] at (110mm, 42.0mm) {Absender: \vspace{2mm} \\ <<sender)>>>}; + \node[anchor=north west,fill=white,text width=80mm,minimum height=30mm,inner sep=1mm] at (110mm, 42.0mm) {Absender: \vspace{2mm} \\ <<values())>>>}; \end{tikzpicture} \end{document} diff --git a/routes/web.php b/routes/web.php index 322f60e4..178b8c4e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -2,6 +2,7 @@ use App\Contribution\ContributionController; use App\Course\Controllers\CourseController; +use App\Efz\ShowEfzDocumentAction; use App\Http\Controllers\HomeController; use App\Initialize\Actions\InitializeAction; use App\Initialize\Actions\InitializeFormAction; @@ -13,7 +14,6 @@ use App\Payment\AllpaymentController; use App\Payment\PaymentController; use App\Payment\SendpaymentController; use App\Payment\SubscriptionController; -use App\Pdf\MemberEfzController; use App\Pdf\MemberPdfController; Route::group(['namespace' => 'App\\Http\\Controllers'], function (): void { @@ -35,7 +35,7 @@ Route::group(['middleware' => 'auth:web'], function (): void { Route::get('/sendpayment/pdf', [SendpaymentController::class, 'send'])->name('sendpayment.pdf'); Route::apiResource('member.membership', MembershipController::class); Route::resource('member.course', CourseController::class); - Route::get('/member/{member}/efz', MemberEfzController::class)->name('efz'); + Route::get('/member/{member}/efz', ShowEfzDocumentAction::class)->name('efz'); Route::get('/member/{member}/resync', MemberResyncController::class)->name('member.resync'); Route::get('/contribution', [ContributionController::class, 'form'])->name('contribution.form'); Route::get('/contribution/generate', [ContributionController::class, 'generate'])->name('contribution.generate'); diff --git a/tests/Feature/Pdf/EfzTest.php b/tests/Feature/Pdf/EfzTest.php index 5af9718b..1515b58f 100644 --- a/tests/Feature/Pdf/EfzTest.php +++ b/tests/Feature/Pdf/EfzTest.php @@ -2,9 +2,11 @@ namespace Tests\Feature\Pdf; +use App\Efz\EfzDocument; use App\Member\Member; use Illuminate\Foundation\Testing\DatabaseTransactions; use Tests\TestCase; +use Zoomyboy\Tex\Tex; class EfzTest extends TestCase { @@ -12,6 +14,38 @@ class EfzTest extends TestCase public function testItCreatesAEfzPdfFile(): void { + Tex::fake(); + $this->withoutExceptionHandling()->login()->withNamiSettings(); + $member = Member::factory()->defaults()->create([ + 'firstname' => 'Max', + 'lastname' => 'Muster', + 'address' => 'Itt 4', + 'zip' => '12345', + 'location' => 'Solingen', + 'birthday' => '2015-02-11', + 'nami_id' => 552, + ]); + + $response = $this->get("/member/{$member->id}/efz"); + + $response->assertOk(); + $response->assertHeader('Content-Disposition', 'inline; filename="efz-fuer-max-muster.pdf"'); + Tex::assertCompiled(EfzDocument::class, fn ($document) => 'Max Muster' === $document->name + && 'efz-fuer-max-muster' === $document->basename() + && 'geb. am 11.02.2015, wohnhaft in Solingen' === $document->secondLine + && now()->format('d.m.Y') === $document->now + && [ + 'Max Muster', + 'Itt 4', + '12345 Solingen', + 'Mglnr.: 552', + ] === $document->sender->values() + ); + } + + public function testItReallyCreatesAEfzPdfFile(): void + { + Tex::spy(); $this->withoutExceptionHandling()->login()->withNamiSettings(); $member = Member::factory()->defaults()->create(['firstname' => 'Max', 'lastname' => 'Muster']); @@ -19,5 +53,6 @@ class EfzTest extends TestCase $response->assertOk(); $response->assertHeader('Content-Disposition', 'inline; filename="efz-fuer-max-muster.pdf"'); + Tex::assertCompiled(EfzDocument::class, fn ($document) => $document->hasContent('Absender:') && $document->hasContent('Max Muster')); } }