#!/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.")