Skip to content

Instantly share code, notes, and snippets.

@erkattak
Created April 16, 2014 20:08
Show Gist options
  • Save erkattak/10927738 to your computer and use it in GitHub Desktop.
Save erkattak/10927738 to your computer and use it in GitHub Desktop.
class Allocation < AR::Base
# allocations schema
# - line_item_id - indexed
# - type - string [ ‘CreditAllocation’, ‘DebitAllocation’ ] - indexed
# - allocatable_id - integer - indexed
# - amount - integer
belongs_to :line_item
belongs_to :allocatable, class_name: ‘LineItem’
end
class CreditAllocation < Allocation
end
class DebitAllocation < Allocation
end
class Violation < AR::Base
belongs_to :line_item
# join payments via allocations
# join adjustments via allocations
end
class LineItem < AR::Base
has_many :violations
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment