S29
Batch Profitability
FIFO-based batch profitability analysis with P&L by batch, vendor performance ranking, quality cost analysis, and expiry tracking.
Route/batch-profitability
Entry pathAnalytics nav > Batch Profitability
Detailed source
16-UC-BatchProfitability.md
UC-BATCH: Batch Profitability Analytics Page Use Cases
Page: BatchProfitabilityAnalytics.razor
Route: /batch-profitability
Menu Position: 19 (Analytics & Tracking > Batch Profitability Analytics)
Execution Note: /batch-profitability is the wrapper route for the shared analytics component. Use 20-UC-BatchProfitabilityAnalytics.md only as the alias/reference note for the direct analytics route.
Overview
FIFO-based batch profitability analysis with P&L by batch, vendor performance ranking, quality cost analysis, and expiry tracking.
Section: Page Header & Filter
| ID |
Section |
Action |
Expected Outcome |
Controls Affected |
| UC-BATCH-001 |
Header |
Load Batch Profitability page |
Page shows: (1) Green header "Batch Profitability Analytics - FIFO P&L Reports", (2) Refresh Analytics button, (3) Date filter section |
card-header bg-success, h5 title, Refresh Analytics btn, From Date input, To Date input, Apply Filter btn |
| UC-BATCH-002 |
Header |
No business selected |
Alert shows "Please select a business to view batch profitability analytics" |
alert alert-info |
| UC-BATCH-003 |
Filter |
Default date range |
From Date = 30 days ago, To Date = today |
From Date input, To Date input |
| UC-BATCH-004 |
Filter |
Change From Date |
Updates fromDate variable |
From Date input |
| UC-BATCH-005 |
Filter |
Change To Date |
Updates toDate variable |
To Date input |
| UC-BATCH-006 |
Filter |
Click Apply Filter |
Loading spinner shows "Calculating batch profitability...", then data reloads for new date range |
spinner-border, loading text, all summary cards, all tables |
| UC-BATCH-007 |
Header |
Click Refresh Analytics |
Same as Apply Filter - reloads all data |
All data sections |
Section: Loading State
| ID |
Section |
Action |
Expected Outcome |
Controls Affected |
| UC-BATCH-008 |
Loading |
During data load |
Green spinner visible, text "Calculating batch profitability..." |
spinner-border text-success, p text-muted |
| UC-BATCH-009 |
Loading |
Load completes |
Spinner hidden, summary cards and tables display |
All sections render |
Section: Summary Cards (4 cards)
| ID |
Section |
Action |
Expected Outcome |
Controls Affected |
| UC-BATCH-010 |
Total Revenue Card |
View card |
Blue card (bg-primary) showing: (1) "Total Revenue" title, (2) Amount in currency format, (3) Rupee icon |
card bg-primary, h5 "Total Revenue", h3 amount, fa-rupee-sign icon |
| UC-BATCH-011 |
Total FIFO Cost Card |
View card |
Yellow/orange card (bg-warning) showing: (1) "Total FIFO Cost" title, (2) Amount in currency format, (3) Layer icon |
card bg-warning, h5 "Total FIFO Cost", h3 amount, fa-layer-group icon |
| UC-BATCH-012 |
Gross Profit Card |
View card |
Green card (bg-success) showing: (1) "Gross Profit" title, (2) Amount = Revenue - Cost, (3) Chart icon |
card bg-success, h5 "Gross Profit", h3 amount, fa-chart-line icon |
| UC-BATCH-013 |
Profit Margin Card |
View card |
Blue card (bg-info) showing: (1) "Profit Margin" title, (2) Percentage with 1 decimal (X.X%), (3) Percentage icon |
card bg-info, h5 "Profit Margin", h3 percentage, fa-percentage icon |
| UC-BATCH-014 |
Summary Math |
Verify calculations |
Gross Profit = Total Revenue - Total FIFO Cost, Profit Margin = (Gross Profit / Revenue) × 100 |
Gross Profit h3, Profit Margin h3 |
Section: Batch P&L Analysis Table
| ID |
Section |
Action |
Expected Outcome |
Controls Affected |
| UC-BATCH-015 |
Table Header |
View section |
Card header shows "Batch-Level P&L Analysis (FIFO Costing)" with table icon |
card-header h6, fa-table icon |
| UC-BATCH-016 |
Table Empty |
No data for period |
Alert info "No batch profitability data available for the selected period" |
alert alert-info |
| UC-BATCH-017 |
Table Headers |
View column headers |
9 columns: Product, Batch, Vendor, Units Sold, Revenue, FIFO Cost, Gross Profit, Margin %, Quality Impact |
thead th × 9 |
| UC-BATCH-018 |
Product Column |
View product cell |
Shows: (1) Product name in bold, (2) SKU below in muted small text |
td strong ProductName, small text-muted SKU |
| UC-BATCH-019 |
Batch Column |
View batch cell |
Shows: (1) Batch number badge (bg-secondary), (2) Batch date below (dd/MM/yyyy format) |
badge bg-secondary BatchNumber, small text-muted date |
| UC-BATCH-020 |
Units Sold |
View column |
Center-aligned integer |
td text-center UnitsSold |
| UC-BATCH-021 |
Revenue |
View column |
Right-aligned currency (C2 format) |
td text-end Revenue |
| UC-BATCH-022 |
FIFO Cost |
View column |
Right-aligned currency (C2 format) |
td text-end FifoCost |
| UC-BATCH-023 |
Gross Profit Positive |
Profit >= 0 |
Green text (text-success), bold |
span text-success fw-bold |
| UC-BATCH-024 |
Gross Profit Negative |
Profit < 0 |
Red text (text-danger), bold |
span text-danger fw-bold |
| UC-BATCH-025 |
Margin % Positive |
Margin >= 0 |
Green text (text-success), bold |
span text-success fw-bold |
| UC-BATCH-026 |
Margin % Negative |
Margin < 0 |
Red text (text-danger), bold |
span text-danger fw-bold |
| UC-BATCH-027 |
Quality Impact Good |
DefectLoss = 0 |
Green checkmark (✓) |
span text-success ✓ |
| UC-BATCH-028 |
Quality Impact Bad |
DefectLoss > 0 |
Red badge with negative amount |
badge bg-danger -amount |
| UC-BATCH-029 |
Table Rows |
View data |
Shows max 20 rows ordered by Gross Profit descending |
tbody tr × 20 max |
Section: Vendor Performance Ranking
| ID |
Section |
Action |
Expected Outcome |
Controls Affected |
| UC-BATCH-030 |
Section Header |
View header |
"Vendor Performance Ranking" with trophy icon |
card-header h6, fa-trophy icon |
| UC-BATCH-031 |
Empty State |
No vendor data |
Alert "No vendor performance data available" |
alert alert-info |
| UC-BATCH-032 |
Vendor Item |
View vendor row |
List item showing: (1) Vendor name h6, (2) Revenue + Batch count small text, (3) Profit margin badge (bg-success), (4) Total profit small text |
list-group-item, h6 VendorName, small Revenue/Batches, badge bg-success margin%, small TotalProfit |
| UC-BATCH-033 |
Vendor List |
View list |
Shows max 10 vendors ordered by profit margin desc |
list-group with 10 items max |
Section: Quality Cost Analysis
| ID |
Section |
Action |
Expected Outcome |
Controls Affected |
| UC-BATCH-034 |
Section Header |
View header |
"Quality Cost Analysis" with warning triangle icon |
card-header h6, fa-exclamation-triangle icon |
| UC-BATCH-035 |
Defect Loss Box |
View total defect |
Left box (bg-light): Red h4 amount "Total Defect Loss" |
h4 text-danger DefectLoss, small text-muted label |
| UC-BATCH-036 |
Expiry Loss Box |
View expiry loss |
Right box (bg-light): Yellow h4 amount "Expiry/Stale Loss" |
h4 text-warning ExpiryLoss, small text-muted label |
| UC-BATCH-037 |
Quality Issues List |
View top issues |
Shows "Top Quality Issues:" header, then up to 5 items with product name, issue type, and red negative impact amount |
h6 header, div items × 5, small product-issue, span text-danger -amount |
Section: Expiry & Stale Inventory Tracking
| ID |
Section |
Action |
Expected Outcome |
Controls Affected |
| UC-BATCH-038 |
Section Header |
View header |
"Expiry & Stale Inventory Tracking" with clock icon |
card-header h6, fa-clock icon |
| UC-BATCH-039 |
No Issues |
All inventory good |
Green success alert "No expiry or stale inventory issues detected" |
alert alert-success |
| UC-BATCH-040 |
Table Headers |
View columns |
7 columns: Product, Batch, Age (Days), Remaining Qty, Book Value, Estimated Loss, Status |
thead th × 7 |
| UC-BATCH-041 |
Age Column |
View age |
Center-aligned integer (days old) |
td text-center AgeDays |
| UC-BATCH-042 |
Remaining Qty |
View quantity |
Center-aligned integer |
td text-center RemainingQuantity |
| UC-BATCH-043 |
Book Value |
View value |
Right-aligned currency (C2 format) |
td text-end BookValue |
| UC-BATCH-044 |
Estimated Loss |
View loss |
Right-aligned red bold currency |
span text-danger fw-bold EstimatedLoss |
| UC-BATCH-045 |
Status Critical |
Age > 365 days |
Red badge "Critical" |
badge bg-danger "Critical" |
| UC-BATCH-046 |
Status Warning |
Age 270-365 days |
Yellow badge "Warning" |
badge bg-warning "Warning" |
| UC-BATCH-047 |
Status Caution |
Age 180-270 days |
(implied - not shown in code but logical) |
badge "Caution" |
| UC-BATCH-048 |
Table Rows |
View data |
Shows max 10 rows where Status != "Good", ordered by EstimatedLoss desc |
tbody tr × 10 max |
Section: Data Validation Requirements
| ID |
Validation |
Requirement |
| UC-BATCH-049 |
Loading State |
Page MUST complete loading and show data |
| UC-BATCH-050 |
Summary Cards |
All 4 summary cards must show calculated values when batch data exists |
| UC-BATCH-051 |
Table Data |
Batch table must show rows when InventoryConsumptions exist for period |
| UC-BATCH-052 |
Currency Format |
All amounts must display in currency format (uses .ToString("C")) |
Total Use Cases: 52