S08
FIFO Sales
FIFO Sales supports FIFO costing review, stock-consumption visibility, filters and summaries.
Route/fifo-sales
Entry pathMain nav > FIFO Sales
Detailed source
07-UC-FifoSales.md
FIFO Sales Use Cases (FifoSales.razor)
| ID |
Section |
Action |
Expected Outcome |
Controls |
| UC-FIFO-001 |
Page Load |
Navigate to /fifo-sales |
Loads FIFO sales dashboard |
Container |
| UC-FIFO-002 |
Auth |
CustomerOperator required |
Authorized access |
Authorize |
| UC-FIFO-003 |
Header |
New FIFO Sale button |
ShowNewSaleModal opens modal |
Button primary |
| UC-FIFO-004 |
Loading |
Data loading |
Shows spinner with text |
Spinner |
| UC-FIFO-005 |
Summary Card |
Total Sales |
₹N2 totalSalesAmount |
Card primary |
| UC-FIFO-006 |
Summary Card |
Total Profit |
₹N2 totalProfit |
Card success |
| UC-FIFO-007 |
Summary Card |
Avg Profit Margin |
N1% averageProfitMargin |
Card info |
| UC-FIFO-008 |
Summary Card |
Sales Count |
salesAnalysis.Count |
Card warning |
| UC-FIFO-009 |
Table |
Date column |
dd/MM/yyyy HH:mm format |
td small |
| UC-FIFO-010 |
Table |
Product column |
Bold product name |
td strong |
| UC-FIFO-011 |
Table |
Quantity |
Badge bg-primary |
Badge |
| UC-FIFO-012 |
Table |
Batch Info |
BatchNumber + Date stacked |
td flex-column |
| UC-FIFO-013 |
Table |
Cost/Unit |
₹N2 text-success |
Span |
| UC-FIFO-014 |
Table |
Sale Price |
₹N2 text-primary |
Span |
| UC-FIFO-015 |
Table |
Profit/Unit |
₹N2 conditional color |
Span |
| UC-FIFO-016 |
Table |
Total Profit |
₹N2 conditional color |
Span |
| UC-FIFO-017 |
Table |
Margin % |
N1% conditional color |
Span |
| UC-FIFO-018 |
Empty State |
No sales |
Icon + message + create btn |
Div text-center |
| UC-FIFO-019 |
Table Limit |
Display |
Take(20) records |
Take |
| UC-FIFO-020 |
Modal |
Show modal |
showModal JS call |
Modal |
| UC-FIFO-021 |
Modal |
Customer select |
customers dropdown |
Select |
| UC-FIFO-022 |
Modal |
Product select |
products dropdown |
Select |
| UC-FIFO-023 |
Modal |
Quantity input |
saleQuantity min=1 |
Input number |
| UC-FIFO-024 |
Modal |
Unit Selling Price |
unitSellingPrice step=0.01 |
Input number |
| UC-FIFO-025 |
Batch Preview |
No product selected |
Info icon + message |
Div text-center |
| UC-FIFO-026 |
Batch Preview |
Invalid preview |
Alert danger with error |
Alert danger |
| UC-FIFO-027 |
Batch Preview |
Valid preview |
Summary + batch cards + profit |
Card |
| UC-FIFO-028 |
Preview Summary |
Requested qty |
RequestedQuantity |
Strong text-primary |
| UC-FIFO-029 |
Preview Summary |
Available qty |
TotalInventoryAvailable |
Strong text-success |
| UC-FIFO-030 |
Preview Summary |
Avg Cost |
₹N2 WeightedAverageCost |
Strong text-info |
| UC-FIFO-031 |
Batch Card |
Batch number |
Strong header |
Card header |
| UC-FIFO-032 |
Batch Card |
Batch date |
dd/MM/yyyy format |
Small text-muted |
| UC-FIFO-033 |
Batch Card |
Consumed qty |
Badge bg-primary |
Badge |
| UC-FIFO-034 |
Batch Card |
Unit Cost |
₹N2 text-success |
Strong |
| UC-FIFO-035 |
Batch Card |
Total Cost |
₹N2 text-success |
Strong |
| UC-FIFO-036 |
Profit Analysis |
Total COGS |
₹N2 text-success |
Strong |
| UC-FIFO-037 |
Profit Analysis |
Revenue |
₹N2 text-primary |
Strong |
| UC-FIFO-038 |
Profit Analysis |
Profit |
₹N2 conditional color |
Strong |
| UC-FIFO-039 |
Profit Analysis |
Margin % |
N1% conditional color |
Strong |
| UC-FIFO-040 |
CanProcessSale |
Validation |
All fields + valid preview |
Boolean |
| UC-FIFO-041 |
Process Sale |
Submit |
ProcessFifoSale service call |
Button primary |
| UC-FIFO-042 |
Process Sale |
Success |
hideModal + toast + reload |
JS interop |
| UC-FIFO-043 |
Process Sale |
Error |
Toast with error message |
JS interop |
| UC-FIFO-044 |
Product Change |
OnProductChanged |
Sets price + UpdateBatchPreview |
Event |
| UC-FIFO-045 |
Quantity Change |
OnQuantityChanged |
UpdateBatchPreview |
Event |
| UC-FIFO-046 |
Calculate Profit |
CalculateProfit |
COGS/Revenue/Profit/Margin |
Method |
| UC-FIFO-047 |
Modal Cancel |
Click Cancel |
data-bs-dismiss="modal" |
Button secondary |
| UC-FIFO-048 |
Data test |
New sale btn |
data-test="new-fifo-sale-btn" |
Attribute |
| UC-FIFO-049 |
Data test |
Table |
data-test="fifo-sales-table" |
Attribute |
| UC-FIFO-050 |
Data test |
Modal |
data-test="fifo-sale-modal" |
Attribute |
| UC-FIFO-051 |
Data test |
Customer select |
data-test="customer-select" |
Attribute |
| UC-FIFO-052 |
Data test |
Product select |
data-test="product-select" |
Attribute |
| UC-FIFO-053 |
Data test |
Quantity input |
data-test="quantity-input" |
Attribute |
| UC-FIFO-054 |
Data test |
Price input |
data-test="price-input" |
Attribute |
| UC-FIFO-055 |
Data test |
Process btn |
data-test="process-sale-btn" |
Attribute |
Unit Test Coverage
Test Project: Rabbit.Accounts.Tests
Test Location: FifoSales/
Total Tests: 42
Status: ✅ All Passing
Unit Test Classes
| Test Class |
Tests |
Description |
FifoSalesAnalysisTests |
18 |
Tests for profit calculations: ProfitPerUnit, TotalProfit, ProfitMargin |
SaleBatchResultTests |
6 |
Tests for per-batch profit calculations during FIFO sales |
SalesBatchPreviewTests |
10 |
Tests for FIFO preview: WAC, inventory availability, batch consumption order |
FifoSaleResultTests |
8 |
Tests for complete sale result: TotalProfit, OverallProfitMargin, batch aggregation |
Unit Test Details by Use Case
| Use Case |
Unit Test Coverage |
Test File |
| UC-FIFO-015 (Profit/Unit) |
✅ 5 tests |
FifoSalesAnalysisTests.cs |
| UC-FIFO-016 (Total Profit) |
✅ 4 tests |
FifoSalesAnalysisTests.cs |
| UC-FIFO-017 (Margin %) |
✅ 6 tests |
FifoSalesAnalysisTests.cs |
| UC-FIFO-028 (Requested qty) |
✅ 2 tests |
SalesBatchPreviewTests.cs |
| UC-FIFO-029 (Available qty) |
✅ 2 tests |
SalesBatchPreviewTests.cs |
| UC-FIFO-030 (Avg Cost/WAC) |
✅ 2 tests |
SalesBatchPreviewTests.cs |
| UC-FIFO-031-035 (Batch Cards) |
✅ 4 tests |
SalesBatchPreviewTests.cs |
| UC-FIFO-036 (Total COGS) |
✅ 2 tests |
FifoSaleResultTests.cs |
| UC-FIFO-037 (Revenue) |
✅ 2 tests |
FifoSaleResultTests.cs |
| UC-FIFO-038 (Profit) |
✅ 3 tests |
FifoSaleResultTests.cs |
| UC-FIFO-039 (Margin %) |
✅ 4 tests |
FifoSaleResultTests.cs |
Non-Unit-Testable Use Cases (UI/Integration)
| Use Case Range |
Reason |
| UC-FIFO-001 to UC-FIFO-014 |
UI rendering, navigation, authentication - covered by Playwright E2E tests |
| UC-FIFO-018 to UC-FIFO-027 |
Modal interactions, JS interop - covered by Playwright E2E tests |
| UC-FIFO-040 to UC-FIFO-055 |
Form validation, event handlers, data attributes - covered by Playwright E2E tests |
Running Unit Tests
# Run all FIFO Sales unit tests
dotnet test Rabbit.Accounts.Tests --filter "FullyQualifiedName~FifoSales"
# Run with detailed output
dotnet test Rabbit.Accounts.Tests --logger "console;verbosity=detailed"