Modelling a Chart of Accounts

110 views
Skip to first unread message

Stuart Ferguson

unread,
May 9, 2016, 5:57:51 PM5/9/16
to DDD/CQRS
A project I have recently started to work on involves me creating a Domain model that represents a Chart of Accounts within an Accounting package.

The information I need to hold on an account is as follows:

Id
Name
Description
Account Code
Parent Account Id
Account Type

Now my initial design was to have Account being the aggregate root but then I started to try and decide how the tree structure of the CoA would fit into that.  In reading a bit on this I have seen a number of different approaches on how this could be modelled, one of which was to hold the entire CoA under a single root and that each level had child accounts which fits with the Chart of Accounts structure exatly but now sure on how efficient that would be.

Does anyone have any thoughts/experiences on how I can achieve this.

The company I am working for is following a CQRS/Event Sourcing approach for this part of our system.

Any thoughts/help would be most appreciated.

Regards,

Stuart

Greg Young

unread,
May 9, 2016, 6:13:45 PM5/9/16
to ddd...@googlegroups.com
I would guess CoA is a read model concept ...
> --
> You received this message because you are subscribed to the Google Groups
> "DDD/CQRS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to dddcqrs+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Studying for the Turing test

Stuart Ferguson

unread,
May 10, 2016, 3:27:15 AM5/10/16
to DDD/CQRS
Hi Greg,

Thanks for the reply.

Yes I think you are right that is the case however, the challenge I have is that if a child account is created then some of the values allocated to it depend on the parent, which was why I struggled to see how this rule could be implemented.

The only suggestion I could see was at the Command Handling level rehydrating the new accounts parent and deriving the values from this rehydrated object.  

What I wasn't sure of with this approach is this was indeed a valid thing to be doing at the command handler?

This would mean each individual account would be stored as individual aggregate roots.

Regards,

Stuart

Chris Sampson

unread,
May 10, 2016, 4:46:00 AM5/10/16
to ddd...@googlegroups.com
" the challenge I have is that if a child account is created then some of the values allocated to it depend on the parent," Wouldn't you model that relationship in an aggregate? Rather than rehydrating the accounts parent and deriving the values from the... etc 

Chris Sampson

unread,
May 10, 2016, 4:48:47 AM5/10/16
to ddd...@googlegroups.com
Think about your events that you need first and then worry about composing them into aggregate roots that do what you want with those events in the most workable manner after, rather than coming up with the aggregate roots first.
Reply all
Reply to author
Forward
0 new messages