diff --git a/wwwroot/billing.dspy b/wwwroot/billing.dspy index 2a472f3..16e941a 100644 --- a/wwwroot/billing.dspy +++ b/wwwroot/billing.dspy @@ -14,12 +14,12 @@ ns = { 'end_date': end_date, 'page': int(params_kw.get('page', 1)), '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: - sql = """select d.acc_date, d.acc_timestamp, -d.acc_dir, + sql = """select d.acc_timestamp, +case when d.acc_dir = '0' then '借' else '贷' end as acc_dir, d.amount, d.balance, s.name as subject_name, count(*) over() as _total, coalesce(sum(case when d.acc_dir = '0' then d.amount else 0 end) over(), 0) as _debit, diff --git a/wwwroot/billing.ui b/wwwroot/billing.ui index 1afb518..366de05 100644 --- a/wwwroot/billing.ui +++ b/wwwroot/billing.ui @@ -90,15 +90,6 @@ "exclouded": ["row_num_"] }, "fields": [ - { - "name": "acc_date", - "title": "日期", - "type": "date", - "uitype": "date", - "datatype": "date", - "label": "日期", - "cwidth": 12 - }, { "name": "acc_timestamp", "title": "时间", @@ -106,7 +97,7 @@ "uitype": "timestamp", "datatype": "timestamp", "label": "时间", - "cwidth": 16 + "cwidth": 18 }, { "name": "subject_name", diff --git a/wwwroot/billing_download.dspy b/wwwroot/billing_download.dspy index 95a6bd9..f88bae0 100644 --- a/wwwroot/billing_download.dspy +++ b/wwwroot/billing_download.dspy @@ -19,16 +19,18 @@ ns = { } 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, -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 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 where a.orgid = ${orgid}$ and d.acc_date >= ${start_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) # 生成 xlsx @@ -37,21 +39,19 @@ order by d.acc_date desc""" ws.title = '账单明细' # 表头 - headers = ['日期', '时间', '科目', '方向', '摘要', '金额', '余额'] + headers = ['时间', '科目', '方向', '摘要', '金额', '余额'] ws.append(headers) header_font = Font(bold=True) for cell in ws[1]: cell.font = header_font cell.alignment = Alignment(horizontal='center') - + # 数据 for rec in recs: - direction = '借' if rec.acc_dir == '0' else '贷' ws.append([ - str(rec.acc_date), str(rec.acc_timestamp), rec.subject_name, - direction, + rec.acc_dir, rec.summary, float(rec.amount), float(rec.balance)