-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Account fields #10
Comments
Michael, I'm not quite clear on why you want to do this, unless you plan to implement added model functionality related to those added columns. Are you planning to allow for organization of accounts in a tree/list based on account_code, and changing the models to be aware of valid/invalid account dates in the gem itself? My point is that unless you plan to implement those features, you should let gem users decide how to augment the schema for their needs... what if I like to have 2 string account codes instead of a single integer one? I'm not saying those 2 features are not needed, I'm saying either I would like for you to implement the functionality related in the gem itself or focus on giving the gem users an easy way to augment/customize their models... Either one of these would be OK, but the hybrid of simply adding unused fields in the model smells fishy to me... just my $0.02 |
Point taken, and I agree with you generally. The last thing we want is to add a whole bunch of custom fields that only some people use, and then end up with a spagetti mess of fields. However, regarding the valid_to/from dates, I think we need at least a valid_to, or single "inactive" field. In accounting obviously it's a no go to delete anything, so we need a way to hide old accounts, and prevent inactive accounts from being used in transactions. Every accounting system I have seen has this functionality. I would add also propose to add a validation to the amounts that checks against inactive accounts. The sample views and reporting features of plutus still need a lot of work, but I think the views and reporting will need to implement the field as well. As for the account code, it's a fairly universal practice to have a human readable code for each account (see http://en.wikipedia.org/wiki/Chart_of_accounts). I think there's a good argument though that this should be a string field instead of an integer. (it's for display and human consumption, and I can't imagine anyone doing calculations with the field) I'd also add the field to the sample chart of accounts view. This field would be primary for human consumption, so the business logic in the model might be fairly limited or non existant. I think that's okay since it seems to me plutus is in many ways about human data consumption. Obviously computers don't need double entry for accuracy's sake, so much of plutus's value (at least it seems to me) is in the point were it integrates with accounting people in the business, or outside accounting systems, where the account codes would be critical. |
Oh and @enrico thanks for the 2 cents, it's much appreciated! Exactly the kind if feedback I was looking for. |
Thank you for your work on this gem. I am about to start using it for a project and immediately I wished to extend this account class and add fields. Perhaps using your established model of using the business_object polymorphic association would be adequate to accomplish this goal. In the attempt to create my own model "Account" and make an association belongs_to :plutus_account, I painfully discovered that ActiveRecord does not like to have multiple models with the same class name, regardless of their module namespace. I wouldn't have attempted creating my own Account class if you provided business object support for Plutus::Account |
@kjbkjb Rails engines are pretty flexible and are easily extended. Instead of creating your own class, I'd suggest using a decorator pattern with ActiveSupport::Concern. You can read more about extending rails engines here: http://guides.rubyonrails.org/engines.html#improving-engine-functionality |
@mbulat I can't believe this actually works
Which when run:
|
@mbulat Thanks for linking me here from #45. Adding account codes makes sense to me. I think when we do that we should fully implement it not just as an identifier, but also a statement of hierarchy, where the number of trailing zeroes defines the level of the account. E.g. Current assets might be 1000; Cash equivalents, 1100; Checking account, 1110; Petty cash held, 1120. This impacts not only how these accounts are presented on financial statements, but also how they may be used by the application. For instance, Current assets in this example is a roll-up account that appears on a balance sheet, but should never appear directly in a journal entry. I am nervous about having Barring easy resolution to these questions, I think a safer, and simpler approach would be to have an |
We ended up overloading the account object with code and rollup_code which provides hierarchy. From there we do not allow entries against accounts where code == rollup_code and instead we perform sum operations of all accounts that have the same rollup_code. # == Schema Information
#
# Table name: plutus_accounts
#
# id :integer not null, primary key
# name :string(255)
# type :string(255)
# contra :boolean default(FALSE), not null
# created_at :datetime
# updated_at :datetime
# display_name :string(255)
# external_name :string(255)
# code :integer
# rollup_code :integer
# ledger_id :integer
#
require Plutus::Engine.root.join('app', 'models', 'plutus', 'account')
class Plutus::Account < ActiveRecord::Base
has_paper_trail
scope_accessible :ledger_id, :omit_rollups
belongs_to :ledger, inverse_of: :accounts
scope :by_name, ->(name) { where(name: name) }
scope :ledger_id, ->(ledger_id) { where(ledger_id: ledger_id) }
scope :omit_rollups, ->(omit) { where('plutus_accounts.code != plutus_accounts.rollup_code')}
validates :name, presence: true
validates :display_name, presence: true, length: { maximum: 128 }
validates :external_name, length: { maximum: 128 }
validates :rollup_code, presence: true, numericality: { greater_than_or_equal_to: 100 }
validates :code, presence: true, numericality: { greater_than_or_equal_to: 100 }
validates :code, numericality: { greater_than_or_equal_to: :rollup_code , message: "must be greater than or equal to Rollup Code."}
validates :ledger, presence: true |
@freerobby, @kjbkjb Thanks for the input on the codes. I agree that a hierarchy with rollup codes would be the way to go, and I'm sure it would be helpful from a reporting standpoint. I think it would make sense to implement in a way that allows people to continue to use plutus without using the codes. @freerobby I agree completely with your assessment of the |
I'm thinking of having a native model in my app called |
Is Plutus currently supporting codes, or do we need to add this ourselves? |
It seems like the approach that is most flexible to all would be to create local models that own a plutus account. The plutus account would be used just for double entry accounting, while the local model would have everything your app needs. |
ezmend on Google Groups inquired about a couple of fields he felt were missing on the Account model, specifically an Account Code field for numbering and organizing like accounts, and valid dates to allow the book of Accounts to change over time. I agree that they should really be included, so I've opened this issue to keep track of adding those fields. At the moment, I think we can simply add the fields to the migration, and developers can choose to implement them or not.
Here's what I'd add to the migration
Comments and other suggestions welcome
The text was updated successfully, but these errors were encountered: