Remove foreign keys for verifactu in order to preserve logs

This commit is contained in:
David Bomba 2025-10-20 08:46:12 +11:00
parent 9e032ad723
commit b174656e87
2 changed files with 17 additions and 20 deletions

View File

@ -849,28 +849,26 @@ class Invoice extends BaseXmlModel implements XmlModelInterface
$root->appendChild($this->createElement($doc, 'DescripcionOperacion', $this->descripcionOperacion));
// 9. Destinatarios (if set)
// 9. Destinatarios (if set)
if ($this->destinatarios !== null && count($this->destinatarios) > 0) {
$destinatariosElement = $this->createElement($doc, 'Destinatarios');
foreach ($this->destinatarios as $destinatario) {
$idDestinatarioElement = $this->createElement($doc, 'IDDestinatario');
if ($this->destinatarios !== null && count($this->destinatarios) > 0) {
$destinatariosElement = $this->createElement($doc, 'Destinatarios');
foreach ($this->destinatarios as $destinatario) {
$idDestinatarioElement = $this->createElement($doc, 'IDDestinatario');
// Add NombreRazon
$idDestinatarioElement->appendChild($this->createElement($doc, 'NombreRazon', $destinatario->getNombreRazon()));
// Add NombreRazon
$idDestinatarioElement->appendChild($this->createElement($doc, 'NombreRazon', $destinatario->getNombreRazon()));
if ($destinatario instanceof PersonaFisicaJuridica) {
$idDestinatarioElement->appendChild($this->createElement($doc, 'NIF', $destinatario->getNif()));
} elseif ($destinatario instanceof IDOtro) {
// Use the full IDOtro XML structure
$idDestinatarioElement->appendChild($destinatario->toXml($doc));
if ($destinatario instanceof PersonaFisicaJuridica) {
$idDestinatarioElement->appendChild($this->createElement($doc, 'NIF', $destinatario->getNif()));
} elseif ($destinatario instanceof IDOtro) {
// Use the full IDOtro XML structure
$idDestinatarioElement->appendChild($destinatario->toXml($doc));
}
$destinatariosElement->appendChild($idDestinatarioElement);
}
$root->appendChild($destinatariosElement);
}
$destinatariosElement->appendChild($idDestinatarioElement);
}
$root->appendChild($destinatariosElement);
}
// 10. Desglose
if ($this->desglose !== null) {

View File

@ -27,8 +27,7 @@ return new class extends Migration
$table->text('state')->nullable();
$table->timestamps();
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade')->onUpdate('cascade');
$table->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade')->onUpdate('cascade');
// Foreign key constraints removed - data integrity handled at application level
});
}