{{-- Logo --}} @if(isset($imgLogo) && $imgLogo)
logo
@endif {{-- Empresa y Establecimiento --}}
{{ $user->name ?? '' }} @if(isset($request->establishment_name) && $request->establishment_name != 'Oficina Principal')
{{ $request->establishment_name }} @endif
NIT: {{ $company->identification_number ?? '' }}{{ isset($company->dv) ? '-'.$company->dv : '' }} @if(isset($request->establishment_address) && $request->establishment_address)
Dirección: {{ $request->establishment_address }} @else
Dirección: {{ $company->address ?? '' }} @endif @inject('municipality', 'App\Municipality') @if(isset($request->establishment_municipality))
{{ $municipality->findOrFail($request->establishment_municipality)['name'] ?? '' }} - {{ $municipality->findOrFail($request->establishment_municipality)['department']['name'] ?? '' }} - {{ $company->country->name ?? '' }} @elseif(isset($company->municipality->name))
{{ $company->municipality->name ?? '' }} - {{ $company->municipality->department->name ?? '' }} - {{ $company->country->name ?? '' }} @endif @if(isset($request->establishment_phone) && $request->establishment_phone)
Tel: {{ $request->establishment_phone }} @elseif(isset($company->phone))
Tel: {{ $company->phone }} @endif @if(isset($request->establishment_email) && $request->establishment_email)
Correo: {{ $request->establishment_email }} @elseif(isset($user->email))
Correo: {{ $user->email }} @endif

{{-- Datos de la factura y resolución DIAN --}}
FACTURA ELECTRÓNICA DE VENTA
{{$resolution->prefix}} - {{$request->number}}
Fecha Emisión: {{$date}}
Hora: {{$time}}
Resolución DIAN: {{$resolution->resolution}} de {{$resolution->resolution_date}}
Prefijo: {{$resolution->prefix}}, Rango {{$resolution->from}} al {{$resolution->to}}
Vigencia: {{$resolution->date_from}} a {{$resolution->date_to}}

{{-- Información adicional DIAN --}}
@php $infoDian = []; if(isset($request->ivaresponsable) && $request->ivaresponsable != $company->type_regime->name) { $infoDian[] = $company->type_regime->name.' - '.$request->ivaresponsable; } if(isset($request->nombretipodocid)) { $infoDian[] = 'Tipo Doc: '.$request->nombretipodocid; } if(isset($request->tarifaica) && $request->tarifaica != '100') { $infoDian[] = 'ICA: '.$request->tarifaica.'‰'; } if(isset($request->actividadeconomica)) { $infoDian[] = 'Act. Econ.: '.$request->actividadeconomica; } echo implode(' | ', $infoDian); @endphp
{{-- Cliente --}} @if(isset($customer->company->type_regime->name) || isset($customer->company->type_liability->name)) @endif
Cliente: {{ $customer->name ?? '' }}
NIT/CC: {{ $customer->company->identification_number ?? '' }}{{ isset($request->customer['dv']) ? '-'.$request->customer['dv'] : '' }}
Dir./Ciudad: {{ $customer->company->address ?? '' }} @if(isset($customer->company->country) && isset($customer->company->country->id) && $customer->company->country->id == 46) - {{ $customer->company->municipality->name ?? '' }} - {{ $customer->company->country->name ?? '' }} @else - {{ $customer->company->municipality_name ?? '' }} - {{ $customer->company->state_name ?? '' }} - {{ $customer->company->country->name ?? '' }} @endif
Tel/Email: {{ $customer->company->phone ?? '' }}{{ isset($customer->email) && $customer->email ? ' / '.$customer->email : '' }}
Rég/Obl.: {{ $customer->company->type_regime->name ?? '' }} @if(isset($customer->company->type_regime->name) && isset($customer->company->type_liability->name)) / @endif {{ $customer->company->type_liability->name ?? '' }}
{{-- Información de pedido y moneda --}} @if(isset($request['order_reference']['id_order']))
Número Pedido: {{$request['order_reference']['id_order']}}
@endif @if(isset($request['order_reference']['issue_date_order']))
Fecha Pedido: {{$request['order_reference']['issue_date_order']}}
@endif @if(isset($request['deliveryterms']))
Terminos de Entrega: {{$request['deliveryterms']['loss_risk_responsibility_code']}} - {{ $request['deliveryterms']['loss_risk'] }}
T.R.M: {{number_format($request['calculationrate'], 2)}}
Fecha T.R.M: {{$request['calculationratedate']}}
@inject('currency', 'App\TypeCurrency') Tipo Moneda: {{$currency->findOrFail($request['idcurrency'])['name']}}
@endif
{{-- Información sector salud (healthfields) --}} @isset($healthfields) @foreach ($healthfields->user_info as $item) @endforeach
INFORMACIÓN REFERENCIAL SECTOR SALUD
Cod Prestador Info. Contratación Info. de Pagos
{{$item->provider_code}} Modalidad Contratación: {{$item->health_contracting_payment_method()->name}}
Nro Contrato: {{$item->contract_number}}
Cobertura: {{$item->health_coverage()->name}}
Copago: {{number_format($item->co_payment, 2)}}
Cuota Moderadora: {{number_format($item->moderating_fee, 2)}}
Pagos Compartidos: {{number_format($item->shared_payment, 2)}}
Anticipos: {{number_format($item->advance_payment, 2)}}
Inicio Periodo Facturación: {{$healthfields->invoice_period_start_date}}
Fin Periodo Facturación: {{$healthfields->invoice_period_end_date}}

