fix: replace uuid.uuid4() with getID() from appPublic.uniqueID for all table ID generation

This commit is contained in:
yumoqing 2026-05-08 15:47:23 +08:00
parent 09c374d47a
commit dd4a1ad609

View File

@ -5,6 +5,7 @@ Financial Management Module - Core Business Logic
""" """
import uuid import uuid
from appPublic.uniqueID import getID
from datetime import datetime, date, timedelta from datetime import datetime, date, timedelta
from typing import Dict, List, Optional from typing import Dict, List, Optional
from decimal import Decimal from decimal import Decimal
@ -43,7 +44,7 @@ async def create_receivable_from_order(order_id: str, org_id: str) -> str:
created_at = datetime.strptime(created_at, "%Y-%m-%d %H:%M:%S") created_at = datetime.strptime(created_at, "%Y-%m-%d %H:%M:%S")
due_date = (created_at + timedelta(days=30)).date() if created_at else None due_date = (created_at + timedelta(days=30)).date() if created_at else None
receivable_id = str(uuid.uuid4()).replace('-', '')[:32] receivable_id = getID()[:32]
await sor.sqlExe(""" await sor.sqlExe("""
INSERT INTO receivables (id, order_id, contract_id, customer_id, receivable_amount, received_amount, due_date, status, org_id, created_at, updated_at) INSERT INTO receivables (id, order_id, contract_id, customer_id, receivable_amount, received_amount, due_date, status, org_id, created_at, updated_at)
@ -64,7 +65,7 @@ async def create_receivable_from_order(order_id: str, org_id: str) -> str:
async def create_receipt(receipt_data: Dict, user_id: str, org_id: str) -> str: async def create_receipt(receipt_data: Dict, user_id: str, org_id: str) -> str:
"""收款录入""" """收款录入"""
async with await get_financial_db() as sor: async with await get_financial_db() as sor:
receipt_id = str(uuid.uuid4()).replace('-', '')[:32] receipt_id = getID()[:32]
await sor.sqlExe(""" await sor.sqlExe("""
INSERT INTO receipts (id, customer_id, total_amount, receipt_date, receipt_method, status, org_id, created_by, created_at, updated_at) INSERT INTO receipts (id, customer_id, total_amount, receipt_date, receipt_method, status, org_id, created_by, created_at, updated_at)
@ -132,7 +133,7 @@ async def send_overdue_notifications(org_id: str, days_overdue: int = 30) -> int
async def create_payment(payment_data: Dict, user_id: str, org_id: str) -> str: async def create_payment(payment_data: Dict, user_id: str, org_id: str) -> str:
"""创建支出记录""" """创建支出记录"""
async with await get_financial_db() as sor: async with await get_financial_db() as sor:
payment_id = str(uuid.uuid4()).replace('-', '')[:32] payment_id = getID()[:32]
await sor.sqlExe(""" await sor.sqlExe("""
INSERT INTO payments (id, contract_id, payment_amount, payment_date, payment_method, status, org_id, created_by, created_at, updated_at) INSERT INTO payments (id, contract_id, payment_amount, payment_date, payment_method, status, org_id, created_by, created_at, updated_at)