Validation fixes for rectification invoices
This commit is contained in:
parent
d54f677c0b
commit
a5cac9814b
|
|
@ -214,7 +214,7 @@ class UpdateCompanyRequest extends Request
|
|||
}
|
||||
}
|
||||
|
||||
if($this->company->settings->e_invoice_type == 'VERIFACTU') {
|
||||
if($this->company->verifactuEnabled()) {
|
||||
$settings['lock_invoices'] = 'when_sent';
|
||||
$settings['e_invoice_type'] = 'VERIFACTU';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,6 +98,14 @@ class UpdateInvoiceRequest extends Request
|
|||
return $rules;
|
||||
}
|
||||
|
||||
public function withValidator($validator)
|
||||
{
|
||||
if($this->invoice->company->verifactuEnabled() && $this->invoice->status_id !== \App\Models\Invoice::STATUS_DRAFT){
|
||||
$validator->errors()->add('status_id', ctrans('texts.locked_invoice'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function prepareForValidation()
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -98,8 +98,13 @@ class EntityLevel implements EntityLevelInterface
|
|||
|
||||
}
|
||||
|
||||
$_invoice = (new \App\Services\EDocument\Standards\Verifactu\RegistroAlta($invoice))->run()->getInvoice();
|
||||
$xml = $_invoice->toXmlString();
|
||||
$_invoice = (new \App\Services\EDocument\Standards\Verifactu\RegistroAlta($invoice))->run();
|
||||
|
||||
if($invoice->amount < 0) {
|
||||
$_invoice = $_invoice->setRectification();
|
||||
}
|
||||
|
||||
$xml = $_invoice->getInvoice()->toXmlString();
|
||||
|
||||
$xslt = new \App\Services\EDocument\Standards\Validation\VerifactuDocumentValidator($xml);
|
||||
$xslt->validate();
|
||||
|
|
|
|||
|
|
@ -289,7 +289,6 @@ class RegistroAlta
|
|||
$this->v_invoice->setTipoRectificativa('I'); // S for substitutive rectification
|
||||
|
||||
//need to harvest the parent invoice!!
|
||||
|
||||
$_i = Invoice::withTrashed()->find($this->decodePrimaryKey($this->invoice->backup->parent_invoice_id));
|
||||
|
||||
if(!$_i) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue