{{-- Control Variables --}} @php // Imports use Carbon\Carbon; use App\Helpers\Database\SatCatalogsHelper; use App\Helpers\Environment\SystemFeaturesHelper; use App\Helpers\Support\PdfResourcesHelper; use App\Helpers\Support\TaxCertificateHelper; use App\Helpers\Formats\AddressFormatterHelper; use App\Helpers\Formats\FormatCurrencyHelper; use App\Helpers\Formats\QuantityConverterHelper; use App\Helpers\Formats\TextTransformHelper; use App\Enums\Invoicing\BillableService; // Variables // Controls $reduce_invoice = SystemFeaturesHelper::getFeatureStatus("reduced_invoices"); $is_global_invoice = $invoice->receptor->tax_id === "XAXX010101000" && !is_null($invoice->global); // Classes $contrast_color = PdfResourcesHelper::getTextContrastColor($invoice->taxFormat->base_color ?? "#0D6889"); // Header $tax_folio = $invoice->sat_uuid ?? "0000XXXX-00XX-00XX-00XX-000000XXXXXX"; $cds_issuer = TaxCertificateHelper::serialHexToSatCertificateNumber($issuer->cer_serial_number); $emission_date = Carbon::parse($invoice->date)->format('d/m/Y H:i:s'); $certification_date = Carbon::parse($invoice->certification_date ?? "2099-01-01")->format('d/m/Y H:i:s'); $serie_folio = ($invoice->taxFormat->serie ?? $invoice->invoice_type)."-X"; if (!in_array(null, [$invoice->system_service_id, $invoice->system_service_type], true)) { $label = BillableService::labelFrom($invoice->system_service_type); if ($label) $serie_folio .= " | ".$label." #{$invoice->system_service_id}"; } // Global Data if($is_global_invoice) $global = (object) $invoice->global; // Receiver $receiver_address = (object) $invoice->receptor->tax_address; $receiver_sample_address = AddressFormatterHelper::format( [ "street" => $receiver_address->street, "exterior" => $receiver_address->exterior, "interior" => $receiver_address->interior, "neighborhood" => $receiver_address->neighborhood, "city" => $receiver_address->city, "municipality" => $receiver_address->municipality, "state" => $receiver_address->state ?? null, "country" => $receiver_address->country, 'zip' => $invoice->receptor->zip, ], ['ext_label' => 'No.', 'int_label' => 'Int.', 'zip_label' => 'C.P.' ] ); @endphp {{ $title }} @include('invoicing.invoices.pdf.resources.invoice-styles') {{-- Watermark --}}
PREVIEW
{{-- Header --}}
{{-- Logo --}}
{{-- Issuer Data --}}
{{-- Legal Name --}}

{{ $issuer->legal_name }}

{{-- Tax Data --}}

{{-- RFC --}} {{ $issuer->tax_id }}
{{-- Address --}} {{ $invoice->taxBranch->sample_address }}
{{-- email --}} {{ $invoice->taxBranch->email }}

{{-- Invoice Header --}}
{{-- Versión --}} {{-- Folio Fiscal --}} {{-- CSD del Emisor --}} {{-- Datetime Emisión --}} {{-- Datetime Certificación --}} {{-- Uso de CFDI --}} {{-- Regimen Fiscal --}} {{-- Tipo de CFDI --}} {{-- Serie y Folio --}}
Versión: 4.0
Folio Fiscal: {{ $tax_folio }}
No. de serie del CSD del Emisor: {{ $cds_issuer }}
Fecha y hora de operación: {{ $emission_date }} (Tiempo del Centro)
Fecha y hora de Certificación: {{ $certification_date }} (Tiempo del Centro)
Uso de CFDI: {{ SatCatalogsHelper::getItem('c_UsoCFDI', $invoice->cfdi_use, true) }}
Regimen fiscal: {{ SatCatalogsHelper::getItem('c_RegimenFiscal', $issuer->tax_system, true) }}
Tipo de CFDI: {{ SatCatalogsHelper::getItem('c_TipoDeComprobante', $invoice->invoice_type, true) }}
Serie y Folio: {{ $serie_folio }}
{{-- Footer --}} {{-- Content --}}
{{-- Receiver - CFDI Data --}}
{{-- Receiver Data --}}

Receptor

Nombre: {{ $invoice->receptor->legal_name }}

RFC: {{ $invoice->receptor->tax_id }}

{{ $receiver_sample_address }}

Régimen Fiscal: {{ SatCatalogsHelper::getItem('c_RegimenFiscal', $invoice->receptor->tax_system, true) }}

{{-- CFDI Data --}}

Datos del CFDI

Moneda: {{ SatCatalogsHelper::getItem('c_Moneda', $invoice->currency, true) }}

Tipo de Cambio: {{ QuantityConverterHelper::removeUnnecessaryDecimal($invoice->exchange_rate) }}

Método de Pago: @if ($reduce_invoice) {{ $invoice->payment_method }} @else {{ SatCatalogsHelper::getItem('c_MetodoPago', $invoice->payment_method, true) }} @endif

