Back to prompt library
Build an OPC UA Supplier Chargeback and Quality Hold Calculator — implementation
Linked challenge: Build an OPC UA Supplier Chargeback and Quality Hold Calculator
Prompt source
implementation91 lines11 sectionsNo variables1 code block
## Build
Parse open62541 OPC UA lot tracking nodes to isolate defective components. Calculate supplier chargeback costs based on scrapped sub-assemblies and generate quality hold manifests for affected inventory.
## User
Plant Quality and Traceability Manager
## Workflow
1. Ingest normalized OPC UA node variables representing component batch IDs and workstation transitions.
2. Traverse forward component lot consumption links to isolate downstream finished assemblies containing defective parts.
3. Calculate total scrapped material value by summing the unit costs of the affected sub-assemblies and finished units.
4. Synthesize an itemized supplier chargeback report detailing affected inventory lots and financial recovery sums.
## Interface
Web dashboard showing interactive lot tree traversals, financial scrap calculators, and one-click chargeback manifest export.
## Data
Generate 400 normalized JSON records modeled after open62541 OPC UA node variable tables with parent-child lot relations, timestamps, station IDs, and unit cost tables.
Starter examples below are synthetic. They are not downloaded records.
## Source
[open62541 OPC UA](https://raw.githubusercontent.com/open62541/open62541/master/README.md)
Utilizes open62541 OPC UA information model conventions for node attributes and hierarchical references to structure lot tracking variables.
## Tools
pydantic-ai, networkx, fastapi.
Pydantic AI guarantees strictly validated schema structures for complex lot graph traversals and financial chargeback data outputs.
Requires strong structured data extraction and logical reasoning via hosted API or local 8B+ parameter model.
## Deliverables
Submit runnable source, pinned dependencies, setup commands, a working interface, example outputs, and a recorded end-to-end demo. Include tests and an action log.
## Acceptance
- Reconstructs full parent-child sub-assembly lineage for multi-stage component lots without circular references.
- Identifies 100% of finished assemblies containing components from designated contaminated input lots.
- Exports a structured JSON supplier chargeback manifest containing hold dispositions and accurate sum of scrapped material costs.
## Starter Examples
```json
[
{
"input": {
"data_context": "Simplified synthetic app records, not complete official schema files",
"suspect_lot_id": "RAW-CAP-8841",
"genealogy_records": [
{
"node_id": "ns=2;s=Station1.Mount",
"component_lot": "RAW-CAP-8841",
"parent_lot": "PCB-SUB-101"
},
{
"node_id": "ns=2;s=Station2.Enclosure",
"component_lot": "PCB-SUB-101",
"parent_lot": "FIN-ASSY-900"
}
],
"unit_costs": {
"PCB-SUB-101": 45,
"FIN-ASSY-900": 120
}
},
"expected_output": {
"target_suspect_lot": "RAW-CAP-8841",
"affected_subassemblies": [
"PCB-SUB-101"
],
"quarantine_units": [
"FIN-ASSY-900"
],
"chargeback_total": 165,
"containment_status": "ISOLATED"
}
},
{
"input": {
"data_context": "Simplified synthetic app records, not complete official schema files",
"suspect_lot_id": "RAW-RES-4040",
"genealogy_records": [
{
"node_id": "ns=2;s=Station1.Mount",
"component_lot": "RAW-RES-9999",
"parent_lot": "PCB-SUB-200"
}
],
"unit_costs": {
"PCB-SUB-200": 30
}
},
"expected_output": {
"target_suspect_lot": "RAW-RES-4040",
"affected_subassemblies": [],
"quarantine_units": [],
"chargeback_total": 0,
"containment_status": "CLEAN"
}
}
]
```
## Safety
Read-only simulation data; strictly mock containment tags with no direct actuation of factory conveyors or automated storage systems.
Use mock external writes. Require human review before any real deployment.