Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
95 lines (81 sloc) 4.65 KB
#!/usr/bin/env python3
import sys
sys.path.append("./Importers")
from beanmaker import Debit_or_credit, Col, Importer
# Col为枚举类型,预定义了每笔交易记录所需要的内容,_config_alipay负责定义枚举内容与csv表头之间的对应关系
_config_alipay = {}
_config_alipay[Col.DATE] = u"交易创建时间"
_config_alipay[Col.PAYEE] = u"交易对方"
_config_alipay[Col.NARRATION] = u"商品名称"
_config_alipay[Col.REMARK] = u"备注"
_config_alipay[Col.AMOUNT] = u"金额(元)"
_config_alipay[Col.DRCR] = u"收/支"
_config_alipay[Col.STATUS] = u"资金状态"
_config_wechat = {}
_config_wechat[Col.DATE] = u"交易时间"
_config_wechat[Col.PAYEE] = u"交易对方"
_config_wechat[Col.NARRATION] = u"商品"
_config_wechat[Col.REMARK] = u"支付方式"
_config_wechat[Col.AMOUNT] = u"金额(元)"
_config_wechat[Col.DRCR] = u"收/支"
_config_wechat[Col.STATUS] = u"当前状态"
# _default_account负责定义默认账户
_default_account_alipay = "Assets:MoneyFund:Yuebao"
_default_account_wechat = "Assets:VirtualCard:Wechat"
# _currency定义货币单位
_currency = "CNY"
# Debit_or_credit也是枚举类型,预定义了支出和收入两类,_DRCR_dict负责定义这两类与csv中能够表明该状态的文本之间的对应关系
_DRCR_dict = {Debit_or_credit.DEBIT: "支出", Debit_or_credit.CREDIT: "收入"}
# _assets_account负责保存账户信息,key为手工对账时在备注中输入的关键词;
# 关键词中,"DEFAULT"为非必选项,不提供时将以"_default_account_xxx"的属性值作为"DEFAULT"对应的值;
# 多个关键词用竖线分割,只要备注中出现该关键词,就把该交易分类到对应账户下。
_assets_account = {}
_assets_account["DEFAULT"] = "Assets:Cash"
_assets_account["花呗"] = "Liabilities:VirtualCard:Huabei"
_assets_account["招行信用卡|0000"] = "Liabilities:CreditCard:CMB"
_assets_account["招行储蓄卡|1111"] = "Assets:DepositCard:CMB"
_assets_account["支付宝"] = "Assets:VirtualCard:Alipay"
_assets_account["余额宝"] = "Assets:MoneyFund:Yuebao"
_assets_account["微信"] = "Assets:VirtualCard:Wechat"
_assets_account["零钱通"] = "Assets:MoneyFund:ChangeTong"
# _debit_account负责保存支出账户信息,key为与该账户相关的关键词;
# 关键词中,"DEFAULT"为非必选项,不提供时将以"_default_account_xxx"的属性值作为"DEFAULT"对应的值;
# 多个关键词用竖线分割,只要当交易为“支出”,且交易对方名称和商品名称中出现该关键词,就把该交易分类为对应支出。
_debit_account = {}
_debit_account["DEFAULT"] = "Expenses:Daily:Food"
_debit_account["iCloud|腾讯云|阿里云"] = "Expenses:Tech:Subscription"
_debit_account["App Store|Steam|会员"] = "Expenses:Fun:SoftwareAndGame"
_debit_account["全时|华联|家乐福|超市|红旗|WOWO|百货|伊藤|永旺|全家"] = "Expenses:Daily:Commodity"
_debit_account["汽车票|蒜芽信息科技|优步|火车|动车|空铁无忧网|滴滴|汽车|运输|机场|航空|机票|高铁|出行|车费|打车"] = "Expenses:Travelling"
_debit_account["捐赠"] = "Expenses:PublicWelfare"
_debit_account["话费|流量|手机|中国移动"] = "Expenses:Daily:PhoneCharge"
_debit_account["电影"] = "Expenses:Fun:Amusement"
_debit_account["地铁"] = "Expenses:Travelling:TransportCard"
_debit_account["衣|裤|鞋"] = "Expenses:Dressup:Clothing"
_debit_account["造型"] = "Expenses:Dressup:Maintain"
_debit_account["医院|药房"] = "Expenses:Health:Hospital"
_debit_account["酒店"] = "Expenses:House:Hotel"
_debit_account["借款"] = "Assets:Receivables"
_debit_account["蚂蚁财富"] = "Assets:MoneyFund:BondFund"
# _credit_account负责保存收入账户信息,key为与该账户相关的关键词
# 关键词中,"DEFAULT"为非必选项,不提供时将以"_default_account_xxx"的属性值作为"DEFAULT"对应的值;
# 多个关键词用竖线分割,只要当交易为“收入”,且交易对方名称和商品名称中出现该关键词,就把该交易分类为对应收入。
_credit_account = {}
_credit_account["DEFAULT"] = "Income:MoneyFund"
_credit_account["借款"] = "Assets:Receivables"
CONFIG = [
Importer(config=_config_alipay,
default_account=_default_account_alipay,
currency=_currency,
DRCR_dict=_DRCR_dict,
assets_account=_assets_account,
debit_account=_debit_account,
credit_account=_credit_account),
Importer(config=_config_wechat,
default_account=_default_account_wechat,
currency=_currency,
DRCR_dict=_DRCR_dict,
assets_account=_assets_account,
debit_account=_debit_account,
credit_account=_credit_account)
]
You can’t perform that action at this time.