# Purchase Global Prefix Test Guide

## Purchase Global Prefix System - IMPLEMENTED

The purchase transaction creation is already fixed to use the global prefix system!

## How It Works

When you create a purchase transaction:
1. System gets the `purchase_invoice_scheme_id` from the business location
2. Uses that scheme to generate invoice number with global prefix
3. Results: "PUR-0001", "PUR-0002", etc.

## Test Steps

### Step 1: Set Global Purchase Prefix
1. Go to: Business Settings > Business Locations > Edit your location
2. Find "Global Invoice Scheme Prefixes" section
3. Enter purchase prefix (e.g., "PUR-") in the purchase field
4. Click "Apply" button
5. Confirm when prompted

### Step 2: Create Purchase Transaction
1. Go to: Purchases > Add Purchase
2. Fill in purchase details
3. **Leave the reference number field empty** (important!)
4. Save the purchase
5. Check the generated reference number

### Expected Result
Purchase reference should be: `PUR-0001` instead of generic "purchase" format

## Debug Information

If purchase global prefix is not working, check Laravel logs:
```
Purchase transaction - Location ID: 1, Purchase Scheme ID: 123
Purchase transaction - Generated Ref No: PUR-0001
```

## Troubleshooting

### Issue: Purchase still shows generic reference
**Check:**
1. Did you set the purchase prefix in business location settings?
2. Did you click "Apply" button?
3. Are you leaving the reference number field empty when creating purchase?
4. Check Laravel logs for debug messages

### Issue: Purchase prefix field is empty
**Solution:** 
- Set the prefix in business location settings
- Click Apply to save it
- Refresh the edit page to verify it persists

## Complete Global Prefix Coverage

All transaction types now use global prefixes:

| Transaction Type | Prefix Field | Example |
|------------------|--------------|---------|
| Expense | `EXP-` | EXP-0001 |
| Purchase | `PUR-` | PUR-0001 |
| Purchase Return | `PR-` | PR-0001 |
| Sell Return | Uses sale prefix | SR-0001 |

## Quick Test

1. Set all prefixes: EXP-, PUR-, PR-
2. Create each transaction type
3. Verify all show proper prefix format

The purchase global prefix system is fully implemented and ready to use!
