nacha文件生成
nacha3的Python项目详细描述
纳卡
NACHA是固定大小的 用于表示如下组成的金融交易的记录格式:
FileHeader CompanyBatchHeader EntryDetail EntryDetailAddendum ... ... CompanyBatchControl ... FileControl
我们用bryl来表达。写作是 这样做:
withopen('sample.nacha','w')asfo:writer=nacha.Writer(fo)withwriter.begin_file(...):withwriter.begin_company_batch(...):writer.entry(...):......
读取是通过重复这样的记录来完成的:
withopen('sample.nacha','r')asfo:reader=Reader(fo,include_terminal=True)forrecord,terminalinreader:...
或类似这样的结构:
withopen('sample.nacha','r')asfo:reader=Reader(fo)reader.file_header()forcompany_batch_headerinreader.company_batches():forentry_detail,entry_addendainreader.entries():...reader.company_batch_control()reader.file_control()
使用
$ pip install nacha3
开发
$ git clone https://github.com/rockxraj68/nacha3.git $ cd nacha $ mkvirtualenv nacha (nacha)$ pip install -e .[tests](nacha)$ py.test tests.py --cov=nacha --cov-report term-missing