supplychain/wwwroot/update_provider_settlement.dspy

42 lines
1.2 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 供应商结算确认(同add_provider_settlement逻辑update用于确认操作)
ns = params_kw.copy()
record_id = ns.get('id', '')
remark = ns.get('remark', '')
if not record_id:
return json.dumps({'success': False, 'error': '缺少记录ID'}, ensure_ascii=False)
sc_dbname = get_module_dbname('supplychain')
userorgid = await get_userorgid()
db = DBPools()
async with db.sqlorContext(sc_dbname) as sor:
recs = await sor.sqlExe("""
SELECT sa.* FROM supplychain_accounting sa
WHERE sa.id = ${record_id}$
""", {'record_id': record_id})
if not recs:
return json.dumps({'success': False, 'error': '记录不存在'}, ensure_ascii=False)
rec = recs[0]
# 更新结算状态
async with db.sqlorContext(sc_dbname) as sc_sor:
await sc_sor.sqlExe("""
UPDATE sales_ledger
SET settlement_status = '1', updated_at = NOW(), remark = ${remark}$
WHERE productid = ${productid}$
AND supplier_id = ${supplier_id}$
AND sale_date = ${sale_date}$
""", {
'productid': rec.productid,
'supplier_id': rec.supplier_id,
'sale_date': str(rec.sale_date),
'remark': remark
})
debug(f'update_provider_settlement: confirmed {record_id}')
return json.dumps({'success': True, 'message': '结算已确认'}, ensure_ascii=False)