Bounce the calculation logic before the implementation
I wanted to spell out one interesting challenge I have and would like to hear your opinion on whether my logic makes sense as it might be faulty.
We have two tables: one is with the crane moves (it contains a crane id, # of containers and working hrs) and another is the breakdown information (it has such columns as equipment id, work start date and work end date).
If a user selects 11/18/2018, he will see, the # of moves and # of hours a crane worked from the first table. He also should be able to see the # of hours an equipment was broken.
1. An equipment could have been broken on 11/17/2018
2. An equipment could have been broken on 11/18/2018 or any previous day.
3. It could have been repaid on 11/18/2018.
4. Or it could have not been repaid on the day a person was checking the statistics.
I think the logic should be:
1. If a person selects a day 11/18/2018, it will show only cranes that did some moves that day.
2. If the current selection from the calendar (day) is equal to the work start date OR equal to the work end date, it would mean that either an equipment got broken on 11/18/2018 (work start date =current selection) or got repaid at some point in time on 11/18/2018 (work end date = current selection).
3. If both, work start date & work end date fall on 11/18/2018, subtract work end date - work start date to get the # of hours an equipment was broken.
4. If there is just work start date, 24-(24 - work start date) to find how many hours an equipment was broken.
5. If there is just a work end date, 24-(24 - work end date) to find how many hours an equipment was broken.
Do you see any flaw in the logic? If no, how could it be implemented practically? I am thinking about IntervalMatch - not confirmed and checking sth like get current selection...