Support CVFCU Account Details (recent activity) PDFs; never double-count overlapping statements
build-container / build (push) Successful in 37s
build-container / build (push) Successful in 37s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5068021b09
commit
3d956f3fd2
3 files changed
+56
-9
No files matched your search
@@ -23,9 +23,12 @@ def coverage(sts):
|
||||
today = dt.date.today()
|
||||
cfg = {a[0]: a[2] for a in L.ACCOUNTS}
|
||||
by = {}
|
||||
for st in sts: by.setdefault(st.account, []).append(st)
|
||||
recent = {} # "Account Details" pages: partial months, never count as a full statement
|
||||
for st in sts:
|
||||
if st.kind == "activity": recent[st.account] = max(recent.get(st.account, st.end), st.end)
|
||||
else: by.setdefault(st.account, []).append(st)
|
||||
if not by: return dict(months=[], accounts=[])
|
||||
lo = min(s.start or s.end for s in sts); months = []
|
||||
lo = min(s.start or s.end for s in sum(by.values(), [])); months = []
|
||||
y, m = lo.year, lo.month
|
||||
while (y, m) <= (today.year, today.month):
|
||||
months.append(f"{y}-{m:02d}"); m += 1
|
||||
@@ -52,6 +55,7 @@ def coverage(sts):
|
||||
if cfg.get(acct) is None and last.day != eom(last.year, last.month): ny, nm = last.year, last.month
|
||||
nd = dt.date(ny, nm, cfg.get(acct) or eom(ny, nm))
|
||||
nxt = f"Next statement closes ~{nd:%b %-d, %Y}" + (" (ready to download)" if nd <= today else "")
|
||||
if acct in recent and recent[acct] > last: nxt += f" · recent activity loaded through {recent[acct]:%b %-d}"
|
||||
out.append(dict(account=acct, cells=cells, count=len(lst), through=f"{last:%b %-d, %Y}", next=nxt, kind="csv" if csv_only else "pdf"))
|
||||
return dict(months=months, accounts=out)
|
||||
|
||||
|
||||
Reference in new issue
Block a user