Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72e0502bb9 | ||
|
|
3b47979265 |
@@ -56,6 +56,8 @@ MAIL_PASSWORD=null
|
|||||||
MAIL_FROM_ADDRESS="hello@example.com"
|
MAIL_FROM_ADDRESS="hello@example.com"
|
||||||
MAIL_FROM_NAME="${APP_NAME}"
|
MAIL_FROM_NAME="${APP_NAME}"
|
||||||
|
|
||||||
|
APP_ADMIN_MAIL=
|
||||||
|
|
||||||
AWS_ACCESS_KEY_ID=
|
AWS_ACCESS_KEY_ID=
|
||||||
AWS_SECRET_ACCESS_KEY=
|
AWS_SECRET_ACCESS_KEY=
|
||||||
AWS_DEFAULT_REGION=us-east-1
|
AWS_DEFAULT_REGION=us-east-1
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Mail\AdminMails;
|
||||||
|
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Mail\Mailables\Attachment;
|
||||||
|
use Illuminate\Mail\Mailables\Content;
|
||||||
|
use Illuminate\Mail\Mailables\Envelope;
|
||||||
|
|
||||||
|
class CostUnitInvalidBillingDeadlineMail extends Mailable
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private int|string $costUnitId,
|
||||||
|
private ?string $costUnitName,
|
||||||
|
private ?string $invalidBillingDeadline,
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message envelope.
|
||||||
|
*/
|
||||||
|
public function envelope(): Envelope
|
||||||
|
{
|
||||||
|
return new Envelope(
|
||||||
|
subject: sprintf('Ungültiges Abrechnungsende für Kostenstelle #%s', $this->costUnitId),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message content definition.
|
||||||
|
*/
|
||||||
|
public function content(): Content
|
||||||
|
{
|
||||||
|
return new Content(
|
||||||
|
view: 'emails.admin.cost_unit_invalid_billing_deadline',
|
||||||
|
with: [
|
||||||
|
'costUnitId' => $this->costUnitId,
|
||||||
|
'costUnitName' => $this->costUnitName,
|
||||||
|
'invalidBillingDeadline' => $this->invalidBillingDeadline,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the attachments for the message.
|
||||||
|
*
|
||||||
|
* @return array<int, Attachment>
|
||||||
|
*/
|
||||||
|
public function attachments(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,9 +6,11 @@ use App\Domains\CostUnit\Actions\ChangeCostUnitDetails\ChangeCostUnitDetailsComm
|
|||||||
use App\Domains\CostUnit\Actions\ChangeCostUnitDetails\ChangeCostUnitDetailsRequest;
|
use App\Domains\CostUnit\Actions\ChangeCostUnitDetails\ChangeCostUnitDetailsRequest;
|
||||||
use App\Domains\CostUnit\Actions\ChangeCostUnitState\ChangeCostUnitStateCommand;
|
use App\Domains\CostUnit\Actions\ChangeCostUnitState\ChangeCostUnitStateCommand;
|
||||||
use App\Domains\CostUnit\Actions\ChangeCostUnitState\ChangeCostUnitStateRequest;
|
use App\Domains\CostUnit\Actions\ChangeCostUnitState\ChangeCostUnitStateRequest;
|
||||||
|
use App\Mail\AdminMails\CostUnitInvalidBillingDeadlineMail;
|
||||||
use App\Models\CostUnit;
|
use App\Models\CostUnit;
|
||||||
use App\Repositories\CostUnitRepository;
|
use App\Repositories\CostUnitRepository;
|
||||||
use App\ValueObjects\Amount;
|
use App\ValueObjects\Amount;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
|
||||||
class CloseCostUnit implements CronTask {
|
class CloseCostUnit implements CronTask {
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
@@ -33,6 +35,27 @@ class CloseCostUnit implements CronTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$billingEndTime = \DateTime::createFromFormat('Y-m-d H:i:s', $billingEnd);
|
$billingEndTime = \DateTime::createFromFormat('Y-m-d H:i:s', $billingEnd);
|
||||||
|
if (false === $billingEndTime) {
|
||||||
|
$billingEndTime = \DateTime::createFromFormat('Y-m-d', $billingEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (false === $billingEndTime) {
|
||||||
|
$recipients = config('app.admin_mail');
|
||||||
|
if (null === $recipients) {
|
||||||
|
$recipients = CostUnit::where('id', $costUnit['id'])->first()
|
||||||
|
?->treasurers()->pluck('email')->all() ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($recipients)) {
|
||||||
|
Mail::to($recipients)->send(new CostUnitInvalidBillingDeadlineMail(
|
||||||
|
costUnitId: $costUnit['id'],
|
||||||
|
costUnitName: $costUnit['name'] ?? null,
|
||||||
|
invalidBillingDeadline: $billingEnd,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$billingEndTime->setTime(0,0,0);
|
$billingEndTime->setTime(0,0,0);
|
||||||
$billingEndTime->add(new \DateInterval('P1D'));
|
$billingEndTime->add(new \DateInterval('P1D'));
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ return [
|
|||||||
|
|
||||||
'name' => env('APP_NAME', 'Laravel'),
|
'name' => env('APP_NAME', 'Laravel'),
|
||||||
|
|
||||||
|
'admin_mail' => env('APP_ADMIN_MAIL'),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Application Environment
|
| Application Environment
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<p>
|
||||||
|
Für die Kostenstelle "{{ $costUnitName }}" (ID {{ $costUnitId }}) konnte das Abrechnungsende
|
||||||
|
nicht verarbeitet werden.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Der hinterlegte Wert "{{ $invalidBillingDeadline }}" ist weder ein gültiges Datum noch ein
|
||||||
|
Datum mit Uhrzeit. Die automatische Verarbeitung dieser Kostenstelle wurde deshalb übersprungen.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Bitte prüft und korrigiert das Abrechnungsende dieser Kostenstelle.
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user