Pagamento por checkout + consolidação por veículo (em vez de rota)

Regra de pagamento:
- Entrega.pagas agora exige status='completed' E checkout preenchido
  (antes era checkin). Afeta dashboard, painel do motorista, job 1h e
  elegibilidade das consolidações de forma consistente.

Veículo no lugar de rota na consolidação:
- migration troca consolidacoes.route_ids por vehicle_ids (jsonb + gin)
- Entrega: da_veiculo/veiculos_unicos; contar_pagas usa vehicle
- new.html.erb: filtro "Veículos" (multi-select por vehicle)
- validar.html.erb: mostra o veículo em vez do código da rota
- filtros/elegibilidade do controller passam a usar vehicle_ids

Docs/diagnóstico atualizados.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-16 02:17:25 -03:00
parent 13b0161dd5
commit 19b7cc838f
11 changed files with 58 additions and 35 deletions

View File

@@ -54,7 +54,7 @@ Default credentials (change in production): `admin@gade.com` / `Gade@2026!`
The table `public.db_reem_simplerout_2026` is owned by an external system (SimpleRoute) that updates it every hour. **NEVER** create migrations for it, and never run INSERT/UPDATE/DELETE/DROP/TRUNCATE on it.
`Entrega` (app/models/entrega.rb) maps to this table and enforces `readonly? = true`. All queries go through its scopes — the most important being `.pagas` (`status='completed' AND checkin IS NOT NULL`), which defines payment eligibility.
`Entrega` (app/models/entrega.rb) maps to this table and enforces `readonly? = true`. All queries go through its scopes — the most important being `.pagas` (`status='completed' AND checkout IS NOT NULL`), which defines payment eligibility. Consolidations filter eligible deliveries by **vehicle** (`vehicle` column → `Consolidacao#vehicle_ids`), not by route.
## Architecture