Notification after invoice state

This commit is contained in:
2026-04-25 13:28:23 +02:00
parent 2e8daf78e1
commit 6f8be58943
9 changed files with 367 additions and 6 deletions

View File

@@ -3,6 +3,11 @@
namespace App\Domains\Invoice\Actions\ChangeStatus;
use App\Enumerations\InvoiceStatus;
use App\Mail\InvoiceMails\InvoiceMailsApprovedInvoiceMail;
use App\Mail\InvoiceMails\InvoiceMailsDeniedInvoiceMail;
use App\Mail\InvoiceMails\InvoiceMailsReopenedInvoiceMail;
use App\Mail\ParticipantCocMails\ParticipantCocCompleteMail;
use Illuminate\Support\Facades\Mail;
class ChangeStatusCommand {
private ChangeStatusRequest $request;
@@ -19,6 +24,13 @@ class ChangeStatusCommand {
$this->request->invoice->status = InvoiceStatus::INVOICE_STATUS_APPROVED;
$this->request->invoice->approved_by = auth()->user()->id;
$this->request->invoice->approved_at = now();
if ($this->request->invoice->contact_email !== null) {
Mail::to($this->request->invoice->contact_email)->send(new InvoiceMailsApprovedInvoiceMail(
invoice: $this->request->invoice,
costUnit: $this->request->invoice->costUnit()->first(),
));
}
break;
case InvoiceStatus::INVOICE_STATUS_DENIED:
@@ -26,6 +38,12 @@ class ChangeStatusCommand {
$this->request->invoice->denied_by = auth()->user()->id;
$this->request->invoice->denied_at = now();
$this->request->invoice->denied_reason = $this->request->comment;
if ($this->request->invoice->contact_email !== null) {
Mail::to($this->request->invoice->contact_email)->send(new InvoiceMailsDeniedInvoiceMail(
invoice: $this->request->invoice,
costUnit: $this->request->invoice->costUnit()->first(),
));
}
break;
case InvoiceStatus::INVOICE_STATUS_NEW:
$this->request->invoice->status = InvoiceStatus::INVOICE_STATUS_NEW;
@@ -35,6 +53,12 @@ class ChangeStatusCommand {
$this->request->invoice->denied_at = null;
$this->request->invoice->comment = $this->request->invoice->denied_reason;
$this->request->invoice->denied_reason = null;
if ($this->request->invoice->contact_email !== null) {
Mail::to($this->request->invoice->contact_email)->send(new InvoiceMailsReopenedInvoiceMail(
invoice: $this->request->invoice,
costUnit: $this->request->invoice->costUnit()->first(),
));
}
break;
case InvoiceStatus::INVOICE_STATUS_DELETED:
$this->request->invoice->status = InvoiceStatus::INVOICE_STATUS_DELETED;
@@ -49,7 +73,6 @@ class ChangeStatusCommand {
$response->success = true;
}
return $response;
}
}

View File

@@ -177,7 +177,7 @@ async function reopenInvoice() {
<Modal title="Abrechnung ablehnen" :show="denyInvoiceDialog" @close="denyInvoiceDialog = false" >
Begründung:
<textarea class="mareike-textarea" style="width: 100%; height: 100px; margin-top: 10px;" id="deny_invoice_reason" />
<input type="button" class="mareike-button mareike-deny-invoice-button" value="Abrechnung ablehnen" @click="denyInvoice" />
<input type="button" class="mareike-button mareike-deny-invoice-button" style="width: 250px !important;" value="Abrechnung ablehnen" @click="denyInvoice" />
</Modal>
</template>

View File

@@ -102,25 +102,27 @@ async function sendData() {
name="contact_name" v-model="userName"
style="font-size: 14pt; width: 550px;" /><br /><br />
<label>
<label v-if="userName !== ''">
<strong>E-Mail-Adresse (Für Rückfragen):</strong>
</label><br />
<input
v-if="userName !== ''"
type="email"
name="contact_email"
v-model="userEmail"
style="font-size: 14pt; width: 550px;" /><br /><br />
<label>
<label v-if="userName !== ''">
<strong>Telefonnummer (für Rückfragen):</strong>
</label><br />
<input
v-if="userName !== ''"
type="text"
id="contact_telephone"
name="contact_telephone" v-model="userTelephone"
style="font-size: 14pt; width: 550px;" /><br /><br />
<span id="decision" v-if="userName !== '' && decision === ''">
<span id="decision" v-if="userEmail !== '' && decision === ''">
<label><br />
<strong>Möchtest du den Betrag spenden?</strong>
</label><br />