Coder Social home page Coder Social logo

china_bean_importers's Introduction

china_bean_importers

Test Python package

Beancount 导入脚本,支持的数据源包括:

  • 微信支付
  • 支付宝(网页端、手机端)
  • **银行信用卡、借记卡
  • 招商银行借记卡
  • 建设银行借记卡
  • 民生银行借记卡、信用卡(测试)
  • 清华大学校园卡(新、旧)

使用方法

克隆本仓库或作为 submodule:

git clone https://github.com/jiegec/china_bean_importers
# or
git submodule add [email protected]:jiegec/china_bean_importers.git

安装 importer 和依赖:

pip install --editable .

运行 cp config.example.py config.py 复制配置模板,编辑 config.py 填入你的配置,放置在你的项目目录中

最后,在 beancount 使用的导入脚本中按需加入:

from china_bean_importers import wechat, alipay_web, alipay_mobile, boc_credit_card, boc_debit_card, cmb_debit_card

from china_bean_importer_config import config # your config file name

CONFIG = [
    wechat.Importer(config),
    alipay_web.Importer(config),
    alipay_mobile.Importer(config),
    boc_credit_card.Importer(config),
    boc_debit_card.Importer(config),
    cmb_debit_card.Importer(config),
]

可用 Importer

微信支付(wechat

导出方法:我的->支付->钱包->账单->常见问题->下载账单->用于个人对账

下载邮件附件,解压得到 csv 文件,如:

微信支付账单明细,,,,,,,,
微信昵称:[123412341234],,,,,,,,
起始时间:[2022-11-01 00:00:00] 终止时间:[2023-02-01 00:00:00],,,,,,,,

支付宝(网页端)(alipay_web

导出方法:访问支付宝官网->登录->查看所有交易记录->筛选->下载 Txt 格式账单

下载后,解压得到 txt 文件,如:

支付宝交易记录明细查询
账号:[123412341234]
起始日期:[2023-01-26 00:00:00]    终止日期:[2023-02-01 00:00:00]

但支付宝网页端导出的数据并没有记录付款账户,因此不适合 beancount,不推荐使用

支付宝(手机端)(alipay_mobile

导出方法:我的->账单->...->开具交易流水证明->用于个人对账->申请

下载邮件附件,解压得到 csv 文件,如:

------------------------支付宝(**)网络技术有限公司  电子客户回单------------------------
收/支                 ,交易对方                ,对方账号                ,商品说明                ,收/付款方式              ,金额                  ,交易状态                ,交易分类                ,交易订单号     ,商家订单号           ,交易时间            ,

**银行信用卡(boc_credit_card

每个月中行会发送信用卡合并账单,下载邮件附件 PDF;或者在**银行手机客户端-信用卡-历史账单-选择月份-发送电子账单,从邮箱保存,获得 EML 格式的文件。

Importer 可自动识别上述两种格式。

**银行借记卡(boc_debit_card

在**银行手机客户端,点击更多->助手->交易流水打印->立即申请,记录下 PDF 密码。

下载邮件附件,得到带有密码的 PDF 文件,把密码记录到 config.py 中,或者使用工具去除密码。

**建设银行借记卡(ccb_debit_card

手机客户端导出方法:我的->银行卡->管理->明细导出->明细导出申请->选择发送方式为 Excel。申请成功后,查询导出历史,得到解压密码。

下载邮件附件,输入密码解压 ZIP 文件,得到 XLS,转换为 CSV 格式。

招商银行借记卡(cmb_debit_card

在手机银行客户端,点击首页->流水打印->高级筛选->显示完整卡号->显示收入及支出汇总金额->同意协议并提交,记录下解压密码。

下载邮件附件,输入密码解压 ZIP 文件,得到 PDF。

民生银行借记卡(cmbc_debit_card

在手机银行客户端,点击收支明细->(右上角菜单)交易明细->导出(下载电子版明细)->交易类型全部->排版方式横版->同意协议并提交。

下载邮件附件,解压 ZIP 文件,得到 PDF。

民生银行信用卡(cmbc_crebit_card

Importer 支持以下两种格式:

  1. 民生银行发送至邮箱的电子账单 EML 文件(推荐,可自动识别货币)。

  2. 手动将查询(民生银行信用卡-登录-账单查询)的账单转换为 CSV 文件,格式为(带表头,注意各列顺序):

交易日,记账日,卡号末四位,授权码,金额,摘要
0104,20230104,XXXX,,-88.88,foo-bar

注意此方法默认所有交易货币均为 CNY。

清华大学校园卡(旧)(thu_ecard_old

导出方式:校园网环境登录 <ecard.tsinghua.edu.cn>,交易日志查询->导出,并使用 Excel 转存为 CSV 格式。

注意:导出总是包含入学以来所有记录,可根据需要删除此前已经导入的内容。

清华大学校园卡(新)(thu_ecard

由于校园卡系统与浏览器交互的数据进行了一定的“加密”(并无实际意义),原始数据的获取需要按照以下步骤进行:

  1. 使用统一身份认证登录 card.tsinghua.edu.cn
  2. 按 F12 打开浏览器工具,复制 thu_ecard/decode.js 的代码,粘贴到控制台中。修改必要的参数:idserial 改为本人学工号,starttimeendtime 改为需要的日期范围(闭区间)。然后执行。
  3. 将控制台中打印的 JSON 转换为 CSV 格式存储(可使用在线工具 123,或使用 Pandas 等库)。

测试 Importer

微众银行借记卡(尚未实现)

手机客户端导出方法:左上角菜单->证明开具->微众卡交易流水。

下载邮件附件,输入密码解压 ZIP 文件,得到 PDF。

china_bean_importers's People

Contributors

circuitcoder avatar dependabot[bot] avatar earthcompass avatar harry-chen avatar ihopenot avatar jiegec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

china_bean_importers's Issues

**银行信用卡导入项目缺失

现在的**银行信用卡导入是从每月自动发的pdf文件里面提取,但是pdf里面表格一行可能是同一个block,列混合在一起,就会导致提取信息出问题。

**银行手机客户端->信用卡->账单查询->历史账单->右上角三个点->发送电子对账单处得到的账单是原始的HTML格式,可能更适合信息的提取。(挖坑)

卡后后四位0开头导致匹配失败

card_number = str(card_number)

这里将卡号从int转为str的时候,如果卡号后四位开头有0,就会导致匹配不上。

问题源于在于一些地方提取出卡号后,把卡号转成了int,例如:

card_number = int(match[1])

不是很确定如何修复比较合适,是匹配的时候补齐0,还是全部换成str保存卡号,又或者匹配的时候考虑匹配后缀呢?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.