Fixed: dont group by firstname
This commit is contained in:
parent
1c0a68d4c6
commit
21bb6aadf6
|
@ -20,7 +20,7 @@ class PdfRepositoryFactory
|
||||||
|
|
||||||
public function fromSingleRequest(string $type, Member $member): ?PdfRepository
|
public function fromSingleRequest(string $type, Member $member): ?PdfRepository
|
||||||
{
|
{
|
||||||
$members = $this->singleMemberCollection($member);
|
$members = $this->singleMemberCollection($member, $type);
|
||||||
|
|
||||||
if ($members->isEmpty()) {
|
if ($members->isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -34,11 +34,11 @@ class PdfRepositoryFactory
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function singleMemberCollection(Member $member): Collection
|
public function singleMemberCollection(Member $member, string $type): Collection
|
||||||
{
|
{
|
||||||
$members = Member::where($member->only(['firstname', 'lastname', 'address', 'zip', 'location']))
|
$members = Member::where($member->only(['lastname', 'address', 'zip', 'location']))
|
||||||
->whereHas('payments', fn ($q) => $q->whereNeedsPayment())
|
->get()
|
||||||
->get();
|
->filter(fn (Member $member) => app($type)->createable($member));
|
||||||
|
|
||||||
return $this->toMemberGroup($members);
|
return $this->toMemberGroup($members);
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ class PdfRepositoryFactory
|
||||||
{
|
{
|
||||||
return $members->groupBy(
|
return $members->groupBy(
|
||||||
fn ($member) => Str::slug(
|
fn ($member) => Str::slug(
|
||||||
"{$member->firstname}{$member->lastname}{$member->address}{$member->zip}{$member->location}",
|
"{$member->lastname}{$member->address}{$member->zip}{$member->location}",
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,47 @@ class GenerateTest extends TestCase
|
||||||
'29.04.2021',
|
'29.04.2021',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'families' => [
|
||||||
|
'members' => [
|
||||||
|
[
|
||||||
|
'factory' => fn (MemberFactory $member): MemberFactory => $member
|
||||||
|
->state([
|
||||||
|
'firstname' => '::firstname1::',
|
||||||
|
'lastname' => '::lastname::',
|
||||||
|
'address' => '::address::',
|
||||||
|
'zip' => '12345',
|
||||||
|
'location' => '::location::',
|
||||||
|
]),
|
||||||
|
'payments' => [
|
||||||
|
fn (PaymentFactory $payment): PaymentFactory => $payment
|
||||||
|
->nr('::nr::')->notPaid()->subscription('::subName::', 1500),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'factory' => fn (MemberFactory $member): MemberFactory => $member
|
||||||
|
->state([
|
||||||
|
'firstname' => '::firstname2::',
|
||||||
|
'lastname' => '::lastname::',
|
||||||
|
'address' => '::address::',
|
||||||
|
'zip' => '12345',
|
||||||
|
'location' => '::location::',
|
||||||
|
]),
|
||||||
|
'payments' => [
|
||||||
|
fn (PaymentFactory $payment): PaymentFactory => $payment
|
||||||
|
->nr('::nr2::')->notPaid()->subscription('::subName2::', 1600),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'urlCallable' => fn (Collection $members): int => $members->first()->id,
|
||||||
|
'type' => BillType::class,
|
||||||
|
'filename' => 'rechnung-fur-lastname.pdf',
|
||||||
|
'output' => [
|
||||||
|
'::nr::',
|
||||||
|
'::nr2::',
|
||||||
|
'::subName::',
|
||||||
|
'::subName2::',
|
||||||
|
],
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue