Migra a tabela de preços do PricingTables.rb hardcoded pras tabelas captain_pricing_categories + captain_pricing_amounts no DB. Mantém a mesma API pública Captain::Mcp::PricingTables.calculate(...) — código chama o banco via novos modelos Captain::PricingCategory e Captain::PricingAmount. Seed db/seed_pricing_tables.rb faz backfill idempotente pra Dolce Amore (unit 4) e Express (unit 5) com a mesma estrutura que tava no Ruby. Adiciona em captain_assistants: - hermes_subscription_secret (gerado pelo script de provisionamento) - hermes_port (alocado no range 8650-8699) - parent_assistant_id (link informativo Hermes → captain_interno parent pra sombrear FAQs/scenarios via header X-Captain-Assistant-Id) Adiciona em captain_units: extra_person_fee + currency. Primeiro milestone do roadmap arquitetural pro Construtor autônomo (decisões em memory/project_construtor_autonomo_decisions.md). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
41 lines
1.6 KiB
Ruby
41 lines
1.6 KiB
Ruby
# == Schema Information
|
|
#
|
|
# Table name: captain_pricing_amounts
|
|
#
|
|
# id :bigint not null, primary key
|
|
# amount :decimal(10, 2) not null
|
|
# day_bucket :string
|
|
# period :string not null
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
# captain_pricing_category_id :bigint not null
|
|
#
|
|
# Indexes
|
|
#
|
|
# idx_captain_pricing_amount_uniq (captain_pricing_category_id,period,day_bucket) UNIQUE
|
|
# index_captain_pricing_amounts_on_captain_pricing_category_id (captain_pricing_category_id)
|
|
#
|
|
# Foreign Keys
|
|
#
|
|
# fk_rails_... (captain_pricing_category_id => captain_pricing_categories.id)
|
|
#
|
|
# Valor por (categoria, período, dia da semana). day_bucket NULL = preço
|
|
# único todos os dias. day_bucket='mon_wed' = seg-qua. 'thu_sun' = qui-dom.
|
|
class Captain::PricingAmount < ApplicationRecord
|
|
self.table_name = 'captain_pricing_amounts'
|
|
|
|
PERIODS = %w[2h 3h 4h 5h pernoite_promo pernoite_integral diaria].freeze
|
|
DAY_BUCKETS = %w[mon_wed thu_sun].freeze
|
|
|
|
belongs_to :pricing_category,
|
|
class_name: 'Captain::PricingCategory',
|
|
foreign_key: :captain_pricing_category_id,
|
|
inverse_of: :amounts
|
|
|
|
validates :period, inclusion: { in: PERIODS }
|
|
validates :day_bucket, inclusion: { in: DAY_BUCKETS, allow_nil: true }
|
|
validates :amount, numericality: { greater_than: 0 }
|
|
validates :captain_pricing_category_id,
|
|
uniqueness: { scope: %i[period day_bucket] }
|
|
end
|