# Addon Request Types Structure

## Based on Flowchart: 是否需要報價 (Quotation Required Decision)

This document outlines all addon request types organized by their pricing model.

---

## 📊 Overview

```
是否需要報價 (Is Quotation Required?)
├── YES (是)
│   ├── 動態報價需求 (Dynamic Pricing)
│   └── 固定費用服務 (Fixed Fee Service)
└── NO
    └── 免費協助服務 (Free Assistance Service)
```

---

## 🔴 動態報價需求 (Quotation Required)

These services require custom pricing quotes from the department.

### Ticketing (票務)
| #  | Name | Type Code | Description | Processing Time | Approval Required |
|----|------|-----------|-------------|-----------------|-------------------|
| 1  | 機票FIT | `FLIGHT_FIT` | Flight Ticket FIT | 48h | ✅ Yes |

### Ground Control (總務/線控)
| #  | Name | Type Code | Description | Processing Time | Approval Required |
|----|------|-----------|-------------|-----------------|-------------------|
| 2  | 總務:房型升等 | `ROOM_UPGRADE` | Room Upgrade | 48h | ✅ Yes |

### Operations (OP)
| #  | Name | Type Code | Description | Processing Time | Approval Required |
|----|------|-----------|-------------|-----------------|-------------------|
| 3  | OP:保險-時間、額度 | `INSURANCE_CUSTOM` | Insurance - Time & Coverage | 24h | ✅ Yes |

**Total: 3 types**

---

## 💰 固定費用服務 (Fixed Price Service)

These services have predetermined, fixed costs.

### Ticketing (票務)
| #  | Name | Type Code | Base Cost | Processing Time |
|----|------|-----------|-----------|-----------------|
| 1  | 機票自理退款(機票年-大人) | `TICKET_REFUND_ADULT_YEAR` | TWD 500 | 24h |
| 2  | 機票自理退款(機票年-小孩) | `TICKET_REFUND_CHILD_YEAR` | TWD 300 | 24h |
| 3  | 機票自理退款(大人) | `TICKET_REFUND_ADULT` | TWD 500 | 24h |
| 4  | 機票自理退款(小孩) | `TICKET_REFUND_CHILD` | TWD 300 | 24h |

### Operations (OP)
| #  | Name | Type Code | Base Cost | Processing Time |
|----|------|-----------|-----------|-----------------|
| 5  | OP:過退代辦 | `TRANSFER_REFUND` | TWD 800 | 24h |
| 6  | OP: SIM卡：預購加購 | `SIM_CARD_PREORDER` | TWD 600 | 12h |
| 7  | OP: SIM卡：esim | `SIM_CARD_ESIM` | TWD 650 | 12h |

**Total: 7 types**

---

## 🆓 免費協助服務 (Free Assistance Service)

These services are provided at no cost to travelers.

### Ticketing (票務)
| #  | Name | Type Code | Description | Processing Time |
|----|------|-----------|-------------|-----------------|
| 1  | 票務:飛機餐食 | `INFLIGHT_MEAL` | In-flight Meal Assistance | 24h |
| 2  | 票務:耳叫相關服務 | `CALL_SERVICE` | Call Service Related | 24h |
| 3  | 票務:選位 | `SEAT_SELECTION` | Seat Selection Service | 24h |

### Ground Control (總務/線控)
| #  | Name | Type Code | Description | Processing Time |
|----|------|-----------|-------------|-----------------|
| 4  | 總務:生日 | `BIRTHDAY` | Birthday Service | 24h |
| 5  | 總務：實月旅行 | `MONTHLY_TRAVEL` | Monthly Travel | 48h |
| 6  | 總務:酒店餐食 | `HOTEL_DINING` | Hotel Dining Assistance | 24h |

### Operations (OP)
| #  | Name | Type Code | Description | Processing Time |
|----|------|-----------|-------------|-----------------|
| 7  | OP:簽證 | `VISA` | Visa Service | 48h |

**Total: 7 types**

---

## 📈 Summary Statistics

| Pricing Type | Count | Percentage |
|--------------|-------|------------|
| Quotation Required (動態報價需求) | 3 | 17.6% |
| Fixed Price (固定費用服務) | 7 | 41.2% |
| Free (免費協助服務) | 7 | 41.2% |
| **Total** | **17** | **100%** |

---

## 🏷️ Department Distribution

| Department | Quotation Required | Fixed Price | Free | Total |
|------------|-------------------|-------------|------|-------|
| **Ticketing (票務)** | 1 | 4 | 3 | 8 |
| **Ground Control (總務)** | 1 | 0 | 3 | 4 |
| **Operations (OP)** | 1 | 3 | 1 | 5 |
| **Total** | **3** | **7** | **7** | **17** |

---

## 🔄 Seeding Instructions

### Fresh Seed (Recommended for Development)

```bash
# Reset and re-seed everything
php artisan migrate:fresh --seed
```

### Seed Only Addon Requests

```bash
# Seed only the AddonRequestSeeder
php artisan db:seed --class=AddonRequestSeeder
```

**⚠️ Note:** Running the seeder multiple times will create duplicate entries unless you clear the table first.

### Clear and Re-seed

