@if(count($semCadastro) > 0)
Vincular produtos SPED ao cadastro

Itens do SPED sem código vinculado no cadastro interno do cliente.

@foreach($semCadastro as $item) @endforeach
Código SPED Descrição NCM Ação
{{ $item['cod_item'] }} {{ Str::limit($item['descr_item'] ?? '', 60) }} {{ $item['ncm'] ?? '—' }} @if(!empty($item['sugestao']))
@csrf
@endif
@csrf
@endif @if(count($unidadesDiv) > 0) @php $unidadesDivValorTotal = array_sum(array_column($unidadesDiv, 'valor_total')); $unidadesDivPendentes = collect($unidadesDiv)->filter(fn ($u) => empty($u['conversoes']))->count(); @endphp
Conversões de unidade

No SPED o campo unid pode trazer sigla de medida (KG, UN, BAG, SC…) ou código de apresentação/embalagem (50M, 200K, SC40). Escolha a unidade padrão (sempre uma sigla) e converta cada código do SPED para ela: 1 KG = 50 × 50M — ou seja, 1 unidade padrão = quantas da outra.

Produtos com unidade divergente
{{ count($unidadesDiv) }}
{{ $unidadesDivPendentes }} sem conversão cadastrada
Valor movimentado (todos)
R$ {{ number_format($unidadesDivValorTotal, 2, ',', '.') }}
Soma das linhas SPED destes códigos
O que fazer

1. Veja siglas e códigos de apresentação usados no SPED.
2. Defina a unidade padrão (sigla: KG, UN, BAG…).
3. Para cada outro código, informe: 1 padrão = ? outro (ex.: 1 KG = 50 × 50M).

@foreach($unidadesDiv as $ud) @php $metricas = $ud['metricas_unidade'] ?? []; $unidadesLista = $ud['unidades'] ?? []; $siglasLista = $ud['siglas_disponiveis'] ?? ['UN', 'KG']; $padrao = $ud['unidade_padrao'] ?? ($siglasLista[0] ?? 'UN'); $convMap = $ud['conversoes_por_origem'] ?? []; $metricasPorUnid = collect($metricas)->keyBy(fn ($m) => strtoupper($m['unid'])); @endphp
first) data-tour="conv-produto-demo" @endif>
{{ $ud['cod_item'] }}
{{ $ud['descr_item'] ?? '—' }}
Valor total no SPED
R$ {{ number_format((float) ($ud['valor_total'] ?? 0), 2, ',', '.') }}
Códigos no SPED (sigla × apresentação)
@if(!empty($ud['unid_inv']))
Unidade de inventário no cadastro 0200: {{ $ud['unid_inv'] }}
@endif
first) data-tour="conv-tabela-sped" @endif> @foreach($metricas as $mu) @php $ehSigla = ($mu['tipo'] ?? '') === 'sigla'; @endphp @endforeach
Sigla Cód. SPED Volume Valor Preço médio
@if($ehSigla) {{ strtoupper($mu['unid']) }} @else @endif @if($ehSigla) {{ $mu['unid'] }} @else {{ $mu['unid'] }} apresentação @endif @if(!empty($mu['volume'])) {{ number_format((float) $mu['volume'], 2, ',', '.') }} @else — @endif R$ {{ number_format((float) ($mu['valor'] ?? 0), 2, ',', '.') }} @if(!empty($mu['preco_medio'])) R$ {{ number_format((float) $mu['preco_medio'], 2, ',', '.') }} @else — @endif
Sigla única (UN, KG, BAG, SC…) para consolidar volumes e simulações.
@if(!empty($ud['conversoes']))
@foreach($ud['conversoes'] as $c) 1 {{ $c['para'] }} = {{ rtrim(rtrim(number_format((float) $c['fator'], 4, ',', '.'), '0'), ',') }} {{ $c['de'] }} @endforeach
@endif
@php $marcouTourFator = false; @endphp @foreach($unidadesLista as $un) @php $mu = $metricasPorUnid->get(strtoupper($un)); $mPad = $metricasPorUnid->get(strtoupper($padrao)); $fatorVal = $convMap[strtoupper($un)] ?? null; if ($fatorVal === null && $mu && $mPad && strtoupper($un) !== strtoupper($padrao) && ($mPad['volume'] ?? 0) > 0 && ($mu['volume'] ?? 0) > 0) { $fatorVal = round($mu['volume'] / $mPad['volume'], 4); } $ehPadrao = strtoupper($un) === strtoupper($padrao); $ehApresentacao = ($mu['tipo'] ?? '') === 'apresentacao'; $tourFator = $loop->parent->first && !$ehPadrao && !$marcouTourFator; if ($tourFator) { $marcouTourFator = true; } @endphp
@csrf 1 {{ strtoupper($padrao) }} = {{ $un }} @if($ehApresentacao) apresentação @endif @if($mu && $mPad && ($mPad['volume'] ?? 0) > 0 && ($mu['volume'] ?? 0) > 0) SPED: {{ number_format((float) $mu['volume'], 0, ',', '.') }} ÷ {{ number_format((float) $mPad['volume'], 0, ',', '.') }} @endif
@endforeach
@endforeach
@endif @if(count($semCadastro) === 0 && count($unidadesDiv) === 0)

Nenhuma pendência de cadastro ou unidade nesta simulação.

@endif