Initial commit - Fase 1: Setup Rails + Docker

This commit is contained in:
2026-06-10 17:40:07 -03:00
commit eb812868e5
30 changed files with 1390 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
# app/models/consolidacao_entrega.rb
class ConsolidacaoEntrega < ApplicationRecord
belongs_to :consolidacao
enum tipo: {
entrega_normal: 0,
retirada: 1,
bonus: 2,
desconto: 3
}
TIPO_CORES = {
'entrega_normal' => { bg: 'bg-orange-500', text: 'text-white', label: 'Entrega Normal' },
'retirada' => { bg: 'bg-orange-800', text: 'text-white', label: 'Retirada' },
'bonus' => { bg: 'bg-white border border-orange-500', text: 'text-black', label: 'Bônus' },
'desconto' => { bg: 'bg-gray-900', text: 'text-white', label: 'Desconto' }
}.freeze
validates :tracking_id, presence: true, uniqueness: { scope: :consolidacao_id }
validates :motorista_nome, presence: true
validates :tipo, presence: true
validates :valor_aplicado, presence: true, numericality: { greater_than_or_equal_to: 0 }
# Busca a entrega original (leitura do banco existente)
def entrega_original
@entrega_original ||= Entrega.find_by(tracking_id: tracking_id)
end
def tipo_cor
TIPO_CORES[tipo] || TIPO_CORES['entrega_normal']
end
end