feat: Add totals from all filtered records to invoices, treasury, and trial balance
Previously, totals were computed client-side from only the current page data, which gave incorrect results when paginating. Now the backend calculates totals across ALL filtered records and returns them in the API response. - Invoice: Add total_sold_all field for sum of all filtered invoice balances - Treasury: Add sold_precedent_all, total_incasari_all, total_plati_all, sold_final_all - Trial Balance: Add 6-column totals (debit/credit for each balance type) - Frontend stores and views updated to use backend totals 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -64,6 +64,8 @@ class InvoiceListResponse(BaseModel):
|
||||
page_size: int
|
||||
has_more: bool
|
||||
accounting_period: Optional[dict] = Field(default=None, description="Perioada contabilă (an, luna)")
|
||||
# Total sold din TOATE facturile filtrate (nu doar pagina curentă)
|
||||
total_sold_all: Decimal = Field(default=Decimal('0.00'), description="Total sold din toate facturile filtrate")
|
||||
|
||||
class InvoiceSummary(BaseModel):
|
||||
"""Rezumat pentru facturi - pentru dashboard"""
|
||||
|
||||
@@ -44,4 +44,9 @@ class RegisterListResponse(BaseModel):
|
||||
page: int
|
||||
page_size: int
|
||||
has_more: bool
|
||||
accounting_period: Optional[AccountingPeriod] = None
|
||||
accounting_period: Optional[AccountingPeriod] = None
|
||||
# Totaluri din TOATE înregistrările filtrate (nu doar pagina curentă)
|
||||
sold_precedent_all: Decimal = Decimal('0.00')
|
||||
total_incasari_all: Decimal = Decimal('0.00')
|
||||
total_plati_all: Decimal = Decimal('0.00')
|
||||
sold_final_all: Decimal = Decimal('0.00')
|
||||
@@ -49,6 +49,18 @@ class TrialBalancePagination(BaseModel):
|
||||
page_size: int = Field(description="Items per page")
|
||||
|
||||
|
||||
class TrialBalanceTotals(BaseModel):
|
||||
"""
|
||||
Totals for all 6 columns from all filtered records (not just current page)
|
||||
"""
|
||||
total_sold_precedent_debit: Decimal = Decimal('0.00')
|
||||
total_sold_precedent_credit: Decimal = Decimal('0.00')
|
||||
total_rulaj_lunar_debit: Decimal = Decimal('0.00')
|
||||
total_rulaj_lunar_credit: Decimal = Decimal('0.00')
|
||||
total_sold_final_debit: Decimal = Decimal('0.00')
|
||||
total_sold_final_credit: Decimal = Decimal('0.00')
|
||||
|
||||
|
||||
class TrialBalanceResponse(BaseModel):
|
||||
"""
|
||||
Complete response for trial balance endpoint
|
||||
|
||||
Reference in New Issue
Block a user