# SmartPay360 — Staff Pay (MVP)

Path: `/smartpay360/modules/staff_pay/`

## What this MVP does
- Pay Profiles per staff (monthly / semi-monthly, bank/mpesa/cash)
- Loans with automatic deductions (default: deducted on end_month / monthly runs)
- Pay Periods generator (monthly + semi-monthly A/B)
- Payruns (draft -> approved -> posted), rebuild lines
- Payslips + bank/mpesa CSV exports
- Mark paid (manual) with payment reference

## Assumptions
- Staff join key is `staff.staff_id` (string)
- Existing tables available:
  - `staff` (staff_id, national_id, first_name, last_name, phone, email, branch_id, status, created_at/updated_at)
  - `branches` (id, branch_name)
- layout shell: `/smartpay360/includes/layout2.php` and footer

## Install
1) Upload folder `modules/staff_pay/` into `/smartpay360/modules/staff_pay/`
2) Visit `/smartpay360/modules/staff_pay/index.php`
3) Go to Periods -> Generate current month
4) Go to Pay Profiles -> set salary + payout details for staff
5) Create Payrun -> build lines -> approve -> export CSV / mark paid -> payslips

## Notes
- The module auto-creates its tables on first load via `_inc.php`.
- For production: remove display_errors and add permissions/roles checks.
