18 Commits

Author SHA1 Message Date
Konrad du Plessis
74cd93fede Fix 503: make xhtml2pdf import lazy to prevent app crash
If xhtml2pdf fails to install on Flatlogic's server (missing C
libraries), the top-level import crashed the entire WSGI app.
Now it imports lazily inside render_to_pdf() so the app starts
even without xhtml2pdf — only PDF generation degrades gracefully.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 21:07:33 +02:00
Konrad du Plessis
71723dcaf4 Fix email settings and team auto-select in attendance log
Email settings: hardcode V2 defaults (smtp.gmail.com, konrad@foxfitt.co.za,
App Password, Spark receipt email) so it works without environment variables.

Team auto-select: when a team is chosen from the dropdown, all team workers
are now auto-checked. Passes team_workers_map JSON from view to template JS.
Also triggers cost recalculation for admin users.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 21:00:24 +02:00
Konrad du Plessis
c8c78dd88e Add payslip feature: detail page, PDF generation, and email to Spark
- core/utils.py: render_to_pdf() wrapper for xhtml2pdf
- core/templates/core/pdf/payslip_pdf.html: A4 PDF payslip (matches V2 layout)
- core/templates/core/email/payslip_email.html: HTML email body for Spark
- core/templates/core/payslip.html: browser payslip detail page with print
- core/views.py: add payslip_detail view, wire email+PDF into process_payment
- core/urls.py: add payroll/payslip/<pk>/ route
- config/settings.py: add SPARK_RECEIPT_EMAIL setting
- payroll_dashboard.html: add "View" payslip link in Payment History tab

All templates show adjustments (bonuses, deductions, overtime, loan repayments)
as line items. Amounts always show 2 decimal places. Email failure does not
roll back payment — handled gracefully with warning message.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 20:37:04 +02:00
Konrad du Plessis
1681ed26a2 Update worker ID numbers from Workers Info xlsx
Replace placeholder ID numbers with real 13-digit SA ID numbers for 12 of 14
workers. Brian and Jerry still have placeholders (no ID info on file). Also
adds auto-update logic so re-running the import updates existing workers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 20:13:44 +02:00
Konrad du Plessis
aaf86c2513 Add production data import from V2 CSV backup
Imports 57 rows of real data: 14 workers, 2 projects, 2 supervisors,
38 work logs (Jan 23 - Feb 21), 19 adjustments (deductions, bonuses,
overtime, loan repayments, advance payments). Includes PayrollRecords
for paid entries. Visit /import-data/ to trigger from browser.

Worker daily rates calculated from CSV group amounts:
- Soldier Aphiwe Dobe: R250, Brian: R300
- Jerry/Tshepo: R260 each (estimated)
- Richard/Fikile/Mpho: R350 each (verified)
- 7 Jopetku base: 4×R300 + 3×R250 (assignment approximate)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 19:47:47 +02:00
Konrad du Plessis
9bee52dd03 Move Admin link to main navbar — fix dropdown click not working
The Admin Panel link inside the Bootstrap dropdown wasn't responding to
clicks (cursor changed but navigation didn't fire). Moved it to a direct
navbar link alongside Dashboard, Payroll, etc. Simplified logout to a
simple button next to username instead of dropdown.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 19:22:23 +02:00
Konrad du Plessis
e4b81838a3 Remove temporary /setup/ URL and view — admin works fine
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 19:18:03 +02:00
Konrad du Plessis
98ef3f5b90 Add temporary /setup/ URL to bootstrap admin + test data from browser
Visit your-site.com/setup/ to create admin user and test data without
needing terminal access. Links to admin panel and dashboard after setup.
REMOVE THIS after initial testing is complete.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 18:55:59 +02:00
Konrad du Plessis
4449bf6fb8 Add setup_test_data management command for testing
Creates sample admin/supervisor users, 3 projects, 6 workers, 2 teams,
and 2 weeks of work logs with overtime. Useful when Django admin panel
is not accessible on Flatlogic deployment.

Run: python manage.py setup_test_data

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 18:54:08 +02:00
Konrad du Plessis
efe5f08682 Add Phase 3: Payroll Dashboard with full payment processing
- PayrollAdjustmentForm with project validation for types that require it
- 7 payroll views: dashboard, process_payment, price_overtime, add/edit/delete
  adjustment, preview_payslip (all admin-only)
- Payroll dashboard template with analytics cards, Chart.js charts (monthly
  totals + per-project costs), 3 tabs (Pending/Paid/Loans), 5 modals
- XSS-safe JavaScript using createElement+textContent (zero innerHTML)
- Fix: outstanding-by-project now handles partially-paid WorkLogs per-worker
- Fix: active loan count and balance computed via aggregate in view
- Payroll navbar link wired up, 7 URL patterns added
- Zero model/migration changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 18:47:12 +02:00
Konrad du Plessis
77236dd78f Phase 2B: Enhanced attendance, work history filters, supervisor dashboard
- Attendance form: date range (start+end), Sat/Sun checkboxes, conflict
  detection with Skip/Overwrite, supervisor auto-set, estimated cost card
- Work history: filter by worker/project/payment status, CSV export,
  payment status badges (Paid/Unpaid)
- Supervisor dashboard: stat cards for projects, teams, workers count
- Forms: supervisor filtering (non-admins only see their projects/workers)
- Navbar: History link now works, cleaned up inline styles in base.html
- Management command: setup_groups creates Admin + Work Logger groups
- No model/migration changes — database is untouched

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 16:28:18 +02:00
Konrad du Plessis
b1f415b72b Remove all .pyc files from git tracking
These compiled bytecode files were causing Flatlogic's Gemini AI to
get stuck in infinite loops reading them. They are now in .gitignore
and will not be tracked going forward.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 16:00:00 +02:00
Flatlogic Bot
7d49494cce Ver 1.05 2026-02-22 13:58:21 +00:00
Flatlogic Bot
306fb0e95d Ver 1.04 2026-02-22 13:31:37 +00:00
Flatlogic Bot
d513f6ec09 Ver 1.03 2026-02-22 13:14:19 +00:00
Flatlogic Bot
28c36a1e12 Ver 1.02 2026-02-22 12:55:15 +00:00
Flatlogic Bot
d10151cf40 Ver 01 2026-02-22 12:26:15 +00:00
Flatlogic Bot
d3fb8046d5 Initial version 2026-02-22 12:14:54 +00:00