perf(accounting): remove summary from billing, fix acc_dir 0=借/1=贷, add DB index
This commit is contained in:
parent
8976ab6d90
commit
07086034be
@ -18,12 +18,12 @@ 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, d.acc_dir,
|
sql = """select d.acc_date, d.acc_timestamp,
|
||||||
concat('#', substring_index(d.summary, ':', 1)) as summary,
|
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 = '1' 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,
|
||||||
coalesce(sum(case when d.acc_dir = '0' then d.amount else 0 end) over(), 0) as _credit
|
coalesce(sum(case when d.acc_dir = '1' then d.amount else 0 end) over(), 0) as _credit
|
||||||
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
|
||||||
|
|||||||
@ -128,17 +128,7 @@
|
|||||||
"uitype": "str",
|
"uitype": "str",
|
||||||
"datatype": "str",
|
"datatype": "str",
|
||||||
"label": "方向",
|
"label": "方向",
|
||||||
"cwidth": 8
|
"cwidth": 6
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "summary",
|
|
||||||
"title": "摘要",
|
|
||||||
"type": "str",
|
|
||||||
"length": 100,
|
|
||||||
"uitype": "str",
|
|
||||||
"datatype": "str",
|
|
||||||
"label": "摘要",
|
|
||||||
"cwidth": 30
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "amount",
|
"name": "amount",
|
||||||
|
|||||||
@ -46,7 +46,7 @@ order by d.acc_date desc"""
|
|||||||
|
|
||||||
# 数据
|
# 数据
|
||||||
for rec in recs:
|
for rec in recs:
|
||||||
direction = '借' if rec.acc_dir == '1' else '贷'
|
direction = '借' if rec.acc_dir == '0' else '贷'
|
||||||
ws.append([
|
ws.append([
|
||||||
str(rec.acc_date),
|
str(rec.acc_date),
|
||||||
str(rec.acc_timestamp),
|
str(rec.acc_timestamp),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user