Commit Graph

14 Commits

Author SHA1 Message Date
a2de8c5078 feat: implement WeChat cross-batch refund reconciliation and fix misc issues
WeChat cross-batch refund reconciliation:
- Add OriginalAmount field to CleanedBill for accurate cumulative refund math
- DeduplicateRawFile detects WeChat status-update rows (已退款/已全额退款) and
  emits WechatRefundUpdates for Go-side reconciliation (Scenario 1)
- WechatPy cleaner surfaces -退款 income rows with no same-batch expense match
  as unresolved_refunds for Go ReconcileRefund (Scenario 2)
- Add ReconcileWechatRefund to repository interface and MongoDB implementation
- upload.go step 15 iterates WechatRefundUpdates and reconciles against bills_cleaned

Bug fixes:
- ReviewStats: add nil repo check to prevent panic when DB is not connected
- JWT: remove hardcoded fallback secret; return 500/401 if JWTSecret not configured
- Remove unused parsePageParam dead code and its strconv import
- BillDetailDrawer: show 不计收支 amount in muted gray instead of red
- test_jd_cleaner.py: replace hardcoded D:\Projects\BillAI path with dynamic __file__ resolution

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-16 21:38:25 +08:00
e2e1beb6f7 feat: implement cross-batch Alipay refund reconciliation
When a refund row in an uploaded Alipay bill has no matching expense
row in the same batch (because the original purchase was uploaded in a
prior batch), the refund is now reconciled against the stored record in
bills_cleaned rather than being silently discarded.

Changes:
- analyzer/cleaners/base.py: add unresolved_refunds list to BaseCleaner
- analyzer/cleaners/alipay.py: _aggregate_refunds stores full refund
  metadata (dict); _process_expenses tracks matched keys and populates
  self.unresolved_refunds for unmatched refunds
- analyzer/server.py: thread unresolved_refunds through do_clean,
  CleanResponse, and both /clean endpoints
- server/adapter/adapter.go: add UnresolvedRefund type and field to CleanResult
- server/adapter/http/cleaner.go: deserialize unresolved_refunds from
  Python response and populate CleanResult
- server/repository/repository.go: add ReconcileRefund to BillRepository interface
- server/repository/mongo/repository.go: implement ReconcileRefund —
  full refund soft-deletes the bill, partial refund reduces amount and
  appends remark with original amount and refund order number
- server/handler/upload.go: capture clean result and call ReconcileRefund
  for each unresolved refund after saving cleaned bills
- server/model/response.go: add ReconciledRefundCount to UploadData

