novo pilar tipo: termo (valor 5 no enum), lançado como uma linha por lote com manual: true e uma coluna nova quantidade. O valor_aplicado guarda o total do lote (qtd × preço), então recalcular_motorista! e todas as somas existentes seguem corretas sem mudança — linhas antigas ficam com quantidade = 1.
This commit is contained in:
@@ -12,13 +12,14 @@
|
||||
</div>
|
||||
|
||||
<%# Resumo por tipo %>
|
||||
<div class="grid grid-cols-2 md:grid-cols-5 gap-3 mb-6">
|
||||
<div class="grid grid-cols-2 md:grid-cols-6 gap-3 mb-6">
|
||||
<% [
|
||||
['entrega_normal', 'Normal', 'bg-orange-500 text-black'],
|
||||
['retirada', 'Retirada', 'bg-orange-800 text-white'],
|
||||
['bonus', 'Bônus', 'bg-white text-black'],
|
||||
['desconto', 'Desconto', 'bg-black text-white border border-gray-700'],
|
||||
['extraordinaria', 'Extraordinária', 'bg-purple-600 text-white']
|
||||
['extraordinaria', 'Extraordinária', 'bg-purple-600 text-white'],
|
||||
['termo', 'Termo', 'bg-blue-600 text-white']
|
||||
].each do |tipo, label, cores| %>
|
||||
<div class="<%= cores %> rounded-xl p-4 text-center">
|
||||
<p class="font-black text-3xl"><%= @resumo[tipo] || 0 %></p>
|
||||
@@ -66,7 +67,7 @@
|
||||
<td class="px-4 py-3 text-gray-300 text-xs"><%= c.entrega_original&.address.presence || endereco_manual.presence || '—' %></td>
|
||||
<td class="px-4 py-3">
|
||||
<span class="<%= c.tipo_cor[:bg] %> <%= c.tipo_cor[:text] %> px-2 py-1 rounded text-xs font-bold">
|
||||
<%= c.tipo_cor[:label] %>
|
||||
<%= c.tipo_cor[:label] %><% if c.termo? && c.quantidade > 1 %> ×<%= c.quantidade %><% end %>
|
||||
</span>
|
||||
<% if c.manual? %>
|
||||
<span class="ml-1 bg-orange-500/15 text-orange-400 border border-orange-500/40 px-2 py-1 rounded text-xs font-bold">➕ Apontamento</span>
|
||||
|
||||
@@ -197,6 +197,61 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%# Entrega de termo — entrega SEM nota fiscal nem código; só motorista + quantidade. %>
|
||||
<div data-controller="apontamento-termo"
|
||||
data-apontamento-termo-apontar-termo-url-value="<%= apontar_termo_consolidacao_consolidacao_entregas_path(@consolidacao) %>"
|
||||
data-apontamento-termo-motorista-value="<%= @motorista %>"
|
||||
class="mb-4">
|
||||
<button type="button" data-action="apontamento-termo#abrir"
|
||||
class="w-full md:w-auto inline-flex items-center justify-center gap-2 bg-[#1a1a1a] hover:bg-[#2a2a2a] text-white border border-dashed border-blue-500/60 hover:border-blue-500 font-semibold px-4 py-3 rounded-lg min-h-[48px]">
|
||||
➕ Entrega de termo
|
||||
<span class="text-gray-500 text-xs font-normal hidden md:inline">(sem nota/código — só quantidade)</span>
|
||||
</button>
|
||||
|
||||
<%# Modal %>
|
||||
<div data-apontamento-termo-target="modal" data-action="click->apontamento-termo#fundo"
|
||||
class="hidden fixed inset-0 z-50 bg-black/70 flex items-center justify-center p-4">
|
||||
<div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-2xl w-full max-w-md p-6">
|
||||
<div class="flex items-center justify-between mb-1">
|
||||
<h2 class="text-xl font-bold text-white">📄 Entrega de termo</h2>
|
||||
<button type="button" data-action="apontamento-termo#fechar"
|
||||
class="text-gray-500 hover:text-white text-2xl leading-none">✕</button>
|
||||
</div>
|
||||
<p class="text-gray-400 text-sm mb-4">Entrega sem nota fiscal nem código de rastreio. Informe quantos termos foram entregues.</p>
|
||||
|
||||
<p data-apontamento-termo-target="erro" class="hidden bg-red-500/10 text-red-400 border border-red-500/30 rounded-lg px-3 py-2 text-sm mb-3"></p>
|
||||
|
||||
<%# Motorista (contexto da tela) + preço unitário %>
|
||||
<div class="flex items-center justify-between bg-[#0a0a0a] border border-[#2a2a2a] rounded-lg px-4 py-3 mb-4">
|
||||
<div>
|
||||
<p class="text-gray-500 text-xs">Motorista</p>
|
||||
<p class="text-white font-semibold">🚚 <%= @motorista %></p>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<p class="text-gray-500 text-xs">Preço por termo</p>
|
||||
<p class="text-blue-400 font-semibold"><%= moeda(Configuracao.preco_termo) %></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%# Stepper de quantidade %>
|
||||
<label class="block text-gray-400 text-sm mb-2">Quantidade de termos</label>
|
||||
<div class="flex items-center justify-center gap-3 mb-5">
|
||||
<button type="button" data-action="apontamento-termo#menos"
|
||||
class="w-12 h-12 rounded-lg bg-[#0a0a0a] border border-[#2a2a2a] hover:border-blue-500 text-white text-2xl font-bold leading-none">−</button>
|
||||
<input data-apontamento-termo-target="quantidade" type="number" inputmode="numeric" min="1" value="1" readonly
|
||||
class="w-24 text-center bg-[#0a0a0a] border border-[#2a2a2a] text-white text-2xl font-bold rounded-lg py-2.5 focus:outline-none">
|
||||
<button type="button" data-action="apontamento-termo#mais"
|
||||
class="w-12 h-12 rounded-lg bg-[#0a0a0a] border border-[#2a2a2a] hover:border-blue-500 text-white text-2xl font-bold leading-none">+</button>
|
||||
</div>
|
||||
|
||||
<button type="button" data-action="apontamento-termo#adicionar"
|
||||
class="w-full bg-green-600 hover:bg-green-500 text-white font-bold py-3.5 rounded-lg min-h-[48px]">
|
||||
Adicionar termos ✓
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-4 gap-4">
|
||||
|
||||
Reference in New Issue
Block a user