When type=Salary: set pay-type filter to Managers-only, hide daily
rows, and untick any selected daily worker so a Salary can never
silently target a daily worker. Re-applied on the Pay-Salary open
path (the show.bs.modal reset clears it first). Pure JS; verified by
manual checklist; suite stays 207/207.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Konrad-approved: when Add-Adjustment type=Salary, auto-set the pay-type
filter to Managers-only, hide daily rows, and untick any selected daily
worker so a Salary can never silently target a daily worker. Pure JS,
hooks the toggleProjectField() chokepoint. Rides the same HARD STOP.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Prevents a pre-checked quick-adjust worker from opening hidden behind a
stale 'Managers only'/'Daily only' filter. Display-only; no data impact.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Konrad-approved design for a display-only ?pay_type= filter on /workers/
and a "Managers only" toggle on the Add-Adjustment modal picker. No
model/migration/URL changes; rides with the paused Manager/Salaried
feature's HARD STOP (nothing pushed until local verification).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Final whole-feature review flagged the design doc's verification
checklist step 4 over-promised an auto-filled amount. Manual entry is
intentional; corrected so Konrad's local verification expectations match
actual behaviour. Docs-only, local-only — feature still NOT pushed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Task-by-task TDD plan: Worker.pay_type + migration, Salary additive
type, attendance/absence picker exclusions, add_adjustment Salary
branch, per-project salaried-cost report line + byte-for-byte
daily-numbers regression guard, UI, docs. Ends with a HARD STOP
before any push for Konrad's local verification.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Models a manager as a Worker with a pay_type discriminator, reusing the
existing loan/adjustment/payslip/payroll pipeline. New 'Salary'
adjustment type, project-attributed; managers excluded from
attendance/absence pickers so daily-worker math is provably untouched.
HARD STOP after implementation for local verification before any push.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Konrad paused execution. parked-work.md now has a "⏸ Paused —
ready to execute" section pointing at the design (110545b) + plan
(29c36be) commits, with the resume instruction and the hard-stop
constraint. All 3 commits are local-only on ai-dev — nothing
pushed until Konrad verifies the flow locally.
4 small TDD tasks (~120 LOC): display rename, attendance 3-button
branch, Site Journal save+absences button, docs. Reuses Round C
next_action pattern. HARD STOP after Task 4 — local verification
by Konrad before any push (UX change to a daily-use path).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces the forced post-attendance SiteReport redirect with 3
explicit buttons (Log Work → dashboard / + Site Journal / +
Absences) + a parallel "Save Site Journal + Add Absences" on the
journal page. Renames the user-facing "Site Report" → "Site
Journal" (display-only, Path-A; frees "Journal" for the parked
voice feature). Reuses the Round C next_action POST mechanism —
no model/migration/URL changes. NOT to be deployed until Konrad
verifies locally.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Konrad's decision (15 May 2026): Phase A.2 (manual JournalEntry
UI) + Phase B (Letterly inbound webhook) are too complex to
interleave with normal app work — they'll be built and tested
offline on a separate track, not in ai-dev.
Verified there is NOTHING to remove or bypass: zero JournalEntry
model/views/urls/templates, zero Letterly/webhook/@csrf_exempt
code anywhere on ai-dev, latest migration is 0015. The working
app was already 100% clean of journal/voice code — these features
never left the design-doc stage.
Doc changes:
- parked-work.md: "Blocked on Konrad's input" section replaced
with "🧊 Backburner — separate offline track", with an explicit
"do NOT start in ai-dev" warning and the nothing-to-remove
verification recorded.
- CLAUDE.md breadcrumb: reframed from "parked pending Q5/Q7
answers" (implies ready-to-go once answered) to "deliberately
deferred to offline track — do not pick up as normal feature
work".
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Production caught up — all 14 pending commits live after a
second service restart (the first restart ran before the code
reached the target commit; DEBUG=False's cached template loader
held the old templates until restarted again).
CLAUDE.md:
- 'What's mid-flight' breadcrumb: no longer says pending deploy;
now states production is at 1d224bc and fully live.
- Flatlogic Deployment section: new '⚠ DEPLOY ORDERING' bullet
documenting that production runs DEBUG=False → cached template
loader → restart MUST come after the pull, and template-only
changes still need a restart (unlike DEBUG=True local dev).
Includes the symptom ('git log shows right commit but page
looks old') and the fix (restart again).
- Bumped the {# #} bit-us count + added a grep sanity-check
one-liner (from the prior commit, retained).
parked-work.md: 'Pending pull-and-restart' section replaced with
'Production status — fully caught up'.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CLAUDE.md gotcha #1 strikes again — the dashboard audit pass added
7 multi-line {# ... #} comment blocks across index.html, report.html,
and pdf/report_pdf.html. All rendered as literal text on the live
pages (Konrad screenshotted them). Also caught an old one in
admin/base_site.html that was technically broken syntax but
non-rendering (outside any block). All 8 converted to
{% comment %}{% endcomment %}.
CLAUDE.md updated:
- Bumped the bit-us count (4 → confirmed 4 + 5 + 7 across three
features). Added a grep-one-liner sanity check that finds broken
multi-line {# blocks across all templates so future passes can
spot-check before committing.
Cryptic hero-card sublines on /report/ clarified (Konrad asked
what they mean):
- "as of 08:13" → "Live total at 08:13 today · for <scope>" with
hover tooltip explaining the snapshot semantics.
- "Company Avg / Working Day" / "/ Month" labels renamed to
"Avg Labour Cost / Working Day" / "/ Month". Sublines simplified
to "Lifetime average across all crews" / "Daily figure × 30.44
days". Both gain hover tooltips that explain the math and the
"current pay rates" basis.
Pure template + docs change. 173/173 tests still passing
(no test changes — these are cosmetic fixes).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CLAUDE.md breadcrumb: '6 subsequent commits' → '13 subsequent
commits' with a one-paragraph summary of what's pending pull +
restart on production. Points at parked-work.md for the full
commit table.
parked-work.md:
- 'Pending pull-and-restart' table: added 18c75b2 (calendar
month) and the 2e6b78d→c02edce audit-pass range as a single
collapsed entry.
- 'Recently shipped' grew a detailed entry for the 18-finding
audit pass at the top.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Documents two related foot-guns that bit recent audits:
- `Worker.daily_rate` is computed LIVE from `monthly_salary`; it's
never snapshotted onto a WorkLog row. So historical cost totals
inflate retroactively when a worker gets a raise. The new
"at current pay rates" subline on the report hero cards
(commit 4186603) is the visible half of this convention. Future
audits should read this note before deciding "this can't be right".
- Two code paths compute the same formula: Python property and a
SQL `Sum(F('workers__monthly_salary') / Decimal('20'))`. They
produce identical results in normal use but could drift by 1
cent on edge-case rounding. `CompanyCostVelocitySQLAggregateTests`
is the regression test that would catch a real divergence.
Findings 2 + 11.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Three related changes to the executive payroll report:
1. Adjustment Summary table and Worker Breakdown table now render
deductive types (Deductions, Loan Repayment, Advance Repayment)
as "-R 500.00" in muted red. Before, they showed the same way as
bonuses — which read as "everyone gets richer" when a deduction
was actually shrinking net pay. New context keys:
- `adjustment_totals[i]['sign']` and `['is_deductive']`
- `active_adj_headers` (list of {label, is_deductive}) replaces
the parallel `active_adj_labels`/`active_adj_types` lists for
templates. The originals are still emitted for any external
consumer.
- `worker_breakdown[i]['adj_values']` now contains
{'amount', 'is_deductive'} dicts instead of bare Decimals.
Templates updated: report.html + pdf/report_pdf.html.
2. "Total Paid Out" hero card on /report/ now shows a small asterisk
+ tooltip when project/team filters are active, explaining that
a PayrollRecord touching the filtered scope is summed at its
FULL amount — not just the project-attributable portion. Cheap
label approach; the proper per-project attribution would need
proportional splitting across each record's work_logs (deferred).
New context key `total_paid_filter_caveat: bool`.
3. (No code change — Finding 6 was already satisfied by commit 1's
`outstanding_by_project_sorted` rewrite, but the regression test
protects the sort order going forward.)
Findings 3, 4, 6.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pure-template label cleanups on /report/ — no math changes, just
clearer wording for the non-developer reader. Plus one consistency
fix on the payroll dashboard.
- "Outstanding Now" hero card now shows a "scoped to ..." subline
when project/team filters are active (so it's not read as a
company-wide figure when it's actually scoped). Finding 5.
- "Paid This Period" hero card subline adds "includes adjustments"
to head off confusion vs the day-rate-only Labour Cost tables.
Finding 10.
- "FoxFitt Avg / Day" + "FoxFitt Avg / Month" renamed to
"Company Avg / Working Day" / "Company Avg / Month", with a
subline that calls out the "at current pay rates" caveat
(a worker's daily_rate is computed live from monthly_salary,
so retroactive raises inflate historical totals). Findings 2 + 15.
- "Labour Cost by Project" + "Labour Cost by Team" tables: header
renamed to "Day-Rate Cost" with a tooltip clarifying it excludes
adjustments. Finding 10.
- Worker Breakdown table: footnote explaining that "Days" and
"Total Paid" can disagree within a single period when a worker
is paid for previous-period work. Finding 9.
- Payroll dashboard chart data: dropped the `worker__active=True`
pre-filter on the per-worker breakdown queries so the SQL matches
`recent_payments_total` (which has no active filter). The outer
loop still iterates active workers only — this is a SQL-side
consistency fix, not a behaviour change. Finding 18.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two unrelated cleanups in `_build_report_context` and the helper next
to it.
- Removed `year_projects`, `year_teams`, and `current_year` from the
report context dict. No template ever rendered them — they were
added 2026-04 as part of an executive-report design that never
shipped that section. Each render fired 2 extra GROUP BY queries
for nothing.
- `_company_cost_velocity` no longer loops every (work_log × worker)
pair in Python. Single SQL aggregate (`Sum(monthly_salary / 20)`)
instead — one round-trip regardless of dataset size. Old behaviour
loaded the entire WorkLog table + M2M into memory for the hero KPI
card. Regression test (`test_sql_aggregate_matches_python_loop`)
uses the old Python loop as the expected oracle.
Findings 14 + 16.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two related foot-guns on the admin dashboard and payroll dashboard:
1. Every `timezone.now().date()` call returned the date in UTC, not
in Africa/Johannesburg. Between 22:00 and midnight SAST that's the
NEXT calendar day — so the "today" the dashboard thought it was
could be ahead of what the user sees on the clock. Now uses
`timezone.localdate()` which respects `settings.TIME_ZONE`.
Same fix for `datetime.date.today()` calls — those used the
server's system clock, which on the production VM is set to UTC.
2. "Absences (last 7 days)" and "Paid (Last 60 Days)" both subtracted
the FULL window length and combined it with `>=`, producing N+1
inclusive days. E.g. `today - timedelta(days=7)` with `date__gte`
spans 8 calendar days, not 7. Now subtract N-1 so the windows are
exactly N days. Regression test: DateWindowOffByOneTests.
Findings 12 + 13.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The home dashboard and payroll dashboard used to disagree on
"outstanding payments" because the home version included inactive
workers' unpaid wages while the payroll dashboard's per-worker loop
only iterated active workers. Symptom was the same field showing two
different R-amounts depending on which page you opened first.
Also fixes the Outstanding-by-Project card silently merging two
projects when they share a name (it was keyed by project_name).
- `_compute_outstanding` now defaults to active workers only.
Pass `include_inactive_workers=True` to surface deactivated-worker
liabilities (rare; usually means a forgotten payment).
- Output is keyed by project_id (with name as data) so two projects
with identical names stay as separate rows.
- New `outstanding_by_project_sorted` list — pre-sorted by amount
desc — replaces the dict iteration in templates.
- "Active Loans" card on the home dashboard renamed to
"Active Loans & Advances" so the label matches its data (which
already summed both loan_types).
- Regression tests: ComputeOutstandingActiveScopeTests +
ComputeOutstandingProjectIdKeyingTests.
Findings 1, 7/17, 8.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The dashboard card labeled 'Paid This Month' was summing the
last 60 days of PayrollRecords — identical to the payroll
dashboard's 'Paid (60D)' card. Misleading at best, wrong at
worst when explaining the dashboard to a non-developer.
Now filters by date__year + date__month (current calendar month
only). Added 3 regression tests: excludes 45-day-old payment,
includes 1st-of-month payment, returns 0 cleanly when nothing
paid yet this month.
Found during Konrad's 15 May audit of dashboard numbers.
CLAUDE.md breadcrumb: 'subsequent UX polish' → '6 subsequent
commits' so the next session can see at a glance how much is
pending pull-and-restart on production.
parked-work.md:
- 'Small polish follow-ups' section: 7 items cleared on 15 May;
section header retained as a landing pad for future cleanups.
- 'Pending pull-and-restart' table: added rows for 70fa085
(day-name in modal) and d1d3e15 (polish pass) so the deploy
checklist is current.
- 'Recently shipped' grew two new entries at the top: the polish
pass and the day-name modal change.
Small cleanups tracked in docs/plans/parked-work.md:
1. Delete dead AbsenceQuickForm class — Round C replaced the per-row
✗ modal paradigm with the "Submit + Log Absences" button, but the
form class never got wired up. No view, URL, template, or test
ever referenced it.
2. Single-query team_workers_map via shared _build_team_workers_map
helper. Previously fired one SELECT per team because .filter(
active=True) on a prefetched M2M bypasses the prefetch cache.
Now uses Prefetch(to_attr='active_workers_cached'). Both
attendance_log() and absence_log() use the same helper.
3. absence_list permission check now uses _user_can_log_absences
instead of duplicating the same `is_admin OR supervised_teams`
logic inline.
4. Drop misleading var(--badge-neutral-bg, …) wrapper in custom.css —
the variable isn't declared so the fallback always wins. Use the
hex directly.
5. conflicting_worklogs() N+1 → single query: was firing one SELECT
per (worker, date) pair (25 queries on a 5×5 form). Now 2 queries
total via .filter(date__in=…, workers__in=…) + Python-side pair
set check.
6. Extract _apply_absence_filters helper — absence_list and
absence_export_csv were duplicating the same 7-param filter block
(with a TODO comment to factor it out). Now structurally enforced
in one place; list view keeps the raw param read-back for
template-context dropdown preselection.
7. Replace style="color: var(--badge-bonus-bg)" with class="text-success"
on the paid-check icon in site_report_detail.html — same WCAG
contrast bug we fixed on the absence templates (background colour
used as foreground).
All 157 tests still pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
date in the modal header was "2026-05-15" — now reads
"Friday, 15 May 2026". Server-side strftime on the already-loaded
log.date — zero DB / compute overhead. Touches only the modal's
date field; other date fields in the JSON (paid_date,
pay_period_*) still use the ISO format because they don't render
into a human-facing header.
CLAUDE.md changes:
- 'What's mid-flight' breadcrumb updated: SiteReport/Absences
migrations are LIVE on prod; only the 4 latest UX commits await
a pull-and-restart (no migration / collectstatic needed).
- URL Routes table entries for /workers/ and /history/ now document
the new ?team= filter (and team=none for unassigned / no-team cases).
- Worker Management UI inline description mentions the team filter
+ Absences tab on the worker detail page.
- Two new Coding Style gotchas captured: (1) Bootstrap dropdowns
inside .card elements get clipped by sibling cards — fix is to
lift the wrapping card with position:relative + z-index;
(2) JS reading from data-worker-id was unreliable on production —
read input[name="workers"][value] directly (the attendance-form
pattern that's been working for years).
parked-work.md changes:
- Pending-deploy section rewritten: the BIG deploy (migrations +
collectstatic) is DONE; only 4 small commits await a pull +
service restart.
- 'Recently shipped' grew two new entries: the team filters on
/workers/ + /history/, and the two absences UX polish fixes.
- Updated timestamp to 15 May 2026.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mirrors the team filter just added to /workers/. WorkLog.team is a
nullable FK, so the filter accepts:
- empty → all logs (default)
- digit → logs tagged with that team
- 'none' → logs with no team set (ad-hoc attendance)
Filter row reflowed to col-md-3 col-lg-2 so all four selects fit on
a single row on wide screens; mobile stacks them. CSV export link
now passes &team=… through. Supervisors only see teams they
supervise in the dropdown.
4 regression tests covering filter narrowing, no-team match,
empty=show-all, and filter_params round-trip for the List/Calendar
toggle links.
New ?team=<id> URL param narrows the worker list to that team's
members via the Team.workers M2M. ?team=none filters to workers
not assigned to any team. Default (empty) still shows all
matching workers across all teams.
UI: new "Team" dropdown in the filter row, between Search and
Status. Lists active teams alphabetically. Layout reflowed to
col-md-4 / col-md-3 / col-md-3 / col-md-2.
Konrad's checkpoint feedback: "in the worker page - can i have a
filter for teams so i can easely see who is in what team".
4 regression tests covering no-filter, by-team, no-team, and
dropdown options.
The Reasons multi-checkbox dropdown was rendering BEHIND the table
rows even with z-index: 1050 applied. Root cause: the filter card
and the table card are sibling .card elements, both creating their
own stacking contexts. The dropdown's z-index was being measured
inside the filter card's local stacking context, but the table card
(next sibling in document order) sat on top of the whole filter
card in the page's stacking order.
Fix: set position: relative + z-index: 10 on the wrapping <form
class="card mb-3"> so the entire filter card lifts above the table
card globally. The dropdown's z-index: 1050 inside it now resolves
correctly.
Pure template change — no behaviour change, no test change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>