diff --git a/response.xml b/response.xml index 3958409..a287785 100644 --- a/response.xml +++ b/response.xml @@ -3,10 +3,10 @@ -80000001-1758063532 -2025-09-16T22:58:52+00:00 -2025-09-16T22:58:52+00:00 -1758063532 +80000001-1758131687 +2025-09-17T17:54:47+00:00 +2025-09-17T17:54:47+00:00 +1758131687 1% 10 Net 30 true 30 @@ -14,10 +14,10 @@ 1.00 -80000002-1758063532 -2025-09-16T22:58:52+00:00 -2025-09-16T22:58:52+00:00 -1758063532 +80000002-1758131687 +2025-09-17T17:54:47+00:00 +2025-09-17T17:54:47+00:00 +1758131687 2% 10 Net 30 true 30 @@ -25,10 +25,10 @@ 2.00 -80000003-1758063532 -2025-09-16T22:58:52+00:00 -2025-09-16T22:58:52+00:00 -1758063532 +80000003-1758131687 +2025-09-17T17:54:47+00:00 +2025-09-17T17:54:47+00:00 +1758131687 Consignment true 90 @@ -36,10 +36,10 @@ 0.00 -80000004-1758063532 -2025-09-16T22:58:52+00:00 -2025-09-16T22:58:52+00:00 -1758063532 +80000004-1758131687 +2025-09-17T17:54:47+00:00 +2025-09-17T17:54:47+00:00 +1758131687 Due on receipt true 0 @@ -47,10 +47,10 @@ 0.00 -80000005-1758063532 -2025-09-16T22:58:52+00:00 -2025-09-16T22:58:52+00:00 -1758063532 +80000005-1758131687 +2025-09-17T17:54:47+00:00 +2025-09-17T17:54:47+00:00 +1758131687 Net 15 true 15 @@ -58,10 +58,10 @@ 0.00 -80000006-1758063532 -2025-09-16T22:58:52+00:00 -2025-09-16T22:58:52+00:00 -1758063532 +80000006-1758131687 +2025-09-17T17:54:47+00:00 +2025-09-17T17:54:47+00:00 +1758131687 Net 30 true 30 @@ -69,10 +69,10 @@ 0.00 -80000007-1758063532 -2025-09-16T22:58:52+00:00 -2025-09-16T22:58:52+00:00 -1758063532 +80000007-1758131687 +2025-09-17T17:54:47+00:00 +2025-09-17T17:54:47+00:00 +1758131687 Net 60 true 60 diff --git a/terms.py b/terms.py index 574a9d6..e192513 100644 --- a/terms.py +++ b/terms.py @@ -9,13 +9,36 @@ def build_terms_query() -> str: - """Return a minimal TermsQueryRq XML.""" - raise NotImplementedError() + """Return a minimal TermsQueryRq XML (only required fields).""" + request_body = """ + + + + + +""" + return request_body def parse_and_print(response_xml: str) -> None: """Parse response and print term name + discount days.""" - raise NotImplementedError() + root = ET.fromstring(response_xml) + + # Get the statusCode and statusMessage from the response. + msgs_response = root.find(".//QBXMLMsgsRs/TermsQueryRs") + if msgs_response is not None: + status_code = msgs_response.get("statusCode") + status_message = msgs_response.get("statusMessage") + + if status_code != "0": # Not successful + print(f"Error {status_code}: {status_message}") + return + + # Loop through all StandardTermsRet tags. + for terms in root.findall(".//StandardTermsRet"): + name = terms.find("Name") + discount_days = terms.find("DiscountDays") + print(f"{name.text if name is not None else 'N/A'}") def main(): @@ -50,4 +73,4 @@ def main(): if __name__ == "__main__": - main() + main() \ No newline at end of file