Validation fixes for rectification invoices

This commit is contained in:
David Bomba 2025-10-13 09:37:19 +11:00
parent d54f677c0b
commit a5cac9814b
4 changed files with 16 additions and 4 deletions

View File

@ -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';
}

View File

@ -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()
{

View File

@ -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();

View File

@ -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) {