> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wayak.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Work order cost tracking

> Detect production cost overruns by comparing estimated versus actual work order costs daily

Production cost overruns often go undetected until month-end close, when it is too late to correct the root cause. A single material pricing error or unplanned labor hour can cascade across dozens of work orders. By the time finance flags it, you have already shipped the product at a loss.

This use case connects your ERP work order data to a Wayak agent that calculates cost variance in real time and a playbook that scans for overruns every morning. You get alerts the same day a variance appears, not weeks later.

***

## What you need

<CardGroup cols={2}>
  <Card title="Data sources" icon="database">
    * **ERP system (SAP, Oracle, or similar)** — Work order headers with planned costs, posted cost transactions (labor, material, overhead), and BOM details
    * **General ledger** — Cost center postings for overhead allocation validation
  </Card>

  <Card title="Knowledge spaces" icon="book-open">
    * **Cost accounting procedures** — Upload your standard costing methodology and variance investigation guidelines
    * **Work order templates** — Reference documents for standard cost structures by product type
  </Card>
</CardGroup>

**Semantic layer:** Define these in your ontology before setting up the agent.

| Component | Name                 | Definition                                                                                                      |
| --------- | -------------------- | --------------------------------------------------------------------------------------------------------------- |
| Object    | Work Order           | Maps to the ERP work order header table. Represents a single production order with planned and actual costs     |
| Object    | Cost Transaction     | Maps to posted cost line items. Represents individual labor, material, or overhead charges against a work order |
| Metric    | Cost Variance        | Actual total cost minus estimated total cost, expressed in currency and as a percentage                         |
| Metric    | Variance by Category | Cost variance broken down by labor, material, and overhead components                                           |
| Dimension | Product Type         | Categorizes work orders by finished good type (assembly, fabrication, packaging)                                |
| Dimension | Cost Center          | Groups transactions by the responsible department or production area                                            |

<Tip>
  See [building a semantic layer](/quickstart/build-semantic-layer) for a step-by-step guide.
</Tip>

***

## Agent setup

<Steps>
  <Step title="Create the agent">
    Go to **Agent Space** > **New agent**.

    | Field    | Value                                                          |
    | -------- | -------------------------------------------------------------- |
    | **Name** | Production Cost Monitor                                        |
    | **Role** | Production order analyst                                       |
    | **Goal** | Surface cost overruns and variance issues before they escalate |
  </Step>

  <Step title="Set the description">
    > You are a production cost analyst. Monitor work orders and flag any where actual costs deviate significantly from estimates. Lead with the numbers — show the variance first, then explain the likely cause. Use direct, factual language. When a variance exceeds 10%, always recommend a specific next step (review labor entries, check material pricing, audit overhead allocation). Do not speculate about root causes you cannot verify from the data.
  </Step>

  <Step title="Scope data access">
    Grant access to:

    * ERP system data source (work order and cost transaction tables)
    * General ledger data source (cost center postings)
    * Cost accounting procedures knowledge space
    * Work Order and Cost Transaction objects in the semantic layer
  </Step>

  <Step title="Add skills">
    <AccordionGroup>
      <Accordion title="Calculate work order variance">
        **Trigger:** User asks about production cost variance or work order costs

        1. Identify the work order number from the user's request.
        2. Pull the estimated cost from the work order header, including planned labor, planned materials, and planned overhead.
        3. Pull the actual cost by summing all posted transactions against the work order.
        4. Calculate the total variance as actual cost minus estimated cost.
        5. Break the variance into labor, material, and overhead categories.
        6. If the total variance exceeds 10%, flag it and list the top three contributing line items.
        7. Present results in a table with estimated, actual, and variance columns for each cost category.
      </Accordion>

      <Accordion title="Compare work orders by product type">
        **Trigger:** User asks to compare costs across work orders or product types

        1. Identify the product type or date range from the user's request.
        2. Pull all completed work orders matching the criteria.
        3. Calculate the average cost variance percentage for each product type.
        4. Rank product types from highest to lowest average variance.
        5. Highlight any product type with an average variance above 5%.
        6. Present a summary table with order count, average estimated cost, average actual cost, and average variance.
      </Accordion>
    </AccordionGroup>
  </Step>
</Steps>

***

## Automation

### Playbook: Daily cost variance alert

<Steps>
  <Step title="Set the trigger">
    Schedule the playbook to run every weekday at 6:00 AM, before the morning production meeting.
  </Step>

  <Step title="Build the workflow">
    The playbook queries all work orders with transactions posted in the last 24 hours, calculates the variance for each, and filters for any exceeding the 10% threshold.

    1. **Query step** — Pull all work orders with new cost postings since yesterday.
    2. **Python code step** — Calculate variance percentage for each work order and categorize by labor, material, and overhead.
    3. **Condition step** — Filter to only work orders where total variance exceeds 10%.
    4. **Format step** — Build a summary table with work order number, product, estimated cost, actual cost, variance amount, and variance percentage.

    <Info>
      The **Python code step** uses a Python code block to compute variance percentages and categorize overruns by cost type. You can customize the threshold (default 10%) and add additional calculations like rolling averages.
    </Info>
  </Step>

  <Step title="Configure delivery">
    Send the report via email to the production manager and cost accounting team. Include the summary table and a count of flagged work orders in the subject line.
  </Step>

  <Step title="Test and activate">
    Click **Run now** to test with live data, then toggle to **Active**.
  </Step>
</Steps>

***

## What's next

<CardGroup cols={2}>
  <Card title="Shift performance reporting" icon="arrow-right" href="/use-cases/manufacturing/shift-performance-reporting">
    Automate OEE calculations and downtime tracking at the end of every shift.
  </Card>

  <Card title="All manufacturing use cases" icon="list" href="/use-cases/manufacturing">
    See the full list.
  </Card>
</CardGroup>
