AI Party Ledger Reco
flowchart TD
subgraph Stage1["Stage 1: Page Initialization"]
A1["AIRecoPartyLedgerOption.razor"] --> A2["OnInitializedAsync()"]
A2 --> A3["GetUserRolesCnt() - Role Check (PartyLedgerReco)"]
A2 --> A4["GetAiFeatureCnt() - Feature Check (Code 005)"]
end
subgraph Stage2["Stage 2: User File Upload & Processing"]
B1["User Action"] --> B2["OnSystemLedgerChanged() - Validate System .xlsx"]
B1 --> B3["OnPartyLedgerChanged() - Validate Party .xlsx"]
B2 --> B4["ProcessReconciliation()"]
B3 --> B4
B4 --> B5["GetDbGroupCode() & GetAIInsightsCredits()"]
B4 --> B6["AIRecoService.ProcessAiRecoPartyLedger()"]
end
subgraph Stage3["Stage 3: HTTP API Gateway"]
C1["AIRecoService.cs"] -->|Multipart HTTP POST| C2["AIRecoController.cs"]
C2 --> C3["AIRecoPartyLedgerProcess() - Save Temp Upload Files"]
end
subgraph Stage4["Stage 4: Backend AI Orchestration & Analysis"]
D1["AIRecoOrchestrator.cs"] --> D2["ReconcilePartyLedgerAsync()"]
D2 --> D3["PartyLedgerRecoExtractionSkill - Extract System & Party Ledgers"]
D2 --> D4["PartyLedgerRecoMatchingSkill - 4-Pass AI Row Matching Engine"]
D2 --> D5["T-Ledger Unmatched Auto-Calculation Board"]
D2 --> D6["PartyLedgerRecoAnalysisSkill - Generate AI Audit Insights"]
D2 --> D7["ClosedXML - Export Detailed Excel Report"]
D2 --> D8["AIInsightsRepository - Deduct Credit & Update AI Log"]
end
subgraph Stage5["Stage 5: Dashboard Render & Auto Download Cleanup"]
E1["AIRecoPartyLedgerOption.razor"] --> E2["Render KPI Cards & T-Ledger Board & AI Audit Insights"]
E1 -->|NavManager.NavigateTo| E3["FileDownloader.cs"]
E3 --> E4["DownloadFile()"]
E4 --> E5["ReadAllBytesAsync()"]
E4 --> E6["System.IO.File.Delete() - Immediate File Cleanup"]
E4 --> E7["Stream Excel Report Attachment to Browser"]
end
Stage1 --> Stage2
Stage2 --> Stage3
Stage3 --> Stage4
Stage4 --> Stage5