Add Phase 12 server AI semantic accounting layer
This commit is contained in:
@@ -9,6 +9,7 @@ import pandas as pd
|
||||
from sqlalchemy import func, select
|
||||
|
||||
from app.modules.accounting.bank_models import AccountingBankTransaction
|
||||
from app.modules.accounting.ai_service import ai_assist_bank as run_ai_assist_bank, mark_review_outcome
|
||||
from app.modules.accounting.ledger_learning_service import (
|
||||
active_natures,
|
||||
available_tally_guids,
|
||||
@@ -239,9 +240,26 @@ def confirm_review(db, *, tx_id, tenant_id, client_id, nature_id, ledger_name, v
|
||||
|
||||
db.add(tx)
|
||||
db.commit()
|
||||
mark_review_outcome(
|
||||
db,
|
||||
tenant_id=tenant_id,
|
||||
source_type="bank",
|
||||
source_record_id=tx.id,
|
||||
final_nature_id=tx.final_nature_id,
|
||||
final_ledger_name=tx.final_ledger_name,
|
||||
user_id=user_id,
|
||||
)
|
||||
return tx
|
||||
|
||||
|
||||
def ai_assist_transaction(db, *, tx_id, tenant_id, client_id, user_id):
|
||||
tx = db.get(AccountingBankTransaction, int(tx_id))
|
||||
if not tx or int(tx.tenant_id) != int(tenant_id) or int(tx.client_id) != int(client_id):
|
||||
raise ValueError("Bank transaction was not found.")
|
||||
return run_ai_assist_bank(db, tx=tx, user_id=user_id)
|
||||
|
||||
|
||||
|
||||
def visible_workstations(db, tenant_id, branch_id=None):
|
||||
stmt = select(ERPWorkstationAgent).where(
|
||||
ERPWorkstationAgent.tenant_id == tenant_id,
|
||||
|
||||
Reference in New Issue
Block a user