import pandas as pd
from datetime import datetime
def trace_batch(batch_id, production_log):
steps = []
for record in production_log:
if record['batch_id'] == batch_id:
steps.append(record)
return pd.DataFrame(steps)
def map_materials(batch_id, bom, inventory):
materials = []
for mat in bom[batch_id]:
materials.append({
'material': mat,
'source': inventory[mat]['supplier'],
'lot': inventory[mat]['lot_no']
})
return materials
# Generate traceability report