← Mansur Dagane Source code (.zip)

Personal Python project

Sales per hour is easy to calculate.
It is also easy to get wrong.

If one shift is missing from the records, the hours go down and the result looks better than it really is. This tool checks the records first. If something is missing, it says what — and does not show the number.

See the example

One missing shift changes the answer

Same four weeks, same 125 sales. In the second file, the hours for one shift were never recorded. A plain calculation would then show 1.39 kept sales per hour instead of the real 1.30 — and nobody would notice.

Both reports were generated by salgsanalyse.py from these files: shifts.csv, shifts-missing.csv, sales.csv. The numbers are invented.

How it works

  1. Read two CSV files: shifts (date, planned and worked hours) and sales (date, product, kept / cancelled / pending).
  2. Check that every planned shift has hours, every sale belongs to a shift, and old sales have an outcome.
  3. Calculate kept sales per hour only if the check passes, then suggest one next step.
for s in shifts:
    if s.planned_hours > 0 and s.worked_hours is None:
        blocking.append(f"{s.day}: a shift was planned, but no hours are recorded.")

From analysis.py (about 200 lines). 15 tests cover the rules, including that a full period with zero sales gives 0 per hour, not a missing value.

Why I built it

I work in sales alongside my electrical engineering studies at OsloMet (1st year, automation and robotics). In sales, numbers per hour are compared all the time, and I saw how a missing record can make them misleading. I defined the problem, the rules and the output. I used AI assistance to write and refine the code, and checked it with tests.