# Skulitech ERP Payment Voucher Workflow and PDF Upgrade

## Workflow implemented

Supplier payment vouchers now use the controlled sequence:

**Prepare and Submit → Independent Check → Independent Approval → Payment Release → Paid**

A submitted, checked or approved voucher may be rejected before payment. Rejection requires a reason and releases the amount reserved against the supplier invoice.

## Maker-checker controls

The workflow stores both the officer's display name and stable user ID for each stage. The system prevents:

- The preparer from checking the same voucher.
- The preparer or checker from approving it.
- The preparer, checker or approver from releasing payment.
- Payment before independent checking and approval.
- Payment before supplier, invoice, three-way-match and cashbook checks are revalidated.
- Duplicate payment references.
- Future-dated vouchers or payments.
- Posting into closed accounting periods.
- Voucher values exceeding the unreserved supplier-invoice balance.

Legacy approved and paid vouchers remain available. They are identified as legacy combined approvals where applicable instead of being deleted or rewritten.

## Print and PDF document

A new official payment-voucher page is available from the payment voucher register. It includes:

- Institutional letterhead and voucher number.
- Supplier name, contact details, PIN and code.
- Invoice, LPO and contract references.
- Purpose and narration.
- Gross amount, withholding tax, other deductions and net amount.
- Net amount in words.
- Payment method, cashbook account, payment date and payment reference.
- Invoice approval and three-way-match checklist.
- Prepared, checked, approved and payment-released officers.
- Checker and approver comments.
- Rejection information where applicable.
- **NOT PAID** watermark for unpaid vouchers.
- **REJECTED** watermark for rejected vouchers.

Selecting **Print / Save PDF** opens the browser print dialog, where the voucher can be printed or saved as a PDF. Print actions are recorded through an authenticated CSRF-protected request.

## Installation

Back up the database and application files. Run:

```bat
C:\xampp\php\php.exe bin\migrate.php
C:\xampp\php\php.exe bin\check_payment_vouchers.php
C:\xampp\php\php.exe bin\check_integrity.php
C:\xampp\php\php.exe bin\xampp_check.php
```

Test the complete workflow with four separate authorised users on a staging database before production deployment.

## Validation performed

- 221 PHP files passed syntax validation.
- The new migration parsed into three SQL statements.
- No original application files were removed.
- Three files were added and seven existing files were strengthened before adding this upgrade note.
- A live MySQL workflow test could not be run in the build environment because `pdo_mysql` and a MySQL server were unavailable.
