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,55 @@
# app/models/configuracao.rb
class Configuracao < ApplicationRecord
# Chaves válidas do sistema
CHAVES = %w[
preco_entrega
preco_retirada
preco_bonus
preco_desconto
notificacao_whatsapp
notificacao_email
empresa_nome
empresa_logo
].freeze
CHAVES_MOEDA = %w[
preco_entrega
preco_retirada
preco_bonus
preco_desconto
].freeze
validates :chave, presence: true, inclusion: { in: CHAVES }, uniqueness: true
validates :valor, presence: true
# ── Acesso rápido ───────────────────────────────────────────
def self.valor(chave)
find_by(chave: chave)&.valor
end
def self.preco_entrega
valor('preco_entrega').to_f
end
def self.preco_retirada
valor('preco_retirada').to_f
end
def self.preco_bonus
valor('preco_bonus').to_f
end
def self.preco_desconto
valor('preco_desconto').to_f
end
def moeda?
CHAVES_MOEDA.include?(chave)
end
def valor_formatado
return "R$ #{format('%.2f', valor.to_f).gsub('.', ',')}" if moeda?
valor
end
end