Compare commits
14 Commits
b05c5025c0
...
4651a4cb96
Author | SHA1 | Date |
---|---|---|
philipp lang | 4651a4cb96 | |
philipp lang | 688e10e230 | |
philipp lang | 267da38c6b | |
philipp lang | 499c61afff | |
philipp lang | 02531938b3 | |
philipp lang | 1c53e81f1a | |
philipp lang | 98712093b2 | |
philipp lang | a32ef33113 | |
philipp lang | 088ea4f0a2 | |
philipp lang | 4ac89da124 | |
philipp lang | 286ceea0d4 | |
philipp lang | 52ac5937a4 | |
philipp lang | 4690e86bbf | |
philipp lang | 1a4a7c3652 |
|
@ -8,6 +8,7 @@ use App\Contribution\Documents\RdpNrwDocument;
|
||||||
use App\Contribution\Documents\CityRemscheidDocument;
|
use App\Contribution\Documents\CityRemscheidDocument;
|
||||||
use App\Contribution\Documents\CitySolingenDocument;
|
use App\Contribution\Documents\CitySolingenDocument;
|
||||||
use App\Contribution\Documents\CityFrankfurtMainDocument;
|
use App\Contribution\Documents\CityFrankfurtMainDocument;
|
||||||
|
use App\Contribution\Documents\GallierDocument;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
@ -22,6 +23,7 @@ class ContributionFactory
|
||||||
CityRemscheidDocument::class,
|
CityRemscheidDocument::class,
|
||||||
CityFrankfurtMainDocument::class,
|
CityFrankfurtMainDocument::class,
|
||||||
BdkjHesse::class,
|
BdkjHesse::class,
|
||||||
|
GallierDocument::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,7 +32,7 @@ class ContributionFactory
|
||||||
public function compilerSelect(): Collection
|
public function compilerSelect(): Collection
|
||||||
{
|
{
|
||||||
return collect($this->documents)->map(fn ($document) => [
|
return collect($this->documents)->map(fn ($document) => [
|
||||||
'title' => $document::getName(),
|
'title' => $document::buttonName(),
|
||||||
'class' => $document,
|
'class' => $document,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,13 +72,23 @@ class MemberData extends Data
|
||||||
return $this->zip . ' ' . $this->location;
|
return $this->zip . ' ' . $this->location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function age(): string
|
public function age(): int
|
||||||
{
|
{
|
||||||
return (string) $this->birthday->diffInYears(now()) ?: '';
|
return intval($this->birthday->diffInYears(now()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function birthYear(): string
|
public function birthYear(): string
|
||||||
{
|
{
|
||||||
return (string) $this->birthday->year;
|
return (string) $this->birthday->year;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function birthdayHuman(): string
|
||||||
|
{
|
||||||
|
return $this->birthday->format('d.m.Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function genderLetter(): string
|
||||||
|
{
|
||||||
|
return $this->gender->short;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,15 +3,16 @@
|
||||||
namespace App\Contribution\Documents;
|
namespace App\Contribution\Documents;
|
||||||
|
|
||||||
use App\Contribution\Data\MemberData;
|
use App\Contribution\Data\MemberData;
|
||||||
|
use App\Contribution\Traits\HasPdfBackground;
|
||||||
use App\Country;
|
use App\Country;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Zoomyboy\Tex\Engine;
|
|
||||||
use Zoomyboy\Tex\Template;
|
|
||||||
|
|
||||||
class BdkjHesse extends ContributionDocument
|
class BdkjHesse extends ContributionDocument
|
||||||
{
|
{
|
||||||
|
|
||||||
|
use HasPdfBackground;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Collection<int, Collection<int, MemberData>> $members
|
* @param Collection<int, Collection<int, MemberData>> $members
|
||||||
*/
|
*/
|
||||||
|
@ -25,6 +26,7 @@ class BdkjHesse extends ContributionDocument
|
||||||
public ?string $filename = '',
|
public ?string $filename = '',
|
||||||
public string $type = 'F',
|
public string $type = 'F',
|
||||||
) {
|
) {
|
||||||
|
$this->setEventName($eventName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dateFrom(): string
|
public function dateFrom(): string
|
||||||
|
@ -114,36 +116,9 @@ class BdkjHesse extends ContributionDocument
|
||||||
return $member->birthYear();
|
return $member->birthYear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function basename(): string
|
|
||||||
{
|
|
||||||
return 'zuschuesse-bdkj-hessen' . Str::slug($this->eventName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function view(): string
|
|
||||||
{
|
|
||||||
return 'tex.contribution.bdkj-hesse';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function template(): Template
|
|
||||||
{
|
|
||||||
return Template::make('tex.templates.contribution');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setFilename(string $filename): static
|
|
||||||
{
|
|
||||||
$this->filename = $filename;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getEngine(): Engine
|
|
||||||
{
|
|
||||||
return Engine::PDFLATEX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getName(): string
|
public static function getName(): string
|
||||||
{
|
{
|
||||||
return 'Für BDKJ Hessen erstellen';
|
return 'BDKJ Hessen';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,7 +131,6 @@ class BdkjHesse extends ContributionDocument
|
||||||
'dateUntil' => 'required|string|date_format:Y-m-d',
|
'dateUntil' => 'required|string|date_format:Y-m-d',
|
||||||
'country' => 'required|integer|exists:countries,id',
|
'country' => 'required|integer|exists:countries,id',
|
||||||
'zipLocation' => 'required|string',
|
'zipLocation' => 'required|string',
|
||||||
'eventName' => 'required|string',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,16 +3,17 @@
|
||||||
namespace App\Contribution\Documents;
|
namespace App\Contribution\Documents;
|
||||||
|
|
||||||
use App\Contribution\Data\MemberData;
|
use App\Contribution\Data\MemberData;
|
||||||
|
use App\Contribution\Traits\FormatsDates;
|
||||||
|
use App\Contribution\Traits\HasPdfBackground;
|
||||||
use App\Country;
|
use App\Country;
|
||||||
use App\Invoice\InvoiceSettings;
|
use App\Invoice\InvoiceSettings;
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Zoomyboy\Tex\Engine;
|
|
||||||
use Zoomyboy\Tex\Template;
|
|
||||||
|
|
||||||
class CityFrankfurtMainDocument extends ContributionDocument
|
class CityFrankfurtMainDocument extends ContributionDocument
|
||||||
{
|
{
|
||||||
|
use HasPdfBackground;
|
||||||
|
use FormatsDates;
|
||||||
|
|
||||||
public string $fromName;
|
public string $fromName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +29,7 @@ class CityFrankfurtMainDocument extends ContributionDocument
|
||||||
public ?string $filename = '',
|
public ?string $filename = '',
|
||||||
public string $type = 'F',
|
public string $type = 'F',
|
||||||
) {
|
) {
|
||||||
|
$this->setEventName($eventName);
|
||||||
$this->fromName = app(InvoiceSettings::class)->from_long;
|
$this->fromName = app(InvoiceSettings::class)->from_long;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,17 +63,6 @@ class CityFrankfurtMainDocument extends ContributionDocument
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dateFromHuman(): string
|
|
||||||
{
|
|
||||||
return Carbon::parse($this->dateFrom)->format('d.m.Y');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function dateUntilHuman(): string
|
|
||||||
{
|
|
||||||
return Carbon::parse($this->dateUntil)->format('d.m.Y');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function countryName(): string
|
public function countryName(): string
|
||||||
{
|
{
|
||||||
return $this->country->name;
|
return $this->country->name;
|
||||||
|
@ -82,56 +73,9 @@ class CityFrankfurtMainDocument extends ContributionDocument
|
||||||
return count($this->members);
|
return count($this->members);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function memberShort(MemberData $member): string
|
|
||||||
{
|
|
||||||
return $member->isLeader ? 'L' : '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function memberName(MemberData $member): string
|
|
||||||
{
|
|
||||||
return $member->separatedName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function memberAddress(MemberData $member): string
|
|
||||||
{
|
|
||||||
return $member->fullAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function memberAge(MemberData $member): string
|
|
||||||
{
|
|
||||||
return $member->age();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function basename(): string
|
|
||||||
{
|
|
||||||
return 'zuschuesse-frankfurt-' . Str::slug($this->eventName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function view(): string
|
|
||||||
{
|
|
||||||
return 'tex.contribution.city-frankfurt-main';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function template(): Template
|
|
||||||
{
|
|
||||||
return Template::make('tex.templates.contribution');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setFilename(string $filename): static
|
|
||||||
{
|
|
||||||
$this->filename = $filename;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getEngine(): Engine
|
|
||||||
{
|
|
||||||
return Engine::PDFLATEX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getName(): string
|
public static function getName(): string
|
||||||
{
|
{
|
||||||
return 'Für Frankfurt erstellen';
|
return 'Frankfurt';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,7 +88,6 @@ class CityFrankfurtMainDocument extends ContributionDocument
|
||||||
'dateUntil' => 'required|string|date_format:Y-m-d',
|
'dateUntil' => 'required|string|date_format:Y-m-d',
|
||||||
'country' => 'required|integer|exists:countries,id',
|
'country' => 'required|integer|exists:countries,id',
|
||||||
'zipLocation' => 'required|string',
|
'zipLocation' => 'required|string',
|
||||||
'eventName' => 'required|string',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,15 +3,17 @@
|
||||||
namespace App\Contribution\Documents;
|
namespace App\Contribution\Documents;
|
||||||
|
|
||||||
use App\Contribution\Data\MemberData;
|
use App\Contribution\Data\MemberData;
|
||||||
|
use App\Contribution\Traits\FormatsDates;
|
||||||
|
use App\Contribution\Traits\HasPdfBackground;
|
||||||
use App\Country;
|
use App\Country;
|
||||||
use App\Member\Member;
|
use App\Member\Member;
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Zoomyboy\Tex\Engine;
|
|
||||||
use Zoomyboy\Tex\Template;
|
|
||||||
|
|
||||||
class CityRemscheidDocument extends ContributionDocument
|
class CityRemscheidDocument extends ContributionDocument
|
||||||
{
|
{
|
||||||
|
use HasPdfBackground;
|
||||||
|
use FormatsDates;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Collection<int, Collection<int, Member>> $leaders
|
* @param Collection<int, Collection<int, Member>> $leaders
|
||||||
* @param Collection<int, Collection<int, Member>> $children
|
* @param Collection<int, Collection<int, Member>> $children
|
||||||
|
@ -25,17 +27,9 @@ class CityRemscheidDocument extends ContributionDocument
|
||||||
public Collection $children,
|
public Collection $children,
|
||||||
public ?string $filename = '',
|
public ?string $filename = '',
|
||||||
public string $type = 'F',
|
public string $type = 'F',
|
||||||
|
public string $eventName = '',
|
||||||
) {
|
) {
|
||||||
}
|
$this->setEventName($eventName);
|
||||||
|
|
||||||
public function niceDateFrom(): string
|
|
||||||
{
|
|
||||||
return Carbon::parse($this->dateFrom)->format('d.m.Y');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function niceDateUntil(): string
|
|
||||||
{
|
|
||||||
return Carbon::parse($this->dateUntil)->format('d.m.Y');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,6 +46,7 @@ class CityRemscheidDocument extends ContributionDocument
|
||||||
country: Country::where('id', $request['country'])->firstOrFail(),
|
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||||
leaders: $leaders->values()->toBase()->chunk(6),
|
leaders: $leaders->values()->toBase()->chunk(6),
|
||||||
children: $children->values()->toBase()->chunk(20),
|
children: $children->values()->toBase()->chunk(20),
|
||||||
|
eventName: $request['eventName'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,39 +65,13 @@ class CityRemscheidDocument extends ContributionDocument
|
||||||
country: Country::where('id', $request['country'])->firstOrFail(),
|
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||||
leaders: $leaders->values()->toBase()->chunk(6),
|
leaders: $leaders->values()->toBase()->chunk(6),
|
||||||
children: $children->values()->toBase()->chunk(20),
|
children: $children->values()->toBase()->chunk(20),
|
||||||
|
eventName: $request['eventName'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function basename(): string
|
|
||||||
{
|
|
||||||
return 'zuschuesse-remscheid';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function view(): string
|
|
||||||
{
|
|
||||||
return 'tex.contribution.city-remscheid';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function template(): Template
|
|
||||||
{
|
|
||||||
return Template::make('tex.templates.contribution');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setFilename(string $filename): static
|
|
||||||
{
|
|
||||||
$this->filename = $filename;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getEngine(): Engine
|
|
||||||
{
|
|
||||||
return Engine::PDFLATEX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getName(): string
|
public static function getName(): string
|
||||||
{
|
{
|
||||||
return 'Für Remscheid erstellen';
|
return 'Remscheid';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,9 +6,7 @@ use App\Contribution\Data\MemberData;
|
||||||
use App\Invoice\InvoiceSettings;
|
use App\Invoice\InvoiceSettings;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Zoomyboy\Tex\Engine;
|
use Zoomyboy\Tex\Engine;
|
||||||
use Zoomyboy\Tex\Template;
|
|
||||||
|
|
||||||
class CitySolingenDocument extends ContributionDocument
|
class CitySolingenDocument extends ContributionDocument
|
||||||
{
|
{
|
||||||
|
@ -25,6 +23,7 @@ class CitySolingenDocument extends ContributionDocument
|
||||||
public string $eventName,
|
public string $eventName,
|
||||||
public string $type = 'F',
|
public string $type = 'F',
|
||||||
) {
|
) {
|
||||||
|
$this->setEventName($eventName);
|
||||||
$this->fromName = app(InvoiceSettings::class)->from_long;
|
$this->fromName = app(InvoiceSettings::class)->from_long;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,11 +73,6 @@ class CitySolingenDocument extends ContributionDocument
|
||||||
return Carbon::parse($this->dateUntil)->format('d.m.Y');
|
return Carbon::parse($this->dateUntil)->format('d.m.Y');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function template(): Template
|
|
||||||
{
|
|
||||||
return Template::make('tex.templates.contribution');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function checkboxes(): string
|
public function checkboxes(): string
|
||||||
{
|
{
|
||||||
$output = '';
|
$output = '';
|
||||||
|
@ -94,16 +88,6 @@ class CitySolingenDocument extends ContributionDocument
|
||||||
return $firstRow . "\n" . $secondRow;
|
return $firstRow . "\n" . $secondRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function basename(): string
|
|
||||||
{
|
|
||||||
return 'zuschuesse-solingen-' . Str::slug($this->eventName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function view(): string
|
|
||||||
{
|
|
||||||
return 'tex.contribution.city-solingen';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getEngine(): Engine
|
public function getEngine(): Engine
|
||||||
{
|
{
|
||||||
return Engine::PDFLATEX;
|
return Engine::PDFLATEX;
|
||||||
|
@ -111,7 +95,7 @@ class CitySolingenDocument extends ContributionDocument
|
||||||
|
|
||||||
public static function getName(): string
|
public static function getName(): string
|
||||||
{
|
{
|
||||||
return 'Für Stadt Solingen erstellen';
|
return 'Stadt Solingen';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -123,7 +107,6 @@ class CitySolingenDocument extends ContributionDocument
|
||||||
'dateFrom' => 'required|string|date_format:Y-m-d',
|
'dateFrom' => 'required|string|date_format:Y-m-d',
|
||||||
'dateUntil' => 'required|string|date_format:Y-m-d',
|
'dateUntil' => 'required|string|date_format:Y-m-d',
|
||||||
'zipLocation' => 'required|string',
|
'zipLocation' => 'required|string',
|
||||||
'eventName' => 'required|string',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,12 @@
|
||||||
namespace App\Contribution\Documents;
|
namespace App\Contribution\Documents;
|
||||||
|
|
||||||
use Zoomyboy\Tex\Document;
|
use Zoomyboy\Tex\Document;
|
||||||
|
use Zoomyboy\Tex\Template;
|
||||||
|
|
||||||
abstract class ContributionDocument extends Document
|
abstract class ContributionDocument extends Document
|
||||||
{
|
{
|
||||||
|
private string $eventName;
|
||||||
|
|
||||||
abstract public static function getName(): string;
|
abstract public static function getName(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,8 +32,34 @@ abstract class ContributionDocument extends Document
|
||||||
public static function globalRules(): array
|
public static function globalRules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'eventName' => 'required|string',
|
||||||
'members' => 'present|array|min:1',
|
'members' => 'present|array|min:1',
|
||||||
'members.*' => 'integer|exists:members,id',
|
'members.*' => 'integer|exists:members,id',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function buttonName(): string
|
||||||
|
{
|
||||||
|
return 'Für ' . static::getName() . ' erstellen';;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEventName(string $eventName): void
|
||||||
|
{
|
||||||
|
$this->eventName = $eventName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function basename(): string
|
||||||
|
{
|
||||||
|
return str('Zuschüsse ')->append($this->getName())->append(' ')->append($this->eventName)->slug();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function template(): Template
|
||||||
|
{
|
||||||
|
return Template::make('tex.templates.contribution');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function view(): string
|
||||||
|
{
|
||||||
|
return 'tex.contribution.' . str(class_basename(static::class))->replace('Document', '')->kebab()->toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Contribution\Documents;
|
||||||
|
|
||||||
|
use App\Contribution\Data\MemberData;
|
||||||
|
use App\Contribution\Traits\FormatsDates;
|
||||||
|
use App\Contribution\Traits\HasPdfBackground;
|
||||||
|
use App\Country;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
class GallierDocument extends ContributionDocument
|
||||||
|
{
|
||||||
|
|
||||||
|
use HasPdfBackground;
|
||||||
|
use FormatsDates;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection<int, Collection<int, MemberData>> $members
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
public string $dateFrom,
|
||||||
|
public string $dateUntil,
|
||||||
|
public string $zipLocation,
|
||||||
|
public ?Country $country,
|
||||||
|
public Collection $members,
|
||||||
|
public ?string $filename = '',
|
||||||
|
public string $type = 'F',
|
||||||
|
public string $eventName = '',
|
||||||
|
) {
|
||||||
|
$this->setEventName($eventName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function fromRequest(array $request): self
|
||||||
|
{
|
||||||
|
return new self(
|
||||||
|
dateFrom: $request['dateFrom'],
|
||||||
|
dateUntil: $request['dateUntil'],
|
||||||
|
zipLocation: $request['zipLocation'],
|
||||||
|
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||||
|
members: MemberData::fromModels($request['members'])->chunk(14),
|
||||||
|
eventName: $request['eventName'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function fromApiRequest(array $request): self
|
||||||
|
{
|
||||||
|
return new self(
|
||||||
|
dateFrom: $request['dateFrom'],
|
||||||
|
dateUntil: $request['dateUntil'],
|
||||||
|
zipLocation: $request['zipLocation'],
|
||||||
|
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||||
|
members: MemberData::fromApi($request['member_data'])->chunk(14),
|
||||||
|
eventName: $request['eventName'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getName(): string
|
||||||
|
{
|
||||||
|
return 'Gallier';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public static function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'dateFrom' => 'required|string|date_format:Y-m-d',
|
||||||
|
'dateUntil' => 'required|string|date_format:Y-m-d',
|
||||||
|
'zipLocation' => 'required|string',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,14 +3,16 @@
|
||||||
namespace App\Contribution\Documents;
|
namespace App\Contribution\Documents;
|
||||||
|
|
||||||
use App\Contribution\Data\MemberData;
|
use App\Contribution\Data\MemberData;
|
||||||
|
use App\Contribution\Traits\FormatsDates;
|
||||||
|
use App\Contribution\Traits\HasPdfBackground;
|
||||||
use App\Country;
|
use App\Country;
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Zoomyboy\Tex\Engine;
|
|
||||||
use Zoomyboy\Tex\Template;
|
|
||||||
|
|
||||||
class RdpNrwDocument extends ContributionDocument
|
class RdpNrwDocument extends ContributionDocument
|
||||||
{
|
{
|
||||||
|
use HasPdfBackground;
|
||||||
|
use FormatsDates;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Collection<int, Collection<int, MemberData>> $members
|
* @param Collection<int, Collection<int, MemberData>> $members
|
||||||
*/
|
*/
|
||||||
|
@ -22,14 +24,9 @@ class RdpNrwDocument extends ContributionDocument
|
||||||
public Collection $members,
|
public Collection $members,
|
||||||
public ?string $filename = '',
|
public ?string $filename = '',
|
||||||
public string $type = 'F',
|
public string $type = 'F',
|
||||||
|
public string $eventName = '',
|
||||||
) {
|
) {
|
||||||
}
|
$this->setEventName($eventName);
|
||||||
|
|
||||||
public function dateRange(): string
|
|
||||||
{
|
|
||||||
return Carbon::parse($this->dateFrom)->format('d.m.Y')
|
|
||||||
. ' - '
|
|
||||||
. Carbon::parse($this->dateUntil)->format('d.m.Y');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,6 +40,7 @@ class RdpNrwDocument extends ContributionDocument
|
||||||
zipLocation: $request['zipLocation'],
|
zipLocation: $request['zipLocation'],
|
||||||
country: Country::where('id', $request['country'])->firstOrFail(),
|
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||||
members: MemberData::fromModels($request['members'])->chunk(17),
|
members: MemberData::fromModels($request['members'])->chunk(17),
|
||||||
|
eventName: $request['eventName'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +55,7 @@ class RdpNrwDocument extends ContributionDocument
|
||||||
zipLocation: $request['zipLocation'],
|
zipLocation: $request['zipLocation'],
|
||||||
country: Country::where('id', $request['country'])->firstOrFail(),
|
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||||
members: MemberData::fromApi($request['member_data'])->chunk(17),
|
members: MemberData::fromApi($request['member_data'])->chunk(17),
|
||||||
|
eventName: $request['eventName'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,65 +64,9 @@ class RdpNrwDocument extends ContributionDocument
|
||||||
return $this->country->name;
|
return $this->country->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function memberShort(MemberData $member): string
|
|
||||||
{
|
|
||||||
return $member->isLeader ? 'L' : '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function memberName(MemberData $member): string
|
|
||||||
{
|
|
||||||
return $member->separatedName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function memberAddress(MemberData $member): string
|
|
||||||
{
|
|
||||||
return $member->fullAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function memberGender(MemberData $member): string
|
|
||||||
{
|
|
||||||
if (!$member->gender) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return strtolower(substr($member->gender->name, 0, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function memberAge(MemberData $member): string
|
|
||||||
{
|
|
||||||
return $member->age();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function basename(): string
|
|
||||||
{
|
|
||||||
return 'zuschuesse-rdp-nrw';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function view(): string
|
|
||||||
{
|
|
||||||
return 'tex.contribution.rdp-nrw';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function template(): Template
|
|
||||||
{
|
|
||||||
return Template::make('tex.templates.contribution');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setFilename(string $filename): static
|
|
||||||
{
|
|
||||||
$this->filename = $filename;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getEngine(): Engine
|
|
||||||
{
|
|
||||||
return Engine::PDFLATEX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getName(): string
|
public static function getName(): string
|
||||||
{
|
{
|
||||||
return 'Für RdP NRW erstellen';
|
return 'RdP NRW';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,7 +79,6 @@ class RdpNrwDocument extends ContributionDocument
|
||||||
'dateUntil' => 'required|string|date_format:Y-m-d',
|
'dateUntil' => 'required|string|date_format:Y-m-d',
|
||||||
'country' => 'required|integer|exists:countries,id',
|
'country' => 'required|integer|exists:countries,id',
|
||||||
'zipLocation' => 'required|string',
|
'zipLocation' => 'required|string',
|
||||||
'eventName' => 'required|string',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Contribution\Traits;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
trait FormatsDates
|
||||||
|
{
|
||||||
|
|
||||||
|
public function niceDateFrom(): string
|
||||||
|
{
|
||||||
|
return Carbon::parse($this->dateFrom)->format('d.m.Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function niceDateUntil(): string
|
||||||
|
{
|
||||||
|
return Carbon::parse($this->dateUntil)->format('d.m.Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dateRange(): string
|
||||||
|
{
|
||||||
|
return implode(' - ', [$this->niceDateFrom(), $this->niceDateUntil()]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Contribution\Traits;
|
||||||
|
|
||||||
|
use Zoomyboy\Tex\Engine;
|
||||||
|
|
||||||
|
trait HasPdfBackground
|
||||||
|
{
|
||||||
|
public function getEngine(): Engine
|
||||||
|
{
|
||||||
|
return Engine::PDFLATEX;
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,6 +25,15 @@ class Gender extends Model
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getShortAttribute(): string
|
||||||
|
{
|
||||||
|
return match ($this->name) {
|
||||||
|
'Männlich' => 'm',
|
||||||
|
'Weiblich' => 'w',
|
||||||
|
default => ''
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public static function fromString(string $title): self
|
public static function fromString(string $title): self
|
||||||
{
|
{
|
||||||
return self::firstWhere('name', $title);
|
return self::firstWhere('name', $title);
|
||||||
|
|
|
@ -18,15 +18,15 @@
|
||||||
\node[anchor=base west, text width=205.3mm] at (52.9mm,31.0mm) {\bfseries{\large{<<<!!$fromName!!>>>}}}; %Feld: Jugendverband/-Gruppe
|
\node[anchor=base west, text width=205.3mm] at (52.9mm,31.0mm) {\bfseries{\large{<<<!!$fromName!!>>>}}}; %Feld: Jugendverband/-Gruppe
|
||||||
\node[anchor=base west, text width=215.9mm] at (41.3mm,38.8mm) {\bfseries{\large{<<<!!$eventName!!>>>}}}; %Feld: Art der Maßnahme
|
\node[anchor=base west, text width=215.9mm] at (41.3mm,38.8mm) {\bfseries{\large{<<<!!$eventName!!>>>}}}; %Feld: Art der Maßnahme
|
||||||
\node[anchor=base west, text width=104.8mm] at (17.5mm,47.0mm) {\bfseries{\large{<<<!!$zipLocation!!>>>, <<<!!$countryName!!>>>}}};
|
\node[anchor=base west, text width=104.8mm] at (17.5mm,47.0mm) {\bfseries{\large{<<<!!$zipLocation!!>>>, <<<!!$countryName!!>>>}}};
|
||||||
\node[anchor=base west, text width=41.3mm, align=center] at (170.7mm,47.0mm) {\bfseries{\large{<<<!!$dateFromHuman()!!>>>}}};
|
\node[anchor=base west, text width=41.3mm, align=center] at (170.7mm,47.0mm) {\bfseries{\large{<<<!!$niceDateFrom()!!>>>}}};
|
||||||
\node[anchor=base west, text width=38.4mm, align=center] at (219.9mm,47.0mm) {\bfseries{\large{<<<!!$dateUntilHuman()!!>>>}}};
|
\node[anchor=base west, text width=38.4mm, align=center] at (219.9mm,47.0mm) {\bfseries{\large{<<<!!$niceDateUntil()!!>>>}}};
|
||||||
|
|
||||||
@foreach($chunk as $j => $member)
|
@foreach($chunk as $j => $member)
|
||||||
\node[anchor=base, text width=4mm, align=center] at ($(8.0mm, 69.0mm + 8.05mm * <<<$j%15>>>)$) {<<<$memberShort($member)>>>};
|
\node[anchor=base, text width=4mm, align=center] at ($(8.0mm, 69.0mm + 8.05mm * <<<$j%15>>>)$) {<<<$member->isLeader ? 'L' : ''>>>};
|
||||||
\node[anchor=base, text width=6mm, align=center] at ($(13.0mm, 69.0mm + 8.05mm * <<<$j%15>>>)$) {<<<$j+1>>>};
|
\node[anchor=base, text width=6mm, align=center] at ($(13.0mm, 69.0mm + 8.05mm * <<<$j%15>>>)$) {<<<$j+1>>>};
|
||||||
\node[anchor=base, text width=67.5mm, align=center] at ($(50.65mm, 69.0mm + 8.05mm * <<<$j%15>>>)$) {<<<$memberName($member)>>>};
|
\node[anchor=base, text width=67.5mm, align=center] at ($(50.65mm, 69.0mm + 8.05mm * <<<$j%15>>>)$) {<<<$member->separatedName()>>>};
|
||||||
\node[anchor=base, text width=14.6mm, align=center] at ($(92.2mm, 69.0mm + 8.05mm * <<<$j%15>>>)$) {<<<$memberAge($member)>>>};
|
\node[anchor=base, text width=14.6mm, align=center] at ($(92.2mm, 69.0mm + 8.05mm * <<<$j%15>>>)$) {<<<$member->age()>>>};
|
||||||
\node[anchor=base, text width=79.4mm, align=center] at ($(139.7mm, 69.0mm + 8.05mm * <<<$j%15>>>)$) {<<<$memberAddress($member)>>>};
|
\node[anchor=base, text width=79.4mm, align=center] at ($(139.7mm, 69.0mm + 8.05mm * <<<$j%15>>>)$) {<<<$member->fullAddress()>>>};
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
\node[anchor=base, text width=23.0mm, align=center] at (278.2mm,196.1mm) {Seite <<<!!$i + 1!!>>> von <<<!!$pages!!>>>};
|
\node[anchor=base, text width=23.0mm, align=center] at (278.2mm,196.1mm) {Seite <<<!!$i + 1!!>>> von <<<!!$pages!!>>>};
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
\documentclass[a4paper,landscape]{article}
|
||||||
|
|
||||||
|
\usepackage[landscape,top=0cm,left=0cm,bottom=0cm,right=0cm]{geometry}
|
||||||
|
\usepackage{tikz}
|
||||||
|
\usepackage{background}
|
||||||
|
\usepackage{blindtext}
|
||||||
|
\usetikzlibrary{matrix, shapes.misc, calc}
|
||||||
|
|
||||||
|
\pagestyle{empty}
|
||||||
|
\setlength{\parindent}{0cm}
|
||||||
|
\backgroundsetup{scale = 1, angle = 0, opacity = 1, color=black, contents = {\includegraphics[width = \paperwidth, height = \paperheight] {gallier.pdf}}}
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
\noindent \sffamily
|
||||||
|
|
||||||
|
@foreach($members as $chunk)
|
||||||
|
\begin{tikzpicture}[remember picture,overlay,yscale=-1]
|
||||||
|
\node[anchor=base west] at (17mm,29.62mm) {\bfseries{\small{<<<$niceDateFrom>>>}}};
|
||||||
|
\node[anchor=base west] at (34mm,29.62mm) {\bfseries{\small{<<<$niceDateUntil>>>}}};
|
||||||
|
\node[] at (203mm,15.55mm) {\bfseries{\small{<<<$zipLocation>>>}}};
|
||||||
|
|
||||||
|
\node[thick, cross out,draw=black,text width=2.4mm, text height=2.4mm, inner sep=0mm] at (17.76mm,47.10mm) {};
|
||||||
|
|
||||||
|
@foreach($chunk as $i => $member)
|
||||||
|
\node[anchor=center, text width=9.75mm, align=center] at ($(19.35mm, 59.7mm + 9.2mm * <<<$i%14>>>)$) {<<<$i+1>>>};
|
||||||
|
\node[anchor=center, text width=41.75mm, align=center] at ($(48.35mm, 59.7mm + 9.2mm * <<<$i%14>>>)$) {<<<$member->lastname>>>};
|
||||||
|
\node[anchor=center, text width=37.75mm, align=center] at ($(91.35mm, 59.7mm + 9.2mm * <<<$i%14>>>)$) {<<<$member->firstname>>>};
|
||||||
|
\node[anchor=center, text width=45.75mm, align=center] at ($(135.35mm, 59.7mm + 9.2mm * <<<$i%14>>>)$) {<<<$member->address>>>};
|
||||||
|
\node[anchor=center, text width=26.75mm, align=center] at ($(174.35mm, 59.7mm + 9.2mm * <<<$i%14>>>)$) {<<<$member->city()>>>};
|
||||||
|
\node[anchor=center, text width=19.75mm, align=center] at ($(199.35mm, 59.7mm + 9.2mm * <<<$i%14>>>)$) {<<<$member->birthdayHuman()>>>};
|
||||||
|
\node[anchor=center, text width=7.75mm, align=center] at ($(216.35mm, 59.7mm + 9.2mm * <<<$i%14>>>)$) {<<<$member->genderLetter()>>>};
|
||||||
|
\node[anchor=center, text width=7.75mm, align=center] at ($(276.35mm, 59.7mm + 9.2mm * <<<$i%14>>>)$) {<<<$member->isLeader ? 'GL' : 'T'>>>};
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
\end{tikzpicture}
|
||||||
|
|
||||||
|
\pagebreak
|
||||||
|
|
||||||
|
@endforeach
|
||||||
|
\end{document}
|
||||||
|
|
|
@ -23,11 +23,11 @@
|
||||||
|
|
||||||
@foreach($chunk as $i => $member)
|
@foreach($chunk as $i => $member)
|
||||||
\node[anchor=base, text width=7.75mm, align=center] at ($(16.35mm, 76.6mm + 7mm * <<<$i % 17>>>)$) {<<<$i+1>>>};
|
\node[anchor=base, text width=7.75mm, align=center] at ($(16.35mm, 76.6mm + 7mm * <<<$i % 17>>>)$) {<<<$i+1>>>};
|
||||||
\node[anchor=base, text width=18mm, align=center] at ($(32.55mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$memberShort($member)>>>};
|
\node[anchor=base, text width=18mm, align=center] at ($(32.55mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$member->isLeader ? 'L' : ''>>>};
|
||||||
\node[anchor=base, text width=70mm, align=center] at ($(80.25mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$memberName($member)>>>};
|
\node[anchor=base, text width=70mm, align=center] at ($(80.25mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$member->separatedName()>>>};
|
||||||
\node[anchor=base, text width=118mm, align=center] at ($(178.25mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$memberAddress($member)>>>};
|
\node[anchor=base, text width=118mm, align=center] at ($(178.25mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$member->fullAddress()>>>};
|
||||||
\node[anchor=base, text width=16mm, align=center] at ($(249.50mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$memberGender($member)>>>};
|
\node[anchor=base, text width=16mm, align=center] at ($(249.50mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$member->genderLetter()>>>};
|
||||||
\node[anchor=base, text width=16mm, align=center] at ($(269.50mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$memberAge($member)>>>};
|
\node[anchor=base, text width=16mm, align=center] at ($(269.50mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$member->age()>>>};
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
\end{tikzpicture}
|
\end{tikzpicture}
|
||||||
|
|
Binary file not shown.
|
@ -2,211 +2,202 @@
|
||||||
|
|
||||||
namespace Tests\Feature\Contribution;
|
namespace Tests\Feature\Contribution;
|
||||||
|
|
||||||
use App\Contribution\Documents\ContributionDocument;
|
|
||||||
use App\Contribution\Documents\RdpNrwDocument;
|
use App\Contribution\Documents\RdpNrwDocument;
|
||||||
use App\Contribution\Documents\CitySolingenDocument;
|
use App\Contribution\Documents\CitySolingenDocument;
|
||||||
|
use App\Contribution\Documents\GallierDocument;
|
||||||
use App\Country;
|
use App\Country;
|
||||||
use App\Gender;
|
use App\Gender;
|
||||||
use App\Invoice\InvoiceSettings;
|
use App\Invoice\InvoiceSettings;
|
||||||
use App\Member\Member;
|
use App\Member\Member;
|
||||||
use Generator;
|
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
use Laravel\Passport\Client;
|
use Laravel\Passport\Client;
|
||||||
use Laravel\Passport\Passport;
|
use Laravel\Passport\Passport;
|
||||||
use PHPUnit\Framework\Attributes\DataProvider;
|
|
||||||
use Tests\RequestFactories\ContributionMemberApiRequestFactory;
|
use Tests\RequestFactories\ContributionMemberApiRequestFactory;
|
||||||
use Tests\RequestFactories\ContributionRequestFactory;
|
use Tests\RequestFactories\ContributionRequestFactory;
|
||||||
use Tests\TestCase;
|
|
||||||
use Zoomyboy\Tex\Tex;
|
use Zoomyboy\Tex\Tex;
|
||||||
|
|
||||||
class StoreTest extends TestCase
|
uses(DatabaseTransactions::class);
|
||||||
{
|
|
||||||
use DatabaseTransactions;
|
|
||||||
|
|
||||||
/**
|
dataset('validation', function () {
|
||||||
* @testWith ["App\\Contribution\\Documents\\CitySolingenDocument", ["Super tolles Lager", "Max Muster", "Jane Muster", "15.06.1991"]]
|
return [
|
||||||
* ["App\\Contribution\\Documents\\RdpNrwDocument", ["Muster, Max", "Muster, Jane", "15.06.1991", "42777 SG"]]
|
[
|
||||||
* ["App\\Contribution\\Documents\\CityRemscheidDocument", ["Max", "Muster", "Jane"]]
|
|
||||||
* ["App\\Contribution\\Documents\\CityFrankfurtMainDocument", ["Max", "Muster", "Jane"]]
|
|
||||||
* ["App\\Contribution\\Documents\\BdkjHesse", ["Max", "Muster", "Jane"]]
|
|
||||||
*
|
|
||||||
* @param array<int, string> $bodyChecks
|
|
||||||
*/
|
|
||||||
public function testItCompilesContributionDocumentsViaRequest(string $type, array $bodyChecks): void
|
|
||||||
{
|
|
||||||
$this->withoutExceptionHandling();
|
|
||||||
Tex::spy();
|
|
||||||
$this->login()->loginNami();
|
|
||||||
$member1 = Member::factory()->defaults()->create(['address' => 'Maxstr 44', 'zip' => '42719', 'firstname' => 'Max', 'lastname' => 'Muster']);
|
|
||||||
$member2 = Member::factory()->defaults()->create(['address' => 'Maxstr 44', 'zip' => '42719', 'firstname' => 'Jane', 'lastname' => 'Muster']);
|
|
||||||
|
|
||||||
$response = $this->call('GET', '/contribution-generate', [
|
|
||||||
'payload' => ContributionRequestFactory::new()->type($type)->state([
|
|
||||||
'dateFrom' => '1991-06-15',
|
|
||||||
'dateUntil' => '1991-06-16',
|
|
||||||
'eventName' => 'Super tolles Lager',
|
|
||||||
'members' => [$member1->id, $member2->id],
|
|
||||||
'type' => $type,
|
|
||||||
'zipLocation' => '42777 SG',
|
|
||||||
])->toBase64(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
$response->assertSessionDoesntHaveErrors();
|
|
||||||
$response->assertOk();
|
|
||||||
Tex::assertCompiled($type, fn ($document) => $document->hasAllContent($bodyChecks));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItCompilesGroupNameInSolingenDocument(): void
|
|
||||||
{
|
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
|
||||||
Tex::spy();
|
|
||||||
InvoiceSettings::fake(['from_long' => 'Stamm BiPi']);
|
|
||||||
|
|
||||||
$this->call('GET', '/contribution-generate', [
|
|
||||||
'payload' => ContributionRequestFactory::new()->type(CitySolingenDocument::class)->toBase64(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
Tex::assertCompiled(CitySolingenDocument::class, fn ($document) => $document->hasAllContent(['Stamm BiPi']));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItCompilesContributionDocumentsViaApi(): void
|
|
||||||
{
|
|
||||||
$this->withoutExceptionHandling();
|
|
||||||
Tex::spy();
|
|
||||||
Gender::factory()->female()->create();
|
|
||||||
Gender::factory()->male()->create();
|
|
||||||
Passport::actingAsClient(Client::factory()->create(), ['contribution-generate']);
|
|
||||||
$country = Country::factory()->create();
|
|
||||||
Member::factory()->defaults()->create(['address' => 'Maxstr 44', 'zip' => '42719', 'firstname' => 'Max', 'lastname' => 'Muster']);
|
|
||||||
Member::factory()->defaults()->create(['address' => 'Maxstr 44', 'zip' => '42719', 'firstname' => 'Jane', 'lastname' => 'Muster']);
|
|
||||||
|
|
||||||
$response = $this->postJson('/api/contribution-generate', [
|
|
||||||
'country' => $country->id,
|
|
||||||
'dateFrom' => '1991-06-15',
|
|
||||||
'dateUntil' => '1991-06-16',
|
|
||||||
'eventName' => 'Super tolles Lager',
|
|
||||||
'type' => CitySolingenDocument::class,
|
|
||||||
'zipLocation' => '42777 SG',
|
|
||||||
'member_data' => [
|
|
||||||
ContributionMemberApiRequestFactory::new()->create(),
|
|
||||||
ContributionMemberApiRequestFactory::new()->create(),
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
$response->assertSessionDoesntHaveErrors();
|
|
||||||
$response->assertOk();
|
|
||||||
Tex::assertCompiled(CitySolingenDocument::class, fn ($document) => $document->hasAllContent(['Super']));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @testWith [""]
|
|
||||||
* ["aaaa"]
|
|
||||||
* ["YWFhCg=="]
|
|
||||||
*/
|
|
||||||
public function testInputShouldBeBase64EncodedJson(string $payload): void
|
|
||||||
{
|
|
||||||
$this->login()->loginNami();
|
|
||||||
|
|
||||||
$this->call('GET', '/contribution-generate', ['payload' => $payload])->assertSessionHasErrors('payload');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string, string> $input
|
|
||||||
* @param class-string<ContributionDocument> $documentClass
|
|
||||||
*/
|
|
||||||
#[DataProvider('validationDataProvider')]
|
|
||||||
public function testItValidatesInput(array $input, string $documentClass, string $errorField): void
|
|
||||||
{
|
|
||||||
$this->login()->loginNami();
|
|
||||||
Country::factory()->create();
|
|
||||||
Member::factory()->defaults()->create();
|
|
||||||
|
|
||||||
$this->postJson('/contribution-validate', ContributionRequestFactory::new()->type($documentClass)->state($input)->create())
|
|
||||||
->assertJsonValidationErrors($errorField);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string, string> $input
|
|
||||||
* @param class-string<ContributionDocument> $documentClass
|
|
||||||
*/
|
|
||||||
#[DataProvider('validationDataProvider')]
|
|
||||||
public function testItValidatesInputBeforeGeneration(array $input, string $documentClass, string $errorField): void
|
|
||||||
{
|
|
||||||
$this->login()->loginNami();
|
|
||||||
Country::factory()->create();
|
|
||||||
Member::factory()->defaults()->create();
|
|
||||||
|
|
||||||
$this->call('GET', '/contribution-generate', [
|
|
||||||
'payload' => ContributionRequestFactory::new()->type($documentClass)->state($input)->toBase64(),
|
|
||||||
])->assertSessionHasErrors($errorField);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function validationDataProvider(): Generator
|
|
||||||
{
|
|
||||||
yield [
|
|
||||||
['type' => 'aaa'],
|
['type' => 'aaa'],
|
||||||
CitySolingenDocument::class,
|
CitySolingenDocument::class,
|
||||||
'type',
|
'type',
|
||||||
];
|
],
|
||||||
yield [
|
[
|
||||||
['type' => ''],
|
['type' => ''],
|
||||||
CitySolingenDocument::class,
|
CitySolingenDocument::class,
|
||||||
'type',
|
'type',
|
||||||
];
|
],
|
||||||
yield [
|
[
|
||||||
['dateFrom' => ''],
|
['dateFrom' => ''],
|
||||||
CitySolingenDocument::class,
|
CitySolingenDocument::class,
|
||||||
'dateFrom',
|
'dateFrom',
|
||||||
];
|
],
|
||||||
yield [
|
[
|
||||||
['dateFrom' => '2022-01'],
|
['dateFrom' => '2022-01'],
|
||||||
CitySolingenDocument::class,
|
CitySolingenDocument::class,
|
||||||
'dateFrom',
|
'dateFrom',
|
||||||
];
|
],
|
||||||
yield [
|
[
|
||||||
['dateUntil' => ''],
|
['dateUntil' => ''],
|
||||||
CitySolingenDocument::class,
|
CitySolingenDocument::class,
|
||||||
'dateUntil',
|
'dateUntil',
|
||||||
];
|
],
|
||||||
yield [
|
[
|
||||||
['dateUntil' => '2022-01'],
|
['dateUntil' => '2022-01'],
|
||||||
CitySolingenDocument::class,
|
CitySolingenDocument::class,
|
||||||
'dateUntil',
|
'dateUntil',
|
||||||
];
|
],
|
||||||
yield [
|
[
|
||||||
['country' => -1],
|
['country' => -1],
|
||||||
RdpNrwDocument::class,
|
RdpNrwDocument::class,
|
||||||
'country',
|
'country',
|
||||||
];
|
],
|
||||||
yield [
|
[
|
||||||
['country' => 'AAAA'],
|
['country' => 'AAAA'],
|
||||||
RdpNrwDocument::class,
|
RdpNrwDocument::class,
|
||||||
'country',
|
'country',
|
||||||
];
|
],
|
||||||
yield [
|
[
|
||||||
['members' => 'A'],
|
['members' => 'A'],
|
||||||
RdpNrwDocument::class,
|
RdpNrwDocument::class,
|
||||||
'members',
|
'members',
|
||||||
];
|
],
|
||||||
yield [
|
[
|
||||||
['members' => [99999]],
|
['members' => [99999]],
|
||||||
RdpNrwDocument::class,
|
RdpNrwDocument::class,
|
||||||
'members.0',
|
'members.0',
|
||||||
];
|
],
|
||||||
yield [
|
[
|
||||||
['members' => ['lalala']],
|
['members' => ['lalala']],
|
||||||
RdpNrwDocument::class,
|
RdpNrwDocument::class,
|
||||||
'members.0',
|
'members.0',
|
||||||
];
|
],
|
||||||
yield [
|
[
|
||||||
['eventName' => ''],
|
['eventName' => ''],
|
||||||
CitySolingenDocument::class,
|
CitySolingenDocument::class,
|
||||||
'eventName',
|
'eventName',
|
||||||
];
|
],
|
||||||
yield [
|
[
|
||||||
['zipLocation' => ''],
|
['zipLocation' => ''],
|
||||||
CitySolingenDocument::class,
|
CitySolingenDocument::class,
|
||||||
'zipLocation',
|
'zipLocation',
|
||||||
];
|
],
|
||||||
}
|
[
|
||||||
}
|
['zipLocation' => ''],
|
||||||
|
GallierDocument::class,
|
||||||
|
'zipLocation',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
['dateFrom' => ''],
|
||||||
|
GallierDocument::class,
|
||||||
|
'dateFrom',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
['dateUntil' => ''],
|
||||||
|
GallierDocument::class,
|
||||||
|
'dateUntil',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
it('compiles documents via api', function (string $type, array $bodyChecks) {
|
||||||
|
$this->withoutExceptionHandling();
|
||||||
|
Tex::spy();
|
||||||
|
$this->login()->loginNami();
|
||||||
|
$member1 = Member::factory()->defaults()->male()->create(['address' => 'Maxstr 44', 'zip' => '42719', 'firstname' => 'Max', 'lastname' => 'Muster']);
|
||||||
|
$member2 = Member::factory()->defaults()->female()->create(['address' => 'Maxstr 44', 'zip' => '42719', 'firstname' => 'Jane', 'lastname' => 'Muster']);
|
||||||
|
|
||||||
|
$response = $this->call('GET', '/contribution-generate', [
|
||||||
|
'payload' => ContributionRequestFactory::new()->type($type)->state([
|
||||||
|
'dateFrom' => '1991-06-15',
|
||||||
|
'dateUntil' => '1991-06-16',
|
||||||
|
'eventName' => 'Super tolles Lager',
|
||||||
|
'members' => [$member1->id, $member2->id],
|
||||||
|
'type' => $type,
|
||||||
|
'zipLocation' => '42777 SG',
|
||||||
|
])->toBase64(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertSessionDoesntHaveErrors();
|
||||||
|
$response->assertOk();
|
||||||
|
Tex::assertCompiled($type, fn ($document) => $document->hasAllContent($bodyChecks));
|
||||||
|
})->with([
|
||||||
|
["App\\Contribution\\Documents\\CitySolingenDocument", ["Super tolles Lager", "Max Muster", "Jane Muster", "15.06.1991"]],
|
||||||
|
["App\\Contribution\\Documents\\RdpNrwDocument", ["Muster, Max", "Muster, Jane", "15.06.1991", "42777 SG"]],
|
||||||
|
["App\\Contribution\\Documents\\CityRemscheidDocument", ["Max", "Muster", "Jane"]],
|
||||||
|
["App\\Contribution\\Documents\\CityFrankfurtMainDocument", ["Max", "Muster", "Jane"]],
|
||||||
|
["App\\Contribution\\Documents\\BdkjHesse", ["Max", "Muster", "Jane"]],
|
||||||
|
["App\\Contribution\\Documents\\GallierDocument", ["Max", "Muster", "Jane", "42777 SG", "15.06.1991", "16.06.1991"]],
|
||||||
|
]);
|
||||||
|
|
||||||
|
it('testItCompilesGroupNameInSolingenDocument', function () {
|
||||||
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
|
Tex::spy();
|
||||||
|
InvoiceSettings::fake(['from_long' => 'Stamm BiPi']);
|
||||||
|
|
||||||
|
$this->call('GET', '/contribution-generate', [
|
||||||
|
'payload' => ContributionRequestFactory::new()->type(CitySolingenDocument::class)->toBase64(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
Tex::assertCompiled(CitySolingenDocument::class, fn ($document) => $document->hasAllContent(['Stamm BiPi']));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('testItCompilesContributionDocumentsViaApi', function () {
|
||||||
|
$this->withoutExceptionHandling();
|
||||||
|
Tex::spy();
|
||||||
|
Gender::factory()->female()->create();
|
||||||
|
Gender::factory()->male()->create();
|
||||||
|
Passport::actingAsClient(Client::factory()->create(), ['contribution-generate']);
|
||||||
|
$country = Country::factory()->create();
|
||||||
|
Member::factory()->defaults()->create(['address' => 'Maxstr 44', 'zip' => '42719', 'firstname' => 'Max', 'lastname' => 'Muster']);
|
||||||
|
Member::factory()->defaults()->create(['address' => 'Maxstr 44', 'zip' => '42719', 'firstname' => 'Jane', 'lastname' => 'Muster']);
|
||||||
|
|
||||||
|
$response = $this->postJson('/api/contribution-generate', [
|
||||||
|
'country' => $country->id,
|
||||||
|
'dateFrom' => '1991-06-15',
|
||||||
|
'dateUntil' => '1991-06-16',
|
||||||
|
'eventName' => 'Super tolles Lager',
|
||||||
|
'type' => CitySolingenDocument::class,
|
||||||
|
'zipLocation' => '42777 SG',
|
||||||
|
'member_data' => [
|
||||||
|
ContributionMemberApiRequestFactory::new()->create(),
|
||||||
|
ContributionMemberApiRequestFactory::new()->create(),
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertSessionDoesntHaveErrors();
|
||||||
|
$response->assertOk();
|
||||||
|
Tex::assertCompiled(CitySolingenDocument::class, fn ($document) => $document->hasAllContent(['Super']));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('testInputShouldBeBase64EncodedJson', function (string $payload) {
|
||||||
|
$this->login()->loginNami();
|
||||||
|
|
||||||
|
$this->call('GET', '/contribution-generate', ['payload' => $payload])->assertSessionHasErrors('payload');
|
||||||
|
})->with([
|
||||||
|
[""],
|
||||||
|
["aaaa"],
|
||||||
|
["YWFhCg=="],
|
||||||
|
]);
|
||||||
|
|
||||||
|
it('testItValidatesInput', function (array $input, string $documentClass, string $errorField) {
|
||||||
|
$this->login()->loginNami();
|
||||||
|
Country::factory()->create();
|
||||||
|
Member::factory()->defaults()->create();
|
||||||
|
|
||||||
|
$this->postJson('/contribution-validate', ContributionRequestFactory::new()->type($documentClass)->state($input)->create())
|
||||||
|
->assertJsonValidationErrors($errorField);
|
||||||
|
})->with('validation');
|
||||||
|
|
||||||
|
it('testItValidatesInputBeforeGeneration', function (array $input, string $documentClass, string $errorField) {
|
||||||
|
$this->login()->loginNami();
|
||||||
|
Country::factory()->create();
|
||||||
|
Member::factory()->defaults()->create();
|
||||||
|
|
||||||
|
$this->call('GET', '/contribution-generate', [
|
||||||
|
'payload' => ContributionRequestFactory::new()->type($documentClass)->state($input)->toBase64(),
|
||||||
|
])->assertSessionHasErrors($errorField);
|
||||||
|
})->with('validation');
|
||||||
|
|
Loading…
Reference in New Issue