This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StateTax < ApplicationRecord | |
attr_accessor :effective_date | |
def save_temporal | |
StateTax.transaction do | |
raise ArgumentError, 'Effective date is not set' unless effective_date.present? | |
raise ArgumentError, 'Cannot save temporal an existing record' if persisted? | |
now = Time.zone.now | |
new_row = self.class.new(state_id: state_id, tax_type: tax_type, rate: rate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddStateTaxes < ActiveRecord::Migration[7.0] | |
def change | |
create_table :state_taxes do |t| | |
t.integer :state_id, null: false | |
t.string :tax_type, null: false | |
t.decimal :rate, null: false | |
t.daterange :effective_range, null: false | |
t.tsrange :system_range, null: false | |
end |