Forma de Pago: {{ SatCatalogsHelper::getItem('c_FormaPago', $invoice->payment_form, !$reduce_invoice) }}

@if (in_array($invoice->invoice_type, ['I', 'E']))

Exportación: {{ SatCatalogsHelper::getItem('c_Exportacion', $invoice->export, true) }}

@endif @if ( in_array($invoice->invoice_type, ['I', 'E', 'N']) && in_array($invoice->payment_method, ['PPD']) && !is_null($invoice->credit_days) && !is_null($invoice->due_date) )

Días de Crédito: {{ $invoice->credit_days }}

Fecha Límite de Pago: {{ $invoice->due_date }}

@endif
{{-- Global/Generic Data --}} @if ($is_global_invoice)
{{-- Title --}}

Factura Global

{{-- Data --}}
{{-- Periodicity --}}

Periodicidad: @if ($reduce_invoice) {{ SatCatalogsHelper::getItem('c_Periodicidad', $global->periodicity, false) }} @else {{ SatCatalogsHelper::getItem('c_Periodicidad', $global->periodicity, true) }} @endif

{{-- Period --}}

Periodo: @if ($reduce_invoice) {{ SatCatalogsHelper::getItem('c_Meses', $global->months, false) }} @else {{ SatCatalogsHelper::getItem('c_Meses', $global->months, true) }} @endif

{{-- Year --}}

Año: {{ $global->year }}

@endif {{-- Notes / Additional Datae --}} @if (!in_array($invoice->notes, [null, "", __('neutral_words')['none']]))
{{-- Title --}}

Información Extra

{{-- Data --}}
{{-- Periodicity --}}

{{ $invoice->notes }}