```sql
-- Clear existing addon request types
TRUNCATE TABLE addon_request_types;

-- Then run seeder
php artisan db:seed --class=AddonRequestSeeder
```

---

## 🎯 Usage Examples

### Filter by Pricing Type

```php
// Get all services requiring quotation
$quotationServices = AddonRequestType::quotationRequired()
    ->active()
    ->get();

// Get all fixed price services
$fixedPriceServices = AddonRequestType::fixedPrice()
    ->active()
    ->get();

// Get all free services
$freeServices = AddonRequestType::free()
    ->active()
    ->get();
```

### Filter by Department and Pricing Type

```php
// Get free ticketing services
$freeTicketingServices = AddonRequestType::free()
    ->whereHas('category', function($q) {
        $q->where('department_code', 'TICKETING');
    })
    ->get();

// Get fixed price OP services
$fixedPriceOpServices = AddonRequestType::fixedPrice()
    ->whereHas('category', function($q) {
        $q->where('department_code', 'OPERATIONS');
    })
    ->get();
```

### Get Services with Details

```php
// Get all types with category info
$types = AddonRequestType::with('category')
    ->active()
    ->ordered()
    ->get();

foreach ($types as $type) {
    echo "{$type->name} - {$type->pricing_type->label()} - {$type->category->name}\n";
}
```

---

## 🔍 Type Code Reference

### Quotation Required Codes
- `FLIGHT_FIT` - Flight Ticket FIT
- `ROOM_UPGRADE` - Room Upgrade
- `INSURANCE_CUSTOM` - Insurance Custom Coverage

### Fixed Price Codes
- `TICKET_REFUND_ADULT_YEAR` - Ticket Refund Adult (Year)
- `TICKET_REFUND_CHILD_YEAR` - Ticket Refund Child (Year)
- `TICKET_REFUND_ADULT` - Ticket Refund Adult
- `TICKET_REFUND_CHILD` - Ticket Refund Child
- `TRANSFER_REFUND` - Transfer Refund Service
- `SIM_CARD_PREORDER` - SIM Card Pre-order
- `SIM_CARD_ESIM` - eSIM Service

### Free Service Codes
- `INFLIGHT_MEAL` - In-flight Meal Assistance
- `CALL_SERVICE` - Call Service Related
- `SEAT_SELECTION` - Seat Selection
- `BIRTHDAY` - Birthday Service
- `MONTHLY_TRAVEL` - Monthly Travel
- `HOTEL_DINING` - Hotel Dining
- `VISA` - Visa Service

---

## 📝 Notes

### Pricing Strategy

1. **Quotation Required** items typically:
   - Have variable costs based on external factors
   - Require approval from management
   - Need longer processing time (24-48h)
   - Examples: Flight tickets, hotel upgrades, custom insurance

2. **Fixed Price** items typically:
   - Have consistent, predetermined costs
   - Standard refund/processing fees
   - Quick processing (12-24h)
   - Examples: Standard refunds, SIM cards, standard services

3. **Free** items typically:
   - Value-added services included in the package
   - Administrative assistance
   - Standard processing time (24-48h)
   - Examples: Visa assistance, meal requests, seat selection

### Future Enhancements

Consider adding:
- Seasonal pricing adjustments
- Volume discounts for fixed price items
- Priority processing fees
- Add-on bundles or packages

---

## 🔗 Related Documentation

- [PRICING_TYPE_FEATURE.md](./PRICING_TYPE_FEATURE.md) - Complete pricing type feature documentation
- [ADDON_REQUEST_COMMUNICATION_FLOW.md](./ADDON_REQUEST_COMMUNICATION_FLOW.md) - Communication workflow
- [ADDON_REQUEST_FRONTEND_DOCUMENTATION.md](./ADDON_REQUEST_FRONTEND_DOCUMENTATION.md) - Frontend integration guide

---

## ✅ Verification Checklist

After seeding, verify:

- [ ] Total of 17 addon request types created
- [ ] 3 categories exist (Ticketing, Ground Control, Operations)
- [ ] 3 types have `pricing_type = quotation_required`
- [ ] 7 types have `pricing_type = fixed_price`
- [ ] 7 types have `pricing_type = free`
- [ ] All fixed price items have `base_cost` > 0
- [ ] All free items have `base_cost = null`
- [ ] All types have unique `type_code`
- [ ] All types have both Chinese (`name`) and English (`name_en`) names

### Verification Query

```sql
-- Check pricing type distribution
SELECT 
    pricing_type,
    COUNT(*) as count,
    ROUND(COUNT(*) * 100.0 / SUM(COUNT(*)) OVER(), 1) as percentage
FROM addon_request_types
GROUP BY pricing_type;

-- Check department distribution
SELECT 
    c.name as category,
    art.pricing_type,
    COUNT(*) as count
FROM addon_request_types art
JOIN addon_request_categories c ON art.category_id = c.id
GROUP BY c.name, art.pricing_type
ORDER BY c.name, art.pricing_type;

-- Verify all fixed price items have costs
SELECT name, pricing_type, base_cost
FROM addon_request_types
WHERE pricing_type = 'fixed_price' AND (base_cost IS NULL OR base_cost = 0);
-- Should return 0 rows
```

---

**Last Updated:** 2025-11-17  
**Version:** 1.0  
**Status:** ✅ Complete

