Finance Statements
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:
CODEBLOCK0
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
- 1. 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
- 3. 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):
- 1. 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")
- 3. 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
- 1. 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
- 4. 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:
- 1. 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:
CODEBLOCK1
- - bank: Institution name (rbc, bmo, cibc, td, mbna, manulife, hsbc-hk, scb)
- holder: Account holder —
john, jane, or INLINECODE7 - type: Account type (chequing, saving, mc, visa)
- accountid: Last digits or full account number
Examples:
- - INLINECODE8
- INLINECODE9
- INLINECODE10
- INLINECODE11
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:
- 1. 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
- 3. 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
财务报表
跟踪财务报表数据并将其记录到内存跟踪文件中。
工作流程
步骤 1:识别目标文件
扫描 memory/finance/ 目录,查找匹配 statement 模式的文件:
bash
ls memory/finance/statement 2>/dev/null
始终列出文件列表并询问用户要更新哪个(哪些)文件,即使他们提到了目标文件。这确保在写入之前确认正确的文件。
步骤 2:加载目标文件并接受新报表
- 1. 读取目标文件以了解其现有结构、格式和惯例
- 接受用户提供的新报表内容——包括:
-
源文件路径(例如,PDF文件名如 MasterCard Statement-1234 2025-03-25.pdf)
-
报表内容(提取的PDF文本、粘贴的内容等)
- 记录文件路径和内容以供参考
- 3. 从新数据中识别报表期间、卡/账户和关键数字
逐页模式
当用户表示将逐页提供内容(或预先指定目标文件)时:
- 1. 在步骤 1 之后,读取目标文件以了解其结构
- 对于用户提供的每一页:
- 立即解析内容
- 立即将解析的交易追加到目标文件中(不要等待所有页面)
- 确认已记录的内容(例如,第1页:记录了15笔交易,累计总额$X)
- 3. 在最后一页之后(用户说完成、最后一页或就这些了):
- 对整个报表执行步骤 4(验证计算)
- 使用汇总行更新期间索引表
这避免了在多页之间丢失上下文,并让用户看到逐步进展。
中文报表
当报表内容为中文时:
- 示例:Amazon Shopping (亚马逊购物)
- - 将列标题、汇总字段和备注翻译成英文
- 货币金额保持不变(人民币¥等)
- 日期格式:转换为 YYYY-MM-DD
步骤 3:记录
- 1. 精确匹配现有文件的格式和惯例(表格结构、标题、字段名称、日期格式、描述缩写风格)
- 向期间索引表添加汇总行(如果存在)
- 添加详细的报表部分,包括:
- 期间汇总(上期余额、付款、消费、利息、费用、新余额、奖励)
- 包含所有明细项目的交易表
- 4. 按时间顺序插入,放在其他卡部分之前
- 缩写商户描述以匹配现有风格(例如,GOOGLE*YOUTUBE SUPER G.CO/HELPPAY#NS ... → Google YouTube Super)
步骤 4:验证计算
合并后,独立验证报表的算术:
- 1. 汇总所有交易(正数 = 费用,负数 = 贷记/付款)
- 检查: 上期余额 + 消费和借记 − 付款和贷记 + 利息 + 费用 = 新余额
- 检查: 交易总额应等于(消费和借记 − 付款和贷记)
- 向用户报告:
- ✅ 报表计算验证通过(如果总额匹配,允许$0.02的舍入误差)
- ⚠️ 发现差异:计算值为X,报表显示为Y(如果不匹配——尽可能标记具体项目)
同时验证:
- - 现金返还/积分计算(如果有数据)
- 付款到期日和最低付款额已记录
- 无重复交易(相同日期+金额+描述出现两次,除非确实是独立的)
文件命名规范
报表文件位于 memory/finance/ 目录下,遵循以下模式:
{银行}-{持有人}-{类型}-{账户ID}-statements.md
- - 银行: 机构名称(rbc, bmo, cibc, td, mbna, manulife, hsbc-hk, scb)
- 持有人: 账户持有人——john、jane 或 joint
- 类型: 账户类型(chequing, saving, mc, visa)
- 账户ID: 最后几位数字或完整账号
示例:
- - rbc-john-mc-1234-statements.md
- rbc-jane-saving-5678901-statements.md
- td-joint-9876543-statements.md
- bmo-jane-123456789-statements.md
创建新的报表文件时,请遵循此规范。
从现有模板创建新报表文件
当用户希望使用现有文件作为结构模板为不同的银行/账户创建新的报表文件时:
- 1. 读取源文件以提取其结构:章节标题、子节标题、表头、汇总字段名称、索引表格式
- 创建新文件(遵循命名规范),包含:
- 保留所有章节标题和子节标题
- 保留所有表头和列结构
-
不复制任何数据——使用占位符或留空行
- 将银行名称、账号、卡号引用更新为新账户
- 3. 在用户开始添加报表之前,将新文件呈现给用户确认
这确保了所有报表跟踪文件的格式一致。
备注
- - 当一张卡同时有主卡和联名申请人交易时,将它们放在单独的子表中(匹配现有格式)
- 保留现有内容——仅追加新期间,绝不修改历史数据
- 如果报表期间已存在于文件中,在覆盖之前警告用户