# Seller Tool - Price Range Exception Filtering

## Overview
The Seller Tool's Sales Comparison section now filters sales data to show only "complete" sales by default. This ensures price range calculations are based on standard, manufacturer-condition models in their original boxes with COA.

## What is a "Complete Sale"?
A complete sale is defined as:
- **Model**: Present and intact
- **Box**: Original, included
- **COA**: Present and unchanged from manufacturer condition
- **Condition**: Factory original, no modifications

## Exceptions Excluded
The following sale types are excluded from price range calculations as they represent exceptions to the standard condition:

1. **COA Only** - No model included
2. **Box Only** - No model included  
3. **Brochure Only** - Missing model and/or box
4. **Has Brochure** - Non-standard inclusion
5. **Signed** - Modified/personalized
6. **No Box** - Missing original packaging
7. **No COA** - Missing Certificate of Authenticity
8. **Damaged** - Not factory condition
9. **Modified** - Altered from original

## Exceptions Allowed
Despite being variations from standard condition, these TWO exceptions ARE included in price range calculations:

1. **Best Offer Accepted** - Represents standard negotiated sales
2. **Decals** - Common factory variations, doesn't affect standard condition

## Implementation

### Configuration
The exception filtering uses the `config/fields_exclude.php` file, which contains the default filters applied to all sales data:

```php
// config/fields_exclude.php
return [
    ['deleted', 0],
    ['is_brochure_only', 0],
    ['is_signed', 0],
    ['has_no_box', 0],
    ['has_no_coa', 0],
    ['is_damaged', 0],
    ['is_modified', 0],
    ['is_box_only', 0],
    ['has_coa_only', 0],
];
```

### Code Changes
File: `app/Http/Controllers/User/SellerToolController.php`

The `getSalesComparison()` method now applies the `fields_exclude` filter:

```php
$fieldsExclude = config('fields_exclude');

$allSales = CleanSale::where('product_id', $productId)
    ->where(function ($query) {
        $query->whereNull('deleted')
            ->orWhere('deleted', 0);
    })
    ->where('sale_price', '>', 0)
    // Apply the fields_exclude filters - only include complete sales
    ->where($fieldsExclude)
    ->select('sale_price', 'platform', 'sale_date', 'condition', 'postage', 'accepted', 'has_decals')
    ->orderBy('sale_date', 'desc')
    ->get();
```

## Database Fields Filtered
The following fields from `clean_sales` table are checked (must equal 0/false for inclusion):

- `is_brochure_only`
- `is_signed`
- `has_no_box`
- `has_no_coa`
- `is_damaged`
- `is_modified`
- `is_box_only`
- `has_coa_only`

## Sales Comparison Display
The Sales Comparison section shows:
- **eBay Sales (All Time)**: Complete sales only, all platforms combined
- **Private Sales (All Time)**: Complete sales only, all platforms combined
- **Statistics**: Average, Min, Max, Median prices for complete sales only
- **Date Range**: First and last sale dates in the filtered dataset

## Example
If a product has 95 total sales, but:
- 68 are complete sales
- 27 are exceptions (missing COA, no box, etc.)

The Sales Comparison will show data for only the 68 complete sales, providing a more accurate price range reflecting true market conditions for standard products.

## Future Modifications
To adjust which exceptions are excluded:
1. Edit `config/fields_exclude.php` to add/remove filters
2. The Sales Comparison will automatically reflect the updated filters
3. No changes to controller code are needed

To add new allowed exceptions (like "Best Offer Accepted"):
1. Add them to the allowed exceptions list in this documentation
2. Ensure the corresponding database field is selected in the query
3. No additional code changes needed - the logic remains the same
