# Tasks — Smart Save

Source: **Adashe Micro-Credit & Savings Management System (AMCSMS)** proposal (`micro-credit.doc`). The proposal is followed as written.

Status legend: `[ ]` todo · `[~]` in progress · `[x]` done

---

## Already covered

- [x] Member registration, profile, KYC verification
- [x] Wallet with account number, savings plans (daily / weekly / monthly / flexible), auto-save
- [x] Loan (financing) application, approval, repayment schedule, repayment, reminders
- [x] Member-to-member transfers
- [x] Transactions with references, receipts, printable statement
- [x] In-app notifications, support tickets
- [x] Password hashing, secure login, sessions

---

## Phase 2 — Core development (members, savings, contributions, transactions)

- [x] **Users & roles (§4)** — Super Administrator, Administrator/Manager, Accountant, Loan Officer, Member; permission management; staff & user management page
    - Roles & permissions CRUD, assign permissions to roles, admin pages gated by permission, Users list / register with role / change role / user profile (PRs #49–#57)
- [x] **Admin dashboard (§5A)** — Total Members, Active Members, Total Savings, Total Withdrawals, Total Loans, Outstanding Loans, Total Loan Repayments, Total Income, Total Expenses, Available Cash, Pending Loan Applications, Overdue Loans
    - Built at `/admin`; Total Income, Total Expenses and Available Cash show once Accounting (Phase 4) exists
- [x] **Member management (§6)** — Membership ID (`ADS-000125`), photograph, gender, date of birth, phone, email, address, occupation, next of kin, identification number, date joined, membership status, group/branch, signature, guarantor information; registration, member profiles, member statements
    - Done: membership ID, gender, occupation, ID number, next of kin, membership status, photo & signature, staff edit (PRs #58–#59). Guarantor info → §13; group/branch → §20/§21; member statements → §19
- [x] **Member onboarding & verification** — after sign-up: email code → phone SMS code → identity (NIN or BVN, date of birth, ID document, passport photo, optional proof of address → staff KYC review) → transaction PIN → account ready with wallet number
    - New members are held on `/onboarding` until done; staff and existing members skip it. Codes are 6 digits, 10 minutes, 5 tries, one resend a minute. Without SMS the phone code is logged (local) and the phone step is skipped in production. No live BVN/NIN lookup yet (needs a provider such as Dojah, Prembly, VerifyMe or Smile ID)
- [x] **Account opening by staff (§4 Accountant)**
    - Admin → Users → Register user (role optional); wallet opens on first use
- [x] **Smart Save savings (§7)** — daily / weekly / monthly / flexible savings; staff-recorded deposits; balance = opening balance + deposits − withdrawals
    - Savings plans (P5) + Admin → Deposits for cash / POS / bank transfer into wallet or plan (PR #60); balances come from the ledger
- [x] **Contribution management (§8)** — scheduled contributions per member, Paid / Pending register, members who have not contributed
    - Admin → Contributions: register per day / week / month with Paid / Part paid / Pending, totals, and Record → prefilled deposit
- [x] **Withdrawal management (§9)** — member request → verification → approval → payment → receipt; records withdrawal ID, member, amount, date, reason, approved by, payment method, transaction reference, status; statuses Pending / Approved / Rejected / Paid / Cancelled
    - Member: Withdraw (cash at office / bank transfer, PIN, money held at once). Staff: Admin → Withdrawals (approve / reject / mark paid with reference, never own). Printable receipt when paid
- [x] **Transaction management (§17)** — references `TXN-YYYYMMDD-000124`; types: Savings Deposit, Withdrawal, Loan Disbursement, Loan Repayment, Interest, Penalty, Fee, Transfer, Adjustment
    - New entries get `TXN-YYYYMMDD-NNNNNN` references; Admin → Ledger with search, type / money-in-out / date / branch filters, totals and CSV. Loan processing fee is its own type; each loan repayment shows its principal, interest and penalty (ledger, CSV, receipt), and the ledger filters by Interest and Penalty
- [x] **Digital receipt (§18)** — receipt no. `ADS-REC-000245`, member, member ID, transaction, amount, date, payment method, new balance, authorized by; print and PDF
    - `/receipts/{transaction}`: ADS-REC- number, member + ID, type, amount, date, method, new balance, authorized by, signature line; print / save as PDF via the browser (server-side PDF would need a new dependency)
- [x] **Member statement (§19)** — date, description, debit, credit, balance; print and PDF
    - Wallet → Statement for members and Admin → Users → Statement for staff: member ID, opening balance row, Date / Description / Reference / Debit / Credit / Balance, totals, print / save PDF
- [x] **Smart Save group management (§20)** — groups with leader, members, savings target, contribution frequency, loan rules, group account, group reports
    - Admin → Smart Save groups — leader, members, contribution amount / frequency, savings target, loan rules, per-period group report; group account (GRP-000012) pooling members' savings with money saved in / taken out per period, members' loans outstanding and latest movements. Money stays in each member's own wallet and plans (no separate group wallet)
- [x] **Branch management (§21)** — staff, members, savings, loans, transactions and reports per branch, central control
    - Admin → Branches (reports.view to see, branches.manage to create/edit): code, address, phone, manager; per-branch report with members, staff, money held, savings, this month in/out, loans and latest transactions. Users get a branch on register / details edit; Users and Ledger filter by branch

## Phase 3 — Loan system

- [x] **Loan products (§10)** — Emergency, Business, Salary, School Fees, Agricultural, Personal, Smart Save, Group loans; each with max/min amount, interest rate, processing fee, repayment period, penalty, eligibility requirements
    - Admin → Loan products (loans.view to see, new loans.products to create/edit): flat monthly interest, one-off processing fee, late penalty with grace days, membership months, minimum savings, guarantors, other requirements; worked example per product
- [x] **Loan application (§11)** — member, loan type, amount, purpose, repayment period, monthly income, existing loan, guarantor, supporting documents; number `LN-2026-000458`
    - Member: Loans → Apply (KYC verified): product, amount, term with live cost preview, purpose, income, existing loans, guarantors (member or outsider), up to 5 documents; checks product limits, membership months, savings, guarantor count; one open loan at a time; cancel before review. Staff: Admin → Loans list and view (loans.view)
- [x] **Loan approval workflow (§12)** — Application → Loan Officer Review → Guarantor Verification → Accountant/Manager Review → Approval Committee → Final Approval → Disbursement
    - Admin → Loans → loan: each stage completed by its permission (loans.review, guarantors.verify, loans.manager-review, loans.committee, loans.approve, loans.disburse), never on own loan; guarantors verified one by one; reject with reason before disbursement; full trail with who/when/note; disbursement pays the wallet and takes the processing fee; member notified at each step
- [x] **Guarantor management (§13)** — full name, photograph, phone, address, occupation, ID, relationship, signature, status; limit on loans one person can guarantee
    - Guarantor ID number at application, photo and signature (member uploads or staff add at verification); verified only with ID, photo and signature on file; per-person limit of open guarantees (Site settings, default 3) checked at application and verification; Admin → Guarantors list with open-loan count
- [x] **Loan repayment (§14)** — schedule with principal, interest and total per month; amount paid, outstanding, next payment date, overdue amount, penalty, remaining instalments
    - Schedule built at disbursement; member repays any amount from the wallet with PIN; staff record cash / POS / transfer repayments (repayments.record); oldest instalment first, penalty first; daily `loans:apply-penalties` after grace days; loan completes when settled
- [x] **Loan delinquency monitoring (§15)** — performing, due, overdue, defaulted, partially paid; aging report 30 / 60 / 90 / 90+ days
    - Standing worked out from the schedule (due = next instalment within 7 days, defaulted = over 90 days overdue); Admin → Delinquency: counts and outstanding per standing, portfolio at risk, 1–30 / 31–60 / 61–90 / 90+ aging, loans to follow up, branch filter; standing shown on the loan page

## Phase 4 — Accounting

- [x] **Income (§16)** — interest income, processing fees, penalties, membership fees, other income
    - Income ledger: processing fees booked at disbursement, interest and penalties booked from each repayment (penalty → interest → principal), membership fees and other income recorded by staff (accounting.manage); Admin → Income with period totals per category
- [x] **Expenses (§16)** — salaries, office, transportation, utilities, bank charges, administrative
    - Admin → Expenses: record by category with amount, date, payee, method, reference and optional receipt (accounting.manage); period totals per category (accounting.view)
- [x] **Accounting features (§16)** — cashbook, income & expenditure, general ledger, trial balance, account balances, financial statements
    - Double-entry journal derived from wallet transactions, withdrawal payouts, income and expenses over a chart of accounts; Admin → Accounting: trial balance (account balances), income & expenditure, balance sheet, general ledger per account, cashbook; printable
- [x] **Reports (§25)** — savings (daily, weekly, monthly, member, group, branch); loans (applications, approved, rejected, disbursed, outstanding, overdue, repayments); financial (income, expenses, cashbook, general ledger, trial balance, member statement, transactions); export PDF / Excel / CSV / Print
    - Admin → Reports hub; savings report (per day/week/month and per member, by branch/group/member); loan report (applications, approved, rejected, disbursed, outstanding, overdue, repayments, by branch); Download menu with Excel (.xlsx, real numbers), PDF (organisation header, up to 2,000 rows) and CSV for these and income, expenses, trial balance, general ledger, cashbook, transactions and the audit trail; Print from the browser. Packages: barryvdh/laravel-dompdf, maatwebsite/excel

## Phase 5 — Security & notifications

- [x] **SMS & email notifications (§23)** — savings recorded, withdrawal approval, loan approval, disbursement, repayment reminders, overdue loans, contribution reminders, account changes
    - Alerts in the app plus email (verified addresses) and SMS (Termii via SMS_DRIVER / SMS_API_KEY / SMS_SENDER_ID), switched on in Site settings; deposits, withdrawals, loan decisions, disbursement, repayments, `loans:remind` (3 days before, on the day, 1/7/14/30 days late), `groups:remind` (last day of the period), account changes (password, PIN, profile, role, membership)
- [x] **Security (§24)** — role-based access, two-factor authentication, transaction authorization, automatic logout, login history, IP/device logging, database backup, permission management
    - Two-factor sign-in (authenticator app, QR, recovery codes, challenge; optional "required for staff"); sign-in history with IP and device (own on Security page, all on Admin → Security log, audit.view); automatic sign-out after inactivity (Site settings, default 15 min); nightly `backup:database` (14 kept) with Admin → Backups download behind password confirmation; roles, permissions and PIN authorisation were already in place
- [x] **Audit trail (§24)** — who, did what, when, from which account, transaction reference; audit logs page
    - Every create / change / delete of members, transactions, withdrawals, loans, guarantors, savings plans, KYC documents, income, expenses, groups, branches, loan products, roles and settings is recorded with who (or the scheduler), IP and device, the member account, the reference (TXN / LN / WD) and old → new values (passwords, PINs and other hidden fields shown only as changed); role and permission changes recorded; Admin → Audit trail (audit.view) with search, action / record / date filters and Excel / PDF / CSV. Stored with spatie/laravel-activitylog (`activity_log`, log name `audit`)
- [x] **System settings (§27)**
    - Admin → System settings (settings.manage, also in the sidebar): organisation name, address, phone and email (used site-wide and printed on receipts and statements); money limits for withdrawals, member transfers (incl. daily limit) and counter deposits; guarantor limit; email / SMS alerts; staff two-factor and automatic sign-out. Every change is in the audit trail

## Future version

- [ ] **Payment integration (§22)** — on hold (not now, per owner) — bank transfer, payment gateway, USSD, mobile payment, POS, online card payment

## Phase 6–8 — Testing, deployment, training

- [~] **Testing (§28)** — functional, security, usability, performance
    - Run: `php artisan test --compact` (385 tests passing), `vendor/bin/phpstan analyse`, `npm run types:check`, `npm run check`

    **1. Functional (automated, `tests/Feature`)**
    - [x] Sign-up, login, password reset / confirm, email verification (`Auth/*`)
    - [x] Profile, transaction PIN, two-factor, system settings (`Settings/*`)
    - [x] Members: registration by staff, roles, member profile, KYC upload and review (`Admin/UserManagementTest`, `KycTest`, `Admin/KycReviewTest`)
    - [x] Wallet, transfers, statements, receipts (`WalletTest`, `TransferTest`, `TransactionControllerTest`, `ReceiptTest`)
    - [x] Savings plans, auto-save, counter deposits, contributions, Smart Save groups (`SavingsPlanTest`, `Console/ProcessSavingsAutoDebitsTest`, `Admin/CounterDepositTest`, `Admin/ContributionRegisterTest`, `Admin/GroupTest`)
    - [x] Withdrawals: request, approve / reject, pay, receipt (`WithdrawalTest`)
    - [x] Loans: products, application, approval workflow, guarantors, disbursement, repayment, penalties, delinquency (`Admin/LoanProductTest`, `LoanApplicationTest`, `Admin/LoanApprovalTest`, `Admin/GuarantorTest`, `LoanRepaymentTest`, `Admin/LoanDelinquencyTest`)
    - [x] Accounting: income, expenses, journal, trial balance, balance sheet, cashbook, ledger (`Admin/IncomeTest`, `Admin/ExpenseTest`, `Admin/AccountingTest`, `Admin/LedgerTest`)
    - [x] Reports and exports: savings, loans, CSV / Excel / PDF (`Admin/ReportTest`)
    - [x] Branches, investments, financing, support, notifications and reminders (`Admin/BranchTest`, `InvestmentTest`, `FinancingTest`, `SupportTicketTest`, `NotificationAlertTest`)
    - [ ] Money reconciliation check on a copy of real data: wallet balances = sum of ledger entries, trial balance balances, every loan's schedule = principal + interest

    **2. Security**
    - [x] Every admin route closed to guests and plain members; every signed-in route sends guests to login (`RouteProtectionTest`)
    - [x] Permission per action, never approving own loan / withdrawal / KYC (`Admin/StaffAccessTest`, `Admin/RolesAndPermissionsTest`, approval tests)
    - [x] PIN lockout, two-factor, sign-in history, idle sign-out, backups behind password confirmation (`SecurityFeaturesTest`, `Settings/TransactionPinTest`)
    - [x] Audit trail of changes with hidden values masked (`Admin/AuditTrailTest`)
    - [x] CSV / Excel formula-injection guard (`Admin/ReportTest`)
    - [x] Dependency audit: `composer audit` and `npm audit` clean (2026-11-20)
    - [ ] Manual check on the server: HTTPS only, `APP_DEBUG=false`, secure cookies, file uploads not publicly reachable, rate limits on login and money actions
    - [ ] Re-run `composer audit` / `npm audit` before each release

    **3. Performance**
    - [x] N+1 guard: lazy loading throws outside production
    - [x] Indexes for ledger, reports and journal (`transactions` by type / date)
    - [x] Paged lists and ledgers; PDF capped at 2,000 rows
    - [ ] Load test on the server (e.g. 50 concurrent users: login, dashboard, deposit, repayment) and note response times
    - [ ] Time the heavy pages with a year of demo data: trial balance, general ledger, loan and savings reports, audit trail

    **4. Usability (manual, in a browser)**
    - [ ] Member walk-through on a phone: register → KYC → save → transfer → withdraw → apply for a loan → repay
    - [ ] Staff walk-through per role (Super Admin, Manager, Accountant, Loan Officer): each sidebar section, record deposit, approve withdrawal, move a loan through every stage, print a receipt and statement
    - [ ] Check every page at phone width, print layout of receipts / statements / reports, and keyboard-only use of the main forms
    - [ ] Collect feedback from 2–3 real staff and fix what confuses them

    **5. User acceptance & release**
    - [ ] Sign-off from management on each module against the AMCSMS proposal
    - [ ] Scheduler (`savings:auto-debit`, `loans:apply-penalties`, `loans:remind`, `groups:remind`, `financing:remind`, `backup:database`) checked running on the server for a week
    - [ ] Restore test: restore a nightly backup to a spare database and log in

- [ ] **Deployment (§28)** — server, domain, SSL, database, production setup
- [ ] **Training & documentation (§28–29)** — administrator training, user manuals, system documentation

## Still open from earlier work

- [x] **Investments screens** — `investments/index`, `investments/show`, `admin/investments/index` + sidebar links (fixes the one failing test)
    - Members: Investments (open products, invest from wallet with PIN and risk confirmation, own investments with status, detail page with profit / loss after payout). Staff (investments.manage): create / edit products, matured investments with final value payout to the wallet. Full suite green
