Spaces:
Sleeping
Sleeping
Update backend/scripts/generate_template_schema_skeletons.py
Browse files
backend/scripts/generate_template_schema_skeletons.py
CHANGED
|
@@ -23,12 +23,15 @@ TABLE_ANCHORS = [
|
|
| 23 |
{"key": "qty", "expected_text": "Qty"},
|
| 24 |
]
|
| 25 |
|
|
|
|
| 26 |
TABLE_COLUMNS = [
|
| 27 |
{"key": "item_number", "label": "Item Number"},
|
| 28 |
{"key": "lot_number", "label": "Lot Number"},
|
| 29 |
{"key": "description", "label": "Description"},
|
| 30 |
{"key": "qty", "label": "Qty"},
|
| 31 |
{"key": "price", "label": "Price"},
|
|
|
|
|
|
|
| 32 |
]
|
| 33 |
|
| 34 |
|
|
@@ -94,6 +97,8 @@ def schema_skeleton(form_id: str) -> Dict[str, Any]:
|
|
| 94 |
{"key": "description", "label": "Description", "bbox_rel_norm": None},
|
| 95 |
{"key": "qty", "label": "Qty", "bbox_rel_norm": None},
|
| 96 |
{"key": "price", "label": "Price", "bbox_rel_norm": None},
|
|
|
|
|
|
|
| 97 |
],
|
| 98 |
"table_anchors": [
|
| 99 |
{"key": "item_number", "expected_text": "Item Number", "bbox_norm": None},
|
|
@@ -120,9 +125,6 @@ def main() -> None:
|
|
| 120 |
data = json.loads(fp.read_text(encoding="utf-8"))
|
| 121 |
template_id = (data.get("template_id") or fp.stem).strip()
|
| 122 |
|
| 123 |
-
# Only touch your known template IDs if you want:
|
| 124 |
-
# if not template_id.startswith("T"): continue
|
| 125 |
-
|
| 126 |
# Overwrite or create schema skeleton
|
| 127 |
data["schema"] = schema_skeleton(form_id=f"template_{template_id}")
|
| 128 |
|
|
@@ -134,4 +136,4 @@ def main() -> None:
|
|
| 134 |
|
| 135 |
|
| 136 |
if __name__ == "__main__":
|
| 137 |
-
main()
|
|
|
|
| 23 |
{"key": "qty", "expected_text": "Qty"},
|
| 24 |
]
|
| 25 |
|
| 26 |
+
# Canonical line-item column set. Keep in sync with the UI (src/App.jsx) and prompts.py.
|
| 27 |
TABLE_COLUMNS = [
|
| 28 |
{"key": "item_number", "label": "Item Number"},
|
| 29 |
{"key": "lot_number", "label": "Lot Number"},
|
| 30 |
{"key": "description", "label": "Description"},
|
| 31 |
{"key": "qty", "label": "Qty"},
|
| 32 |
{"key": "price", "label": "Price"},
|
| 33 |
+
{"key": "total", "label": "Total"},
|
| 34 |
+
{"key": "bundle", "label": "Bundle"},
|
| 35 |
]
|
| 36 |
|
| 37 |
|
|
|
|
| 97 |
{"key": "description", "label": "Description", "bbox_rel_norm": None},
|
| 98 |
{"key": "qty", "label": "Qty", "bbox_rel_norm": None},
|
| 99 |
{"key": "price", "label": "Price", "bbox_rel_norm": None},
|
| 100 |
+
{"key": "total", "label": "Total", "bbox_rel_norm": None},
|
| 101 |
+
{"key": "bundle", "label": "Bundle", "bbox_rel_norm": None},
|
| 102 |
],
|
| 103 |
"table_anchors": [
|
| 104 |
{"key": "item_number", "expected_text": "Item Number", "bbox_norm": None},
|
|
|
|
| 125 |
data = json.loads(fp.read_text(encoding="utf-8"))
|
| 126 |
template_id = (data.get("template_id") or fp.stem).strip()
|
| 127 |
|
|
|
|
|
|
|
|
|
|
| 128 |
# Overwrite or create schema skeleton
|
| 129 |
data["schema"] = schema_skeleton(form_id=f"template_{template_id}")
|
| 130 |
|
|
|
|
| 136 |
|
| 137 |
|
| 138 |
if __name__ == "__main__":
|
| 139 |
+
main()
|