I find that the problem statement is not precise enough. See my questions inline.
BACKGROUNDWe have departments setup in a hierarchical structure (i.e. parent departments)An employee can belong to one and only one department.
An employee can be the manager of one or more departments; a manager may or not belong to that department.A department can have many employees and many managers.
PROBLEMFind the approver for an employee's expenses.An approver is a 'higher level' manager relative to employee in the organizational hierarchy.Note that since the manager is employee as well, this includes the problem of finding the manager of a manager.RULES1. The approver the nearest manager to the employee (traversing up the department hierarchy)Typical cases then are:- for a non-manager employee, the approver is the manager of the employee's department- for a manager who manages a single department and belongs to that department, the approver is the manager of the parent unit2. The approver for a manager cannot the manager himself or a peer manager (in the same department).
3. An approver cannot report to the employeeThis sometimes happens when the manager is an employee in one department but manager for a department a few levels up in the hierarchy3a. An approver cannot be the peer to someone who reports to the manager
SAMPLE DATAA (manager Hillary)A1 (manager John and Jane )A11A12 (manager Mike; employees John and Mike)A13A2 (manager Kate)A21 (manager Jessica, employee Janet)A22 (manager Erica, employee Jane)1. Approver for Janet is Jessica2. Approver for Jessica is Kate3.Approver for John is Hillary (cannot be Mike, John himself or Jane)4. Approver for Jane is Erica via A22 (no reporting relationship).ALGORITHMIC SOLUTIONDefine the department reporting vector starting from the employee departmente.g. for (1) it would be A21 -> A2 -> A andfor (3) it would be A12 -> A1 -> AThen for each, define managers and then employees(1) : A21( jessica/ janet ) -> A2: ( Kate) -> A( Hillary)(2): A12 (Mike/ John, Mike) -> A1 (John, Jane) -> A (Hillary)Then starting from the top (i.e. A), move down looking for the employee (in manager or employee list)If the employee is found in the manager list, approver is the manager of the parent departmentIf the employee is found in the employee list, the approver is the manager of this unit (not the parent)(I may have missed a few rules in the algorithmic solution)RULE BASED SOLUTION?Is this a good problem for rule bases solution?I started to model this and will post my solution if I can come up with something useful but would absolutely welcome your inputs.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users