[BUG] Missing Cost of Sales/COGS row in income statement display #21

Open
opened 2026-03-15 17:02:57 +00:00 by Francy51 · 1 comment
Owner

Description

The income statement should have a clear "Cost of Sales" row that aggregates COGS (Cost of Goods Sold) items, but it may not be displaying correctly or may not be aggregating all relevant COGS concepts.

Current State

The template defines cost_of_revenue at order 20 in lib/server/financials/standard-template.ts:

income({
  key: 'cost_of_revenue',
  label: 'Cost of Sales',
  order: 20,
  unit: 'currency',
  selectionPolicy: 'prefer_exact_local_name',
  matchers: {
    exactLocalNames: [
      'CostOfRevenue',
      'CostOfGoodsSold',
      'CostOfSales',
      'CostOfGoodsAndServicesSold',
      'CostOfGoodsAndServiceExcludingDepreciationDepletionAndAmortization',
      'CostOfProductsSold',
      'CostOfServices'
    ],
    ...
  }
})

Issues

  1. The surface display (lib/server/financials/surface.ts) uses label "Cost of Revenue" (line 50) vs template's "Cost of Sales"
  2. Some COGS-related concepts may not match the defined patterns
  3. No dedicated detail breakdown section for COGS components

Proposed Fix

  1. Ensure surface display label matches template label ("Cost of Sales")
  2. Add additional COGS-related local names to matchers:
    • CostOfGoodsAndServicesSoldExcludingDepreciationDepletionAndAmortization
    • CostOfMerchandisePurchased
    • CostOfMaterials
    • DirectCostsOfGoodsAndServicesSold
  3. Add a detail breakdown section showing COGS components (materials, labor, overhead)

Files Affected

  • lib/server/financials/standard-template.ts
  • lib/server/financials/surface.ts
## Description The income statement should have a clear "Cost of Sales" row that aggregates COGS (Cost of Goods Sold) items, but it may not be displaying correctly or may not be aggregating all relevant COGS concepts. ## Current State The template defines `cost_of_revenue` at order 20 in `lib/server/financials/standard-template.ts`: ```typescript income({ key: 'cost_of_revenue', label: 'Cost of Sales', order: 20, unit: 'currency', selectionPolicy: 'prefer_exact_local_name', matchers: { exactLocalNames: [ 'CostOfRevenue', 'CostOfGoodsSold', 'CostOfSales', 'CostOfGoodsAndServicesSold', 'CostOfGoodsAndServiceExcludingDepreciationDepletionAndAmortization', 'CostOfProductsSold', 'CostOfServices' ], ... } }) ``` ## Issues 1. The surface display (`lib/server/financials/surface.ts`) uses label "Cost of Revenue" (line 50) vs template's "Cost of Sales" 2. Some COGS-related concepts may not match the defined patterns 3. No dedicated detail breakdown section for COGS components ## Proposed Fix 1. Ensure surface display label matches template label ("Cost of Sales") 2. Add additional COGS-related local names to matchers: - `CostOfGoodsAndServicesSoldExcludingDepreciationDepletionAndAmortization` - `CostOfMerchandisePurchased` - `CostOfMaterials` - `DirectCostsOfGoodsAndServicesSold` 3. Add a detail breakdown section showing COGS components (materials, labor, overhead) ## Files Affected - `lib/server/financials/standard-template.ts` - `lib/server/financials/surface.ts`
Author
Owner

Root Cause Found

cost_of_revenue surface is MISSING from rust/taxonomy/fiscal/v1/core.surface.json!

Evidence:

  1. cost_of_revenue is referenced in core.income-bridge.json (lines 47-56) as a component for gross_profit calculation
  2. The crosswalk rust/taxonomy/crosswalk/us-gaap.json (lines 101-126) maps COGS concepts to cost_of_revenue surface_key
  3. BUT core.surface.json has NO surface definition for cost_of_revenue - it jumps from revenue (order 10) to operating_expenses (order 40)

Missing Surface Definition:

The following should be added to core.surface.json:

{
  "surface_key": "cost_of_revenue",
  "statement": "income",
  "label": "Cost of Revenue",
  "category": "surface",
  "order": 20,
  "unit": "currency",
  "rollup_policy": "direct_or_formula",
  "allowed_source_concepts": [
    "us-gaap:CostOfRevenue",
    "us-gaap:CostOfGoodsSold",
    "us-gaap:CostOfSales",
    "us-gaap:CostOfGoodsAndServicesSold",
    "us-gaap:CostOfProductsSold",
    "us-gaap:CostOfServices"
  ],
  "allowed_authoritative_concepts": [
    "us-gaap:CostOfRevenue",
    "us-gaap:CostOfGoodsSold"
  ],
  "formula_fallback": null,
  "detail_grouping_policy": "top_level_only",
  "materiality_policy": "income_default"
}

Also Missing:

  • gross_profit surface (order 30) - should derive from revenue - cost_of_revenue

Fix:

Add these surface definitions to rust/taxonomy/fiscal/v1/core.surface.json

## Root Cause Found **`cost_of_revenue` surface is MISSING from `rust/taxonomy/fiscal/v1/core.surface.json`!** ### Evidence: 1. `cost_of_revenue` is referenced in `core.income-bridge.json` (lines 47-56) as a component for gross_profit calculation 2. The crosswalk `rust/taxonomy/crosswalk/us-gaap.json` (lines 101-126) maps COGS concepts to `cost_of_revenue` surface_key 3. **BUT** `core.surface.json` has NO surface definition for `cost_of_revenue` - it jumps from `revenue` (order 10) to `operating_expenses` (order 40) ### Missing Surface Definition: The following should be added to `core.surface.json`: ```json { "surface_key": "cost_of_revenue", "statement": "income", "label": "Cost of Revenue", "category": "surface", "order": 20, "unit": "currency", "rollup_policy": "direct_or_formula", "allowed_source_concepts": [ "us-gaap:CostOfRevenue", "us-gaap:CostOfGoodsSold", "us-gaap:CostOfSales", "us-gaap:CostOfGoodsAndServicesSold", "us-gaap:CostOfProductsSold", "us-gaap:CostOfServices" ], "allowed_authoritative_concepts": [ "us-gaap:CostOfRevenue", "us-gaap:CostOfGoodsSold" ], "formula_fallback": null, "detail_grouping_policy": "top_level_only", "materiality_policy": "income_default" } ``` ### Also Missing: - `gross_profit` surface (order 30) - should derive from `revenue - cost_of_revenue` ### Fix: Add these surface definitions to `rust/taxonomy/fiscal/v1/core.surface.json`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Francy51/Neon-Desk#21