# 汇率创建 ns = { 'id': getID(), 'from_currency': params_kw.get('from_currency', ''), 'to_currency': params_kw.get('to_currency', ''), 'buy_rate': params_kw.get('buy_rate', 0), 'sell_rate': params_kw.get('sell_rate', 0), 'mid_rate': params_kw.get('mid_rate', 0), 'effective_date': params_kw.get('effective_date', curDateString()), 'updated_at': timestampstr(), } if not ns['from_currency'] or not ns['to_currency']: return json.dumps({'success': False, 'message': 'from_currency and to_currency required'}) async with get_sor_context(request._run_ns, 'accounting') as sor: await sor.C('exchange_rate', ns) return json.dumps({'success': True, 'message': '汇率已创建'})