# Test Scenario Guide: Auto-Note for Partial Coverage Quotations

### 1. Scenario Introduction 🌟
In corrective maintenance, Sales Officers may choose to exclude certain recommended units or spare parts from a final quotation to reduce costs for the client. To ensure transparency and protect the company from liability, the system now automatically detects when a quotation covers only a **subset** of the original visit report's recommendations. An **auto-note** is added to the quotation PDF and API, alerting the client that some items have been intentionally omitted.

### 2. Technical Schema Changes (Detailed) 🔍

#### Endpoint: `PUT /api/v1/maintenance/price-offers/{offer}`
*   **Response Changes (`MaintenancePriceOfferResource`):**
    *   Added `partial_coverage` object:
        *   `is_partial`: (boolean) `true` if items were removed.
        *   `report_item_count`: (int) Original item count from the visit report.
        *   `offer_item_count`: (int) Number of items currently in the quotation.
        *   `note`: (string) The auto-populated warning message.

#### Database Changes (`mod_maintenance_price_offers`):
*   `source_report_item_count`: (int) Persistent snapshot of original items.
*   `offer_item_count`: (int) Dynamically updated count of quoted items.
*   `partial_coverage_note`: (text) Automated notice content.

### 3. Why the Update? (Change Log) 🔄

| Feature | Previous Behavior | New Behavior | Benefit |
| :--- | :--- | :--- | :--- |
| **Transparency** | Clients might not realize parts were removed from the proposal. | Highlighted warning box in PDF for partial coverage. | Clear communication & liability protection. |
| **Tracking** | No record of original vs. final item counts. | Persistent storage of original item count snapshot. | Better audit trail for sales decisions. |
| **Automation** | Notes had to be added manually by Sales Officers. | **Automatic detection** and note insertion based on item count. | Reduced human error and consistency. |

### 4. API Endpoints Table 📊

| Process | Endpoint | Method | Description |
| :--- | :--- | :--- | :--- |
| Create Offer | `/api/v1/maintenance/requests/{request}/corrective-price-offer` | `POST` | Initializes offer and snapshots original item count. |
| Update Pricing | `/api/v1/maintenance/price-offers/{offer}` | `PUT` | Updates parts and triggers partial coverage check. |
| Get Offer Details | `/api/v1/maintenance/price-offers/{offer}` | `GET` | Returns offer data including `partial_coverage` status. |
| Generate PDF | `/api/v1/maintenance/price-offers/{offer}/pdf` | `GET` | Generates PDF with conditional warning box. |

### 5. Test Cases 🧪

*   **[Case 1] The Happy Path (Full Coverage):**
    *   Create a corrective quotation and keep all recommended items.
    *   **Expectation:** `offer_item_count` == `source_report_item_count`. `partial_coverage_note` is `null`. No warning shown in PDF.
*   **[Case 2] Removal Detection (Partial Coverage):**
    *   Remove one or more items from the quotation and save.
    *   **Expectation:** `offer_item_count` < `source_report_item_count`. `partial_coverage_note` is automatically populated with the warning message. PDF displays the **amber notice box**.
*   **[Case 3] Restoration (Re-adding Items):**
    *   Add back the removed items so the count matches the original report.
    *   **Expectation:** `partial_coverage_note` is automatically cleared (`null`). Warning disappears from PDF.
*   **[Case 4] Email Body Integration:**
    *   Trigger an initial price offer notification for a partial offer.
    *   **Expectation:** The email notification contains the partial coverage note to ensure the client is aware before opening the PDF.
