Compare commits
No commits in common. "4651a4cb96125a2a560e992d2f636e128c1381e5" and "b05c5025c02234bca7de19dbb0fbb7919d8aaf90" have entirely different histories.
4651a4cb96
...
b05c5025c0
|
@ -8,7 +8,6 @@ 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;
|
||||||
|
|
||||||
|
@ -23,7 +22,6 @@ class ContributionFactory
|
||||||
CityRemscheidDocument::class,
|
CityRemscheidDocument::class,
|
||||||
CityFrankfurtMainDocument::class,
|
CityFrankfurtMainDocument::class,
|
||||||
BdkjHesse::class,
|
BdkjHesse::class,
|
||||||
GallierDocument::class,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,7 +30,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::buttonName(),
|
'title' => $document::getName(),
|
||||||
'class' => $document,
|
'class' => $document,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,23 +72,13 @@ class MemberData extends Data
|
||||||
return $this->zip . ' ' . $this->location;
|
return $this->zip . ' ' . $this->location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function age(): int
|
public function age(): string
|
||||||
{
|
{
|
||||||
return intval($this->birthday->diffInYears(now()));
|
return (string) $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,16 +3,15 @@
|
||||||
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
|
||||||
*/
|
*/
|
||||||
|
@ -26,7 +25,6 @@ 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
|
||||||
|
@ -116,9 +114,36 @@ 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 'BDKJ Hessen';
|
return 'Für BDKJ Hessen erstellen';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,6 +156,7 @@ 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,17 +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 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,7 +28,6 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +61,17 @@ 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;
|
||||||
|
@ -73,9 +82,56 @@ 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 'Frankfurt';
|
return 'Für Frankfurt erstellen';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,6 +144,7 @@ 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,17 +3,15 @@
|
||||||
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
|
||||||
|
@ -27,9 +25,17 @@ 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');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +52,6 @@ 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'],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,13 +70,39 @@ 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 'Remscheid';
|
return 'Für Remscheid erstellen';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,7 +6,9 @@ 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
|
||||||
{
|
{
|
||||||
|
@ -23,7 +25,6 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +74,11 @@ 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 = '';
|
||||||
|
@ -88,6 +94,16 @@ 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;
|
||||||
|
@ -95,7 +111,7 @@ class CitySolingenDocument extends ContributionDocument
|
||||||
|
|
||||||
public static function getName(): string
|
public static function getName(): string
|
||||||
{
|
{
|
||||||
return 'Stadt Solingen';
|
return 'Für Stadt Solingen erstellen';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,6 +123,7 @@ 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,12 +3,9 @@
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,34 +29,8 @@ 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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,79 +0,0 @@
|
||||||
<?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,16 +3,14 @@
|
||||||
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
|
||||||
*/
|
*/
|
||||||
|
@ -24,9 +22,14 @@ 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');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,7 +43,6 @@ 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'],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +57,6 @@ 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'],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,9 +65,65 @@ 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 'RdP NRW';
|
return 'Für RdP NRW erstellen';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,6 +136,7 @@ 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',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?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()]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Contribution\Traits;
|
|
||||||
|
|
||||||
use Zoomyboy\Tex\Engine;
|
|
||||||
|
|
||||||
trait HasPdfBackground
|
|
||||||
{
|
|
||||||
public function getEngine(): Engine
|
|
||||||
{
|
|
||||||
return Engine::PDFLATEX;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -25,15 +25,6 @@ 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{<<<!!$niceDateFrom()!!>>>}}};
|
\node[anchor=base west, text width=41.3mm, align=center] at (170.7mm,47.0mm) {\bfseries{\large{<<<!!$dateFromHuman()!!>>>}}};
|
||||||
\node[anchor=base west, text width=38.4mm, align=center] at (219.9mm,47.0mm) {\bfseries{\large{<<<!!$niceDateUntil()!!>>>}}};
|
\node[anchor=base west, text width=38.4mm, align=center] at (219.9mm,47.0mm) {\bfseries{\large{<<<!!$dateUntilHuman()!!>>>}}};
|
||||||
|
|
||||||
@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>>>)$) {<<<$member->isLeader ? 'L' : ''>>>};
|
\node[anchor=base, text width=4mm, align=center] at ($(8.0mm, 69.0mm + 8.05mm * <<<$j%15>>>)$) {<<<$memberShort($member)>>>};
|
||||||
\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>>>)$) {<<<$member->separatedName()>>>};
|
\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=14.6mm, align=center] at ($(92.2mm, 69.0mm + 8.05mm * <<<$j%15>>>)$) {<<<$member->age()>>>};
|
\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=79.4mm, align=center] at ($(139.7mm, 69.0mm + 8.05mm * <<<$j%15>>>)$) {<<<$member->fullAddress()>>>};
|
\node[anchor=base, text width=79.4mm, align=center] at ($(139.7mm, 69.0mm + 8.05mm * <<<$j%15>>>)$) {<<<$memberAddress($member)>>>};
|
||||||
@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!!>>>};
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
\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>>>)$) {<<<$member->isLeader ? 'L' : ''>>>};
|
\node[anchor=base, text width=18mm, align=center] at ($(32.55mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$memberShort($member)>>>};
|
||||||
\node[anchor=base, text width=70mm, align=center] at ($(80.25mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$member->separatedName()>>>};
|
\node[anchor=base, text width=70mm, align=center] at ($(80.25mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$memberName($member)>>>};
|
||||||
\node[anchor=base, text width=118mm, align=center] at ($(178.25mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$member->fullAddress()>>>};
|
\node[anchor=base, text width=118mm, align=center] at ($(178.25mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$memberAddress($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 ($(249.50mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$memberGender($member)>>>};
|
||||||
\node[anchor=base, text width=16mm, align=center] at ($(269.50mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$member->age()>>>};
|
\node[anchor=base, text width=16mm, align=center] at ($(269.50mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$memberAge($member)>>>};
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
\end{tikzpicture}
|
\end{tikzpicture}
|
||||||
|
|
Binary file not shown.
|
@ -2,202 +2,211 @@
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
uses(DatabaseTransactions::class);
|
class StoreTest extends TestCase
|
||||||
|
{
|
||||||
|
use DatabaseTransactions;
|
||||||
|
|
||||||
dataset('validation', function () {
|
/**
|
||||||
return [
|
* @testWith ["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"]]
|
||||||
['type' => 'aaa'],
|
* ["App\\Contribution\\Documents\\CityRemscheidDocument", ["Max", "Muster", "Jane"]]
|
||||||
CitySolingenDocument::class,
|
* ["App\\Contribution\\Documents\\CityFrankfurtMainDocument", ["Max", "Muster", "Jane"]]
|
||||||
'type',
|
* ["App\\Contribution\\Documents\\BdkjHesse", ["Max", "Muster", "Jane"]]
|
||||||
],
|
*
|
||||||
[
|
* @param array<int, string> $bodyChecks
|
||||||
['type' => ''],
|
*/
|
||||||
CitySolingenDocument::class,
|
public function testItCompilesContributionDocumentsViaRequest(string $type, array $bodyChecks): void
|
||||||
'type',
|
{
|
||||||
],
|
$this->withoutExceptionHandling();
|
||||||
[
|
Tex::spy();
|
||||||
['dateFrom' => ''],
|
$this->login()->loginNami();
|
||||||
CitySolingenDocument::class,
|
$member1 = Member::factory()->defaults()->create(['address' => 'Maxstr 44', 'zip' => '42719', 'firstname' => 'Max', 'lastname' => 'Muster']);
|
||||||
'dateFrom',
|
$member2 = Member::factory()->defaults()->create(['address' => 'Maxstr 44', 'zip' => '42719', 'firstname' => 'Jane', 'lastname' => 'Muster']);
|
||||||
],
|
|
||||||
[
|
|
||||||
['dateFrom' => '2022-01'],
|
|
||||||
CitySolingenDocument::class,
|
|
||||||
'dateFrom',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
['dateUntil' => ''],
|
|
||||||
CitySolingenDocument::class,
|
|
||||||
'dateUntil',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
['dateUntil' => '2022-01'],
|
|
||||||
CitySolingenDocument::class,
|
|
||||||
'dateUntil',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
['country' => -1],
|
|
||||||
RdpNrwDocument::class,
|
|
||||||
'country',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
['country' => 'AAAA'],
|
|
||||||
RdpNrwDocument::class,
|
|
||||||
'country',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
['members' => 'A'],
|
|
||||||
RdpNrwDocument::class,
|
|
||||||
'members',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
['members' => [99999]],
|
|
||||||
RdpNrwDocument::class,
|
|
||||||
'members.0',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
['members' => ['lalala']],
|
|
||||||
RdpNrwDocument::class,
|
|
||||||
'members.0',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
['eventName' => ''],
|
|
||||||
CitySolingenDocument::class,
|
|
||||||
'eventName',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
['zipLocation' => ''],
|
|
||||||
CitySolingenDocument::class,
|
|
||||||
'zipLocation',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
['zipLocation' => ''],
|
|
||||||
GallierDocument::class,
|
|
||||||
'zipLocation',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
['dateFrom' => ''],
|
|
||||||
GallierDocument::class,
|
|
||||||
'dateFrom',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
['dateUntil' => ''],
|
|
||||||
GallierDocument::class,
|
|
||||||
'dateUntil',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
it('compiles documents via api', function (string $type, array $bodyChecks) {
|
$response = $this->call('GET', '/contribution-generate', [
|
||||||
$this->withoutExceptionHandling();
|
'payload' => ContributionRequestFactory::new()->type($type)->state([
|
||||||
Tex::spy();
|
'dateFrom' => '1991-06-15',
|
||||||
$this->login()->loginNami();
|
'dateUntil' => '1991-06-16',
|
||||||
$member1 = Member::factory()->defaults()->male()->create(['address' => 'Maxstr 44', 'zip' => '42719', 'firstname' => 'Max', 'lastname' => 'Muster']);
|
'eventName' => 'Super tolles Lager',
|
||||||
$member2 = Member::factory()->defaults()->female()->create(['address' => 'Maxstr 44', 'zip' => '42719', 'firstname' => 'Jane', 'lastname' => 'Muster']);
|
'members' => [$member1->id, $member2->id],
|
||||||
|
'type' => $type,
|
||||||
|
'zipLocation' => '42777 SG',
|
||||||
|
])->toBase64(),
|
||||||
|
]);
|
||||||
|
|
||||||
$response = $this->call('GET', '/contribution-generate', [
|
$response->assertSessionDoesntHaveErrors();
|
||||||
'payload' => ContributionRequestFactory::new()->type($type)->state([
|
$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',
|
'dateFrom' => '1991-06-15',
|
||||||
'dateUntil' => '1991-06-16',
|
'dateUntil' => '1991-06-16',
|
||||||
'eventName' => 'Super tolles Lager',
|
'eventName' => 'Super tolles Lager',
|
||||||
'members' => [$member1->id, $member2->id],
|
'type' => CitySolingenDocument::class,
|
||||||
'type' => $type,
|
|
||||||
'zipLocation' => '42777 SG',
|
'zipLocation' => '42777 SG',
|
||||||
])->toBase64(),
|
'member_data' => [
|
||||||
]);
|
ContributionMemberApiRequestFactory::new()->create(),
|
||||||
|
ContributionMemberApiRequestFactory::new()->create(),
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
$response->assertSessionDoesntHaveErrors();
|
$response->assertSessionDoesntHaveErrors();
|
||||||
$response->assertOk();
|
$response->assertOk();
|
||||||
Tex::assertCompiled($type, fn ($document) => $document->hasAllContent($bodyChecks));
|
Tex::assertCompiled(CitySolingenDocument::class, fn ($document) => $document->hasAllContent(['Super']));
|
||||||
})->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();
|
* @testWith [""]
|
||||||
Tex::spy();
|
* ["aaaa"]
|
||||||
InvoiceSettings::fake(['from_long' => 'Stamm BiPi']);
|
* ["YWFhCg=="]
|
||||||
|
*/
|
||||||
|
public function testInputShouldBeBase64EncodedJson(string $payload): void
|
||||||
|
{
|
||||||
|
$this->login()->loginNami();
|
||||||
|
|
||||||
$this->call('GET', '/contribution-generate', [
|
$this->call('GET', '/contribution-generate', ['payload' => $payload])->assertSessionHasErrors('payload');
|
||||||
'payload' => ContributionRequestFactory::new()->type(CitySolingenDocument::class)->toBase64(),
|
}
|
||||||
]);
|
|
||||||
|
|
||||||
Tex::assertCompiled(CitySolingenDocument::class, fn ($document) => $document->hasAllContent(['Stamm BiPi']));
|
/**
|
||||||
});
|
* @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();
|
||||||
|
|
||||||
it('testItCompilesContributionDocumentsViaApi', function () {
|
$this->postJson('/contribution-validate', ContributionRequestFactory::new()->type($documentClass)->state($input)->create())
|
||||||
$this->withoutExceptionHandling();
|
->assertJsonValidationErrors($errorField);
|
||||||
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,
|
* @param array<string, string> $input
|
||||||
'dateFrom' => '1991-06-15',
|
* @param class-string<ContributionDocument> $documentClass
|
||||||
'dateUntil' => '1991-06-16',
|
*/
|
||||||
'eventName' => 'Super tolles Lager',
|
#[DataProvider('validationDataProvider')]
|
||||||
'type' => CitySolingenDocument::class,
|
public function testItValidatesInputBeforeGeneration(array $input, string $documentClass, string $errorField): void
|
||||||
'zipLocation' => '42777 SG',
|
{
|
||||||
'member_data' => [
|
$this->login()->loginNami();
|
||||||
ContributionMemberApiRequestFactory::new()->create(),
|
Country::factory()->create();
|
||||||
ContributionMemberApiRequestFactory::new()->create(),
|
Member::factory()->defaults()->create();
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
$response->assertSessionDoesntHaveErrors();
|
$this->call('GET', '/contribution-generate', [
|
||||||
$response->assertOk();
|
'payload' => ContributionRequestFactory::new()->type($documentClass)->state($input)->toBase64(),
|
||||||
Tex::assertCompiled(CitySolingenDocument::class, fn ($document) => $document->hasAllContent(['Super']));
|
])->assertSessionHasErrors($errorField);
|
||||||
});
|
}
|
||||||
|
|
||||||
it('testInputShouldBeBase64EncodedJson', function (string $payload) {
|
public static function validationDataProvider(): Generator
|
||||||
$this->login()->loginNami();
|
{
|
||||||
|
yield [
|
||||||
$this->call('GET', '/contribution-generate', ['payload' => $payload])->assertSessionHasErrors('payload');
|
['type' => 'aaa'],
|
||||||
})->with([
|
CitySolingenDocument::class,
|
||||||
[""],
|
'type',
|
||||||
["aaaa"],
|
];
|
||||||
["YWFhCg=="],
|
yield [
|
||||||
]);
|
['type' => ''],
|
||||||
|
CitySolingenDocument::class,
|
||||||
it('testItValidatesInput', function (array $input, string $documentClass, string $errorField) {
|
'type',
|
||||||
$this->login()->loginNami();
|
];
|
||||||
Country::factory()->create();
|
yield [
|
||||||
Member::factory()->defaults()->create();
|
['dateFrom' => ''],
|
||||||
|
CitySolingenDocument::class,
|
||||||
$this->postJson('/contribution-validate', ContributionRequestFactory::new()->type($documentClass)->state($input)->create())
|
'dateFrom',
|
||||||
->assertJsonValidationErrors($errorField);
|
];
|
||||||
})->with('validation');
|
yield [
|
||||||
|
['dateFrom' => '2022-01'],
|
||||||
it('testItValidatesInputBeforeGeneration', function (array $input, string $documentClass, string $errorField) {
|
CitySolingenDocument::class,
|
||||||
$this->login()->loginNami();
|
'dateFrom',
|
||||||
Country::factory()->create();
|
];
|
||||||
Member::factory()->defaults()->create();
|
yield [
|
||||||
|
['dateUntil' => ''],
|
||||||
$this->call('GET', '/contribution-generate', [
|
CitySolingenDocument::class,
|
||||||
'payload' => ContributionRequestFactory::new()->type($documentClass)->state($input)->toBase64(),
|
'dateUntil',
|
||||||
])->assertSessionHasErrors($errorField);
|
];
|
||||||
})->with('validation');
|
yield [
|
||||||
|
['dateUntil' => '2022-01'],
|
||||||
|
CitySolingenDocument::class,
|
||||||
|
'dateUntil',
|
||||||
|
];
|
||||||
|
yield [
|
||||||
|
['country' => -1],
|
||||||
|
RdpNrwDocument::class,
|
||||||
|
'country',
|
||||||
|
];
|
||||||
|
yield [
|
||||||
|
['country' => 'AAAA'],
|
||||||
|
RdpNrwDocument::class,
|
||||||
|
'country',
|
||||||
|
];
|
||||||
|
yield [
|
||||||
|
['members' => 'A'],
|
||||||
|
RdpNrwDocument::class,
|
||||||
|
'members',
|
||||||
|
];
|
||||||
|
yield [
|
||||||
|
['members' => [99999]],
|
||||||
|
RdpNrwDocument::class,
|
||||||
|
'members.0',
|
||||||
|
];
|
||||||
|
yield [
|
||||||
|
['members' => ['lalala']],
|
||||||
|
RdpNrwDocument::class,
|
||||||
|
'members.0',
|
||||||
|
];
|
||||||
|
yield [
|
||||||
|
['eventName' => ''],
|
||||||
|
CitySolingenDocument::class,
|
||||||
|
'eventName',
|
||||||
|
];
|
||||||
|
yield [
|
||||||
|
['zipLocation' => ''],
|
||||||
|
CitySolingenDocument::class,
|
||||||
|
'zipLocation',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue