# Seller Tool Documentation

## Overview
The Seller Tool helps diecast collectors and sellers determine the optimal selling strategy between eBay and private sales by calculating net revenue after fees and providing market-based feasibility assessments.

## Features

### 1. Revenue Calculator
- **From Asking Price**: Calculate net revenue from a proposed eBay listing price
- **From Target Net Revenue**: Calculate the required eBay asking price to achieve a specific net revenue target

### 2. eBay Fee Calculation
- Current eBay fee rate: 13.4% plus $0.30 fixed fee (configurable in controller)
- Fees applied to total transaction value (including postage)
- Support for free postage scenarios where seller absorbs the cost

### 3. Postage Handling
- Option to offer free postage to buyers
- Automatic calculation of net revenue impact when seller pays postage
- Consideration of eBay fees on postage charges

### 4. Product-Specific Analysis
- Product search with autocomplete functionality
- DDP (Diecast Detective Price) comparison
- Recent sales history analysis (eBay vs Private sales)

### 5. Feasibility Assessment
Based on current DDP and asking price:
- **High Feasibility (Green)**: Asking price is 5%+ below DDP
- **Medium Feasibility (Yellow)**: Asking price is within ±5% of DDP  
- **Low Feasibility (Red)**: Asking price is 5%+ above DDP

### 6. Sales Platform Comparison
- Historical sales data comparison between eBay and private sales
- Statistical analysis including averages, medians, and price ranges
- Platform performance percentage comparisons

## Calculation Examples

### Example 1: From Asking Price
**Input:**
- Asking Price: $500
- Free Postage: Yes
- Postage Cost: $25

**Calculation:**
- Gross Revenue: $500
- eBay Fees (13.4% + $0.30): $68
- Postage Cost: $25
- **Net Revenue: $407**

### Example 2: From Target Net Revenue
**Input:**
- Target Net Revenue: $350
- Postage Cost: $30
- Free Postage: No (buyer pays)

**Calculation:**
- Required Asking Price: $350 ÷ (1 - 0.136) - $30 = **$375.12**
- Private Sale Minimum: $350 × 1.05 = **$367.50**

## Database Integration

### Data Sources
- **CleanSale Model**: Historical sales data with platform identification
- **DiecastPrice Model**: Current DDP values for feasibility assessment
- **Product Model**: Product information for search and identification

### Platform Identification
- eBay sales: `platform = 'ebay'`
- Private sales: `platform IN ('private', 'auction', 'other')`

## Usage Workflow

1. **Optional Product Selection**: Search and select a specific product for enhanced analysis
2. **Choose Calculation Mode**: 
   - From asking price → net revenue
   - From target net revenue → asking price
3. **Enter Values**: Input prices and postage information
4. **Configure Postage**: Choose between buyer-pays or free postage options
5. **Review Results**: Analyze calculations, feasibility, and historical comparisons

## Technical Implementation

### Controller: `SellerToolController`
- `index()`: Display main interface
- `calculateFromAskingPrice()`: Revenue calculation from asking price
- `calculateFromNetRevenue()`: Asking price calculation from target revenue
- `searchProducts()`: Product autocomplete search
- `getSalesComparison()`: Historical sales analysis
- `assessFeasibility()`: DDP-based feasibility assessment

### Routes
- `GET /user/dashboard/seller-tool` - Main interface
- `POST /user/dashboard/seller-tool/calculate-from-asking-price` - Calculate net revenue
- `POST /user/dashboard/seller-tool/calculate-from-net-revenue` - Calculate asking price
- `GET /user/dashboard/seller-tool/search-products` - Product search
- `GET /user/dashboard/seller-tool/sales-comparison` - Sales comparison data

### Frontend Features
- Responsive design with Tailwind CSS
- Select2 integration for product search
- AJAX-powered calculations and data loading
- Dynamic result display with color-coded feasibility indicators

## Configuration

### eBay Fee Rate
The eBay fee rate is configurable in the `SellerToolController`. Currently set to 13.4% with a fixed $0.30 fee but can be easily adjusted:

```php
// eBay fee rate (13.4% + $0.30)
$ebayFeeRate = 0.136;
```

### Feasibility Thresholds
Feasibility assessment thresholds can be modified in the `assessFeasibility()` method:

```php
if ($percentageDiff <= -5) {
    $level = 'high';  // 5%+ below DDP
} elseif ($percentageDiff >= -5 && $percentageDiff <= 5) {
    $level = 'medium'; // Within ±5% of DDP
} else {
    $level = 'low';    // 5%+ above DDP
}
```

## Access Control
The Seller Tool is restricted to premium users with valid subscriptions:
```blade
@if (Auth::check() && Auth::user()->hasValidSubscription())
```
