feat(dashboard): add datorat/achitat/sold breakdown for budget debts

Replaces "luna prec / luna curentă" columns with a clearer accounting
reconciliation flow: Datorat (owed) → Achitat (paid) → Sold (remaining).
Backend models gain 3 new fields per sub-account and group. Frontend
shows ✓ when a debt is fully cleared. Mobile TVA card now shows both
total and remaining sold. SwipeableCards gains fixedDots/fillHeight props
for better layout above MobileBottomNav. Telegram formatter updated to
use new fields and drops redundant RON suffix from amounts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-02-23 15:05:41 +00:00
parent aac49542e4
commit 6c78fec8a7
8 changed files with 606 additions and 123 deletions

View File

@@ -18,16 +18,16 @@ def format_dashboard_response(data: Dict[str, Any], company_name: str = None) ->
# Sold total trezorerie (casa + banca) - rotunjit la leu
treasury_totals = data.get('treasury_totals_by_currency', {})
sold_trezorerie = round(float(treasury_totals.get('RON', 0)))
text += f"**Sold Trezorerie:** {sold_trezorerie:,} RON\n\n"
text += f"**Sold Trezorerie:** {sold_trezorerie:,}\n\n"
# Sold Clienți - rotunjit la leu
clienti_sold = round(float(data.get('clienti_sold_total', 0)))
clienti_in_termen = round(float(data.get('clienti_sold_in_termen', 0)))
clienti_restant = round(float(data.get('clienti_sold_restant', 0)))
text += f"**Sold Clienți:** {clienti_sold:,} RON\n"
text += f" - În termen: {clienti_in_termen:,} RON\n"
text += f" - Restanță: {clienti_restant:,} RON\n\n"
text += f"**Sold Clienți:** {clienti_sold:,}\n"
text += f" - În termen: {clienti_in_termen:,}\n"
text += f" - Restanță: {clienti_restant:,}\n\n"
# Sold Furnizori BRUT (pentru consistență cu detaliile) - rotunjit la leu
furnizori_in_termen = round(float(data.get('furnizori_sold_in_termen', 0)))
@@ -36,47 +36,40 @@ def format_dashboard_response(data: Dict[str, Any], company_name: str = None) ->
furnizori_avansuri = round(float(data.get('furnizori_avansuri', 0)))
furnizori_sold_net = round(float(data.get('furnizori_sold_total', 0)))
text += f"**Sold Furnizori:** {furnizori_sold_brut:,} RON\n"
text += f" - În termen: {furnizori_in_termen:,} RON\n"
text += f" - Restanță: {furnizori_restant:,} RON\n"
text += f"**Sold Furnizori:** {furnizori_sold_brut:,}\n"
text += f" - În termen: {furnizori_in_termen:,}\n"
text += f" - Restanță: {furnizori_restant:,}\n"
if furnizori_avansuri != 0:
text += f" - Avansuri: {furnizori_avansuri:,} RON\n"
text += f" - Net (după avansuri): {furnizori_sold_net:,} RON"
text += f" - Avansuri: {furnizori_avansuri:,}\n"
text += f" - Net (după avansuri): {furnizori_sold_net:,}"
else:
text += f" - Net: {furnizori_sold_net:,} RON"
text += f" - Net: {furnizori_sold_net:,}"
# Solduri TVA - rotunjit la leu
tva_plata_prec = round(float(data.get('tva_plata_precedent', 0)))
tva_recup_prec = round(float(data.get('tva_recuperat_precedent', 0)))
tva_plata_cur = round(float(data.get('tva_plata_curent', 0)))
tva_recup_cur = round(float(data.get('tva_recuperat_curent', 0)))
# Afișează secțiunea doar dacă există cel puțin o valoare > 0
if tva_plata_prec > 0 or tva_recup_prec > 0 or tva_plata_cur > 0 or tva_recup_cur > 0:
text += "\n\n**Solduri TVA:**\n"
if tva_plata_prec > 0:
text += f" - TVA de plată precedent: {tva_plata_prec:,} RON\n"
if tva_recup_prec > 0:
text += f" - TVA de recuperat precedent: {tva_recup_prec:,} RON\n"
if tva_plata_cur > 0:
text += f" - TVA de plată curent: {tva_plata_cur:,} RON\n"
if tva_recup_cur > 0:
text += f" - TVA de recuperat curent: {tva_recup_cur:,} RON\n"
# Datorii la Buget - breakdown pe grupe (TVA / BASS / CAM), valori luna precedentă
# Datorii la Buget - două secțiuni: luna precedentă și luna curentă
budget_breakdown = data.get('budget_debt_breakdown', [])
if budget_breakdown:
grupe_cu_datorie = [
g for g in budget_breakdown
if round(float(g.get('precedent', 0))) > 0
]
if grupe_cu_datorie:
total_buget = sum(round(float(g.get('precedent', 0))) for g in grupe_cu_datorie)
grupe_prec = [g for g in budget_breakdown if round(float(g.get('datorat', g.get('precedent', 0)))) > 0]
grupe_crt = [g for g in budget_breakdown if round(float(g.get('curent', 0))) > 0]
if grupe_prec or grupe_crt:
text += "\n\n**Datorii la Buget:**\n"
for grupa in grupe_cu_datorie:
val = round(float(grupa.get('precedent', 0)))
text += f" - {grupa.get('label', '')}: {val:,} RON\n"
text += f" Total: {total_buget:,} RON\n"
if grupe_prec:
total_sold = sum(round(float(g.get('sold', 0))) for g in grupe_prec)
total_dat = sum(round(float(g.get('datorat', g.get('precedent', 0)))) for g in grupe_prec)
sold_total_str = f"{total_sold:,}" if total_sold > 0 else "0 \u2713"
text += f"\n _Precedent: dat: {total_dat:,}, sold: {sold_total_str}_\n"
for g in grupe_prec:
datorat = round(float(g.get('datorat', g.get('precedent', 0))))
sold = round(float(g.get('sold', 0)))
label = g.get('label', '')
sold_str = f"{sold:,}" if sold > 0 else "0 \u2713"
text += f" {label:<6} {datorat:,} · {sold_str}\n"
if grupe_crt:
items = [f"{g.get('label', '')} {round(float(g.get('curent', 0))):,}" for g in grupe_crt]
total_crt = sum(round(float(g.get('curent', 0))) for g in grupe_crt)
text += f"\n _Curent: {' \u00b7 '.join(items)} = {total_crt:,}_\n"
return text