fix(accounting): remove date column, sort by timestamp, direction 借/贷
This commit is contained in:
parent
b8541d6730
commit
da4b0877c8
@ -14,12 +14,12 @@ ns = {
|
|||||||
'end_date': end_date,
|
'end_date': end_date,
|
||||||
'page': int(params_kw.get('page', 1)),
|
'page': int(params_kw.get('page', 1)),
|
||||||
'rows': int(params_kw.get('rows', 60)),
|
'rows': int(params_kw.get('rows', 60)),
|
||||||
'sort': 'acc_date desc'
|
'sort': 'acc_timestamp desc'
|
||||||
}
|
}
|
||||||
|
|
||||||
async with get_sor_context(request._run_ns, 'accounting') as sor:
|
async with get_sor_context(request._run_ns, 'accounting') as sor:
|
||||||
sql = """select d.acc_date, d.acc_timestamp,
|
sql = """select d.acc_timestamp,
|
||||||
d.acc_dir,
|
case when d.acc_dir = '0' then '借' else '贷' end as acc_dir,
|
||||||
d.amount, d.balance, s.name as subject_name,
|
d.amount, d.balance, s.name as subject_name,
|
||||||
count(*) over() as _total,
|
count(*) over() as _total,
|
||||||
coalesce(sum(case when d.acc_dir = '0' then d.amount else 0 end) over(), 0) as _debit,
|
coalesce(sum(case when d.acc_dir = '0' then d.amount else 0 end) over(), 0) as _debit,
|
||||||
|
|||||||
@ -90,15 +90,6 @@
|
|||||||
"exclouded": ["row_num_"]
|
"exclouded": ["row_num_"]
|
||||||
},
|
},
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
|
||||||
"name": "acc_date",
|
|
||||||
"title": "日期",
|
|
||||||
"type": "date",
|
|
||||||
"uitype": "date",
|
|
||||||
"datatype": "date",
|
|
||||||
"label": "日期",
|
|
||||||
"cwidth": 12
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "acc_timestamp",
|
"name": "acc_timestamp",
|
||||||
"title": "时间",
|
"title": "时间",
|
||||||
@ -106,7 +97,7 @@
|
|||||||
"uitype": "timestamp",
|
"uitype": "timestamp",
|
||||||
"datatype": "timestamp",
|
"datatype": "timestamp",
|
||||||
"label": "时间",
|
"label": "时间",
|
||||||
"cwidth": 16
|
"cwidth": 18
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "subject_name",
|
"name": "subject_name",
|
||||||
|
|||||||
@ -19,16 +19,18 @@ ns = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async with get_sor_context(request._run_ns, 'accounting') as sor:
|
async with get_sor_context(request._run_ns, 'accounting') as sor:
|
||||||
sql = """select d.acc_date, d.acc_timestamp,
|
sql = """select d.acc_timestamp,
|
||||||
concat('#', substring_index(d.summary, ':', 1)) as summary,
|
concat('#', substring_index(d.summary, ':', 1)) as summary,
|
||||||
s.name as subject_name, d.acc_dir, d.amount, d.balance
|
s.name as subject_name,
|
||||||
|
case when d.acc_dir = '0' then '借' else '贷' end as acc_dir,
|
||||||
|
d.amount, d.balance
|
||||||
from acc_detail d
|
from acc_detail d
|
||||||
join account a on d.accountid = a.id COLLATE utf8mb4_unicode_ci
|
join account a on d.accountid = a.id COLLATE utf8mb4_unicode_ci
|
||||||
left join subject s on a.subjectid = s.id COLLATE utf8mb4_unicode_ci
|
left join subject s on a.subjectid = s.id COLLATE utf8mb4_unicode_ci
|
||||||
where a.orgid = ${orgid}$
|
where a.orgid = ${orgid}$
|
||||||
and d.acc_date >= ${start_date}$
|
and d.acc_date >= ${start_date}$
|
||||||
and d.acc_date <= ${end_date}$
|
and d.acc_date <= ${end_date}$
|
||||||
order by d.acc_date desc"""
|
order by d.acc_timestamp desc"""
|
||||||
recs = await sor.sqlExe(sql, ns)
|
recs = await sor.sqlExe(sql, ns)
|
||||||
|
|
||||||
# 生成 xlsx
|
# 生成 xlsx
|
||||||
@ -37,21 +39,19 @@ order by d.acc_date desc"""
|
|||||||
ws.title = '账单明细'
|
ws.title = '账单明细'
|
||||||
|
|
||||||
# 表头
|
# 表头
|
||||||
headers = ['日期', '时间', '科目', '方向', '摘要', '金额', '余额']
|
headers = ['时间', '科目', '方向', '摘要', '金额', '余额']
|
||||||
ws.append(headers)
|
ws.append(headers)
|
||||||
header_font = Font(bold=True)
|
header_font = Font(bold=True)
|
||||||
for cell in ws[1]:
|
for cell in ws[1]:
|
||||||
cell.font = header_font
|
cell.font = header_font
|
||||||
cell.alignment = Alignment(horizontal='center')
|
cell.alignment = Alignment(horizontal='center')
|
||||||
|
|
||||||
# 数据
|
# 数据
|
||||||
for rec in recs:
|
for rec in recs:
|
||||||
direction = '借' if rec.acc_dir == '0' else '贷'
|
|
||||||
ws.append([
|
ws.append([
|
||||||
str(rec.acc_date),
|
|
||||||
str(rec.acc_timestamp),
|
str(rec.acc_timestamp),
|
||||||
rec.subject_name,
|
rec.subject_name,
|
||||||
direction,
|
rec.acc_dir,
|
||||||
rec.summary,
|
rec.summary,
|
||||||
float(rec.amount),
|
float(rec.amount),
|
||||||
float(rec.balance)
|
float(rec.balance)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user