# Test Import Instructions

## Test CSV Files Created

Two test CSV files have been created in the project root:

1. **test_pos_transactions.csv** - 10 POS transactions
2. **test_qr_transactions.csv** - 10 QR transactions

## How to Use

1. **Navigate to Test Import page**:
   - Go to: Security & Compliance → Test Import
   - Or visit: http://localhost:4099/risk-management/import

2. **Select Transaction Type**:
   - Click "POS Transactions" or "QR Transactions"

3. **Upload CSV File**:
   - Drag and drop the CSV file, or click to browse
   - Use `test_pos_transactions.csv` for POS
   - Use `test_qr_transactions.csv` for QR

4. **Import & Evaluate**:
   - Click "Import POS/QR Transactions" button
   - Wait for processing (should take 5-10 seconds)

5. **View Results**:
   - See summary cards with counts
   - Review detailed table showing which rules were triggered

## What the Test Data Will Trigger

### POS Transactions (test_pos_transactions.csv):

**TXN001** - AED 15,000 from GB (UK) → **HOLD**
- ✓ Rule 1: Suspicious International transactions (≥ AED 5,000)
- ✓ Rule 9: High Value Transaction

**TXN002** - AED 500 domestic → **RELEASED**
- ✓ No rules triggered (clean transaction)

**TXN003** - AED 25,000 MANUAL entry from US → **HOLD**
- ✓ Rule 27: Suspicious High Value Manual Entry
- ✓ Rule 9: High Value Transaction
- ✓ Rule 1: Suspicious International transactions

**TXN004** - AED 350 domestic (Cat B) → **RELEASED**
- ✓ No rules triggered

**TXN005** - AED 8,500 from FR (France) → **HOLD**
- ✓ Rule 1: Suspicious International transactions

**TXN007** - AED 580 at 10:31 (1 min after TXN001) → **HOLD**
- ✓ Rule 6: High Velocity transaction (same terminal, < 2 min apart)

**TXN009** - AED 35,000 from EG (Egypt) → **HOLD**
- ✓ Rule 26: Suspicious countries (Egypt is high-risk)
- ✓ Rule 1: Suspicious International transactions
- ✓ Rule 9: High Value Transaction

### QR Transactions (test_qr_transactions.csv):

**QRTXN003** - AED 12,500 → **HOLD/ALERT**
- ✓ Rule 9: High Value Transaction

**QRTXN005** - AED 8,000 → **HOLD/ALERT**  
- ✓ Rule 9: High Value Transaction

**QRTXN007** - AED 22,000 → **HOLD/ALERT**
- ✓ Rule 9: High Value Transaction

## Expected Results

After importing **test_pos_transactions.csv**:
- **Total Processed**: 10
- **Successful**: 10
- **Rule Hits**: ~15-20 triggers
- **Status Distribution**:
  - 🔴 HOLD: 5-6 transactions
  - 🟢 RELEASED: 4-5 transactions

After importing **test_qr_transactions.csv**:
- **Total Processed**: 10
- **Successful**: 10
- **Rule Hits**: 3-5 triggers
- **Status Distribution**:
  - 🟡 ALERT: 3 transactions
  - 🟢 RELEASED: 7 transactions

## Troubleshooting

If you see loading but no results:
1. Check the Phoenix server terminal for error logs
2. Verify CSV format matches the template exactly
3. Check that risk rules are **enabled** in the database:
   ```sql
   SELECT COUNT(*) FROM shukria_transactions.risk_rules WHERE enabled = true;
   ```
   Should show 176 enabled rules (44 per category × 4 categories)

4. Enable rules if needed:
   ```sql
   UPDATE shukria_transactions.risk_rules SET enabled = true;
   ```

## Creating Your Own Test Data

Download the template from the Test Import page and modify:
- Change amounts to test different thresholds
- Use different countries to test international rules
- Adjust timestamps to test velocity rules
- Add multiple cards to test duplicate/velocity patterns
