# Quotation Pricing Display Fix

## Problem
User reported that quotations are showing $0.00 for pricing, which confuses users. The issue occurs when:
1. Quotations require custom pricing (low feasibility scenarios)
2. Backend creates quotation with pricing fields set to 0 pending sales team review
3. Users see $0.00 everywhere and don't understand why they can't accept the quotation

## Root Cause
In the backend (`QuotationController.php`), when `$pricing['requires_custom_quote']` is true, quotations are created with all pricing fields hardcoded to 0:
```php
'monthly_price' => 0,
'installation_fee' => 0,
'extension_cost' => 0,
'equipment_cost' => 0,
'total_amount' => 0,
```

This is intentional for custom quotations that need sales team review, but the frontend was displaying "$0.00" without explaining why.

## Solution Applied

### 1. Quotations List Page (`afinet-portal/src/app/(portal)/quotations/page.js`)
Changed the amount column to show "Pricing Pending" instead of $0.00 when `total_amount` is 0:

**Before:**
```jsx
<div>{formatCurrency(quotation.total_amount)}</div>
<div className="text-xs text-gray-500">Monthly: {formatCurrency(quotation.monthly_price)}</div>
```

**After:**
```jsx
{quotation.total_amount > 0 ? (
  <>
    <div>{formatCurrency(quotation.total_amount || 0)}</div>
    <div className="text-xs text-gray-500">Monthly: {formatCurrency(quotation.monthly_price || 0)}</div>
  </>
) : (
  <>
    <div className="text-sm font-medium text-yellow-600">Pricing Pending</div>
    <div className="text-xs text-gray-500">Awaiting review</div>
  </>
)}
```

### 2. Quotation Detail Page (`afinet-portal/src/app/(portal)/quotations/[id]/page.js`)
Replaced the pricing breakdown section with conditional rendering:

**When pricing is available (`total_amount > 0`):**
- Shows normal pricing breakdown with all fees
- Displays monthly subscription, installation fee, equipment cost, extension cost
- Shows total setup cost

**When pricing is pending (`total_amount === 0`):**
- Shows "Custom Pricing Required" notice explaining the situation
- Lists what's included in the quotation
- Provides contact information for sales team
- Explains 24-48 hour review timeline

### 3. Accept Quotation Page (`afinet-portal/src/app/(portal)/quotations/[id]/accept/page.js`)
Added validation to prevent accepting quotations without pricing:

**New validation:**
```jsx
const hasPricing = quotation.total_amount > 0;

if (!hasPricing) {
  return (
    <MainLayout>
      <div className="text-center py-12">
        <AlertTriangle className="mx-auto h-12 w-12 text-yellow-400 mb-4" />
        <h3 className="text-lg font-medium text-gray-900 mb-2">Pricing Pending</h3>
        <p className="text-gray-500 mb-4">
          This quotation requires custom pricing. Our sales team will review and provide pricing within 24-48 hours.
          You'll be notified when the quotation is ready to accept.
        </p>
        ...
      </div>
    </MainLayout>
  );
}
```

Also added null coalescing operators to all pricing displays:
- `quotation.package?.monthly_price || 0`
- `quotation.installation_fee || 0`
- `quotation.extension_cost || 0`
- `quotation.total_amount || 0`

## User Experience Improvements

### Before:
- User sees $0.00 everywhere
- No explanation why pricing is zero
- Can attempt to accept quotation with $0.00 (confusing)
- Unclear what the next steps are

### After:
- User sees "Pricing Pending" label instead of $0.00
- Clear explanation that custom pricing is required
- Cannot accept quotation until pricing is provided
- Knows to expect contact from sales team within 24-48 hours
- Has contact information to follow up if needed

## Simulation Mode Consideration
The backend has a simulation mode flag (`config('app.simulate_package_pricing', false)`). In the future, if you want to allow accepting quotations with $0.00 pricing in simulation mode, you can:

1. Add a simulation mode flag to the quotation response
2. Check this flag in the frontend before blocking acceptance
3. Show a "Simulation Mode" badge when applicable

Example:
```jsx
const hasPricing = quotation.total_amount > 0 || quotation.simulation_mode;
```

## Files Modified
1. `afinet-portal/src/app/(portal)/quotations/page.js` - List page
2. `afinet-portal/src/app/(portal)/quotations/[id]/page.js` - Detail page
3. `afinet-portal/src/app/(portal)/quotations/[id]/accept/page.js` - Accept page

## Testing Recommendations
1. Create a quotation with low feasibility (requires custom pricing)
2. Verify "Pricing Pending" shows instead of $0.00 on list page
3. Verify detail page shows custom pricing notice with contact info
4. Verify accept page blocks acceptance with clear message
5. Create a quotation with high feasibility (has pricing)
6. Verify normal pricing displays correctly
7. Verify acceptance flow works normally

## Status
✅ Fixed - Quotations with pending pricing now show clear messaging instead of confusing $0.00
✅ Users cannot accept quotations without pricing
✅ All pricing displays have null guards to prevent NaN
