fix: Update Trial Balance to use real VBAL VIEW structure

After database verification, VBAL is a VIEW (not a table) that exists
in each company schema with a different structure than initially assumed.

Backend Changes:
- Updated models (trial_balance.py):
  - Changed column names to match real VBAL VIEW
  - CONT (account number)
  - DENUMIRE (account description, not DCONT)
  - PRECDEB/PRECCRED (previous balance, not SD_PREC/SC_PREC)
  - RULDEB/RULCRED (monthly movement, not RD_LUNA/RC_LUNA)
  - SOLDDEB/SOLDCRED (final balance, not SD_FINAL/SC_FINAL)
  - Made DENUMIRE optional (can be NULL in VIEW)

- Updated router (trial_balance.py):
  - Removed COD_FIRMA filter (not in VIEW)
  - Query now uses: {schema}.VBAL WHERE AN = :an AND LUNA = :luna
  - Fixed column names in SELECT (DENUMIRE instead of DCONT)
  - Updated sort columns validation
  - Fixed result processing to match new column order

Frontend Changes:
- Updated TrialBalanceView.vue:
  - Changed field from 'dcont' to 'denumire' in DataTable column

Database Verification:
- VBAL VIEW confirmed in ROMFAST schema (24,217 records)
- Current data available up to November 2025
- Structure verified with 22 columns
- VIEW exists in all company schemas

Testing Notes:
- Backend endpoint ready for testing
- Frontend field names now match API response
- Ready for manual testing with real company data

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-20 00:57:14 +02:00
parent 0b00b66ed5
commit 6c373c609e
5 changed files with 728 additions and 26 deletions

View File

@@ -1,6 +1,6 @@
"""
Pydantic models for Trial Balance (Balanță de Verificare)
Maps to Oracle VBAL table
Maps to Oracle VBAL VIEW (exists in each company schema)
"""
from pydantic import BaseModel, Field
from typing import Optional, List
@@ -8,16 +8,22 @@ from decimal import Decimal
class TrialBalanceItem(BaseModel):
"""
Individual trial balance record from VBAL table
Individual trial balance record from VBAL VIEW
Real structure from Oracle:
- CONT: account number
- DENUMIRE: account description
- PRECDEB/PRECCRED: previous balance debit/credit
- RULDEB/RULCRED: monthly movement debit/credit
- SOLDDEB/SOLDCRED: final balance debit/credit
"""
cont: str = Field(description="Număr cont contabil")
dcont: str = Field(description="Denumire cont")
sold_precedent_debit: Decimal = Field(description="Sold precedent debit", decimal_places=2)
sold_precedent_credit: Decimal = Field(description="Sold precedent credit", decimal_places=2)
rulaj_lunar_debit: Decimal = Field(description="Rulaj lunar debit", decimal_places=2)
rulaj_lunar_credit: Decimal = Field(description="Rulaj lunar credit", decimal_places=2)
sold_final_debit: Decimal = Field(description="Sold final debit", decimal_places=2)
sold_final_credit: Decimal = Field(description="Sold final credit", decimal_places=2)
cont: str = Field(description="Număr cont contabil (CONT)")
denumire: Optional[str] = Field(default="", description="Denumire cont (DENUMIRE)")
sold_precedent_debit: Decimal = Field(description="Sold precedent debit (PRECDEB)", decimal_places=2)
sold_precedent_credit: Decimal = Field(description="Sold precedent credit (PRECCRED)", decimal_places=2)
rulaj_lunar_debit: Decimal = Field(description="Rulaj lunar debit (RULDEB)", decimal_places=2)
rulaj_lunar_credit: Decimal = Field(description="Rulaj lunar credit (RULCRED)", decimal_places=2)
sold_final_debit: Decimal = Field(description="Sold final debit (SOLDDEB)", decimal_places=2)
sold_final_credit: Decimal = Field(description="Sold final credit (SOLDCRED)", decimal_places=2)
class Config:
from_attributes = True