Move sent function
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
1ef23eb45e
commit
72695ea172
|
|
@ -38,14 +38,14 @@ class InvoiceSendAction
|
|||
$document = BillDocument::fromInvoice($invoice);
|
||||
$path = Storage::disk('temp')->path(Tex::compile($document)->storeIn('', 'temp'));
|
||||
Mail::to($invoice->getRecipient())->send(new BillMail($invoice, $path));
|
||||
$invoice->sent($document);
|
||||
$document->sent($invoice);
|
||||
}
|
||||
|
||||
foreach (Invoice::whereNeedsRemember()->where('via', BillKind::EMAIL)->get() as $invoice) {
|
||||
$document = RememberDocument::fromInvoice($invoice);
|
||||
$path = Storage::disk('temp')->path(Tex::compile($document)->storeIn('', 'temp'));
|
||||
Mail::to($invoice->getRecipient())->send(new RememberMail($invoice, $path));
|
||||
$invoice->sent($document);
|
||||
$document->sent($invoice);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -22,13 +22,13 @@ class MassPostPdfAction
|
|||
foreach (Invoice::whereNeedsBill()->where('via', BillKind::POST)->get() as $invoice) {
|
||||
$document = BillDocument::fromInvoice($invoice);
|
||||
$documents[] = $document;
|
||||
$invoice->sent($document);
|
||||
$document->sent($invoice);
|
||||
}
|
||||
|
||||
foreach (Invoice::whereNeedsRemember()->where('via', BillKind::POST)->get() as $invoice) {
|
||||
$document = RememberDocument::fromInvoice($invoice);
|
||||
$documents[] = $document;
|
||||
$invoice->sent($document);
|
||||
$document->sent($invoice);
|
||||
}
|
||||
|
||||
if (!count($documents)) {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
namespace App\Invoice;
|
||||
|
||||
use App\Payment\Payment;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use App\Invoice\Models\Invoice;
|
||||
|
||||
class BillDocument extends InvoiceDocument
|
||||
{
|
||||
|
|
@ -17,4 +16,8 @@ class BillDocument extends InvoiceDocument
|
|||
{
|
||||
return 'tex.invoice.bill';
|
||||
}
|
||||
|
||||
public function sent(Invoice $invoice): void {
|
||||
$invoice->sentNow();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ abstract class InvoiceDocument extends Document
|
|||
{
|
||||
abstract public function getSubject(): string;
|
||||
abstract public function view(): string;
|
||||
abstract public function sent(Invoice $invoice): void;
|
||||
|
||||
public string $until;
|
||||
public string $filename;
|
||||
|
|
|
|||
|
|
@ -101,22 +101,12 @@ class Invoice extends Model
|
|||
return $this->to;
|
||||
}
|
||||
|
||||
public function sent(InvoiceDocument $document): void
|
||||
{
|
||||
if (is_a($document, BillDocument::class)) {
|
||||
$this->update([
|
||||
'sent_at' => now(),
|
||||
'status' => InvoiceStatus::SENT,
|
||||
'last_remembered_at' => now(),
|
||||
]);
|
||||
}
|
||||
public function rememberedNow(): void {
|
||||
$this->update(['last_remembered_at' => now(), 'status' => InvoiceStatus::SENT]);
|
||||
}
|
||||
|
||||
if (is_a($document, RememberDocument::class)) {
|
||||
$this->update([
|
||||
'last_remembered_at' => now(),
|
||||
'status' => InvoiceStatus::SENT,
|
||||
]);
|
||||
}
|
||||
public function sentNow(): void {
|
||||
$this->update(['sent_at' => now(), 'status' => InvoiceStatus::SENT, 'last_remembered_at' => now()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
namespace App\Invoice;
|
||||
|
||||
use App\Payment\Payment;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use App\Invoice\Models\Invoice;
|
||||
|
||||
class RememberDocument extends InvoiceDocument
|
||||
{
|
||||
|
|
@ -17,4 +16,8 @@ class RememberDocument extends InvoiceDocument
|
|||
{
|
||||
return 'tex.invoice.remember';
|
||||
}
|
||||
|
||||
public function sent(Invoice $invoice): void {
|
||||
$invoice->rememberedNow();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue