Move letter to invoice
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
b0874cecda
commit
aba214614c
|
@ -4,7 +4,7 @@ namespace App\Console;
|
|||
|
||||
use App\Initialize\Actions\InitializeAction;
|
||||
use App\Initialize\InitializeMembers;
|
||||
use App\Letter\Actions\LetterSendAction;
|
||||
use App\Invoice\Actions\InvoiceSendAction;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
use Laravel\Telescope\Console\PruneCommand;
|
||||
|
@ -17,7 +17,7 @@ class Kernel extends ConsoleKernel
|
|||
* @var array<int, class-string>
|
||||
*/
|
||||
protected $commands = [
|
||||
LetterSendAction::class,
|
||||
InvoiceSendAction::class,
|
||||
InitializeAction::class,
|
||||
InitializeMembers::class,
|
||||
];
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace App\Invoice\Actions;
|
||||
|
||||
use App\Invoice\BillKind;
|
||||
use App\Invoice\DocumentFactory;
|
||||
use App\Invoice\Queries\BillKindQuery;
|
||||
use App\Payment\PaymentMail;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
use Zoomyboy\Tex\Tex;
|
||||
|
||||
class InvoiceSendAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*/
|
||||
public string $commandSignature = 'invoice:send';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Sends Bills';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
foreach (app(DocumentFactory::class)->getTypes() as $type) {
|
||||
$invoices = app(DocumentFactory::class)->invoiceCollection($type, new BillKindQuery(BillKind::EMAIL));
|
||||
|
||||
foreach ($invoices as $invoice) {
|
||||
$invoicePath = Storage::disk('temp')->path(Tex::compile($invoice)->storeIn('', 'temp'));
|
||||
Mail::to($invoice->getRecipient())
|
||||
->send(new PaymentMail($invoice, $invoicePath));
|
||||
app(DocumentFactory::class)->afterSingle($invoice);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace App\Letter;
|
||||
namespace App\Invoice;
|
||||
|
||||
use App\Payment\Payment;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class BillDocument extends Letter
|
||||
class BillDocument extends Invoice
|
||||
{
|
||||
public function linkLabel(): string
|
||||
{
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Letter;
|
||||
namespace App\Invoice;
|
||||
|
||||
enum BillKind: string
|
||||
{
|
|
@ -1,14 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace App\Letter;
|
||||
namespace App\Invoice;
|
||||
|
||||
use App\Letter\Queries\LetterMemberQuery;
|
||||
use App\Invoice\Queries\InvoiceMemberQuery;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class DocumentFactory
|
||||
{
|
||||
/**
|
||||
* @var array<int, class-string<Letter>>
|
||||
* @var array<int, class-string<Invoice>>
|
||||
*/
|
||||
private array $types = [
|
||||
BillDocument::class,
|
||||
|
@ -16,7 +16,7 @@ class DocumentFactory
|
|||
];
|
||||
|
||||
/**
|
||||
* @return Collection<int, class-string<Letter>>
|
||||
* @return Collection<int, class-string<Invoice>>
|
||||
*/
|
||||
public function getTypes(): Collection
|
||||
{
|
||||
|
@ -24,9 +24,9 @@ class DocumentFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* @param class-string<Letter> $type
|
||||
* @param class-string<Invoice> $type
|
||||
*/
|
||||
public function singleLetter(string $type, LetterMemberQuery $query): ?Letter
|
||||
public function singleInvoice(string $type, InvoiceMemberQuery $query): ?Invoice
|
||||
{
|
||||
$pages = $query->getPages($type);
|
||||
|
||||
|
@ -38,29 +38,29 @@ class DocumentFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* @param class-string<Letter> $type
|
||||
* @param class-string<Invoice> $type
|
||||
*
|
||||
* @return Collection<int, Letter>
|
||||
* @return Collection<int, Invoice>
|
||||
*/
|
||||
public function letterCollection(string $type, LetterMemberQuery $query): Collection
|
||||
public function invoiceCollection(string $type, InvoiceMemberQuery $query): Collection
|
||||
{
|
||||
return $query
|
||||
->getPages($type)
|
||||
->map(fn ($page) => $this->resolve($type, collect([$page])));
|
||||
}
|
||||
|
||||
public function afterSingle(Letter $letter): void
|
||||
public function afterSingle(Invoice $invoice): void
|
||||
{
|
||||
foreach ($letter->allPayments() as $payment) {
|
||||
$letter->afterSingle($payment);
|
||||
foreach ($invoice->allPayments() as $payment) {
|
||||
$invoice->afterSingle($payment);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<Letter> $type
|
||||
* @param class-string<Invoice> $type
|
||||
* @param Collection<int, Page> $pages
|
||||
*/
|
||||
private function resolve(string $type, Collection $pages): Letter
|
||||
private function resolve(string $type, Collection $pages): Invoice
|
||||
{
|
||||
return new $type($pages);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Letter;
|
||||
namespace App\Invoice;
|
||||
|
||||
use App\Payment\Payment;
|
||||
use Carbon\Carbon;
|
||||
|
@ -13,7 +13,7 @@ use Zoomyboy\Tex\Document;
|
|||
use Zoomyboy\Tex\Engine;
|
||||
use Zoomyboy\Tex\Template;
|
||||
|
||||
abstract class Letter extends Document
|
||||
abstract class Invoice extends Document
|
||||
{
|
||||
abstract public function getSubject(): string;
|
||||
|
||||
|
@ -44,7 +44,7 @@ abstract class Letter extends Document
|
|||
public string $subject;
|
||||
protected string $filename;
|
||||
public string $until;
|
||||
public LetterSettings $settings;
|
||||
public InvoiceSettings $settings;
|
||||
|
||||
/**
|
||||
* @param Collection<int, Page> $pages
|
||||
|
@ -55,7 +55,7 @@ abstract class Letter extends Document
|
|||
$this->subject = $this->getSubject();
|
||||
$this->until = now()->addWeeks(2)->format('d.m.Y');
|
||||
$this->setFilename(Str::slug("{$this->getSubject()} für {$pages->first()?->familyName}"));
|
||||
$this->settings = app(LetterSettings::class);
|
||||
$this->settings = app(InvoiceSettings::class);
|
||||
}
|
||||
|
||||
public function number(int $number): string
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Letter;
|
||||
namespace App\Invoice;
|
||||
|
||||
use App\Setting\LocalSettings;
|
||||
|
||||
class LetterSettings extends LocalSettings
|
||||
class InvoiceSettings extends LocalSettings
|
||||
{
|
||||
public string $from_long;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Letter;
|
||||
namespace App\Invoice;
|
||||
|
||||
class MailRecipient
|
||||
{
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Letter;
|
||||
namespace App\Invoice;
|
||||
|
||||
use App\Member\Member;
|
||||
use App\Payment\Payment;
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace App\Letter\Queries;
|
||||
namespace App\Invoice\Queries;
|
||||
|
||||
use App\Letter\BillKind;
|
||||
use App\Invoice\BillKind;
|
||||
use App\Member\Member;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class BillKindQuery extends LetterMemberQuery
|
||||
class BillKindQuery extends InvoiceMemberQuery
|
||||
{
|
||||
public function __construct(
|
||||
private BillKind $billKind
|
|
@ -1,16 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace App\Letter\Queries;
|
||||
namespace App\Invoice\Queries;
|
||||
|
||||
use App\Letter\Letter;
|
||||
use App\Letter\Page;
|
||||
use App\Invoice\Invoice;
|
||||
use App\Invoice\Page;
|
||||
use App\Member\Member;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
abstract class LetterMemberQuery
|
||||
abstract class InvoiceMemberQuery
|
||||
{
|
||||
/**
|
||||
* @return Builder<Member>
|
||||
|
@ -18,7 +18,7 @@ abstract class LetterMemberQuery
|
|||
abstract protected function getQuery(): Builder;
|
||||
|
||||
/**
|
||||
* @param class-string<Letter> $type
|
||||
* @param class-string<Invoice> $type
|
||||
*
|
||||
* @return Collection<int, Page>
|
||||
*/
|
||||
|
@ -32,7 +32,7 @@ abstract class LetterMemberQuery
|
|||
}
|
||||
|
||||
/**
|
||||
* @param class-string<Letter> $type
|
||||
* @param class-string<Invoice> $type
|
||||
*
|
||||
* @return EloquentCollection<int, Member>
|
||||
*/
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace App\Letter\Queries;
|
||||
namespace App\Invoice\Queries;
|
||||
|
||||
use App\Member\Member;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class SingleMemberQuery extends LetterMemberQuery
|
||||
class SingleMemberQuery extends InvoiceMemberQuery
|
||||
{
|
||||
public function __construct(
|
||||
private Member $member
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace App\Letter;
|
||||
namespace App\Invoice;
|
||||
|
||||
use App\Payment\Payment;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class RememberDocument extends Letter
|
||||
class RememberDocument extends Invoice
|
||||
{
|
||||
public function linkLabel(): string
|
||||
{
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Letter;
|
||||
namespace App\Invoice;
|
||||
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
@ -13,7 +13,7 @@ class SettingIndexAction
|
|||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function handle(LetterSettings $settings): array
|
||||
public function handle(InvoiceSettings $settings): array
|
||||
{
|
||||
return [
|
||||
'from_long' => $settings->from_long,
|
||||
|
@ -29,7 +29,7 @@ class SettingIndexAction
|
|||
];
|
||||
}
|
||||
|
||||
public function asController(LetterSettings $settings): Response
|
||||
public function asController(InvoiceSettings $settings): Response
|
||||
{
|
||||
session()->put('menu', 'setting');
|
||||
session()->put('title', 'Rechnungs-Einstellungen');
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Letter;
|
||||
namespace App\Invoice;
|
||||
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
|
@ -15,7 +15,7 @@ class SettingSaveAction
|
|||
*/
|
||||
public function handle(array $input): void
|
||||
{
|
||||
$settings = app(LetterSettings::class);
|
||||
$settings = app(InvoiceSettings::class);
|
||||
|
||||
$settings->fill([
|
||||
'from_long' => $input['from_long'] ?? '',
|
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Letter\Actions;
|
||||
|
||||
use App\Letter\BillKind;
|
||||
use App\Letter\DocumentFactory;
|
||||
use App\Letter\Queries\BillKindQuery;
|
||||
use App\Payment\PaymentMail;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
use Zoomyboy\Tex\Tex;
|
||||
|
||||
class LetterSendAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*/
|
||||
public string $commandSignature = 'letter:send';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Sends Bills';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
foreach (app(DocumentFactory::class)->getTypes() as $type) {
|
||||
$letters = app(DocumentFactory::class)->letterCollection($type, new BillKindQuery(BillKind::EMAIL));
|
||||
|
||||
foreach ($letters as $letter) {
|
||||
$letterPath = Storage::disk('temp')->path(Tex::compile($letter)->storeIn('', 'temp'));
|
||||
Mail::to($letter->getRecipient())
|
||||
->send(new PaymentMail($letter, $letterPath));
|
||||
app(DocumentFactory::class)->afterSingle($letter);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Member;
|
||||
|
||||
use App\Letter\BillKind;
|
||||
use App\Invoice\BillKind;
|
||||
use App\Lib\Filter;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Spatie\LaravelData\Attributes\MapInputName;
|
||||
|
|
|
@ -7,7 +7,7 @@ use App\Country;
|
|||
use App\Course\Models\CourseMember;
|
||||
use App\Gender;
|
||||
use App\Group;
|
||||
use App\Letter\BillKind;
|
||||
use App\Invoice\BillKind;
|
||||
use App\Nami\HasNamiField;
|
||||
use App\Nationality;
|
||||
use App\Payment\Payment;
|
||||
|
|
|
@ -8,7 +8,7 @@ use App\Country;
|
|||
use App\Gender;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Views\MemberView;
|
||||
use App\Letter\BillKind;
|
||||
use App\Invoice\BillKind;
|
||||
use App\Nationality;
|
||||
use App\Payment\Subscription;
|
||||
use App\Region;
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Member;
|
|||
|
||||
use App\Activity;
|
||||
use App\Group;
|
||||
use App\Letter\BillKind;
|
||||
use App\Invoice\BillKind;
|
||||
use App\Member\Actions\NamiPutMemberAction;
|
||||
use App\Setting\NamiSettings;
|
||||
use App\Subactivity;
|
||||
|
@ -72,7 +72,7 @@ class MemberRequest extends FormRequest
|
|||
'send_newspaper' => 'boolean',
|
||||
'main_phone' => ['nullable', new ValidPhoneRule('Telefon (Eltern)')],
|
||||
'mobile_phone' => ['nullable', new ValidPhoneRule('Handy (Eltern)')],
|
||||
'letter_address' => '',
|
||||
'invoice_address' => '',
|
||||
'gender_id' => 'nullable|exists:genders,id',
|
||||
'region_id' => 'nullable|exists:regions,id',
|
||||
'nationality_id' => 'required|exists:nationalities,id',
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Payment;
|
||||
|
||||
use App\Letter\DocumentFactory;
|
||||
use App\Invoice\DocumentFactory;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class ActionFactory
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Payment;
|
||||
|
||||
use App\Letter\Letter;
|
||||
use App\Invoice\Invoice;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
@ -12,7 +12,7 @@ class PaymentMail extends Mailable
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
public Letter $letter;
|
||||
public Invoice $invoice;
|
||||
public string $filename;
|
||||
public string $salutation;
|
||||
|
||||
|
@ -21,11 +21,11 @@ class PaymentMail extends Mailable
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Letter $letter, string $filename)
|
||||
public function __construct(Invoice $invoice, string $filename)
|
||||
{
|
||||
$this->letter = $letter;
|
||||
$this->invoice = $invoice;
|
||||
$this->filename = $filename;
|
||||
$this->salutation = 'Liebe Familie '.$letter->pages->first()->familyName;
|
||||
$this->salutation = 'Liebe Familie '.$invoice->pages->first()->familyName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,9 +35,9 @@ class PaymentMail extends Mailable
|
|||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this->markdown($this->letter->mailView())
|
||||
return $this->markdown($this->invoice->mailView())
|
||||
->attach($this->filename)
|
||||
->replyTo('kasse@stamm-silva.de')
|
||||
->subject($this->letter->getSubject().' | DPSG Stamm Silva');
|
||||
->subject($this->invoice->getSubject().' | DPSG Stamm Silva');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
namespace App\Payment;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Letter\BillKind;
|
||||
use App\Letter\DocumentFactory;
|
||||
use App\Letter\Queries\BillKindQuery;
|
||||
use App\Invoice\BillKind;
|
||||
use App\Invoice\DocumentFactory;
|
||||
use App\Invoice\Queries\BillKindQuery;
|
||||
use Illuminate\Contracts\Support\Responsable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
@ -30,14 +30,14 @@ class SendpaymentController extends Controller
|
|||
*/
|
||||
public function send(Request $request)
|
||||
{
|
||||
$letter = app(DocumentFactory::class)->singleLetter($request->type, new BillKindQuery(BillKind::POST));
|
||||
$invoice = app(DocumentFactory::class)->singleInvoice($request->type, new BillKindQuery(BillKind::POST));
|
||||
|
||||
if (is_null($letter)) {
|
||||
if (is_null($invoice)) {
|
||||
return response()->noContent();
|
||||
}
|
||||
|
||||
$pdfFile = Tex::compile($letter);
|
||||
app(DocumentFactory::class)->afterSingle($letter);
|
||||
$pdfFile = Tex::compile($invoice);
|
||||
app(DocumentFactory::class)->afterSingle($invoice);
|
||||
|
||||
return $pdfFile;
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
namespace App\Pdf;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Letter\DocumentFactory;
|
||||
use App\Letter\Queries\SingleMemberQuery;
|
||||
use App\Invoice\DocumentFactory;
|
||||
use App\Invoice\Queries\SingleMemberQuery;
|
||||
use App\Member\Member;
|
||||
use Illuminate\Contracts\Support\Responsable;
|
||||
use Illuminate\Http\Request;
|
||||
|
@ -18,10 +18,10 @@ class MemberPdfController extends Controller
|
|||
*/
|
||||
public function __invoke(Request $request, Member $member)
|
||||
{
|
||||
$letter = app(DocumentFactory::class)->singleLetter($request->type, new SingleMemberQuery($member));
|
||||
$invoice = app(DocumentFactory::class)->singleInvoice($request->type, new SingleMemberQuery($member));
|
||||
|
||||
return null === $letter
|
||||
return null === $invoice
|
||||
? response()->noContent()
|
||||
: Tex::compile($letter);
|
||||
: Tex::compile($invoice);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Setting;
|
||||
|
||||
use App\Letter\LetterSettings;
|
||||
use App\Invoice\InvoiceSettings;
|
||||
use App\Mailman\MailmanSettings;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
|
@ -25,7 +25,7 @@ class SettingServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function boot()
|
||||
{
|
||||
app(SettingFactory::class)->register(LetterSettings::class);
|
||||
app(SettingFactory::class)->register(InvoiceSettings::class);
|
||||
app(SettingFactory::class)->register(MailmanSettings::class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Database\Factories\Member;
|
|||
use App\Country;
|
||||
use App\Fee;
|
||||
use App\Group;
|
||||
use App\Letter\BillKind;
|
||||
use App\Invoice\BillKind;
|
||||
use App\Member\Member;
|
||||
use App\Nationality;
|
||||
use App\Payment\Payment;
|
||||
|
|
|
@ -630,7 +630,7 @@ parameters:
|
|||
path: app/Contribution/ContributionFactory.php
|
||||
|
||||
-
|
||||
message: "#^Return type of call to method Illuminate\\\\Support\\\\Collection\\<int,class\\-string\\<App\\\\Letter\\\\Letter\\>\\>\\:\\:map\\(\\) contains unresolvable type\\.$#"
|
||||
message: "#^Return type of call to method Illuminate\\\\Support\\\\Collection\\<int,class\\-string\\<App\\\\Invoice\\\\Invoice\\>\\>\\:\\:map\\(\\) contains unresolvable type\\.$#"
|
||||
count: 1
|
||||
path: app/Payment/ActionFactory.php
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Tests\Feature\Bill;
|
||||
|
||||
use App\Letter\LetterSettings;
|
||||
use App\Invoice\InvoiceSettings;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
@ -13,7 +13,7 @@ class SettingTest extends TestCase
|
|||
public function testSettingIndex(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
LetterSettings::fake([
|
||||
InvoiceSettings::fake([
|
||||
'from_long' => 'DPSG Stamm Muster',
|
||||
'from' => 'Stamm Muster',
|
||||
'mobile' => '+49 176 55555',
|
||||
|
@ -80,7 +80,7 @@ class SettingTest extends TestCase
|
|||
]);
|
||||
|
||||
$response->assertRedirect('/setting/bill');
|
||||
$settings = app(LetterSettings::class);
|
||||
$settings = app(InvoiceSettings::class);
|
||||
$this->assertEquals('DPSG Stamm Muster', $settings->from_long);
|
||||
$this->assertEquals('DE05', $settings->iban);
|
||||
$this->assertEquals('SOLSDE', $settings->bic);
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Letter;
|
||||
namespace Tests\Feature\Invoice;
|
||||
|
||||
use App\Letter\BillDocument;
|
||||
use App\Letter\DocumentFactory;
|
||||
use App\Letter\LetterSettings;
|
||||
use App\Letter\Queries\LetterMemberQuery;
|
||||
use App\Letter\Queries\SingleMemberQuery;
|
||||
use App\Letter\RememberDocument;
|
||||
use App\Invoice\BillDocument;
|
||||
use App\Invoice\DocumentFactory;
|
||||
use App\Invoice\InvoiceSettings;
|
||||
use App\Invoice\Queries\InvoiceMemberQuery;
|
||||
use App\Invoice\Queries\SingleMemberQuery;
|
||||
use App\Invoice\RememberDocument;
|
||||
use App\Member\Member;
|
||||
use App\Payment\Payment;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
@ -20,14 +20,14 @@ class DocumentFactoryTest extends TestCase
|
|||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* @testWith ["\\App\\Letter\\BillDocument"]
|
||||
* ["\\App\\Letter\\RememberDocument"]
|
||||
* @testWith ["\\App\\Invoice\\BillDocument"]
|
||||
* ["\\App\\Invoice\\RememberDocument"]
|
||||
*/
|
||||
public function testItDoesntReturnARepositoryWhenMemberDoesntHavePayments(): void
|
||||
{
|
||||
$member = Member::factory()->defaults()->create();
|
||||
$letter = app(DocumentFactory::class)->singleLetter(BillDocument::class, $this->query($member));
|
||||
$this->assertNull($letter);
|
||||
$invoice = app(DocumentFactory::class)->singleInvoice(BillDocument::class, $this->query($member));
|
||||
$this->assertNull($invoice);
|
||||
}
|
||||
|
||||
public function testItDisplaysMemberInformation(): void
|
||||
|
@ -47,9 +47,9 @@ class DocumentFactoryTest extends TestCase
|
|||
]))
|
||||
->create();
|
||||
|
||||
$letter = app(DocumentFactory::class)->singleLetter(BillDocument::class, $this->query($member));
|
||||
$invoice = app(DocumentFactory::class)->singleInvoice(BillDocument::class, $this->query($member));
|
||||
|
||||
$letter->assertHasAllContent([
|
||||
$invoice->assertHasAllContent([
|
||||
'Rechnung',
|
||||
'15.00',
|
||||
'::subName:: 1995 für ::firstname:: ::lastname::',
|
||||
|
@ -72,9 +72,9 @@ class DocumentFactoryTest extends TestCase
|
|||
], ['split' => true]))
|
||||
->create();
|
||||
|
||||
$letter = app(DocumentFactory::class)->singleLetter(BillDocument::class, $this->query($member));
|
||||
$invoice = app(DocumentFactory::class)->singleInvoice(BillDocument::class, $this->query($member));
|
||||
|
||||
$letter->assertHasAllContent([
|
||||
$invoice->assertHasAllContent([
|
||||
'Rechnung',
|
||||
'10.00',
|
||||
'5.00',
|
||||
|
@ -92,9 +92,9 @@ class DocumentFactoryTest extends TestCase
|
|||
->has(Payment::factory()->notPaid()->nr('1995'))
|
||||
->create();
|
||||
|
||||
$letter = app(DocumentFactory::class)->singleLetter(BillDocument::class, $this->query($member));
|
||||
$invoice = app(DocumentFactory::class)->singleInvoice(BillDocument::class, $this->query($member));
|
||||
|
||||
$this->assertEquals('rechnung-fur-lastname.pdf', $letter->compiledFilename());
|
||||
$this->assertEquals('rechnung-fur-lastname.pdf', $invoice->compiledFilename());
|
||||
}
|
||||
|
||||
public function testRememberSetsFilename(): void
|
||||
|
@ -105,9 +105,9 @@ class DocumentFactoryTest extends TestCase
|
|||
->has(Payment::factory()->notPaid())
|
||||
->create();
|
||||
|
||||
$letter = app(DocumentFactory::class)->singleLetter(RememberDocument::class, $this->query($member));
|
||||
$invoice = app(DocumentFactory::class)->singleInvoice(RememberDocument::class, $this->query($member));
|
||||
|
||||
$this->assertEquals('zahlungserinnerung-fur-lastname.pdf', $letter->compiledFilename());
|
||||
$this->assertEquals('zahlungserinnerung-fur-lastname.pdf', $invoice->compiledFilename());
|
||||
}
|
||||
|
||||
public function testItCreatesOneFileForFamilyMembers(): void
|
||||
|
@ -123,18 +123,18 @@ class DocumentFactoryTest extends TestCase
|
|||
->has(Payment::factory()->notPaid()->nr('nr2'))
|
||||
->create();
|
||||
|
||||
$letter = app(DocumentFactory::class)->singleLetter(BillDocument::class, $this->query($firstMember));
|
||||
$invoice = app(DocumentFactory::class)->singleInvoice(BillDocument::class, $this->query($firstMember));
|
||||
|
||||
$letter->assertHasAllContent(['Max1', 'Max2', 'nr1', 'nr2']);
|
||||
$invoice->assertHasAllContent(['Max1', 'Max2', 'nr1', 'nr2']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @testWith ["App\\Letter\\BillDocument"]
|
||||
* ["App\\Letter\\RememberDocument"]
|
||||
* @testWith ["App\\Invoice\\BillDocument"]
|
||||
* ["App\\Invoice\\RememberDocument"]
|
||||
*/
|
||||
public function testItDisplaysSettings(string $type): void
|
||||
{
|
||||
LetterSettings::fake([
|
||||
InvoiceSettings::fake([
|
||||
'from_long' => 'langer Stammesname',
|
||||
'from' => 'Stammeskurz',
|
||||
'mobile' => '+49 176 55555',
|
||||
|
@ -151,9 +151,9 @@ class DocumentFactoryTest extends TestCase
|
|||
->has(Payment::factory()->notPaid()->nr('nr2'))
|
||||
->create();
|
||||
|
||||
$letter = app(DocumentFactory::class)->singleLetter($type, $this->query($member));
|
||||
$invoice = app(DocumentFactory::class)->singleInvoice($type, $this->query($member));
|
||||
|
||||
$letter->assertHasAllContent([
|
||||
$invoice->assertHasAllContent([
|
||||
'langer Stammesname',
|
||||
'Stammeskurz',
|
||||
'+49 176 55555',
|
||||
|
@ -185,7 +185,7 @@ class DocumentFactoryTest extends TestCase
|
|||
$this->assertEquals('inline; filename="rechnung-fur-lastname.pdf"', $response->headers->get('content-disposition'));
|
||||
}
|
||||
|
||||
private function query(Member $member): LetterMemberQuery
|
||||
private function query(Member $member): InvoiceMemberQuery
|
||||
{
|
||||
return new SingleMemberQuery($member);
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Letter;
|
||||
namespace Tests\Feature\Invoice;
|
||||
|
||||
use App\Letter\Actions\LetterSendAction;
|
||||
use App\Letter\BillDocument;
|
||||
use App\Invoice\Actions\InvoiceSendAction;
|
||||
use App\Invoice\BillDocument;
|
||||
use App\Member\Member;
|
||||
use App\Payment\Payment;
|
||||
use App\Payment\PaymentMail;
|
||||
|
@ -15,7 +15,7 @@ use Tests\RequestFactories\Child;
|
|||
use Tests\TestCase;
|
||||
use Zoomyboy\Tex\Tex;
|
||||
|
||||
class LetterSendActionTest extends TestCase
|
||||
class InvoiceSendActionTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
|
@ -41,7 +41,7 @@ class LetterSendActionTest extends TestCase
|
|||
{
|
||||
Mail::fake();
|
||||
|
||||
Artisan::call('letter:send');
|
||||
Artisan::call('invoice:send');
|
||||
|
||||
Mail::assertSent(PaymentMail::class, fn ($mail) => Storage::disk('temp')->path('rechnung-fur-mom.pdf') === $mail->filename && Storage::disk('temp')->exists('rechnung-fur-mom.pdf'));
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class LetterSendActionTest extends TestCase
|
|||
Mail::fake();
|
||||
Tex::spy();
|
||||
|
||||
LetterSendAction::run();
|
||||
InvoiceSendAction::run();
|
||||
|
||||
Tex::assertCompiled(BillDocument::class, fn ($document) => 'Mom' === $document->pages->first()->familyName
|
||||
&& $document->pages->first()->getPositions() === ['tollerbeitrag 1997 für Lah Mom' => '54.00']
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
namespace Tests\Feature\Sendpayment;
|
||||
|
||||
use App\Letter\BillDocument;
|
||||
use App\Letter\LetterSettings;
|
||||
use App\Invoice\BillDocument;
|
||||
use App\Invoice\InvoiceSettings;
|
||||
use App\Member\Member;
|
||||
use App\Payment\Payment;
|
||||
use App\Payment\Status;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\RequestFactories\Child;
|
||||
use Tests\RequestFactories\LetterSettingsFake;
|
||||
use Tests\RequestFactories\InvoiceSettingsFake;
|
||||
use Tests\TestCase;
|
||||
use Zoomyboy\Tex\Tex;
|
||||
|
||||
|
@ -32,7 +32,7 @@ class SendpaymentTest extends TestCase
|
|||
|
||||
public function testItCanCreatePdfPayments(): void
|
||||
{
|
||||
LetterSettings::fake(LetterSettingsFake::new()->create());
|
||||
InvoiceSettings::fake(InvoiceSettingsFake::new()->create());
|
||||
Tex::spy();
|
||||
$this->withoutExceptionHandling();
|
||||
$this->login()->loginNami();
|
||||
|
@ -43,7 +43,7 @@ class SendpaymentTest extends TestCase
|
|||
->postBillKind()
|
||||
->create();
|
||||
|
||||
$response = $this->call('GET', route('sendpayment.pdf'), ['type' => 'App\\Letter\\BillDocument']);
|
||||
$response = $this->call('GET', route('sendpayment.pdf'), ['type' => 'App\\Invoice\\BillDocument']);
|
||||
|
||||
$response->assertOk();
|
||||
$this->assertEquals(Status::firstWhere('name', 'Rechnung gestellt')->id, $member->payments->firstWhere('nr', '1997')->status_id);
|
||||
|
@ -64,7 +64,7 @@ class SendpaymentTest extends TestCase
|
|||
->emailBillKind()
|
||||
->create();
|
||||
|
||||
$response = $this->call('GET', route('sendpayment.pdf'), ['type' => 'App\\Letter\\BillDocument']);
|
||||
$response = $this->call('GET', route('sendpayment.pdf'), ['type' => 'App\\Invoice\\BillDocument']);
|
||||
|
||||
$response->assertStatus(204);
|
||||
Tex::assertNotCompiled(BillDocument::class);
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Tests\RequestFactories;
|
|||
|
||||
use Worksome\RequestFactories\RequestFactory;
|
||||
|
||||
class LetterSettingsFake extends RequestFactory
|
||||
class InvoiceSettingsFake extends RequestFactory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
Loading…
Reference in New Issue