Wiring up verifactu sending

This commit is contained in:
David Bomba 2025-08-13 14:39:50 +10:00
parent c5c9c4325e
commit af926a394c
4 changed files with 9 additions and 3 deletions

View File

@ -23,7 +23,7 @@ use Illuminate\Support\Collection;
class InvoiceBackup implements Castable class InvoiceBackup implements Castable
{ {
public function __construct( public function __construct(
public string $guid = '', // The E-INVOICE SENT GUID reference public string $guid = '', // The E-INVOICE SENT GUID reference - or enum to advise the document has been successfully sent.
public Cancellation $cancellation = new Cancellation(0,0), public Cancellation $cancellation = new Cancellation(0,0),
public ?string $parent_invoice_id = null, // The id of the invoice that was cancelled public ?string $parent_invoice_id = null, // The id of the invoice that was cancelled
public ?string $parent_invoice_number = null, // The number of the invoice that was cancelled public ?string $parent_invoice_number = null, // The number of the invoice that was cancelled

View File

@ -29,7 +29,7 @@ class RetrySendRequest extends Request
return true; return true;
} }
return $user->account->isPaid() && $user->isAdmin() && $user->company()->legal_entity_id != null; return $user->account->isPaid() && $user->isAdmin() && ($user->company()->legal_entity_id != null || $user->company()->verifactuEnabled());
} }
/** /**

View File

@ -73,6 +73,12 @@ class SendToAeat implements ShouldQueue
$invoice = Invoice::withTrashed()->find($this->invoice_id); $invoice = Invoice::withTrashed()->find($this->invoice_id);
if($invoice->client->country->iso_3166_2 != 'ES') {
$invoice->backup->guid = 'NOT_ES';
$invoice->saveQuietly();
return;
}
switch($this->action) { switch($this->action) {
case 'create': case 'create':
$this->createInvoice($invoice); $this->createInvoice($invoice);

View File

@ -81,7 +81,7 @@ class TriggeredActions extends AbstractService
$company->save(); $company->save();
} }
if($this->request->has('retry_e_send') && $this->request->input('retry_e_send') == 'true' && strlen($this->invoice->backup->guid ?? '') < 2 && $this->invoice->client->peppolSendingEnabled()) { if($this->request->has('retry_e_send') && $this->request->input('retry_e_send') == 'true' && strlen($this->invoice->backup->guid ?? '') == 0 && $this->invoice->client->peppolSendingEnabled()) {
\App\Services\EDocument\Jobs\SendEDocument::dispatch(get_class($this->invoice), $this->invoice->id, $this->invoice->company->db); \App\Services\EDocument\Jobs\SendEDocument::dispatch(get_class($this->invoice), $this->invoice->id, $this->invoice->company->db);
} }