Track and record financial statement data into memory tracking files.
Workflow
Step 1: Identify Target File
Scan memory/finance/ for files matching statement patterns:
ls memory/finance/statement 2>/dev/null
Always present the list and ask the user which file(s) to update, even if they mentioned a target. This ensures the right file is confirmed before writing.
Step 2: 加载 Target File & Accept 新的 语句
- 读取 target file 到 understand existing structure, 格式, 和 conventions
- Accept 新的 语句 content 从 用户 — includes:
-
source file path (e.g., PDF filename 点赞
MasterCard 语句-1234 2025-03-25.pdf)
-
语句 content (extracted PDF text, pasted content, etc.)
- 记录 both file path 和 content 对于 reference
- Identify 语句 period, card/账户, 和 键 figures 从 新的 data
Page-由-Page Mode
When the user says they'll provide pages one by one (or specifies a target file upfront):
- 之后 Step 1, 读取 target file 到 learn structure
- 对于 每个 page 用户 provides:
- 解析 content immediately
- Append parsed transactions 到 target file right away (don't wait 对于 所有 pages)
- Confirm 什么 是 recorded (e.g., "Page 1: recorded 15 transactions, running 总计 $X")
- 之后 最后的 page (用户 says "已完成", "最后的 page", 或 "'s 所有"):
- Run Step 4 (验证 math) against 满 语句
- 更新 period 索引 表 带有 summary 行
This avoids losing context across many pages and gives the user incremental progress.
Chinese Statements
When statement content is in Chinese:
- Translate descriptions 到 English 但是 keep original Chinese 在...中 parentheses
- 示例:
Amazon Shopping (亚马逊购物)
- Translate 列 headers, summary fields, 和 notes 到 English
- Currency amounts stay 作为- (CNY ¥, etc.)
- 日期 formats: convert 到 YYYY-MM-DD
Step 3: 记录
- Match 格式 和 conventions 的 existing file exactly (表 structure, headers, 字段 names, 日期 formats, description shortening 样式)
- 添加 summary 行 到 period 索引 表 (如果 one exists)
- 添加 detailed 语句 section 带有:
- Period summary (上一个 balance, payments, purchases, interest, fees, 新的 balance, rewards)
- 事务 表 带有 所有 line items
- Insert 在...中 chronological order, 之前 任何 其他 card sections
- Shorten merchant descriptions 到 match existing 样式 (e.g., "GOOGLE*YOUTUBE SUPER G.CO/HELPPAY#NS ..." → "Google YouTube Super")
Step 4: 验证 Math
After merging, independently verify the statement's arithmetic:
- 求和 所有 transactions (positive = charges, negative = credits/payments)
- Check: 上一个 Balance + Purchases & Debits − Payments & Credits + Interest + Fees = 新的 Balance
- Check: 事务 求和 应该 equal (Purchases & Debits − Payments & Credits)
- 举报 到 用户:
- ✅ "语句 math checks out" 如果 totals match (在...内 $0.02 rounding tolerance)
- ⚠️ "Discrepancy found: calculated X, 语句 says Y" 如果 它们 don't match — 标志 specific items 如果 possible
Also verify:
- Cash back / points calculations 如果 data 可用
- Payment due dates 和 minimum payments recorded
- 否 duplicate transactions (相同 日期 + amount + description appearing twice unless genuinely separate)
File Naming Convention
Statement files live in memory/finance/ and follow this pattern:
{bank}-{holder}-{type}-{accountid}-statements.md
- bank: Institution name (rbc, bmo, cibc, td, mbna, manulife, hsbc-hk, scb)
- holder: 账户 holder —
john, jane, 或 joint
- 类型: 账户 类型 (chequing, saving, mc, visa)
- accountid: 最后的 digits 或 满 账户 数字
Examples:
rbc-john-mc-1234-statements.md
rbc-jane-saving-5678901-statements.md
td-joint-9876543-statements.md
bmo-jane-123456789-statements.md
When creating a new statement file, follow this convention.
创建 新的 语句 File 从 Existing 模板
When the user wants to create a new statement file for a different bank/account using an existing file as a structural template:
- 读取 source file 到 extract structure: section headings, subsection titles, 表 headers, summary 字段 names, 索引 表 格式
- 创建 新的 file (following naming convention) 带有:
- 所有 section headings 和 subsection titles preserved
- 所有 表 headers 和 列 structures preserved
-
否 data copied — 使用 placeholders 或 leave 空 rows
- 更新 bank name, 账户 数字, card 数字 references 到 新的 账户
- Present 新的 file 到 用户 对于 confirmation 之前 它们 开始 adding statements
This ensures consistent formatting across all statement tracking files.
Notes
- 当...时 card 有 both primary 和 co-applicant transactions, keep them 在...中 separate sub-tables (matching existing 格式)
- Preserve existing content — 仅 append 新的 periods, never 修改 historical data
- 如果 语句 period 已经 exists 在...中 file, warn 用户 之前 overwriting
Track and record financial statement data into memory tracking files.
Workflow
Step 1: Identify the Target File
Scan memory/finance/ for files matching statement patterns:
ls memory/finance/statement 2>/dev/null
Always present the list and ask the user which file(s) to update, even if they mentioned a target. This ensures the right file is confirmed before writing.
Step 2: Load Target File & Accept New Statement
- Read the target file to understand its existing structure, format, and conventions
- Accept the new statement content from the user — this includes:
- The
source file path (e.g., PDF filename like
MasterCard Statement-1234 2025-03-25.pdf)
- The
statement content (extracted PDF text, pasted content, etc.)
- Record both the file path and content for reference
- Identify the statement period, card/account, and key figures from the new data
Page-by-Page Mode
When the user says they'll provide pages one by one (or specifies a target file upfront):
- After Step 1, read the target file to learn its structure
- For each page the user provides:
- Parse the content immediately
- Append the parsed transactions to the target file right away (don't wait for all pages)
- Confirm what was recorded (e.g., "Page 1: recorded 15 transactions, running total $X")
- After the last page (user says "done", "last page", or "that's all"):
- Run Step 4 (validate math) against the full statement
- Update the period index table with the summary row
This avoids losing context across many pages and gives the user incremental progress.
Chinese Statements
When statement content is in Chinese:
- Translate descriptions to English but keep the original Chinese in parentheses
- Example:
Amazon Shopping (亚马逊购物)
- Translate column headers, summary fields, and notes to English
- Currency amounts stay as-is (CNY ¥, etc.)
- Date formats: convert to YYYY-MM-DD
Step 3: Record
- Match the format and conventions of the existing file exactly (table structure, headers, field names, date formats, description shortening style)
- Add a summary row to the period index table (if one exists)
- Add the detailed statement section with:
- Period summary (previous balance, payments, purchases, interest, fees, new balance, rewards)
- Transaction table with all line items
- Insert in chronological order, before any other card sections
- Shorten merchant descriptions to match existing style (e.g., "GOOGLE*YOUTUBE SUPER G.CO/HELPPAY#NS ..." → "Google YouTube Super")
Step 4: Validate the Math
After merging, independently verify the statement's arithmetic:
- Sum all transactions (positive = charges, negative = credits/payments)
- Check: Previous Balance + Purchases & Debits − Payments & Credits + Interest + Fees = New Balance
- Check: Transaction sum should equal (Purchases & Debits − Payments & Credits)
- Report to user:
- ✅ "Statement math checks out" if totals match (within $0.02 rounding tolerance)
- ⚠️ "Discrepancy found: calculated X, statement says Y" if they don't match — flag specific items if possible
Also verify:
- Cash back / points calculations if data is available
- Payment due dates and minimum payments are recorded
- No duplicate transactions (same date + amount + description appearing twice unless genuinely separate)
File Naming Convention
Statement files live in memory/finance/ and follow this pattern:
{bank}-{holder}-{type}-{accountid}-statements.md
- bank: Institution name (rbc, bmo, cibc, td, mbna, manulife, hsbc-hk, scb)
- holder: Account holder —
john, jane, or joint
- type: Account type (chequing, saving, mc, visa)
- accountid: Last digits or full account number
Examples:
rbc-john-mc-1234-statements.md
rbc-jane-saving-5678901-statements.md
td-joint-9876543-statements.md
bmo-jane-123456789-statements.md
When creating a new statement file, follow this convention.
Create New Statement File from Existing Template
When the user wants to create a new statement file for a different bank/account using an existing file as a structural template:
- Read the source file to extract its structure: section headings, subsection titles, table headers, summary field names, index table format
- Create the new file (following the naming convention) with:
- All section headings and subsection titles preserved
- All table headers and column structures preserved
-
No data copied — use placeholders or leave empty rows
- Update bank name, account number, card number references to the new account
- Present the new file to the user for confirmation before they start adding statements
This ensures consistent formatting across all statement tracking files.
Notes
- When a card has both primary and co-applicant transactions, keep them in separate sub-tables (matching existing format)
- Preserve existing content — only append new periods, never modify historical data
- If the statement period already exists in the file, warn the user before overwriting