@endif {{-- Concepts --}}
@php $include_discount_data = $invoice->taxItems->where("discount_total", ">", 0.00)->count(); $dynamic_colspan = $include_discount_data ? 5 : 4; @endphp @if ($include_discount_data) @endif @php $federal_tax_config = [ [ 'label' => 'IVA Trasladado', 'rate_path' => 'taxes.iva.rate', 'charge_path'=> 'taxes.iva', ], [ 'label' => 'IEPS Trasladado', 'rate_path' => 'taxes.ieps.rate', 'charge_path'=> 'taxes.ieps', ], [ 'label' => 'ISR Retenido', 'rate_path' => 'withholding_taxes.isr.rate', 'charge_path'=> 'withholding_taxes.isr', ], [ 'label' => 'IVA Retenido', 'rate_path' => 'withholding_taxes.iva.rate', 'charge_path'=> 'withholding_taxes.iva', ], ]; @endphp @foreach ($invoice->taxItems as $concept) @php // Normalizar impuestos federales $federal_taxes = (array) ($concept->tax_profile ?? []); $federal_tax_charges = (array) ($concept->tax_charges_summary ?? []); // Normalizar impuestos locales siempre a objeto con propiedades $local_tax_profile = $concept->local_tax_profile ?? (object)[]; $local_taxes = is_array($local_tax_profile) ? (object) $local_tax_profile : $local_tax_profile; @endphp @if ($include_discount_data) @endif @endforeach {{-- Subtotal --}} {{-- Taxes Breakdown --}} @php // Federal Taxes $federal_tax_profile = []; foreach ($invoice->taxItems as $item) { $profile = $item->tax_profile ?? []; $charges = $item->tax_charges_summary ?? []; if ($item->object_tax === "04") { $federal_tax_profile["IVA_Trasladado_Exento"] = [ 'label' => "IVA - Exento", 'rate' => 0.00, 'charge' => 0.0, ]; } else { foreach ($federal_tax_config as $ftx) { $rate = data_get($profile, $ftx['rate_path']); $charge = data_get($charges, $ftx['charge_path']); if ($rate === null || $charge === null) continue; $key = $ftx['label'] . '_' . $rate; if (!isset($federal_tax_profile[$key])) $federal_tax_profile[$key] = [ 'label' => $ftx['label'], 'rate' => $rate, 'charge' => 0 ]; $federal_tax_profile[$key]['charge'] += $charge; } } } // Local Taxes $ltx_summary = is_array($invoice->local_taxes) ? (object) $invoice->local_taxes : $invoice->local_taxes; @endphp {{-- Federal Taxes --}} @foreach ($federal_tax_profile as $label => $ftx_profile) {{-- @dd($ftx_profile) --}} @endforeach {{-- Local Taxes --}} {{-- Transferred --}} @foreach ($ltx_summary->transferred as $ltx_tr) @php $ltx_tr = (array) $ltx_tr; @endphp @endforeach {{-- Withheld --}} @foreach ($ltx_summary->withheld as $ltx_rt) @php $ltx_rt = (array) $ltx_rt; @endphp @endforeach {{-- Total --}}
Cantidad Unidad Concepto Impuesto Precio UnitarioDescuentoTotal
{{ QuantityConverterHelper::removeUnnecessaryDecimal($concept->quantity) }} @if ($reduce_invoice) {{ $concept->unit_key }} @else {{ SatCatalogsHelper::getUnit($concept->unit_key, true) }} @endif @if ($reduce_invoice) @if (!in_array($concept->description, [__('neutral_words')['none'], __('neutral_words')['none_2']])) {{ mb_strtoupper($concept->description) }}
@else {{ $concept->name }}
@endif {{ $concept->prod_serv_key }}
{{ SatCatalogsHelper::getItem('c_ObjetoImp', $concept->object_tax, false) }}
@if ($concept->property_tax_account) Cuenta Predial: {{ $concept->property_tax_account }} @endif @else {{ $concept->name }}
@if (!in_array($concept->description, [__('neutral_words')['none'], __('neutral_words')['none_2']])) {{ mb_strtoupper($concept->description) }}
@endif {{ $concept->prod_serv_key }} - {{ $concept->sat_description }}
{{ SatCatalogsHelper::getItem('c_ObjetoImp', $concept->object_tax, true) }}
@if ($concept->property_tax_account) Cuenta Predial: {{ $concept->property_tax_account }} @endif @endif
{{-- Impuestos federales --}} @if ($concept->object_tax === '04') IVA (Exento)
{{ QuantityConverterHelper::str_toStrPercentage(0.0) }} {{ FormatCurrencyHelper::formatCurrency(0.0) }}
@else @foreach ($federal_tax_config as $tax) @php $rate = data_get($federal_taxes, $tax['rate_path']); $charge = data_get($federal_tax_charges, $tax['charge_path']); @endphp @if (!is_null($rate)) {{ $tax['label'] }}
{{ QuantityConverterHelper::str_toStrPercentage($rate) }} {{ FormatCurrencyHelper::formatCurrency($charge, $invoice->currency) }}
@endif @endforeach @endif {{-- Impuestos locales --}} @foreach ((array) ($local_taxes->transferred ?? []) as $tr_ltx) @php $tr_ltx = (array) $tr_ltx; @endphp {{ $tr_ltx['name'] }} Transferido
{{ QuantityConverterHelper::str_toStrPercentage($tr_ltx['rate'], 2, false) }} {{ FormatCurrencyHelper::formatCurrency($tr_ltx['charge'], $invoice->currency) }}
@endforeach @foreach ((array) ($local_taxes->withheld ?? []) as $rt_ltx) @php $rt_ltx = (array) $rt_ltx; @endphp {{ $rt_ltx['name'] }} Retenido
{{ QuantityConverterHelper::str_toStrPercentage($rt_ltx['rate'], 2, false) }} {{ FormatCurrencyHelper::formatCurrency($rt_ltx['charge'], $invoice->currency) }}
@endforeach
{{ FormatCurrencyHelper::formatCurrency($concept->unit_price, $invoice->currency) }} {{-- {{ QuantityConverterHelper::str_toStrPercentage($concept->discount_value, 6, false) }}
--}} {{ FormatCurrencyHelper::formatCurrency($concept->discount_total, $invoice->currency) }}
{{ FormatCurrencyHelper::formatCurrency(($concept->subtotal - $concept->discount_total), $invoice->currency) }}
Subtotal {{ FormatCurrencyHelper::formatCurrency($invoice->subtotal, $invoice->currency) }}
{{ $ftx_profile['label'] }} {{ QuantityConverterHelper::str_toStrPercentage($ftx_profile['rate']) }} {{ FormatCurrencyHelper::formatCurrency($ftx_profile['charge'], $invoice->currency) }}
{{ $ltx_tr['name'] }} Trasladado {{ QuantityConverterHelper::str_toStrPercentage($ltx_tr['rate'], 2, false) }} {{ FormatCurrencyHelper::formatCurrency($ltx_tr['charge'], $invoice->currency) }}
{{ $ltx_rt['name'] }} Retenido {{ QuantityConverterHelper::str_toStrPercentage($ltx_rt['rate'], 2, false) }} {{ FormatCurrencyHelper::formatCurrency($ltx_rt['charge'], $invoice->currency) }}
Importe con Letra: {{ QuantityConverterHelper::convertToPesosText($invoice->total, $invoice->currency) }} Total {{ FormatCurrencyHelper::formatCurrency($invoice->total, $invoice->currency) }}
{{-- Related Documents --}} @if ($invoice->related_documents)
@foreach ($invoice->related_documents as $rd) @php $relation_type = collect($document_relations) ->firstWhere('item_key', $rd->relation_type)?->label; @endphp @endforeach
Documentos Relacionados
Tipo de Relación Folio Fiscal Relacionado
{{ TextTransformHelper::trimText($relation_type, 35) }} {{ $rd->uuid }}
@endif {{-- SAT Certificates --}}
@php $illusionary_certificated_data = 'Lorem ipsum dolor sit, amet consectetur adipisicing elit. Repudiandae nemo debitis recusandae maiores natus doloribus quaerat? Delectus quasi nobis reprehenderit vel molestias quis ullam, qui rerum a suscipit nulla harum!'; @endphp
Sello digital Emisor
{{ $illusionary_certificated_data }}
Sello digital del SAT
{{ $illusionary_certificated_data }}
Cadena Original del Complemento de certificación digital del SAT
{{ $illusionary_certificated_data }}
Invoice QR