Compare invoice header fields (number, date).
(gt: dict, agent: dict)
| 282 | |
| 283 | |
| 284 | def compare_header(gt: dict, agent: dict) -> dict: |
| 285 | """Compare invoice header fields (number, date).""" |
| 286 | gt_details = gt.get("Invoice Details") or {} |
| 287 | agent_details = agent.get("Invoice Details") or {} |
| 288 | |
| 289 | results = {} |
| 290 | all_match = True |
| 291 | |
| 292 | for field in ["Vendor Invoice", "Invoice Date"]: |
| 293 | gt_val = str(gt_details.get(field, "")).strip() |
| 294 | agent_val = str(agent_details.get(field, "")).strip() |
| 295 | match = normalize_string(gt_val) == normalize_string(agent_val) |
| 296 | if not match: |
| 297 | all_match = False |
| 298 | results[field] = { |
| 299 | "ground_truth": gt_val, |
| 300 | "agent": agent_val, |
| 301 | "match": match, |
| 302 | } |
| 303 | |
| 304 | results["all_match"] = all_match |
| 305 | return results |
| 306 | |
| 307 | |
| 308 | def compare_field_group( |
no test coverage detected