Rules, Time, Hierarchies, Oh My!

time to read 2 min | 358 words

I have been talking vaguely about time dependant stuff for quite a while, and I figure that it is about time to talk about some of the problems in a more concrete way. One of the things that I work on are time and hierarchy depednant rules.

For instnace, take the following rules structure:

(Image from clipboard).png

All employees are allowed 3 paid lunch breaks, but managers are allowed 4. For the week of 10/09 - 16/09, Bob (a manager) got a benefit of as many paid lunches as he wants. (Yes, a silly example, but it shows the point.)

Now, let us say that we run a validation checks at the end of the month and find out that Bob reported of:

  • 0 lunches on the week of 01/09 - 02/09
  • 3 lunches on the week of 03/09 - 09/09
  • 6 lunches on the week of 10/09 - 16/09
  • 5 lucnhes on the week of 17/09 - 23/09
  • 4 lunches on the week of 24/09 - 30/09

The results for this validation should are:

  • 01/09 - 02/09 - OK
  • 03/09 - 09/09 - OK
  • 10/09 - 16/09 - OK
  • 17/09 - 23/09 - Error, allowed 4 but had 5
  • 24/09 - 30/09 - OK

How would you go about implementing such a thing?

I will discuss my implementation tomorrow.