Add page-marker grouping and party-aware naming

Consecutive captures whose printed PAGE X OF Y markers advance under the same total are grouped into one multi-page PDF, with duplicate pages keeping the better read. Naming gains doc-title/party components and a scan-date fallback so nothing lands in UNSORTED. Vision LLM default switches to minicpm-v (faster, fewer false blanks on dense mono pages).
This commit is contained in:
2026-07-26 15:37:28 -04:00
parent b11f46b00f
commit 12e5d1aeb1
10 changed files with 986 additions and 135 deletions
+27 -6
View File
@@ -28,24 +28,45 @@ def test_build_name_full_metadata():
def test_build_name_date_only():
dt = datetime(2026, 1, 1, 12, 0, 0)
result = build_name("2023-03-14", None, dt)
assert result.stem == "2023-03-14_UNSORTED"
assert result.stem == "2023-03-14_document"
assert result.source == "ocr"
def test_build_name_vendor_only():
def test_build_name_vendor_only_uses_scan_date():
dt = datetime(2026, 1, 1, 12, 0, 0)
result = build_name(None, "METRO", dt)
assert result.stem == "UNSORTED_metro_20260101_120000"
assert result.source == "ocr"
assert result.stem == "2026-01-01_metro"
assert result.source == "scan_date"
def test_build_name_nothing_found():
dt = datetime(2026, 1, 1, 12, 0, 0)
result = build_name(None, None, dt)
assert result.stem == "UNSORTED_20260101_120000"
assert result.stem == "2026-01-01_scan"
assert result.source == "none"
def test_build_name_appends_doc_title():
dt = datetime(2026, 1, 1, 12, 0, 0)
result = build_name("2025-01-31", "TD Canada Trust", dt, doc_title="transaction_history")
assert result.stem == "2025-01-31_td_canada_trust_transaction_history"
def test_build_name_appends_party_shortname():
dt = datetime(2026, 1, 1, 12, 0, 0)
result = build_name(
"2025-01-31", "TD Canada Trust", dt,
doc_title="transaction_history", party="LEVIT I",
)
assert result.stem == "2025-01-31_td_canada_trust_transaction_history_levit_i"
def test_build_name_doc_title_not_duplicated_when_vendor_says_same():
dt = datetime(2026, 1, 1, 12, 0, 0)
result = build_name("2025-01-31", "Transaction History", dt, doc_title="transaction_history")
assert result.stem == "2025-01-31_transaction_history"
def test_build_name_with_time_disambiguates_same_day_visits():
dt = datetime(2026, 1, 1, 12, 0, 0)
morning = build_name("2023-03-20", "WALMART", dt, time="09:05")
@@ -64,7 +85,7 @@ def test_build_name_invalid_time_ignored():
def test_build_name_time_without_date_ignored():
dt = datetime(2026, 1, 1, 12, 0, 0)
result = build_name(None, "METRO", dt, time="09:05")
assert result.stem == "UNSORTED_metro_20260101_120000"
assert result.stem == "2026-01-01_metro"
def test_build_name_tax_form_with_year_and_org():