How PEYTS Works

Complete step-by-step user guide and system administration manual.


Introduction

Welcome to the official user guide for PEYTS (Production Expense & Yield Tracking System). PEYTS is built on a lightweight, secure PHP MVC (Model-View-Controller) architecture using OOP design patterns.

Unlike standard software, PEYTS uses a **financial ledger** approach. Every batch workers produce and every expense paid for them acts as a double-entry transaction. This ensures that every Ugandan Shilling (UGX) earned, spent, or paid out can be audited.

Core Philosophy: The system maintains strict ledger verification. Cached balances in the database can be rebuilt chronologically from raw source data at any time.

1. Authentication & Logins

The authentication system manages secure sessions and dynamically filters view panels based on user role assignments.

User Roles & Access matrix
System Role Access Coverage
Owner Full authorization: Reports, user logs, password resets, worker profile status toggles, deletion checks, and recovery bypasses.
Admin Operational oversight: Registers workers, logs production batches, issues stock, approves payouts, views payroll reports.
Storekeeper Inventory-focused: Exclusive stock-in/out registers. Cannot view wages, profit margins, or settle payroll cash lists.
Operator Roster entry: Permitted only to enter daily production sheets. Cannot edit existing ledger balances or delete runs.
Forgot Password flow

If a user forgets their credentials, they can click "Forgot your password?" on the login page.

  1. Enter the registered Username.
  2. The system loads the customized **Security Questions** for that account.
  3. If answered correctly, the user can reset their password immediately.
  4. Alternatively, an Owner can override the password from Settings, or trigger recovery using the server's `MASTER_RECOVERY_KEY` configuration.
Active vs. Inactive Accounts: An Owner can toggle any user status to inactive via Settings. Inactive accounts are blocked from logging in. If already logged in, their active session is terminated instantly on their next click.

2. Dashboard Overview

The dashboard aggregates real-time indicators for operational health.

Key Performance Indicators (KPIs)
  • Today's Production: Sum of units produced today across all valid batches.
  • Today's Expenses: Labor costs combined with the Weighted Average Cost (WAC) of materials consumed.
  • Today's Revenue: Value of output calculated against selling unit prices.
  • Low Stock Alert: Live notification if raw materials drop below configured minimum inventory thresholds.
Audits & Activity Log

The right sidebar displays a live feed of the latest 8 logs recorded in the system. This provides a clear log of who did what and when, ensuring transparency.

3. Workers Directory

Manages the workforce directory and runs the Worker Intelligence Ledger.

Registering and Deactivating

When creating a worker, the system assigns a unique code (e.g. WRK-0001). If a worker is deactivated:

  • They are hidden from active dropdown forms to prevent logging errors.
  • All historical ledger journals and profile history remain fully auditable.
Worker Ledger: Credits & Debits

Each worker profile features a chronological ledger statement:

  • Credits (Wages Earned): Added when a production batch is approved.
  • Debits (Payouts / Expenses): Added when a wage payout is settled or when advances/welfare claims are logged.
  • Running Balance: Displays outstanding company liability (positive balance) or if the worker owes money (negative balance).
Expense Approval Guard: Any individual worker allowance or advance exceeding 500,000 UGX is marked as Pending and will not affect the ledger until an Owner manually approves the entry.

4. Materials & WAC Costing

Tracks raw ingredients and inventory value. PEYTS utilizes the industry standard Weighted Average Cost (WAC) methodology.

WAC Costing Logic

When stock is purchased at different prices, the system dynamically recalculates unit valuation:

New WAC = (Current Stock Quantity × Current WAC) + (Incoming Quantity × Incoming Cost) ÷ (Current Stock + Incoming Stock)
Stock Operations
  • Stock In: Log new shipments with cost to automatically update the WAC.
  • Stock Out: Issue items manually directly to workers. The system blocks attempts to stock out more quantity than is physically available.

5. Product Catalog

The Product Types Catalog manages final products (e.g. Clay Bricks, Hollow Blocks, Cement Bags) and their corresponding units of measurement. These product classes are mapped directly into production entries to log yield.

6. Production Entry Sheet

The Production Entry Sheet records raw material consumption and workforce yield.

Step-by-Step Production Logging
  1. Go to Production and click Add Entry.
  2. Select the Date, Worker, and Product Type.
  3. Input Good Units and Damaged Units (the system enforces that their sum equals the total produced).
  4. Specify Unit Price (market selling value) and Piece-Rate Wage (amount the worker earns per unit).
  5. Click Add Material Line to select and input the quantities of raw ingredients consumed.
  6. Submit. The stock is deducted immediately, and the batch is saved as Pending.
Admin Review: To finalize wages, an Admin or Owner must review the batch, click Approve, and sign with their digital initials. This appends the credit to the worker's ledger and creates a payment voucher.

7. Payments & Payouts

Tracks and logs wage payouts to settle outstanding worker balances.

The Settle Workflow
  1. Navigate to the Payments dashboard.
  2. In the Pending Payments tab, locate the unpaid voucher and click Process Payout.
  3. Select Payment Date, input Payment Method (Cash, Mobile Money, Bank Transfer) and write transaction notes.
  4. Confirm. The voucher status changes to Paid, and a **Debit** entry is chronologically added to the worker's ledger.
  5. Click Receipt to print a transaction receipt with signature lines.

8. Reports & Analytics

The Reports dashboard displays operational performance metrics.

Analytical KPIs
  • Total Output: Cumulative yield of good and damaged items.
  • Expense Matrix: Labor piece-rate wages + raw material cost (calculated via WAC).
  • Net Margin: Total revenue generated minus total expenses.
  • Wastage Rate: The percentage of damaged products, helping flag production quality issues.
Material Consumption table

A detailed list showing total quantities of raw materials used, their average unit cost, and the exact material cost component per finished item unit.

9. Payroll Liabilities

The Payroll Report handles wage payouts and overall financial standings.

Roster Balance Standings

A centralized summary table shows all workers, their cumulative earnings, actual payments made, and their current **Ledger Balance**.

  • Positive Balance: Wages currently owed to the worker.
  • Negative Balance: The worker has received advances exceeding their earnings, indicating a debt to the company.

10. System Settings

Settings allows the Owner to configure application parameters.

  • Company Profile: Update company name, phone, address, default currency, and upload a business logo (displayed on all statements, receipts, and printouts).
  • User Accounts: Register new system operators, reset user passwords, and toggle active status flags.

11. Expense Categories

Organizes worker allowances, advances, and penalties. Deactivating a category hides it from future forms while keeping historical records intact.

Safety & Integrity Checks

PEYTS includes built-in safeguards to ensure data integrity.

1. Concurrency Locks

To prevent conflicts when two users perform actions simultaneously, the database locks row updates (`FOR UPDATE`). In case of a temporary conflict, the system retries the request up to 3 times automatically with a random delay before returning an error.

2. Invariant Guards

The system checks that production records match: good_units + damaged_units == quantity_produced, values like wage cost are valid, and inventory counts do not fall below zero.

3. Database Audits & Reconciliations

If a system disruption or manual database edit causes balances to get out of sync, administrators can run the following command on the server:

php reconcile.php --repair