This commit is contained in:
yumoqing 2026-06-29 12:14:04 +08:00
parent b880673d79
commit 17554a1038
2 changed files with 5 additions and 4 deletions

View File

@ -72,7 +72,7 @@ async def get_all_customer_credits(sor, orgid, status_filter=None):
For distributor sales to see all their customers' credit status. For distributor sales to see all their customers' credit status.
""" """
where_clause = "WHERE cl.orgid = ${orgid}$" where_clause = "WHERE cl.orgid = ${orgid}$"
params = {'orgid': orgid} params = {'orgid': orgid, 'sort': 'update_at desc'}
if status_filter and status_filter != 'all': if status_filter and status_filter != 'all':
where_clause += " AND cl.status = ${status}$" where_clause += " AND cl.status = ${status}$"
params['status'] = status_filter params['status'] = status_filter
@ -92,9 +92,10 @@ async def get_all_customer_credits(sor, orgid, status_filter=None):
LEFT JOIN account acc ON cl.accountid = acc.id COLLATE utf8mb4_unicode_ci LEFT JOIN account acc ON cl.accountid = acc.id COLLATE utf8mb4_unicode_ci
LEFT JOIN subject sub ON acc.subjectid = sub.id COLLATE utf8mb4_unicode_ci LEFT JOIN subject sub ON acc.subjectid = sub.id COLLATE utf8mb4_unicode_ci
{where_clause} {where_clause}
ORDER BY cl.updated_at DESC
""" """
recs = await sor.sqlExe(sql, params) recs = await sor.sqlExe(sql, params.copy())
if len(recs) == 0:
debug(f'{sql=}, {params=} get no data')
return recs return recs

View File

@ -105,6 +105,6 @@ async def get_all_credits_web(request):
"""Web wrapper for get_all_customer_credits - used in Jinja2 .ui templates""" """Web wrapper for get_all_customer_credits - used in Jinja2 .ui templates"""
env = request._run_ns env = request._run_ns
userorgid = await env.get_userorgid() userorgid = await env.get_userorgid()
status_filter = getattr(request, '_params_kw', {}).get('status', None) if hasattr(request, '_params_kw') else None status_filter = env.params_kw.get('status', None)
async with get_sor_context(env, 'accounting') as sor: async with get_sor_context(env, 'accounting') as sor:
return await get_all_customer_credits(sor, userorgid, status_filter) return await get_all_customer_credits(sor, userorgid, status_filter)