# Variance Analysis

## Overview

Variance Analysis is the management accounting capability of the accounting module that compares planned (budget) amounts against actual costs and revenues by cost object and accounting period. A VarianceReport entity captures the cost object reference (cost center, profit center, or internal order), the accounting period, report status (DRAFT or FINAL), and summary totals (total planned, total actual, total variance). Each VarianceReport contains one or more VarianceReportLine child records, each keyed by cost element and accounting period, that capture the planned amount, actual amount, computed variance amount, variance percentage, and variance direction (FAVORABLE or UNFAVORABLE). This cost-element-level detail enables managers to diagnose which cost types are driving deviations rather than only seeing aggregate totals. Actual amounts are sourced from posted journal entries in the finance-ledger module, aggregated by cost element, period, and cost object. Planned amounts are sourced from BudgetLineItems in the budget-management module, which use cost elements as their planning axis.

The feature follows a five-step workflow: collect actuals from posted journal entries, collect plan amounts from budget line items, calculate variance per cost element as the difference between actual and planned, categorize the variance direction based on account type, and generate a management report with detail lines. Variance reports are scoped to a Company and reference a specific AccountingPeriod. Reports can be generated at the individual cost object level or aggregated up cost center and profit center hierarchies. Variance analysis typically runs as a period-end process after all postings for the period are complete. Detailed variance categorization (input price, input quantity, volume, mix) and manufacturing-specific variances (price, usage, efficiency) are out of scope for this feature.

## Business Purpose

Organizations need systematic variance analysis to monitor financial performance against plans and enable timely corrective action:

- **Budget adherence monitoring**: Comparing actual costs and revenues against budgeted amounts by cost object reveals where spending is on track and where deviations require management attention
- **Favorable/unfavorable categorization**: Automatically classifying variances as favorable (actual costs below plan, or actual revenue above plan) or unfavorable (the inverse) provides immediate directional context for decision-makers without manual interpretation
- **Cost element detail**: VarianceReportLine records break down variances by cost element (salaries, travel, materials, etc.) within each cost object, enabling managers to identify exactly which cost type is driving deviations rather than only seeing an aggregate total — this is essential for actionable root-cause analysis
- **Cost object granularity**: Generating variance reports per cost center, profit center, or internal order allows managers to pinpoint exactly which organizational unit or project is driving deviations from plan
- **Hierarchy aggregation**: Rolling up variances along cost center and profit center hierarchies enables both detailed drill-down analysis and executive-level summary reporting in a single feature
- **Period-end management reporting**: Running variance analysis after all period postings are complete produces accurate, comprehensive reports that inform budget revisions, resource reallocation, and strategic decisions for subsequent periods
- **Variance quantification**: Calculating both absolute variance amounts and variance percentages allows managers to assess deviations in context — a large absolute variance on a small budget line signals a different issue than the same amount on a large budget line
- **Draft-to-final lifecycle**: The DRAFT to FINAL status progression allows controllers to review and validate variance reports before distributing them to management, preventing premature or incorrect reporting

## Process Flow

```mermaid
stateDiagram-v2
    [*] --> CollectActuals: initiateVarianceAnalysis
    CollectActuals --> CollectPlan: actuals aggregated
    CollectPlan --> CalculateVariance: plan amounts retrieved
    CalculateVariance --> Categorize: variance computed
    Categorize --> GenerateReport: direction assigned
    GenerateReport --> [*]: VarianceReport created (DRAFT)
```

```mermaid
flowchart TD
    A[Period-end: all postings complete] --> B[Collect actual amounts from posted journal entries]
    B --> C[Aggregate actuals by cost element + cost object + period]
    C --> D[Collect planned amounts from budget-management BudgetLineItems by cost element]
    D --> E[Match actuals to plan by cost element, cost object, and period]
    E --> F[Calculate variance per cost element: Actual - Planned]
    F --> G{Account type?}
    G -- Cost/Expense --> H{Actual < Planned?}
    H -- Yes --> I[FAVORABLE]
    H -- No --> J[UNFAVORABLE]
    G -- Revenue --> K{Actual > Planned?}
    K -- Yes --> L[FAVORABLE]
    K -- No --> M[UNFAVORABLE]
    I --> N[Compute variance percentage]
    J --> N
    L --> N
    M --> N
    N --> O[Create VarianceReportLine per cost element]
    O --> O2[Create VarianceReport in DRAFT with summary totals and detail lines]
    O2 --> P{Review and validate}
    P -- Approved --> Q[Finalize report: status FINAL]
    P -- Issues found --> R[Investigate and correct source data]
    R --> A
```

```mermaid
flowchart TD
    A[Select reporting scope] --> B{Report level?}
    B -- Individual cost object --> C[Generate report for single cost center / profit center / internal order]
    B -- Hierarchy --> D[Retrieve child cost objects from hierarchy]
    D --> E[Generate individual reports per child]
    E --> F[Aggregate variances up hierarchy levels]
    F --> G[Produce consolidated hierarchy report]
    C --> H[VarianceReport ready for review]
    G --> H
```

## Scenario Patterns