@endisset {{-- Items --}} @foreach($request['invoice_lines'] as $item) @if( isset($item['description']) && ( $item['description'] == 'Administración' || $item['description'] == 'Imprevisto' || $item['description'] == 'Utilidad' ) ) @else @endif @endforeach
Código Cantidad UM Descripción Val. Unit Val. Item
{{ $item['code'] ?? '' }} {{ $item['description'] }} {{ isset($item['price_amount']) ? number_format($item['price_amount'], 2) : '' }} {{ isset($item['invoiced_quantity']) && isset($item['price_amount']) ? number_format($item['invoiced_quantity'] * $item['price_amount'], 2) : '' }}
{{ $item['code'] ?? '' }} {{ isset($item['invoiced_quantity']) ? number_format($item['invoiced_quantity'], 2) : '' }} @inject('um', 'App\UnitMeasure') @if(isset($item['unit_measure_id'])) {{ $um->findOrFail($item['unit_measure_id'])['name'] }} @else {{ $item['unit_measure'] ?? '' }} @endif {{ $item['description'] ?? '' }} @if(isset($item['notes']))
{{ $item['notes'] }} @endif
@php $cantidad = isset($item['invoiced_quantity']) && $item['invoiced_quantity'] > 0 ? $item['invoiced_quantity'] : 1; $precioUnidad = (isset($item['tax_totals']) && isset($item['tax_totals'][0]['tax_amount'])) ? (($item['line_extension_amount'] ?? 0) + $item['tax_totals'][0]['tax_amount']) / $cantidad : ($item['line_extension_amount'] ?? 0) / $cantidad; @endphp {{ number_format($precioUnidad, 2) }} @if(isset($item['tax_totals']) && isset($item['tax_totals'][0]['tax_amount'])) {{ number_format(($item['line_extension_amount'] ?? 0) + $item['tax_totals'][0]['tax_amount'], 2) }} @else {{ number_format($item['line_extension_amount'] ?? 0, 2) }} @endif
{{-- Impuestos y retenciones --}}
IVA
@if(isset($request->tax_totals)) @php $TotalImpuestos = 0; @endphp @foreach($request->tax_totals as $item) @php $TotalImpuestos += $item['tax_amount']; @endphp @inject('tax', 'App\Tax')
{{$tax->findOrFail($item['tax_id'])['name']}} @if(isset($item['percent'])) {{ number_format($item['percent'], 2) }}% @elseif(isset($item['per_unit_amount']) && isset($item['base_unit_measure'])) {{ number_format($item['per_unit_amount'], 2) }} x {{ number_format($item['base_unit_measure'], 2) }} @else - @endif: {{number_format($item['tax_amount'], 2)}}
@endforeach @endif
Retenciones
@if(isset($withHoldingTaxTotal)) @php $TotalRetenciones = 0; @endphp @foreach($withHoldingTaxTotal as $item) @php $TotalRetenciones += $item['tax_amount']; @endphp @inject('tax', 'App\Tax')
{{$tax->findOrFail($item['tax_id'])['name']}}: {{number_format($item['tax_amount'], 2)}}
@endforeach @endif
{{-- Totales --}} @php $TotalImpuestos = 0; if(isset($request->tax_totals)){ foreach($request->tax_totals as $item){ $TotalImpuestos += $item['tax_amount']; } } $TotalRetenciones = 0; if(isset($withHoldingTaxTotal)){ foreach($withHoldingTaxTotal as $item){ $TotalRetenciones += $item['tax_amount']; } } @endphp @if(isset($request->legal_monetary_totals['allowance_total_amount'])) @endif @if(isset($withHoldingTaxTotal)) @endif @if(isset($request->previous_balance) && $request->previous_balance > 0) @endif
SUBTOTAL: {{ number_format($request->legal_monetary_totals['line_extension_amount'], 2) }}
IMPUESTOS: {{ number_format($TotalImpuestos, 2) }}
DESCUENTOS: {{ number_format($request->legal_monetary_totals['allowance_total_amount'], 2) }}
RETENCIONES: {{ number_format($TotalRetenciones, 2) }}
Saldo Anterior: {{ number_format($request->previous_balance, 2) }}
TOTAL A PAGAR: @php $totalAmount = $request->legal_monetary_totals['payable_amount']; if(isset($request->previous_balance)) $totalAmount += $request->previous_balance; if(isset($TotalRetenciones)) $totalAmount -= $TotalRetenciones; @endphp {{ number_format($totalAmount, 2) }}

{{-- Valor en letras --}} @inject('Varios', 'App\Custom\NumberSpellOut')
SON: {{$Varios->convertir($totalAmount, $request->idcurrency ?? null)}} M/CTE

{{-- Pagos --}} @if(!empty($paymentForm) && $paymentForm->count() > 0)
Forma de Pago: {{$paymentForm[0]->name}}
Medios: @foreach ($paymentForm as $paymentF) {{$paymentF->nameMethod}}@if(!$loop->last), @endif @endforeach
Plazo: {{$paymentForm[0]->duration_measure}} días
Vence: {{$paymentForm[0]->payment_due_date}}
@endif {{-- QR y CUFE --}}
CUFE: {{$cufecude}}
{{-- Notas --}} @if(isset($notes))
{{$notes}}
@endif @if(isset($request->foot_note))
{{$request->foot_note}}
@endif {{-- Footer --}}

GRACIAS POR SU COMPRA