AgentSkillsCN

formulation-reader

只读配方数据读取器,适用于芦荟粉配方。从ERPNext中读取AMB批次、AMB2 COA、产品TDS以及销售订单数据。在不修改任何数据的前提下,计算加权平均值,用于配方模拟。当用户读取配方数据、模拟混合配比或检查TDS规格时,即可触发此功能。

SKILL.md
--- frontmatter
name: formulation-reader
description: >
  Read-only formulation data reader for aloe powder formulation.
  Reads Batch AMB, COA AMB2, Item TDS, and Sales Order data from ERPNext.
  Computes weighted averages for blend simulations without modifying any data.
  Trigger: When reading formulation data, simulating blends, checking TDS specs.
license: MIT
metadata:
  author: AMB-Wellness
  version: "1.0.0"
  scope: [root, skills, formulation]
  auto_invoke:
    - "Reading batch data"
    - "Simulating blend"
    - "Checking TDS specifications"
    - "Getting COA parameters"
    - "Analyzing formulation"
allowed-tools: Read

Formulation Reader

Phase 1 Skill: Data Model & Read-Only Analytics

CRITICAL RULES

  • ALWAYS read-only: Never modify ERPNext data
  • ALWAYS validate batch existence before reading COA
  • ALWAYS return calculations with source data for traceability
  • NEVER create, update, or delete any ERPNext documents

System Prompt

You are a formulation reader agent for aloe powder formulation. You receive item code, warehouse, and batch identifiers. You read data from ERPNext doctypes: Batch AMB, COA AMB2, Item, Sales Order. You compute weighted averages for blend simulations. You never modify ERPNext data; you only return data and calculations.


Capabilities

1. Read TDS Specifications

Retrieve Technical Data Sheet (TDS) parameters for a Sales Order item.

Function: get_tds_for_sales_order_item(so_name, item_code)

Returns:

  • TDS parameter ranges (min, max, nominal)
  • Customer-specific specifications
  • Item default specifications

2. Read Batch Data

Get all Batch AMB records for an item in a specific warehouse.

Function: get_batches_for_item_and_warehouse(item_code, warehouse)

Returns:

  • List of Batch AMB records
  • Cunete details (containers, kilos available)
  • Manufacturing dates and WWDYY codes
  • Subproduct codes (0301-0304)

3. Read COA Parameters

Get internal COA (COA AMB2) analytical parameters for a batch.

Function: get_coa_amb2_for_batch(batch_amb_name)

Returns:

  • All analytical parameters (pH, polysaccharides, ash, color, etc.)
  • Measured values and averages
  • PASS/FAIL status against TDS

4. Simulate Blend

Compute weighted averages for a proposed blend without creating any documents.

Function: simulate_blend(blend_inputs)

Input:

python
blend_inputs = [
    {"cunete_id": "BATCH-001-C1", "mass_kg": 10.0},
    {"cunete_id": "BATCH-002-C1", "mass_kg": 15.0}
]
target_item = "AL-QX-90-10"

Returns:

  • Predicted values for each parameter
  • Comparison against TDS ranges
  • PASS/FAIL status for each parameter
  • Total mass and weighted calculation details

Data Model Mappings

Batch AMB Fields

JSON FieldDescription
productMain product code (e.g., 0227)
subproductSubproduct code (0301-0304)
lotLot identifier
sublotSublot identifier
containersContainer serials per cunete
kilosTotal kilos available
brixBRIX measured on production floor
total_solidsTotal solids measured in lab

Subproduct Codes

CodeDescription
0227-0301Permeate
0227-0302Retentate
0227-0303Normal
0227-0304Puntas, colas y raspaduras (scrap)

COA AMB2 Fields

FieldDescription
parameter_codeParameter identifier
nominal_valueExpected/target value
min_valueMinimum acceptable value
max_valueMaximum acceptable value
averageCalculated average of measurements
resultPASS/FAIL status

Weighted Average Formula

code
Final_value = SUM(wi × value_i) / SUM(wi)

Where wi is the mass (kg) taken from cunete i.


Example Queries

Read batch data

code
"Show all batches for item 0227-0303 in warehouse Almacen-MP"

Read COA for batch

code
"Get COA parameters for batch BATCH-AMB-2024-001"

Simulate blend

code
"Simulate a blend of 10 kg from batch X cunete 1 and 15 kg from batch Y cunete 2 
for item AL-QX-90-10. Show predicted pH, polysaccharides, ash versus TDS."

Get TDS for order

code
"What are the TDS specifications for item AL-QX-90-10 in Sales Order SO-00754?"

Test Cases (Phase 1)

IDDescriptionVerification
TC1.1Read Batch AMB list for item X in warehouse YVerify count and fields returned
TC1.2Read COA AMB2 parameters for a known batchVerify all analytics returned
TC1.3Simulate blend with 2 cunetesVerify weighted average calculation
TC1.4Compare simulation result to TDSVerify PASS/FAIL flags

Dependencies

  • frappe framework
  • amb_w_tds app (Batch AMB, COA AMB, COA AMB2 doctypes)
  • ERPNext (Item, Sales Order doctypes)