Spaces:
Sleeping
Sleeping
Lock Step 2 for forms 2-5 and auto-fill PO + work title
Browse filesForms 2-5 were uses_po=False, which forced step1_done=True so Step 2 never locked before a PO lookup. They actually depend on the lookup (vendor already, plus PO + title per the reference line). Set uses_po=True for forms 2-5 so Step 2 gates on the lookup like form1, and fill the work title and PO into the 'อ้างถึง (1) สัญญา...' line.
- form_logic.py: uses_po=True for forms 2-5; fill title/PO in the form2-5 branch.
- templates/form2-5.docx: insert ชื่องาน / PO_No tokens into the reference line.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- form_logic.py +11 -5
- templates/form2.docx +0 -0
- templates/form3.docx +0 -0
- templates/form4.docx +0 -0
- templates/form5.docx +0 -0
form_logic.py
CHANGED
|
@@ -19,16 +19,16 @@ FORM_TYPES = [
|
|
| 19 |
"uses_po": True, "uses_doc_type": True},
|
| 20 |
{"id": 2, "filename": "form2.docx",
|
| 21 |
"label": "2. หนังสือแจ้งให้กลับเข้าทำงาน (หลังแจ้งหยุดงาน)",
|
| 22 |
-
"uses_po":
|
| 23 |
{"id": 3, "filename": "form3.docx",
|
| 24 |
"label": "3. หนังสือแจ้งหยุดงาน (มิใช่ความผิดของ ปตท. และคู่สัญญา)",
|
| 25 |
-
"uses_po":
|
| 26 |
{"id": 4, "filename": "form4.docx",
|
| 27 |
"label": "4. หนังสือแจ้งหยุดงาน (เหตุจากความผิดของคู่สัญญา)",
|
| 28 |
-
"uses_po":
|
| 29 |
{"id": 5, "filename": "form5.docx",
|
| 30 |
"label": "5. หนังสือแจ้งหยุดงาน (เหตุจากความผิดของ ปตท.)",
|
| 31 |
-
"uses_po":
|
| 32 |
]
|
| 33 |
|
| 34 |
DOC_TYPE_OPTIONS = ["แจ้งให้เริ่มเข้าทำงาน", "แจ้งให้เริ่มส่งมอบสินค้า"]
|
|
@@ -47,6 +47,8 @@ PLACEHOLDER_SIGNER_F2_5 = (
|
|
| 47 |
"( )"
|
| 48 |
)
|
| 49 |
PLACEHOLDER_VENDOR_F2_5 = "[ระบุชื่อคู่สัญญา]"
|
|
|
|
|
|
|
| 50 |
|
| 51 |
# Mapping จาก column ใน Excel → label ที่แสดงในผลลัพธ์
|
| 52 |
DISPLAY_FIELDS = [
|
|
@@ -174,8 +176,12 @@ def generate_form(form_id, template_path, output_path,
|
|
| 174 |
if vendor_name:
|
| 175 |
n = replace_text(doc, PLACEHOLDER_VENDOR_F2_5, vendor_name)
|
| 176 |
log.append(f"ชื่อคู่สัญญา (Excel): แทนที่ {n} จุด")
|
|
|
|
|
|
|
|
|
|
| 177 |
if po_number:
|
| 178 |
-
|
|
|
|
| 179 |
|
| 180 |
doc.save(output_path)
|
| 181 |
return log
|
|
|
|
| 19 |
"uses_po": True, "uses_doc_type": True},
|
| 20 |
{"id": 2, "filename": "form2.docx",
|
| 21 |
"label": "2. หนังสือแจ้งให้กลับเข้าทำงาน (หลังแจ้งหยุดงาน)",
|
| 22 |
+
"uses_po": True, "uses_doc_type": False},
|
| 23 |
{"id": 3, "filename": "form3.docx",
|
| 24 |
"label": "3. หนังสือแจ้งหยุดงาน (มิใช่ความผิดของ ปตท. และคู่สัญญา)",
|
| 25 |
+
"uses_po": True, "uses_doc_type": False},
|
| 26 |
{"id": 4, "filename": "form4.docx",
|
| 27 |
"label": "4. หนังสือแจ้งหยุดงาน (เหตุจากความผิดของคู่สัญญา)",
|
| 28 |
+
"uses_po": True, "uses_doc_type": False},
|
| 29 |
{"id": 5, "filename": "form5.docx",
|
| 30 |
"label": "5. หนังสือแจ้งหยุดงาน (เหตุจากความผิดของ ปตท.)",
|
| 31 |
+
"uses_po": True, "uses_doc_type": False},
|
| 32 |
]
|
| 33 |
|
| 34 |
DOC_TYPE_OPTIONS = ["แจ้งให้เริ่มเข้าทำงาน", "แจ้งให้เริ่มส่งมอบสินค้า"]
|
|
|
|
| 47 |
"( )"
|
| 48 |
)
|
| 49 |
PLACEHOLDER_VENDOR_F2_5 = "[ระบุชื่อคู่สัญญา]"
|
| 50 |
+
PLACEHOLDER_TITLE_F2_5 = "ชื่องาน" # token inserted in the "อ้างถึง (1) สัญญา…" line
|
| 51 |
+
PLACEHOLDER_PO_F2_5 = "PO_No" # token inserted after "เลขที่" on the same line
|
| 52 |
|
| 53 |
# Mapping จาก column ใน Excel → label ที่แสดงในผลลัพธ์
|
| 54 |
DISPLAY_FIELDS = [
|
|
|
|
| 176 |
if vendor_name:
|
| 177 |
n = replace_text(doc, PLACEHOLDER_VENDOR_F2_5, vendor_name)
|
| 178 |
log.append(f"ชื่อคู่สัญญา (Excel): แทนที่ {n} จุด")
|
| 179 |
+
if work_title:
|
| 180 |
+
n = replace_text(doc, PLACEHOLDER_TITLE_F2_5, work_title)
|
| 181 |
+
log.append(f"ชื่องาน (Excel): แทนที่ {n} จุด")
|
| 182 |
if po_number:
|
| 183 |
+
n = replace_text(doc, PLACEHOLDER_PO_F2_5, po_number)
|
| 184 |
+
log.append(f"เลข PO: แทนที่ {n} จุด")
|
| 185 |
|
| 186 |
doc.save(output_path)
|
| 187 |
return log
|
templates/form2.docx
CHANGED
|
Binary files a/templates/form2.docx and b/templates/form2.docx differ
|
|
|
templates/form3.docx
CHANGED
|
Binary files a/templates/form3.docx and b/templates/form3.docx differ
|
|
|
templates/form4.docx
CHANGED
|
Binary files a/templates/form4.docx and b/templates/form4.docx differ
|
|
|
templates/form5.docx
CHANGED
|
Binary files a/templates/form5.docx and b/templates/form5.docx differ
|
|
|