Last active
December 23, 2015 19:59
-
-
Save crispincornett/6686108 to your computer and use it in GitHub Desktop.
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 Client < ActiveRecord::Base | |
has_many :accounts | |
end | |
class Account < ActiveRecord::Base | |
belongs_to :client | |
has_many :invoices | |
has_many :payments | |
end | |
class Invoice < ActiveRecord::Base | |
belongs_to :account | |
has_many :line_items | |
has_many :invoice_payments | |
end | |
class LineItem < ActiveRecord::Base | |
belongs_to :invoice | |
end | |
class Payment < ActiveRecord::Base | |
belongs_to :account | |
has_many :invoice_payments | |
end | |
class InvoicePayment < ActiveRecord::Base | |
belongs_to :invoice | |
belongs_to :payment | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the data model I've come up with to track invoices and payments for a client managing many accounts. The customer has requested that all "InvoicePayments" be reviewed before they take effect.
The customer workflow goes like this:
The tricky part is how to display the summary of unapproved InvoicePayments, by account then by invoice. Should I be selecting the InvoicePayments that are unapproved, then working back through the relationships? Or maybe set a flag on accounts with unapproved InvoicePayments, so I'm not checking through all the accounts to see if they have an unapproved InvoicePayment.