# Warehouse and ShipStation Configuration Mappings Found

## 1. **CarrierRateService.php** (`/app/Services/CarrierRateService.php`)
### Lines 26-57: SUPPLIER_WAREHOUSES mapping
Maps supplier IDs to state/warehouse codes:

```php
private const SUPPLIER_WAREHOUSES = [
    // ELT suppliers
    2 => ['NJ', 'CA'],   // ELTWC - maps to NJ and CA warehouses
    18 => ['NJ', 'CA'],  // ELTEC - maps to NJ and CA warehouses
    
    // DEPO suppliers  
    3 => ['GA'],    // DEPO-EC - maps to GA warehouse
    51 => ['CA'],   // DEPO-WC - maps to CA warehouse
    52 => ['NJ'],   // DEPO-NJ - maps to NJ warehouse
    53 => ['IL'],   // DEPO-IL - maps to IL warehouse
    
    // TYC
    1 => ['NJ'],    // TYC-EC - maps to NJ warehouse
    55 => ['CA'],   // TYC-WC - maps to CA warehouse
    
    // PBI suppliers
    12 => ['TX'],   // PBI - maps to TX warehouse
    21 => ['VA'],   // PBIVA - maps to VA warehouse
    43 => ['TX'],   // PBITX - maps to TX warehouse
    
    // KEYSTONE
    8 => ['PA'],    // Keystone - maps to PA warehouse
    
    // JCAUTO
    56 => ['FL'],   // JC Auto - maps to FL warehouse
    
    // EXPRESS
    57 => ['MI'],   // EXPRS-MI - maps to MI warehouse
    58 => ['OR'],   // EXPRS-OR - maps to OR warehouse
    
    // PERFRAD
    59 => ['PA'],   // PERFRAD-PA - maps to PA warehouse
    60 => ['WA'],   // PERFRAD-WA - maps to WA warehouse
    
    // MEYER
    61 => ['MI'],   // MEYER - maps to MI warehouse
    
    // MEYER B2B (IDs 62-69 all map to MI)
    62-69 => ['MI']  // MEYER B2B variations
];
```

## 2. **ShipStationService.php** (`/app/Services/ShipStationService.php`)
### Lines 35-80: WAREHOUSE_CREDENTIALS mapping (LEGACY - being replaced by config)
Maps state codes to ShipStation credentials:

```php
private const WAREHOUSE_CREDENTIALS = [
    'GA' => [...],  // Maps to GA configuration
    'NJ' => [...],  // Maps to NJ configuration  
    'CA' => [...],  // Maps to CA configuration
    'IL' => [...],  // Maps to DEPO-IL configuration
    'TX' => [...],  // Maps to PBITX configuration
    'VA' => [...],  // Maps to PBIVA configuration
    'PA' => [...],  // Maps to PERFRAD-PA configuration
    'WA' => [...],  // Maps to PERFRAD-WA configuration
    'MI' => [...],  // Uses GA default configuration
    'OR' => [...],  // Uses GA default configuration
    'FL' => [...],  // Uses GA default configuration
];
```

## 3. **CacheShippingRates.php** (`/app/Console/Commands/CacheShippingRates.php`)
### Line 34: Allowed supplier IDs for caching
```php
$allowedSupplierIds = [1, 2, 3, 12, 18, 21, 43, 51, 52, 53, 56, 57, 59, 60];
```

These correspond to:
- 1: TYC-EC
- 2: ELTWC
- 3: DEPO-EC
- 12: PBI
- 18: ELTEC
- 21: PBIVA
- 43: PBITX
- 51: DEPO-WC
- 52: DEPO-NJ
- 53: DEPO-IL
- 56: JCAUTO
- 57: EXPRS-MI
- 59: PERFRAD-PA
- 60: PERFRAD-WA

## Key Issues Found:

### 1. **State Code to ShipStation Config Mismatch**
The system uses state codes (TX, CA, IL, etc.) but the actual ShipStation configs use warehouse codes:
- `TX` should map to → `PBITX` 
- `CA` should map to → Multiple options (ELTCA, DEPO-CA, TYC-WC, CA)
- `IL` should map to → `DEPO-IL`
- `VA` should map to → `PBIVA`
- `PA` should map to → `PERFRAD-PA`
- `WA` should map to → `PERFRAD-WA`
- `FL` should map to → `JCAUTO` (but JCAUTO config shows postal code 90670 which is CA, not FL)
- `MI` should map to → `EXPRS` 
- `OR` should map to → No specific config (uses GA default)

### 2. **Missing ShipStation Configurations**
Some state codes don't have corresponding ShipStation configs:
- `MI` (Michigan) - defaults to GA
- `OR` (Oregon) - defaults to GA  
- `FL` (Florida) - defaults to GA (but should probably use JCAUTO)

### 3. **Authentication Issues**
The following ShipStation configs have invalid credentials:
- DTL (not mapped in state codes)
- TYC-WC (should be mapped from supplier 55 → CA → TYC-WC)
- DEPO-IL (mapped from supplier 53 → IL → DEPO-IL)
- DEPO-CA (mapped from supplier 51 → CA → DEPO-CA)
- DEPO-NJ (mapped from supplier 52 → NJ → DEPO-NJ)
- JCAUTO (mapped from supplier 56 → FL → JCAUTO)

### 4. **Mapping Chain**
The current flow is:
1. Supplier ID → State Code (in CarrierRateService::SUPPLIER_WAREHOUSES)
2. State Code → ShipStation Config (in ShipStationService::getWarehouseCredentials)
3. But the actual configs use warehouse codes like DEPO-IL, not state codes like IL

## Recommendations:
1. The mapping should be updated to use actual warehouse codes instead of state codes
2. The ShipStationService should map state codes to the correct warehouse codes
3. Fix the authentication issues for the failing configurations
4. Consider direct supplier ID to warehouse code mapping to avoid the intermediate state code step