[BUG] Duplicate rows: Operating expenses appearing both mapped and unmapped (e.g., Advertising Expense) #20

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

Description

Several expense line items appear in both the mapped financial statements AND in the unmapped/residual section, creating duplicate rows in the UI.

Specific Example

Advertising Expense (us-gaap:AdvertisingExpense) appears in the unmapped section despite potentially being relevant to operating expenses.

Evidence

From lib/server/financial-taxonomy.test.ts:741-842:

unmapped: [
  {
    key: 'http://fasb.org/us-gaap/2024#AdvertisingExpense',
    parentSurfaceKey: 'unmapped',
    label: 'Advertising Expense',
    localName: 'AdvertisingExpense',
    ...
  }
]

Root Cause

The AdvertisingExpense US-GAAP concept has no template definition in lib/server/financials/standard-template.ts. The income statement template only includes:

  • selling_general_and_administrative
  • research_and_development
  • sales_and_marketing
  • general_and_administrative

Advertising expense should be mapped to one of these or have its own template row.

Impact

  • Confusing UI with duplicate rows
  • Incorrect expense categorization
  • Users see the same expense in multiple places

Proposed Fix

  1. Add AdvertisingExpense to the matchers for selling_general_and_administrative or create a dedicated advertising_expense row
  2. Review other common operating expenses that may be unmapped
  3. Ensure mapped items are excluded from the unmapped section

Files Affected

  • lib/server/financials/standard-template.ts
  • lib/server/financials/surface.ts
## Description Several expense line items appear in both the mapped financial statements AND in the unmapped/residual section, creating duplicate rows in the UI. ## Specific Example **Advertising Expense** (`us-gaap:AdvertisingExpense`) appears in the unmapped section despite potentially being relevant to operating expenses. ## Evidence From `lib/server/financial-taxonomy.test.ts:741-842`: ```typescript unmapped: [ { key: 'http://fasb.org/us-gaap/2024#AdvertisingExpense', parentSurfaceKey: 'unmapped', label: 'Advertising Expense', localName: 'AdvertisingExpense', ... } ] ``` ## Root Cause The `AdvertisingExpense` US-GAAP concept has no template definition in `lib/server/financials/standard-template.ts`. The income statement template only includes: - `selling_general_and_administrative` - `research_and_development` - `sales_and_marketing` - `general_and_administrative` Advertising expense should be mapped to one of these or have its own template row. ## Impact - Confusing UI with duplicate rows - Incorrect expense categorization - Users see the same expense in multiple places ## Proposed Fix 1. Add `AdvertisingExpense` to the matchers for `selling_general_and_administrative` or create a dedicated `advertising_expense` row 2. Review other common operating expenses that may be unmapped 3. Ensure mapped items are excluded from the unmapped section ## Files Affected - `lib/server/financials/standard-template.ts` - `lib/server/financials/surface.ts`
Author
Owner

Update: Root Cause Analysis

The Rust sidecar IS being used and IS authoritative.

Data Flow Confirmed:

Rust fiscal-xbrl CLI
    ↓ (spawns via Bun.spawn)
lib/server/taxonomy/parser-client.ts
    ↓ (stores surface_rows, detail_rows, faithful_rows)
Database: filing_taxonomy_snapshot
    ↓ (reads for display)
lib/server/financial-taxonomy.ts
    ↓ (uses snapshot.surface_rows directly)
UI Components

Finding for Advertising Expense:

The AdvertisingExpense concept IS mapped in rust/taxonomy/fiscal/v1/core.income-bridge.json (line 123) as a component of selling_general_and_administrative:

{
  "name": "sales_and_marketing",
  "concepts": [
    "us-gaap:SalesAndMarketingExpense",
    "us-gaap:SellingAndMarketingExpense",
    "us-gaap:MarketingExpense",
    "us-gaap:AdvertisingExpense"
  ]
}

However, core.surface.json doesn't have an allowed_source_concepts entry for AdvertisingExpense in the selling_general_and_administrative surface. The mapping exists in the income-bridge but may not be propagating to the surface output.

Fix Required:

  1. Add us-gaap:AdvertisingExpense to allowed_source_concepts in core.surface.json for the relevant operating expense surfaces
  2. Verify the Rust surface_mapper.rs correctly applies income-bridge concept groups to surface rows

Files to Update:

  • rust/taxonomy/fiscal/v1/core.surface.json
## Update: Root Cause Analysis **The Rust sidecar IS being used and IS authoritative.** ### Data Flow Confirmed: ``` Rust fiscal-xbrl CLI ↓ (spawns via Bun.spawn) lib/server/taxonomy/parser-client.ts ↓ (stores surface_rows, detail_rows, faithful_rows) Database: filing_taxonomy_snapshot ↓ (reads for display) lib/server/financial-taxonomy.ts ↓ (uses snapshot.surface_rows directly) UI Components ``` ### Finding for Advertising Expense: The `AdvertisingExpense` concept **IS mapped** in `rust/taxonomy/fiscal/v1/core.income-bridge.json` (line 123) as a component of `selling_general_and_administrative`: ```json { "name": "sales_and_marketing", "concepts": [ "us-gaap:SalesAndMarketingExpense", "us-gaap:SellingAndMarketingExpense", "us-gaap:MarketingExpense", "us-gaap:AdvertisingExpense" ] } ``` However, `core.surface.json` doesn't have an `allowed_source_concepts` entry for `AdvertisingExpense` in the `selling_general_and_administrative` surface. The mapping exists in the income-bridge but may not be propagating to the surface output. ### Fix Required: 1. Add `us-gaap:AdvertisingExpense` to `allowed_source_concepts` in `core.surface.json` for the relevant operating expense surfaces 2. Verify the Rust `surface_mapper.rs` correctly applies income-bridge concept groups to surface rows ### Files to Update: - `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#20