- **Monthly cost center review**: At month-end close, the controller initiates variance analysis for all cost centers within a company for the current accounting period. The system collects posted journal entry totals by cost center, retrieves corresponding budget line items, computes variances, and generates DRAFT variance reports. The controller reviews and finalizes each report before distributing to cost center managers
- **Profit center profitability check**: A division head requests a variance report for their profit center to compare actual revenue and costs against the annual plan. The report's detail lines show revenue above plan (FAVORABLE) but the material cost element significantly above plan (UNFAVORABLE), enabling the manager to pinpoint supplier pricing changes as the root cause without needing a separate drill-down report
- **Internal order cost overrun detection**: A project manager reviews the variance report for an internal order representing a capital project. The report reveals actual spending at 120% of the planned amount with two periods remaining, triggering a budget revision request and scope review
- **Hierarchy roll-up for executive reporting**: The CFO requests a consolidated variance report across all profit centers. The system generates individual profit center variance reports and then aggregates them up the profit center hierarchy, producing a company-level summary showing total planned vs. actual with net variance amounts and percentages
- **Cross-period trend analysis**: A controller generates variance reports for the same cost center across multiple consecutive periods to identify whether an unfavorable variance is a one-time event or a recurring trend, informing whether a structural budget adjustment is needed
- **Revenue variance investigation**: A sales manager receives a variance report showing actual revenue below plan (UNFAVORABLE) for their profit center. The variance percentage of -15% triggers a review of sales pipeline and customer order patterns to understand the shortfall
- **Period-end sequential processing**: The accounting team completes all journal entry postings and subledger reconciliations for the period, then runs variance analysis as the final step before period close. This sequence ensures variance reports reflect the complete and accurate financial picture for the period

## Test Cases

- Variance report can only be created for a valid Company that is in ACTIVE status
- Variance report must reference a valid AccountingPeriod
- Variance report must reference a valid cost object (cost center, profit center, or internal order)
- Variance report is created in DRAFT status
- Variance report can transition from DRAFT to FINAL
- Variance report in FINAL status cannot be transitioned back to DRAFT
- A VarianceReport contains one or more VarianceReportLine child records, each keyed by cost element and accounting period
- Each VarianceReportLine records: cost element reference, accounting period, planned amount, actual amount, variance amount, variance percentage, and variance direction
- VarianceReport summary totals (total planned, total actual, total variance) are computed from the sum of its detail lines
- Variance amount on each VarianceReportLine is calculated as actual amount minus planned amount
- Variance percentage on each VarianceReportLine is calculated as (actual - planned) / planned * 100
- When planned amount is zero and actual amount is non-zero on a detail line, variance percentage is handled gracefully (not division by zero)
- For cost/expense cost elements, variance direction is FAVORABLE when actual amount is less than planned amount
- For cost/expense cost elements, variance direction is UNFAVORABLE when actual amount is greater than planned amount
- For revenue cost elements, variance direction is FAVORABLE when actual amount is greater than planned amount
- For revenue cost elements, variance direction is UNFAVORABLE when actual amount is less than planned amount
- When actual equals planned on a detail line, variance amount is zero and variance direction is FAVORABLE
- Actual amounts are sourced exclusively from POSTED journal entries in the finance-ledger module
- DRAFT journal entries are excluded from actual amount aggregation
- Actual amounts are aggregated by cost element, cost object, and accounting period
- Planned amounts are sourced from BudgetLineItems in the budget-management module, matched by cost element
- A variance report cannot be generated if no budget line items exist for the specified cost object and period
- A VarianceReportLine is created for each cost element that has either a planned amount or an actual amount (or both)
- A cost element with actual postings but no corresponding budget line item generates a detail line with zero planned amount
- Variance reports for cost centers aggregate all journal lines assigned to that cost center in the given period, grouped by cost element
- Variance reports for profit centers aggregate all journal lines assigned to that profit center in the given period, grouped by cost element
- Variance reports for internal orders aggregate all journal lines assigned to that internal order in the given period, grouped by cost element
- Hierarchy aggregation for cost centers sums child cost center variances into the parent cost center report
- Hierarchy aggregation for profit centers sums child profit center variances into the parent profit center report
- Hierarchy-aggregated reports include both the individual child variances and the consolidated parent totals
- A DRAFT variance report can be updated (e.g., to correct a cost object reference) before finalization
- A FINAL variance report cannot be modified
- Generating a variance report for a period with no posted journal entries results in zero actual amounts
- Variance reports are scoped to a single company; data from other companies is excluded
- Multiple variance reports can exist for the same cost object across different accounting periods
- Regenerating a variance report for the same cost object and period replaces the existing DRAFT report
- A FINAL variance report is not overwritten by regeneration; a new DRAFT is created alongside it if source data changes
- Variance report includes both the absolute variance amount and the variance percentage
- Variance report records the variance direction as either FAVORABLE or UNFAVORABLE

## Reference Links

- [SAP S/4HANA Variance Analysis in Controlling](https://help.sap.com/docs/SAP_S4HANA_ON-PREMISE/ee3509643e954b3da2e0ebfa846c02e1/b33fa239f4d446e9a6c8a585c4e148c8.html)
- [Oracle Fusion Budgetary Control and Variance Reporting](https://docs.oracle.com/en/cloud/saas/financials/24d/oafcf/budgetary-control.html)
- [Odoo Budget Management and Analysis](https://www.odoo.com/documentation/19.0/applications/finance/accounting/reporting/budget.html)
- [NetSuite Budget vs. Actual Reporting](https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_N1584498.html)
- [CIMA Management Accounting Variance Analysis](https://www.cimaglobal.com/resources/)
