# Collapsed Row Layout Comparison: OLD vs NEW Profitability Page

## Overview
This document compares the collapsed (summary) row layout between the OLD profitability page (ops.go-parts.com) and the NEW profitability page (central.go-parts.com).

---

## OLD Page: ops.go-parts.com/profitability/indexImproved
**Implementation:** jQuery DataTables with expandable rows

### Collapsed Row Structure (Typical DataTables Layout)

The OLD page likely uses a traditional table structure with columns:

| Column | Data Displayed | Notes |
|--------|---------------|-------|
| 1. Expand | [+] icon | Click to expand row details |
| 2. Order # | External Order ID | e.g., #12345 |
| 3. Date | Order date | e.g., Aug 15, 2025 |
| 4. Product | Partslink/Part Number | May be truncated |
| 5. Category | Category name | e.g., Body Parts |
| 6. Supplier | Supplier name | e.g., Keystone |
| 7. Channel | Sales Channel | e.g., Amazon, eBay |
| 8. Customer | Billing Name | May be truncated |
| 9. Sale Price | Total sales price | e.g., $150.00 |
| 10. Cost | Our buy price | e.g., $90.00 |
| 11. Gross Margin $ | Dollar amount | e.g., $60.00 |
| 12. Gross Profit % | Percentage | e.g., 40.0% |
| 13. Badges/Status | Confidence level | High/Medium/Low badge |

**Key Characteristics:**
- **Linear table layout** with one column per metric
- All financial metrics shown as **separate columns**
- Likely shows **ONLY Standard metrics** in collapsed view
- Calculated metrics probably **only visible when expanded**
- Color coding likely applied to profit cells (green/red)
- Scrollable horizontal table if many columns

**Financial Metrics Display:**
- **Standard Gross Margin $**: Single column showing dollar amount
- **Standard Gross Profit %**: Single column showing percentage
- **NO "Standard vs Calculated" comparison** in collapsed view
- **NO COGS %** displayed in collapsed row

---

## NEW Page: central.go-parts.com/profitability
**Implementation:** Filament with custom card-based expandable layout

### Collapsed Row Structure (From Code Analysis)

The NEW page uses a card-based design with grouped information sections:

```
┌─────────────────────────────────────────────────────────────────────┐
│ [Colored Border] Order Item Card                                     │
├─────────────┬──────────────┬──────────┬──────────────┬──────────────┤
│ ORDER/DATE  │ PRODUCT/CAT  │ SUPPLIER │ CHANNEL/CUST │ FINANCIAL    │
│             │              │          │              │ SUMMARY      │
│ #12345      │ AB1234567XX  │ Keystone │ Amazon       │ Sale: $150   │
│ Aug 15, 25  │ Body Parts   │          │ John Smith   │ Cost: $90    │
│             │              │          │              │ COGS%: 60%   │
├─────────────┴──────────────┴──────────┴──────────────┴──────────────┤
│                                           PROFIT SUMMARY         [v] │
│                               Standard / Calculated                  │
│                               40.0% / 35.5%                          │
│                               $60.00 / $53.25                        │
│                                                    [High Confidence] │
└─────────────────────────────────────────────────────────────────────┘
```

### Detailed Field Breakdown