Also: add CLAUDE.md (@AGENTS.md), update AGENTS.md, fix DailyTrendChart
missing-date gap by filling zero-expense dates in daily map.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-16 19:29:47 +08:00
clz
aa4f1615ce fix: 统一各页面账单分类来源
bills 和 review 页面改从 $lib/data/categories 导入分类列表,
删除本地重复硬编码的旧版 13 项分类。
BillDetailDrawer 的 categories prop 类型改为 readonly string[]
以兼容 as const 导出的元组类型。
2026-03-03 20:50:45 +08:00
clz
642ea2d3ef fix: 修复账单删除功能并支持分析页面删除操作
Some checks failed
Deploy BillAI / Deploy to Production (push) Has been cancelled
- 将删除接口从 DELETE /api/bills/:id 改为 POST /api/bills/:id/delete 以兼容 SvelteKit 代理
- 分析页面组件 (TopExpenses/BillRecordsTable/DailyTrendChart) 支持删除并同步更新统计数据
- Review 接口改为直接查询 MongoDB 而非读取文件
- 软删除时记录 updated_at 时间戳
- 添加 .dockerignore 文件优化构建
- 完善 AGENTS.md 文档
2026-02-16 22:28:49 +08:00
clz
bacbabc0a5 feat: 添加账单软删除功能
- 新增删除按钮(带二次确认)到账单详情抽屉
- 后端实现软删除(设置 is_deleted 标记)
- 所有查询方法自动过滤已删除记录
- 账单列表和复核页面都支持删除
- 版本更新至 1.2.0
2026-01-25 18:49:07 +08:00
clz
654989d3dd fix: 修复账单编辑后刷新才生效的问题
- 在分析页面添加 handleBillUpdated 回调,编辑后同步更新 records 和 allRecords
- 为 TopExpenses、CategoryRanking、DailyTrendChart 组件添加 onUpdate prop
- 修复 TopExpenses 组件内响应式更新,使用新数组引用触发更新
- 建立完整的更新传播链:BillDetailDrawer -> BillRecordsTable -> 各分析组件 -> 分析页面
- 确保所有派生数据(topExpenses、categoryStats、pieChartData)自动刷新
2026-01-19 01:12:33 +08:00
clz
65ea2fa477 refactor(web): unify bills as UIBill, remove BillRecord 2026-01-18 21:14:54 +08:00
clz
c61691249f fix(web): 修复弹窗裁切/宽度与日期选择器 2026-01-18 20:17:48 +08:00
clz
f5afb0c135 feat: 支持账单编辑(PATCH /api/bills/:id) 2026-01-18 20:17:19 +08:00
48332efce4 fix: 修复日期范围选择器时区和性能问题
- 修复时区问题:使用本地时区格式化日期,避免 toISOString() 导致的日期偏移
- 优化日期范围选择器性能:使用 untrack 避免循环更新
- 统一日期格式化方法:在 utils.ts 中添加 formatLocalDate 工具函数
- 修复分页逻辑:优化页码计算和显示
- 更新相关页面:bills 和 analysis 页面使用统一的日期格式化方法
2026-01-10 01:51:18 +08:00
087ae027cc feat: 完善项目架构并增强分析页面功能
- 新增项目文档和 Docker 配置
  - 添加 README.md 和 TODO.md 项目文档
  - 为各服务添加 Dockerfile 和 docker-compose 配置

- 重构后端架构
  - 新增 adapter 层(HTTP/Python 适配器)
  - 新增 repository 层(数据访问抽象)
  - 新增 router 模块统一管理路由
  - 新增账单处理 handler

- 扩展前端 UI 组件库
  - 新增 Calendar、DateRangePicker、Drawer、Popover 等组件
  - 集成 shadcn-svelte 组件库

- 增强分析页面功能
  - 添加时间范围筛选器(支持本月默认值)
  - 修复 DateRangePicker 默认值显示问题
  - 优化数据获取和展示逻辑

- 完善分析器服务
  - 新增 FastAPI 服务接口
  - 改进账单清理器实现
2026-01-10 01:23:36 +08:00
CHE LIANG ZHAO
ccd2d0386a feat(analysis): 趋势图增加本周选项、线性图简化为总金额曲线
- 添加本周时间范围选项
- 线性图模式只显示总支出曲线,不再显示分类曲线
- 图例根据图表类型动态切换(堆叠图显示分类,线性图显示总支出)
- 时间范围选项:7天、本周、30天、本月、3个月、本年
2026-01-08 11:33:30 +08:00
CHE LIANG ZHAO
b226c85fa7 feat(analysis): 添加账单详情查看和编辑功能
- BillRecordsTable: 新增点击行查看详情弹窗,支持编辑模式
- CategoryRanking: 分类支出表格支持点击查看/编辑账单详情
- DailyTrendChart: 每日趋势表格支持点击查看/编辑账单详情
- TopExpenses: Top10支出支持点击查看/编辑,前三名高亮显示
- OverviewCards/MonthlyTrend: 添加卡片hover效果
- 新增 categories.ts: 集中管理账单分类数据
- 分类下拉按使用频率排序
2026-01-08 10:48:11 +08:00
clz
9d409d6a93 feat(analysis): 增强图表交互功能
- 分类支出排行: 饼图支持点击类别切换显示/隐藏,百分比动态重新计算
- 每日支出趋势: 图例支持点击切换类别显示,隐藏类别不参与堆叠计算
- Dialog列表: 添加列排序功能(时间/商家/描述/金额)
- Dialog列表: 添加分页功能,每页10条(分类)/8条(每日)
- 饼图hover效果: 扇形放大、阴影增强、中心显示详情
2026-01-08 02:55:54 +08:00