Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -46,6 +46,8 @@ Primary goals for reconcile rate:
|
|
| 46 |
drop leading ITM rows and each fragment row whose (date, amount) still has count in the previous
|
| 47 |
debits table; remove the ED wrapper if the table becomes empty. If a small orphan tail remains
|
| 48 |
(≤6 rows), append those rows to the preceding debits table and drop the extra ED heading.
|
|
|
|
|
|
|
| 49 |
- Fix 17e: Repeat EC/ED fused + 17d passes until stable (handles chained replacements). Centered section titles
|
| 50 |
match both align=\"center\" and style=\"text-align:center\" on divs.
|
| 51 |
- Post-pass: dedupe 3-col Date|Description|Amount tables when one is a duplicate fragment
|
|
@@ -3210,10 +3212,10 @@ def _ucb_strip_redundant_ed_subset_fragment(text: str) -> str:
|
|
| 3210 |
|
| 3211 |
def _ucb_prune_ed_fragment_dupes_vs_prev_table(text: str) -> str:
|
| 3212 |
"""
|
| 3213 |
-
Fix 17g: Under
|
| 3214 |
-
the immediately preceding
|
| 3215 |
-
|
| 3216 |
-
|
| 3217 |
"""
|
| 3218 |
if not text or "electronic debits" not in text.lower():
|
| 3219 |
return text
|
|
@@ -3245,11 +3247,11 @@ def _ucb_prune_ed_fragment_dupes_vs_prev_table(text: str) -> str:
|
|
| 3245 |
return None
|
| 3246 |
return k
|
| 3247 |
|
| 3248 |
-
def
|
| 3249 |
for r in range(1, len(grid)):
|
| 3250 |
if not any(str(c or "").strip() for c in grid[r]):
|
| 3251 |
continue
|
| 3252 |
-
if
|
| 3253 |
return True
|
| 3254 |
return False
|
| 3255 |
|
|
@@ -3271,7 +3273,8 @@ def _ucb_prune_ed_fragment_dupes_vs_prev_table(text: str) -> str:
|
|
| 3271 |
or not _is_da3_header(g_frag)
|
| 3272 |
):
|
| 3273 |
continue
|
| 3274 |
-
|
|
|
|
| 3275 |
continue
|
| 3276 |
cb = Counter()
|
| 3277 |
for r in range(1, len(g_big)):
|
|
|
|
| 46 |
drop leading ITM rows and each fragment row whose (date, amount) still has count in the previous
|
| 47 |
debits table; remove the ED wrapper if the table becomes empty. If a small orphan tail remains
|
| 48 |
(≤6 rows), append those rows to the preceding debits table and drop the extra ED heading.
|
| 49 |
+
Skip the *first* Electronic Debits + table on the page when the previous table is ITM/credits-only
|
| 50 |
+
and the fragment is clearly debits (so we do not treat the main debits section as a duplicate).
|
| 51 |
- Fix 17e: Repeat EC/ED fused + 17d passes until stable (handles chained replacements). Centered section titles
|
| 52 |
match both align=\"center\" and style=\"text-align:center\" on divs.
|
| 53 |
- Post-pass: dedupe 3-col Date|Description|Amount tables when one is a duplicate fragment
|
|
|
|
| 3212 |
|
| 3213 |
def _ucb_prune_ed_fragment_dupes_vs_prev_table(text: str) -> str:
|
| 3214 |
"""
|
| 3215 |
+
Fix 17g: Under an Electronic Debits + DA3 table, drop leading ITM rows and rows that duplicate
|
| 3216 |
+
the immediately preceding DA3 table by (date, amount). Skips the case where the previous table is
|
| 3217 |
+
credits/ITM-only and this table is the main debits block. If ≤6 orphan rows remain, merge into prev
|
| 3218 |
+
and remove this ED block.
|
| 3219 |
"""
|
| 3220 |
if not text or "electronic debits" not in text.lower():
|
| 3221 |
return text
|
|
|
|
| 3247 |
return None
|
| 3248 |
return k
|
| 3249 |
|
| 3250 |
+
def _grid_has_strong_debit_row(grid):
|
| 3251 |
for r in range(1, len(grid)):
|
| 3252 |
if not any(str(c or "").strip() for c in grid[r]):
|
| 3253 |
continue
|
| 3254 |
+
if _is_strong_ucb_electronic_debit_row(grid, r):
|
| 3255 |
return True
|
| 3256 |
return False
|
| 3257 |
|
|
|
|
| 3273 |
or not _is_da3_header(g_frag)
|
| 3274 |
):
|
| 3275 |
continue
|
| 3276 |
+
# Legitimate layout: ITM/credits-only table, then Electronic Debits + main debits — do not prune.
|
| 3277 |
+
if not _grid_has_strong_debit_row(g_big) and _grid_has_strong_debit_row(g_frag):
|
| 3278 |
continue
|
| 3279 |
cb = Counter()
|
| 3280 |
for r in range(1, len(g_big)):
|