@php //function check if a key exists in an array and return the value or return a default value function checkKey($array, $key, $default = null) { return array_key_exists($key, $array) ? $array[$key] : $default; } @endphp Kardex valorizado
{{--

FORMATO 13.1: "REGISTRO DE INVENTARIO PERMANENTE VALORIZADO - DETALLE DEL INVENTARIO VALORIZADO"

--}}

@if ($additionalData['month']) @endif

FORMATO 13.1: "REGISTRO DE INVENTARIO PERMANENTE VALORIZADO - DETALLE DEL INVENTARIO VALORIZADO"

PERÍODO:

{{ $additionalData['period'] }}

MES:

{{ $additionalData['month'] }}

RUC:

{{ $company->number }}

APELLIDOS Y NOMBRES, DENOMINACIÓN O RAZÓN SOCIAL:

{{ $company->name }}

ESTABLECIMIENTO (1):

{{ optional($establishment)->description }}

CÓDIGO DE LA EXISTENCIA:

{{ $additionalData['internal_id'] }}

TIPO (TABLA 5):

01

DESCRIPCIÓN:

{{ $additionalData['description'] }}

CÓDIGO DE LA UNIDAD DE MEDIDA (TABLA 6):

{{ $additionalData['unit_type_table_six']['code'] }} - {{ $additionalData['unit_type_table_six']['description'] }}

MÉTODO DE VALUACIÓN:

COSTO PROMEDIO
{{-- ENTRADAS --}} {{-- SALIDAS --}} {{-- SALDO --}} @php // dd($records); // $balance_quantity = 0; // $balance_total = 0; // $balance_cost = 0; //totals $totals = [ 'input_quantity' => 0, 'input_unit_price' => 0, 'input_total' => 0, 'output_quantity' => 0, 'output_unit_price' => 0, 'output_total' => 0, 'balance_quantity' => $init_stock, 'balance_total' => $init_cost_total, 'balance_cost' => $init_cost_unit, ]; @endphp @if ($show_init) @endif @php // get the last row with key 'type' = 'output' $last_output = array_reverse( array_filter($records, function ($row) { return $row['type'] == 'output'; }), )[0] ?? []; // get the last row with key 'type' = 'input' $last_input = array_reverse( array_filter($records, function ($row) { return $row['type'] == 'input'; }), )[0] ?? []; //get the last row of records $last_row = array_reverse($records)[0] ?? []; @endphp @foreach ($records as $row) {{-- ENTRADAS --}} {{-- SALIDAS --}} @if ($row['type'] == 'output') @else @endif {{-- SALDO --}} @php // $balance_quantity += $row['quantity'] * $row['factor']; // $balance_total += $row['total'] * $row['factor']; // $balance_cost = ($balance_quantity != 0) ? round($balance_total / $balance_quantity, 4) : null; if ($row['type'] == 'input') { $totals['input_quantity'] += $row['input_quantity']; $totals['input_unit_price'] += $row['input_unit_price']; $totals['input_total'] += $row['input_total']; } else { $totals['output_quantity'] += $row['output_quantity']; $totals['output_unit_price'] += $row['output_unit_price']; $totals['output_total'] += $row['output_total']; } $totals['balance_quantity'] += $row['balance_quantity']; $totals['balance_total'] += $row['balance_total_cost']; $totals['balance_cost'] += $row['balance_unit_cost']; @endphp @endforeach {{-- --}}

DOCUMENTO DE TRASLADO, COMPROBANTE DE PAGO, DOCUMENTO DE TRASLADO, COMPROBANTE DE PAGO, DOCUMENTO INTERNO O SIMILAR

TIPO DE OPERACIÓN (TABLA 12)

ENTRADAS

SALIDAS

SALDO FINAL

FECHA

TIPO (TABLA 10)

SERIE

NÚMERO

CANTIDAD

COSTO UNITARIO

COSTO TOTAL

CANTIDAD

COSTO UNITARIO

COSTO TOTAL

CANTIDAD

COSTO UNITARIO

COSTO TOTAL

STOCK INICIAL {{-- {{ $balance_quantity }} --}} {{ $init_stock }} {{-- {{ $balance_cost }} --}} {{ $init_cost_unit }} {{-- {{ $balance_total }} --}} {{ $init_cost_total }}
{{ $row['date_of_issue'] }} {{ $row['document_type_id'] }} {{ $row['series'] }} {{ $row['number'] }} {{ $row['operation_type_code'] }} {{ $row['input_quantity'] }} {{ $row['input_unit_price'] }} {{ $row['input_total'] }} {{ $row['output_quantity'] }} {{ $row['output_unit_price'] }} {{ $row['output_total'] }} {{-- {{ $balance_quantity }} --}} {{ $row['balance_quantity'] }} {{-- {{ $balance_cost }} --}} {{ $row['balance_unit_cost'] }} {{-- {{ $balance_total }} --}} {{ $row['balance_total_cost'] }}
TOTALES {{ checkKey($last_input, 'input_quantity', 0) }} {{ checkKey($last_input, 'input_unit_price', 0) }} {{ checkKey($last_input, 'input_total', 0) }} {{ checkKey($last_output, 'output_quantity', 0) }} {{ checkKey($last_output, 'output_unit_price', 0) }} {{ checkKey($last_output, 'output_total', 0) }} {{ checkKey($last_row, 'balance_quantity', 0) }} {{ checkKey($last_row, 'balance_unit_cost', 0) }} {{ checkKey($last_row, 'balance_total_cost', 0) }}
TOTALES {{ $totals['input_quantity'] }} {{ $totals['input_unit_price'] }} {{ $totals['input_total'] }} {{ $totals['output_quantity'] }} {{ $totals['output_unit_price'] }} {{ $totals['output_total'] }} {{ $totals['balance_quantity'] }} {{ $totals['balance_cost'] }} {{ $totals['balance_total'] }}