#!/usr/bin/env python3
"""Verify the print modification is correct"""
import requests
print("๐ Verifying print modifications...\n")
# Check HTML
print("๐ Checking HTML...")
html_response = requests.get("http://127.0.0.1:18080/trial-balance.html")
html = html_response.text
html_checks = [
("First page header preserved", '
ๆฎ้ซ่ฉฆ็ฎ่กจ๏ผ่ฒธๅใปๆ็๏ผ
', True),
("Period info preserved", 'id="periodInfo"', True),
("Print date div preserved", 'id="printDate"', True),
("Old printHeaderRow removed", 'id="printHeaderRow"', False),
("Original @page structure", '@page {', True),
]
html_pass = 0
for check_name, needle, should_exist in html_checks:
found = needle in html
status = "โ" if found == should_exist else "โ"
result = "found" if found else "not found"
expected = "should exist" if should_exist else "should NOT exist"
if found == should_exist:
html_pass += 1
print(f" {status} {check_name}: {result} ({expected})")
# Check JavaScript
print("\n๐ Checking JavaScript...")
js_response = requests.get("http://127.0.0.1:18080/js/trial-balance.js")
js = js_response.text
js_checks = [
("insertPageHeaders function", "function insertPageHeaders", True),
("removePageHeaders function", "function removePageHeaders", True),
("insertPageHeaders called in print", "insertPageHeaders(dateFrom, dateTo)", True),
("removePageHeaders called after print", "removePageHeaders()", True),
("Old setupPrintHeaderInfo removed", "function setupPrintHeaderInfo", False),
("Old formatPeriodInfo removed", "function formatPeriodInfo", False),
]
js_pass = 0
for check_name, needle, should_exist in js_checks:
found = needle in js
status = "โ" if found == should_exist else "โ"
result = "found" if found else "not found"
expected = "should exist" if should_exist else "should NOT exist"
if found == should_exist:
js_pass += 1
print(f" {status} {check_name}: {result} ({expected})")
# Summary
print(f"\nโ
HTML checks: {html_pass}/{len(html_checks)} passed")
print(f"โ
JS checks: {js_pass}/{len(js_checks)} passed")
if html_pass == len(html_checks) and js_pass == len(js_checks):
print("\n๐ All modifications verified successfully!")
print("๐ Summary of changes:")
print(" - Reverted printHeaderRow from HTML")
print(" - Restored original @page structure")
print(" - Added insertPageHeaders() for dynamic page headers")
print(" - Added removePageHeaders() to clean up after printing")
print(" - First page remains unchanged")
print(" - Each printed page will show title, period, date, and unit")
else:
print("\nโ ๏ธ Some checks failed. Please review the modifications.")