#!/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:VirtualCard:Alipay"

_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:CNY"
_assets_account["花呗"] = "Liabilities:VirtualCard:AntCreditPay"
_assets_account["招行信用卡|0000"] = "Liabilities:CreditCard:CMB"
_assets_account["招行储蓄卡|1111"] = "Assets:Bank:CMB"
_assets_account["支付宝"] = "Assets:VirtualCard:Alipay"
_assets_account["余额宝"] = "Assets:MoneyFund:Yuebao"
_assets_account["零钱"] = "Assets:VirtualCard:WeChat"
_assets_account["/"] = "Assets:VirtualCard:WeChat"
_assets_account["1450"] = "Liabilities:CreditCard:BOC:UnionPay"
_assets_account["1243"] = "Assets:Bank:CMB"
_assets_account["零钱通"] = "Assets:MoneyFund:ChangeTong"


# _debit_account负责保存支出账户信息，key为与该账户相关的关键词；
# 关键词中，"DEFAULT"为非必选项，不提供时将以"_default_account_xxx"的属性值作为"DEFAULT"对应的值；
# 多个关键词用竖线分割，只要当交易为“支出”，且交易对方名称和商品名称中出现该关键词，就把该交易分类为对应支出。
_debit_account = {}
_debit_account["DEFAULT"] = "Expenses:Other"
_debit_account["iCloud|腾讯云|阿里云"] = "Expenses:Digital:Other"
_debit_account["App Store|Steam|会员"] = "Expenses:Digital:Other"
_debit_account["全时|华联|家乐福|超市|红旗|WOWO|百货|伊藤|永旺|全家"] = "Expenses:Other"
_debit_account["汽车票|蒜芽信息科技|优步|火车|动车|空铁无忧网|滴滴|汽车|运输|机场|航空|机票|高铁|出行|车费|打车"] = "Expenses:Transportation:Other"
_debit_account["捐赠"] = "Expenses:PublicWelfare"
_debit_account["话费|流量|手机|中国移动"] = "Expenses:Bills:Phone"
_debit_account["电影"] = "Expenses:Fun:Amusement"
_debit_account["地铁"] = "Expenses:Transportation:Bus"
_debit_account["衣|裤|鞋"] = "Expenses:Clothing:Clothes"
_debit_account["造型"] = "Expenses:Dressup:Maintain"
_debit_account["医院|药房"] = "Expenses:Health:Medical"
_debit_account["深圳市枫叶酒店投资有限公司-消费"] = "Expenses:Bills:Internet"
_debit_account["借款"] = "Assets:Receivables"
_debit_account["蚂蚁财富"] = "Assets:MoneyFund:BondFund"

# _credit_account负责保存收入账户信息，key为与该账户相关的关键词
# 关键词中，"DEFAULT"为非必选项，不提供时将以"_default_account_xxx"的属性值作为"DEFAULT"对应的值；
# 多个关键词用竖线分割，只要当交易为“收入”，且交易对方名称和商品名称中出现该关键词，就把该交易分类为对应收入。
_credit_account = {}
_credit_account["DEFAULT"] = "Income:Other"
_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)
]
