Verifactu invoice generation

This commit is contained in:
David Bomba 2025-08-07 21:56:11 +10:00
parent 6c8c270c2f
commit 33078ee86c
1 changed files with 20 additions and 8 deletions

View File

@ -128,14 +128,26 @@ class Verifactu extends AbstractService
// The tax breakdown
$desglose = new Desglose();
$desglose->setDesgloseIVA([
'Impuesto' => '01', //tax type
'ClaveRegimen' => '01', //tax regime classification code
'CalificacionOperacion' => 'S1', //operation classification code
'BaseImponibleOimporteNoSujeto' => $this->calc->getNetSubtotal(), // taxable base amount
'TipoImpositivo' => 21.00, // Tax Rate
'CuotaRepercutida' => $this->invoice->total_taxes // Tax Amount
]);
//Combine the line taxes with invoice taxes here to get a total tax amount
$taxes = array_merge($calc->getTaxMap()->merge($calc->getTotalTaxMap())->toArray());
$desglose_iva = [];
foreach ($taxes as $tax) {
$desglose_iva[] = [
'Impuesto' => '01' //tax type
'ClaveRegimen' => '01', //tax regime classification code
'CalificacionOperacion' => 'S1', //operation classification code
'BaseImponibleOimporteNoSujeto' => $tax['base_amount'] ?? $this->calc->getNetSubtotal(), // taxable base amount
'TipoImpositivo' => $tax['tax_rate'], // Tax Rate
'CuotaRepercutida' => $tax['total'] // Tax Amount
];
};
$desglose->setDesgloseIVA($desglose_iva);
$invoice->setDesglose($desglose);