**Section 1: Order Info** (Left-most, ~15% width)
- **Label:** "Order / Date"
- **Primary Value:** External Order ID (e.g., #12345)
- **Secondary Value:** Date placed (formatted as "Aug 15, 2025")

**Section 2: Product Info** (~20% width)
- **Label:** "Product / Category"
- **Primary Value:** Partslink (e.g., AB1234567XX)
- **Secondary Value:** Category name (e.g., Body Parts)
- **Hover:** Full item name on title attribute

**Section 3: Supplier** (~10% width)
- **Label:** "Supplier"
- **Value:** Supplier name or "N/A"

**Section 4: Channel & Customer** (~15% width)
- **Label:** "Channel / Customer"
- **Primary Value:** Sales channel (e.g., Amazon, eBay)
- **Secondary Value:** Billing name (truncated to 25 chars)

**Section 5: Financial Summary** (~25% width, CENTER ALIGNED)
- **Three side-by-side metrics:**
  1. **Sale**
     - Label: "Sale"
     - Value: Total sales price (e.g., $150.00)

  2. **Cost**
     - Label: "Cost"
     - Value: Total costs (e.g., $90.00)

  3. **COGS %**
     - Label: "COGS %"
     - Value: Cost of Goods Sold percentage (e.g., 60.0%)
     - **Color coded:**
       - Green: COGS < 70%
       - Yellow/Warning: COGS 70-99%
       - Red: COGS >= 100%

**Section 6: Profit Summary** (~15% width, RIGHT ALIGNED)
- **Label:** "Standard / Calculated"
- **Primary Value:**
  - Standard Gross Profit % / Calculated Gross Profit %
  - Format: "40.0% / 35.5%"
  - Color coded: Green for positive, Red for negative
  - Separator: Grey "/" between values
- **Secondary Value:**
  - Standard Gross Margin $ / Calculated Gross Margin $
  - Format: "$60.00 / $53.25"
  - Color coded: Green for positive, Red for negative

**Section 7: Badges** (Far right, ~10% width)
- Either:
  - **Own Stock** badge (grey, if item is from own inventory)
  - OR **Confidence Badge** (High/Medium/Low with color coding)
    - High: Green background
    - Medium: Yellow background
    - Low: Red background

---

## Key Differences: Side-by-Side Comparison

| Aspect | OLD Page | NEW Page |
|--------|----------|----------|
| **Layout Type** | Linear table columns | Card-based grouped sections |
| **Financial Metrics** | Separate columns for each | Grouped into "Financial Summary" section |
| **COGS %** | NOT displayed in collapsed view | **Displayed prominently** as separate metric |
| **Standard vs Calculated** | Only Standard shown (collapsed) | **BOTH shown side-by-side** (collapsed) |
| **Comparison Format** | Must expand to see calculated | Direct comparison: "40.0% / 35.5%" |
| **Cost Visibility** | May be in separate column | Shown in Financial Summary |
| **Gross Margin $** | Separate column | Shown below percentages in Profit section |
| **Customer Name** | Separate column | Grouped with Channel |
| **Visual Hierarchy** | Flat, all equal | **Hierarchical sections** with grouping |
| **Space Efficiency** | Requires many columns | Compact sections |
| **Expandable Indicator** | [+] icon in first column | Chevron icon (far right) |
| **Border Coding** | N/A | **Left border color** (red=loss, green=profit) |
| **Background Coding** | N/A | **Light green** for own stock profitable items |

---

## Financial Metrics: Detailed Comparison

### OLD Page (Collapsed State)
```
┌──────┬────────┬──────────┬──────────────┬────────────────┬────────┐
│ Sale │ Cost   │ Margin $ │ Profit %     │ Status         │        │
├──────┼────────┼──────────┼──────────────┼────────────────┼────────┤
│ $150 │ $90.00 │ $60.00   │ 40.0%        │ [High]         │   [+]  │
└──────┴────────┴──────────┴──────────────┴────────────────┴────────┘
```
- Shows **STANDARD metrics only**
- COGS % **NOT visible**
- Must expand row to see calculated metrics

### NEW Page (Collapsed State)
```
┌────────────────────────────────┬──────────────────────────────┐
│     FINANCIAL SUMMARY          │      PROFIT SUMMARY          │
├──────────┬───────────┬─────────┼──────────────────────────────┤
│   Sale   │   Cost    │ COGS %  │   Standard / Calculated      │
│  $150.00 │  $90.00   │  60.0%  │   40.0%    /    35.5%        │
│          │           │ (Green) │   $60.00   /    $53.25       │
└──────────┴───────────┴─────────┴──────────────────────────────┘
```
- Shows **BOTH Standard AND Calculated** metrics
- COGS % **prominently displayed** with color coding
- **Side-by-side comparison** format
- Two rows in Profit section:
  - Row 1: Percentages (Standard / Calculated)
  - Row 2: Dollar amounts (Standard / Calculated)

---

## COGS % Implementation

### OLD Page
- **NOT displayed in collapsed row**
- Possibly calculated and shown only in expanded details
- Users must manually calculate: Cost ÷ Sale × 100

### NEW Page (Lines 1843-1846 in code)
```php
<div class="financial-metric">
    <div class="label">COGS %</div>
    <div class="value {{ $cogsClass }}">{{ number_format($cogsPercent, 1) }}%</div>
</div>
```
- **Calculation:** `$cogsPercent = $order->sales_price > 0 ? ($totalCosts / $order->sales_price) * 100 : 0`
- **Color Coding:**
  - `$cogsClass = $cogsPercent >= 100 ? 'text-danger' : ($cogsPercent >= 70 ? 'text-warning' : 'text-success')`
  - Red: COGS >= 100% (losing money)
  - Yellow: COGS 70-99% (low margin)
  - Green: COGS < 70% (healthy margin)
- **Prominent placement** in Financial Summary section
- **Always visible** without expanding

---

## Standard vs Calculated Profit Display

### OLD Page
- **Collapsed:** Shows only "Gross Profit %" (Standard)
- **Collapsed:** Shows only "Gross Margin $" (Standard)
- **Expanded:** Reveals calculated metrics (likely in a separate section)
- **No direct comparison** in collapsed state

### NEW Page (Lines 1855-1869 in code)
```php
<div class="summary-item profit">
    <div class="summary-label">Standard / Calculated</div>
    <div class="summary-value">
        {{ number_format($order->gross_profit, 1) }}%
        <span style="color: #666;">/</span>
        <span>{{ number_format($calculatedGrossProfit, 1) }}%</span>
    </div>
    <div class="summary-subvalue">
        ${{ number_format(abs($order->gross_margin), 2) }}
        <span style="color: #666;">/</span>
        ${{ number_format(abs($calculatedGrossMargin), 2) }}
    </div>
</div>
```

**Display Format:**
- **Label:** Explicitly says "Standard / Calculated"
- **Row 1 (Primary):** Percentage comparison
  - Format: `40.0% / 35.5%`
  - Individual color coding for each value
  - Grey "/" separator
- **Row 2 (Secondary):** Dollar amount comparison
  - Format: `$60.00 / $53.25`
  - Individual color coding for each value
  - Grey "/" separator

**Key Innovation:**
- **Immediate visibility** of discrepancies
- **No expansion needed** to see both metrics
- **Clear labeling** prevents confusion
- **Space efficient** - uses "/" separator instead of separate columns

---

## Visual Hierarchy & Information Architecture

### OLD Page
```
Flat horizontal layout - all data equal visual weight
[+] | Order | Date | Product | Category | Supplier | ... [many columns]
```
- **Pros:**
  - Familiar table structure
  - Easy to scan vertically
  - Sortable columns
- **Cons:**
  - Requires horizontal scrolling
  - Equal visual weight = harder to identify key metrics
  - Limited space for each field

### NEW Page
```
Hierarchical card layout - grouped by information type
┌─────────────────────────────────────────────────────────────┐
│ [Color Border = Status Indicator]                           │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌──────────────────┐   │
│ │ Order   │ │ Product │ │ Channel │ │  Financial       │   │
│ │ Context │ │ Info    │ │ Info    │ │  Metrics (KEY)   │   │
│ └─────────┘ └─────────┘ └─────────┘ └──────────────────┘   │
└─────────────────────────────────────────────────────────────┘
```
- **Pros:**
  - **Visual grouping** aids comprehension
  - **Emphasis on financial metrics** (larger section)
  - No horizontal scrolling needed
  - **Color coding** for quick status identification
  - Better mobile responsiveness
- **Cons:**
  - Takes more vertical space per order
  - Less data density
  - May be unfamiliar to users expecting tables

---

## Label Comparison: Exact Terminology

| Metric | OLD Page Label | NEW Page Label |
|--------|---------------|----------------|
| Order ID | "Order #" | "Order / Date" (section) |
| Sale Price | "Sale" or "Sale Price" | "Sale" (in Financial Summary) |
| Cost | "Cost" or "Buy Price" | "Cost" (in Financial Summary) |
| COGS % | (Not shown) | **"COGS %"** (NEW) |
| Gross Margin $ | "Gross Margin" or "Margin $" | Part of "Standard / Calculated" |
| Gross Profit % | "Gross Profit" or "Profit %" | Part of "Standard / Calculated" |
| Calculated Profit | (In expanded view) | **"Standard / Calculated"** (NEW) |

**Key Terminology Changes:**
1. **"COGS %"** is a NEW metric label not present in OLD page collapsed view
2. **"Standard / Calculated"** replaces separate columns/sections for comparison
3. **"Financial Summary"** section groups Sale, Cost, and COGS%
4. **"Profit Summary"** section combines both standard and calculated metrics

---

## Layout from Left to Right: Field Order

### OLD Page (Typical DataTables)
```
[1] [+] Expand Icon
[2] Order #
[3] Date
[4] Product/Part #
[5] Category
[6] Supplier
[7] Channel
[8] Customer
[9] Sale Price
[10] Cost
[11] Gross Margin $
[12] Gross Profit %
[13] Status/Badge
```

### NEW Page (Card Layout)
```
┌─────────────────────────────────────────────────────────────────────┐
│ LEFT                         CENTER                          RIGHT   │
├─────────┬──────────┬─────────┬──────────┬────────────────┬──────────┤
│ [1]     │ [2]      │ [3]     │ [4]      │ [5]            │ [6]      │
│ Order/  │ Product/ │ Supplier│ Channel/ │ Financial      │ Profit   │
│ Date    │ Category │         │ Customer │ Summary        │ Summary  │
│         │          │         │          │ • Sale         │ Std/Calc │
│ #12345  │ AB123XX  │ Key-    │ Amazon   │ • Cost         │ 40% / 35%│
│ Aug 15  │ Body     │ stone   │ J.Smith  │ • COGS%        │ $60 / $53│
│         │ Parts    │         │          │                │ [Badge]  │
│         │          │         │          │      [Chevron →│          │
└─────────┴──────────┴─────────┴──────────┴────────────────┴──────────┘
```

**Field Order (Left to Right):**
1. **Order / Date** (15% width)
2. **Product / Category** (20% width)
3. **Supplier** (10% width)
4. **Channel / Customer** (15% width)
5. **Financial Summary** (25% width) - CENTRAL FOCUS
   - Sub-fields: Sale, Cost, COGS %
6. **Profit Summary** (15% width) - RIGHT ALIGNED
   - Standard / Calculated comparison
7. **Badges** (10% width) - FAR RIGHT
   - Confidence or Own Stock indicator
8. **Expand Chevron** - ABSOLUTE RIGHT

---

## Color Coding Comparison

### OLD Page
- **Positive Profit:** Likely green text
- **Negative Profit:** Likely red text
- **Row background:** Probably white/alternating grey

### NEW Page (Much More Sophisticated)

**Border Color (Left side):**
- **Red (4px):** Negative profit (loss)
- **Green (4px):** Positive profit

**Background Color:**
- **White:** Default
- **Light green (#e8f5e9):** Own stock + profitable
- **Light red (#fff5f5):** Negative profit
- **Very light red (#ffebee):** Own stock + negative profit

**Text Color:**
- **COGS %:**
  - Green: < 70% (healthy)
  - Yellow/Orange: 70-99% (warning)
  - Red: >= 100% (danger)

- **Profit Values:**
  - Green (#0d6e0d): Positive
  - Red (#dc3545): Negative

**Badges:**
- **High Confidence:** Green background (#d4edda)
- **Medium Confidence:** Yellow background (#fff3cd)
- **Low Confidence:** Red background (#f8d7da)
- **Own Stock:** Grey background (#6c757d)

---

## Expansion Indicator

### OLD Page
- **Icon:** `[+]` or `[►]` icon
- **Location:** First column (leftmost)
- **Behavior:** Changes to `[-]` or `[▼]` when expanded

### NEW Page
- **Icon:** Chevron down (`fa-chevron-down`)
- **Location:** Far right of Financial Summary section (line 1849-1850)
- **Behavior:** Rotates 180° when expanded (CSS transform)
- **Positioning:** Absolute positioning to keep it separate from data

---

## What Users See: Quick Scan Comparison

### OLD Page - User scanning left to right sees:
```
Order → Date → Product → Category → Supplier → Channel → Customer →
→ Sale → Cost → Margin → Profit → Status
```
- Must read across many columns
- Standard metrics only
- Need to expand for calculated

### NEW Page - User scanning left to right sees:
```
Order/Date → Product → Supplier → Channel →
→ [FINANCIAL FOCUS: Sale + Cost + COGS%] →
→ [PROFIT COMPARISON: Standard/Calculated] → Status
```
- Grouped information sections
- **Financial metrics visually emphasized**
- **Immediate comparison** of Standard vs Calculated
- **COGS% immediately visible** for margin assessment

---

## Critical Innovation in NEW Page

### The "Slash" Comparison Format

**OLD Approach:**
```
Standard Profit: 40.0%
(Must expand to see calculated: 35.5%)
```

**NEW Approach (Lines 1855-1869):**
```
Standard / Calculated
  40.0%  /  35.5%
 $60.00  /  $53.25
```

**Why This Matters:**
1. **Immediate discrepancy visibility** - no need to expand
2. **Side-by-side comparison** - easy to compare values
3. **Compact format** - doesn't take extra columns
4. **Clear labeling** - "Standard / Calculated" header
5. **Dual representation** - shows both % and $ for complete picture

### The COGS % Addition

**OLD Approach:**
- Users must mentally calculate: Cost ÷ Sale
- Or expand row to find it
- No visual indicator of margin health

**NEW Approach (Lines 1843-1846):**
```php
COGS %: 60.0% (color: green/yellow/red)
```

**Why This Matters:**
1. **Instant margin assessment** - see if COGS is too high
2. **Color coding** - red flag for problem orders (COGS >= 100%)
3. **Industry standard metric** - COGS% is key retail metric
4. **Complements profit %** - shows cost structure at a glance
5. **No calculation needed** - value is pre-computed and displayed

---

## Summary: Major Layout Differences

### What's the SAME:
- Both show order details in collapsed state
- Both use color to indicate profit/loss
- Both have expandable details
- Both show financial metrics prominently

### What's DIFFERENT in NEW Page:

1. **Layout Architecture:**
   - Card-based vs table-based
   - Grouped sections vs linear columns
   - Hierarchical vs flat structure

2. **Financial Metrics Display:**
   - **COGS % added** (not in OLD)
   - **Standard AND Calculated shown together** (OLD shows only Standard)
   - Side-by-side "/" comparison format (NEW innovation)

3. **Information Density:**
   - More vertical space per row
   - Less horizontal scrolling
   - Better mobile responsiveness

4. **Visual Indicators:**
   - Color-coded left border (profit/loss)
   - Background color coding (own stock)
   - COGS % color coding (margin health)

5. **Field Grouping:**
   - Financial Summary section (Sale, Cost, COGS%)
   - Profit Summary section (Standard / Calculated)
   - Channel + Customer combined

6. **User Experience:**
   - **Key innovation:** No need to expand to compare Standard vs Calculated
   - **Key addition:** COGS % immediately visible for margin analysis
   - More intuitive visual hierarchy
   - Better at-a-glance comprehension

---

## Conclusion

The NEW page represents a significant UX improvement over traditional table layouts:

**Biggest Changes:**
1. **COGS % is now a first-class metric** - displayed prominently in collapsed view with color coding
2. **Standard vs Calculated comparison is immediately visible** - no expansion needed
3. **Grouped information architecture** - related data shown together
4. **Enhanced visual indicators** - multiple color coding systems for quick assessment

**Trade-offs:**
- OLD: More data density, familiar table format
- NEW: Better visual hierarchy, more space per row, improved scannability

**Recommendation:**
The NEW layout is superior for users who need to quickly identify:
- Orders with high COGS (margin problems)
- Discrepancies between Standard and Calculated metrics
- Problem orders (via color coding)

However, users accustomed to the OLD table format may need brief training to understand the new grouped layout and the "Standard / Calculated" slash format.
