14 Commits

Author SHA1 Message Date
Konrad du Plessis
a8ef7bb341 Update CLAUDE.md with cache-busting, email fallback, and deploy context
Documents three things that came out of today's Phase 2 deploy session
and weren't previously written down:

1. Static Assets & Cache-Busting (new section): explains that production
   traffic goes through Cloudflare with 4h edge cache; the
   `deployment_timestamp` template variable is what breaks stale caches;
   and why `request.timestamp` must never be used (the silent-default-to-1.0
   bug that ate a couple of hours).

2. Environment Variables: inline notes for each var. Most important new
   fact is that DEFAULT_FROM_EMAIL is now optional — falls back to
   EMAIL_HOST_USER if unset (prevents the "Invalid address ''" failure
   mode on outbound mail). Also documents that .env lives at BASE_DIR.parent
   on Flatlogic and can only be edited via Gemini/shell.

3. Flatlogic Deployment: collectstatic isn't auto-run, django-dev.service
   runs manage.py runserver (dev server in prod — known but works at this
   scale), Cloudflare sits in front, VM has two git remotes (github +
   gitea) that must stay in sync, VM-local safety branches for rollback,
   and the "pick one write path" workflow rule to avoid divergence.

No code changes — documentation only.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 04:42:32 +02:00
Konrad du Plessis
3c28387dd3 WIP: 2026-04-22 session checkpoint
Complete working state of the session. Will be split into two deploy
phases (safety scaffolding then feature release) before merging to ai-dev.

Includes:
- Security fixes (email creds / SECRET_KEY / DEBUG / CSRF)
- Backup + restore management commands and browser endpoints
- WeasyPrint migration (replaces xhtml2pdf)
- New Worker fields + WorkerCertificate + WorkerWarning models
- Worker / Team / Project friendly management UIs
- Dashboard cert-expiry card + Manage All buttons
- Bootstrap tooltips (global init + theme-aware CSS)
- Django admin template override (taller M2M pickers)
- Money filter for ZAR currency formatting
- Resources dropdown nav
- Massive CLAUDE.md expansion + deploy plan docs

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 00:19:15 +02:00
Konrad du Plessis
a1ac8540ab Add comprehensive features guide and update CLAUDE.md
New docs/FEATURES.md covers all 15 feature areas: dashboard, attendance,
work history, payroll, payments, adjustments, loans, worker lookup, worker
management, team schedules, receipts, emails/PDFs, auth, exports, and
deployment tools. CLAUDE.md updated with accurate line count.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-20 15:15:24 +02:00
Konrad du Plessis
60ee21dd61 Add Worker Lookup modal to payroll dashboard
New AJAX endpoint (worker_lookup_ajax) returns a comprehensive financial
report card for any active worker. Modal shows: amount payable, outstanding
loans, paid this month/year, loans this year, recent activity, active loans
table, current project + days, PPE sizing, drivers license, and notes.
Worker names across all dashboard tabs are now clickable links that open
the modal. Header button with searchable dropdown for quick access.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-20 14:15:04 +02:00
Konrad du Plessis
81009be0c6 Add PPE sizing and drivers license fields to Worker model
New fields: shoe_size, overall_top_size, pants_size, tshirt_size,
has_drivers_license (boolean), drivers_license (file upload).
Admin organised into 3 fieldsets. CSV export updated with new columns.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-20 13:10:46 +02:00
Konrad du Plessis
803f8696e7 Update CLAUDE.md: accurate function count, quick adjust docs
- views.py now has 27 functions (~2470 lines)
- Document the Quick Adjust button on pending payments rows

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-20 12:25:22 +02:00
Konrad du Plessis
c3bbffe9c0 Update CLAUDE.md with Pay Immediately loan documentation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-25 10:00:39 +02:00
Konrad du Plessis
72d40971f1 Update batch pay modal: 3-option loan filter + radio button fix
- Replace "Exclude workers with loans" checkbox with dropdown
  (All Workers / With loans only / Without loans) in batch pay modal,
  matching the pending payments table filter style
- Fix radio button visual state when switching between
  "Until Last Paydate" and "Pay All" modes (set checked after DOM append)
- Update CLAUDE.md with pending table filter and overdue badge docs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-25 09:23:01 +02:00
Konrad du Plessis
2c3410e7c7 Update CLAUDE.md with batch pay feature documentation
- Add batch pay workflow docs (schedule vs pay-all modes, shared helper)
- Add batch-pay preview and process endpoints to URL routes table
- Update view count to 19 (~2000 lines)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 22:32:05 +02:00
Konrad du Plessis
79b6345cb9 Document /run-migrate/ endpoint and unreliable auto-migrations
Flatlogic doesn't always run migrations on Pull Latest. Added note
about using /run-migrate/ to fix "Unknown column" errors after deploy.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 21:22:42 +02:00
Konrad du Plessis
394f9bdfe4 Update CLAUDE.md with split payslip and team pay schedule docs
Document the new split payslip feature, team pay schedule fields,
pay period calculation helpers, and backward-compatible process_payment.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 21:08:32 +02:00
Konrad du Plessis
d51d06d28d Redesign advance payments: auto-process immediately with auto-repayment
Advances are now treated as immediate payments (not pending salary items):
- Auto-creates PayrollRecord + sends payslip email at creation time
- Auto-creates Advance Repayment adjustment for next salary cycle
- Validates worker has unpaid work logs (otherwise use New Loan)
- Requires project selection for cost tracking
- Partial repayment converts advance to regular loan
- Admin can edit auto-repayment amount before payday
- Negative net pay warning in preview modal

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 14:23:03 +02:00
Konrad du Plessis
0257b454af Add Advance Payment system + enhanced preview modal with inline repayments
Redesign Advance Payments to work like loans with tracked balances:
- Add loan_type field to Loan model ('loan' or 'advance')
- Move Advance Payment from DEDUCTIVE to ADDITIVE types (worker receives money)
- Add new Advance Repayment type for deducting from future salary
- Create/edit/delete handlers mirror New Loan behavior for advances
- Loans & Advances tab with type badges and filter buttons

Enhance Payslip Preview modal into "Worker Payment Hub":
- Show outstanding loans & advances with balances in preview
- Inline repayment form per loan (amount pre-filled, note, Deduct button)
- AJAX add_repayment_ajax endpoint creates adjustment without page reload
- Modal auto-refreshes after repayment showing updated net pay
- New refreshPreview() JS function enables re-fetching after AJAX

Other changes:
- Rename History to Work History in navbar
- Advance-specific payslip layout for pure advance payments
- Fix JS noProjectTypes to hide Project field for advance types

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 10:46:58 +02:00
Konrad du Plessis
19c662ec7d Fix 3 critical bugs in dashboard + attendance logging
- Fix outstanding payments: check per-worker (not per-log) to handle partially-paid WorkLogs
- Fix adjustment math: deductions now subtract from outstanding instead of adding
- Fix conflict resolution: use explicit worker ID list (QueryDict.getlist) instead of broken form.data.workers iteration
- Add missing migration 0003 for Project start_date/end_date fields
- Add CLAUDE.md project documentation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 18:28:11 +02:00