Tests around handling cancellations in verifactu
This commit is contained in:
parent
a447b6a20b
commit
6a0fff10ae
|
|
@ -247,6 +247,8 @@ class Invoice extends BaseModel
|
||||||
|
|
||||||
public const STATUS_UNPAID = -2; //status < 4 || < 3 && !is_deleted && !trashed()
|
public const STATUS_UNPAID = -2; //status < 4 || < 3 && !is_deleted && !trashed()
|
||||||
|
|
||||||
|
public const STATUS_REPLACED = 7; // handle the case where the invoice is replaced by another invoice.
|
||||||
|
|
||||||
public function toSearchableArray()
|
public function toSearchableArray()
|
||||||
{
|
{
|
||||||
$locale = $this->company->locale();
|
$locale = $this->company->locale();
|
||||||
|
|
|
||||||
|
|
@ -244,10 +244,13 @@ class InvoiceService
|
||||||
|
|
||||||
public function markDeleted()
|
public function markDeleted()
|
||||||
{
|
{
|
||||||
// $this->removeUnpaidGatewayFees();
|
|
||||||
|
|
||||||
$this->invoice = (new MarkInvoiceDeleted($this->invoice))->run();
|
$this->invoice = (new MarkInvoiceDeleted($this->invoice))->run();
|
||||||
|
|
||||||
|
if($this->invoice->company->verifactuEnabled()) {
|
||||||
|
$this->deleteVerifactu();
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -674,8 +677,16 @@ class InvoiceService
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//@todo - verifactu
|
|
||||||
public function sendVerifactu()
|
/**
|
||||||
|
* sendVerifactu
|
||||||
|
* @todo - send the invoice to AEAT
|
||||||
|
* ONLY send when the transaction is ES => ES
|
||||||
|
* Ensure we run all sending syncronously to ensure chronology
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function sendVerifactu(): self
|
||||||
{
|
{
|
||||||
// if($this->invoice->company->verifactuEnabled()) {
|
// if($this->invoice->company->verifactuEnabled()) {
|
||||||
// (new SendVerifactu($this->invoice))->handle();
|
// (new SendVerifactu($this->invoice))->handle();
|
||||||
|
|
@ -683,6 +694,20 @@ class InvoiceService
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* deleteVerifactu
|
||||||
|
* @todo - handle "cancelling" the invoice in AEAT
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function deleteVerifactu(): self
|
||||||
|
{
|
||||||
|
// if($this->invoice->company->verifactuEnabled()) {
|
||||||
|
// (new DeleteVerifactu($this->invoice))->handle();
|
||||||
|
// }
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Saves the invoice.
|
* Saves the invoice.
|
||||||
* @return Invoice object
|
* @return Invoice object
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue