Fecha de elaboración: {{ date("d/m/Y") }}
@if ($invoice->multiple) @php $firstAuthorizationCode = json_decode($invoice->multiple_codes, true)[0]; $firstAuthorization = \App\Authorization::findByCode($firstAuthorizationCode); @endphp @else @endif
DATOS DEL PACIENTE:

Tipo de Documento: {{ $firstAuthorization->patient->dni_type}}
Número de Documento: {{ $firstAuthorization->patient->dni}}
{{ $firstAuthorization->patient->full_name}}
  DATOS DE LA EMPRESA:

{{ $invoice->eps->code }} - {{ $invoice->eps->name }} - NIT: {{ $invoice->eps->nit }}
Dirección: {{ $invoice->eps->address->address }} - Tel: {{ $invoice->eps->phone->phone }}
  SON:

{{ ucfirst(\App\NumberToLetter::convertirEurosEnLetras(number_format(array_sum(json_decode($invoice->multiple_totals, true)), 0, ",", "."), 0)) }} M/L
DATOS DEL PACIENTE:

Tipo de Documento: {{ $invoice->authorization->patient->dni_type}}
Número de Documento: {{ $invoice->authorization->patient->dni}}
{{ $invoice->authorization->patient->full_name}}
  DATOS DE LA EMPRESA:

{{ $invoice->eps->code }} - {{ $invoice->eps->name }}
NIT: {{ $invoice->eps->nit }}
Dirección: {{ $invoice->eps->address->address }}
Tel: {{ $invoice->eps->phone->phone }}
  SON:

{{ ucfirst(\App\NumberToLetter::convertirEurosEnLetras(number_format($invoice->total, 0, ",", "."), 0)) }} M/L

@if ($invoice->multiple) @php $total = 0; @endphp @foreach (json_decode($invoice->multiple_codes, true) as $k => $authorizationCode) @php $currentAuthorization = \App\Authorization::findByCode($authorizationCode); $services = $currentAuthorization->eps_service_id; $companionService = $currentAuthorization->multiple_services; $flag = false; if ($companionService) { $services .= ",".$companionService; } elseif (count($currentAuthorization->services) > 0) { $services = ''; foreach ($currentAuthorization->services as $servicePrice) { $services .= $servicePrice->eps_service_id.","; } $flag = true; $services = trim($services, ","); } @endphp @if ($flag) @foreach($currentAuthorization->services as $authorizationService) @php $currentTotal = $authorizationService->price * $authorizationService->days; $total += $currentTotal; @endphp @endforeach @else @foreach(explode(",", $services) as $serviceId) @php $service = \App\EpsService::find($serviceId); $currentTotal = json_decode($invoice->multiple_totals, true)[$k] / count(explode(",", $services)); $total += $currentTotal; @endphp @endforeach @endif @endforeach @else @php $total = 0; $services = $invoice->authorization->eps_service_id; $companionService = $invoice->authorization->multiple_services; $flag = false; if ($companionService) { $services .= ",".$companionService; } elseif (count($invoice->authorization->services) > 0) { $services = ''; $flag = true; foreach ($invoice->authorization->services as $servicePrice) { $services .= $servicePrice->eps_service_id.","; } $services = trim($services, ","); } @endphp @if ($flag) @foreach($invoice->authorization->services as $authorizationService) @php $currentTotal = $authorizationService->price * $authorizationService->days; $total += $currentTotal; @endphp @endforeach @else @foreach(explode(",", $services) as $serviceId) @php $service = \App\EpsService::find($serviceId); $total += $invoice->total / count(explode(",", $services)); @endphp @endforeach @endif @endif
Codigo Detalle Autorizacion Cant. Valor Unitario Valor Total
{{ $authorizationService->service->code }} {{ $authorizationService->service->name }} {{ $currentAuthorization->codec }} {!! $authorizationService->days !!} $ {{ number_format($authorizationService->price, 0, ",", ".") }} $ {!! number_format($currentTotal, 0, ",", ".") !!}
{{ $service->code }} {{ $service->name }} {{ $currentAuthorization->codec }} {!! json_decode($invoice->multiple_days, true)[$k] !!} $ {{ number_format($service->price > 0 ? $service->price : $currentAuthorization->daily_price / count(explode(",", $services)), 0, ",", ".") }} $ {!! number_format($currentTotal, 0, ",", ".") !!}
{{ $authorizationService->service->code }} {{ $authorizationService->service->name }} {{ $invoice->authorization->codec }} {!! $authorizationService->days !!} $ {{ number_format($authorizationService->price, 0, ",", ".") }} $ {!! number_format($currentTotal, 0, ",", ".") !!}
{{ $service->code }} {{ $service->name }} {{ $invoice->authorization->codec }} {!! $invoice->days !!} $ {{ number_format($service->price > 0 ? $service->price : $invoice->authorization->daily_price / count(explode(",", $services)), 0, ",", ".") }} $ {!! number_format($invoice->total / count(explode(",", $services)), 0, ",", ".") !!}
TOTAL: $ {!! number_format($total, 0, ",", ".") !!}



_____________________________________
Firma de la persona autorizada
  Recibido: ___________________________
C.C.: _______________________________
Fecha: ________/__________/__________
              DIA         MES          AÑO


Esta factura de venta se asimila en todos sus efectos legales a una letra de cambio.
Art. 774 del código de comercio