I am designing a small budget assignment/checking application for a hierarchy organization structure. The purpose is to check and assign the budget for each employee not exceeds the total budget of a department.
The most difficult part is, a sub-department's total budget is not always lower than the upper level department's budget (i.e. the organization tree does not 100% reflects the relationship that father department node's budget is always more than that of child department node).
So, I put many exception rules to check in such situation. I am wondering whether there is any smarter ways to implement and represent the budget assignment and check model?
(I can re-write anything in this application, including data structure and algorithm, if the budget assignment and checking function is met.)
department goo under larger department foo, is represented as, /foo/goo, and /foo/zoo's budget is lower than /foo (this is a normal senses), but /foo/goo's budget is larger than /foo(this is a special rule, in the business model, even if goo under management of foo, its budget is not controlled by foo, so larger), and I maintain the remaining budget for each department,
for employee, /foo/emp1 and /foo/zoo/emp2, I can check from father node to child node for making all child nodes' budget not exceed father node, but for /foo/goo/emp3, I have to check specially. This is my headache.
If there are any smarter ways to represent the data structure and budget check, I would appreciated. :-)
thanks in advance,