公司的用友NC5.7还有三个月的服役期,写这个也没什么用,且当记录一下了。
因为最近在搞成本核算,所以只导出了部门和项目辅助核算,其他的改起来其实也很简单。
只导出了科目、部门、项目的代码,要对应成中文的话也很简单,需要匹配一下。
import xml.etree.ElementTree as ET
import os
import pandas as pd
filepath = ''
dest = ''
tree = ET.parse(filepath)
root = tree.getroot()
li = []
for voucher in root.findall('.//voucher'):
head = voucher.findall('.//voucher_head')[0]
body = voucher.findall('.//voucher_body')[0]
company = head.find('.//company').text
voucher_type = head.find('.//voucher_type').text
fiscal_year = head.find('.//fiscal_year').text
accounting_period = head.find('.//accounting_period').text
voucher_id = head.find('.//voucher_id').text
date = head.find('.//date').text
enter = head.find('.//enter').text
header = {
'主体名称': company,
'凭证类型': voucher_type,
'会计年度': fiscal_year,
'会计月份': accounting_period,
'凭证号码': voucher_id,
'记账日期': date,
'制单人名': enter,
}
for entry in body.findall('entry'):
item = {i.tag:i.text for i in entry.findall('*')}
r = {
'行号': item['entry_id'],
'会计科目': item['account_code'],
'借方余额': item['primary_debit_amount'],
'贷方余额': item['primary_credit_amount']
}
if 'auxiliary_accounting' in item.keys():
r.update({i.get('name'):i.text for i in entry.find('auxiliary_accounting').findall('*')})
r.update(header)
li.append(r)
pd.DataFrame(li).to_excel(dest,index=None)



Comments | NOTHING