@if($config->logo != null) Logo @else Logo @endif
Emissão: {{ date('d/m/Y - H:i') }}

Ordem de Produção #{{ $item->codigo_sequencial }}

@foreach($item->itens as $prod)
Produto Acabado
@php $somaVenda = 0; $somaCompra = 0; @endphp @php $somaVenda = $prod->produto->valor_unitario * $prod->quantidade; $somaCompra = $prod->produto->valor_compra * $prod->quantidade; @endphp @if($prod->observacao) @endif
Cód Nome Nº Pedido Qtd Preço Custo Preço Venda
{{ $prod->produto->id }} {{ $prod->produto->nome }} {{ $prod->numero_pedido }} @if(!$prod->produto->unidadeDecimal()) {{ number_format($prod->quantidade, 0, '.', '') }} @else {{ $prod->quantidade }} @endif R$ {{ __moeda($prod->produto->valor_compra) }} R$ {{ __moeda($prod->produto->valor_unitario) }}
Observação: {{ $prod->observacao ?? '--' }}
Total R$ {{ __moeda($somaCompra) }} R$ {{ __moeda($somaVenda) }}

@if(sizeof($prod->produto->composicao) > 0)
Produção
@php $somaQtd = 0; $somaEstoqueUsado = 0; $somaValorFalta = 0; $custoUnitario = 0; $valorEmEstoque = 0; @endphp @foreach($prod->produto->composicao as $i) @php $qtdParaProduzir = $i->quantidade*$prod->quantidade; $estoqueAtual = 0; @endphp @php $custoUnitario += $i->ingrediente->valor_compra; @endphp @php $somaQtd += $i->quantidade; $somaEstoqueUsado += ($i->quantidade*$prod->quantidade); @endphp @endforeach
Cód Nome Un Qtd Preço Custo Qtd p/ Produção Custo Produção Estoque Atual Estoque Usado Falta (R$)
{{ $i->ingrediente->numero_sequencial }} {{ $i->ingrediente->nome }} {{ $i->ingrediente->unidade }} @if(!$i->ingrediente->unidadeDecimal()) {{ number_format($i->quantidade, 0, '.', '') }} @else {{ $i->quantidade }} @endif R$ {{ __moeda($i->ingrediente->valor_compra) }} @if(!$prod->produto->unidadeDecimal()) {{ number_format($prod->quantidade, 0, '.', '') }} @else {{ $prod->quantidade }} @endif R$ {{ __moeda($i->ingrediente->valor_compra*($i->quantidade*$prod->quantidade)) }} @if($i->ingrediente->estoque) @if(!$i->ingrediente->unidadeDecimal()) {{ number_format($i->ingrediente->estoque->quantidade, 0, '.', '') }} @else {{ $i->ingrediente->estoque->quantidade }} @endif @php $estoqueAtual = $i->quantidade; @endphp @else -- @endif {{ $qtdParaProduzir }} @if($qtdParaProduzir > $estoqueAtual) @php $falta = $qtdParaProduzir - $estoqueAtual; $somaValorFalta += $i->ingrediente->valor_compra * $falta; @endphp R$ {{ __moeda($i->ingrediente->valor_compra * $falta) }} @else R$ 0,00 @endif @php $valorEmEstoque += $i->ingrediente->valor_compra * $estoqueAtual; @endphp
@if(fmod($somaQtd, 1) != 0) {{ number_format($somaQtd, 2, ',', '.') }} @else {{ intval($somaQtd) }} @endif @if(fmod($somaEstoqueUsado, 1) != 0) {{ number_format($somaEstoqueUsado, 2, ',', '.') }} @else {{ intval($somaEstoqueUsado) }} @endif R$ {{ __moeda($somaValorFalta) }}


CUSTO UNITÁRIO R$ {{ __moeda($custoUnitario) }}
EM ESTOQUE PARA PRODUZIR R$ {{ __moeda($valorEmEstoque) }}
VALOR FALTANTE PARA PRODUZIR R$ {{ __moeda($somaValorFalta) }}
@php $custoTotal = $custoUnitario * $prod->quantidade; @endphp
VENDA A PREÇO DE CUSTO R$ {{ __moeda($custoTotal) }}
VENDA A PREÇO DE VENDA R$ {{ __moeda($somaVenda) }}
@php $lucro = $somaVenda - $custoTotal; $lucroPercentual = $custoTotal > 0 ? ($lucro / $custoTotal) * 100 : 0; @endphp
LUCRO {{ number_format($lucroPercentual, 1, '.', '') }}%
@endif

@endforeach