fix(anaf): show TVA badge only on GoMag vs ANAF mismatch
Previously the TVA badge/dot appeared whenever ANAF reported neplatitor. Now it only appears when GoMag CUI prefix (RO=platitor) disagrees with ANAF status — aligned across JS badges, red dots, SQL filter and count. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -697,7 +697,12 @@ async def get_orders(page: int = 1, per_page: int = 50,
|
||||
if status_filter.upper() == "IMPORTED":
|
||||
data_clauses.append("UPPER(status) IN ('IMPORTED', 'ALREADY_IMPORTED')")
|
||||
elif status_filter.upper() == "DIFFS":
|
||||
data_clauses.append("(anaf_cod_fiscal_adjusted = 1 OR anaf_denumire_mismatch = 1 OR address_mismatch = 1)")
|
||||
data_clauses.append(
|
||||
"(anaf_cod_fiscal_adjusted = 1 OR anaf_denumire_mismatch = 1 OR address_mismatch = 1"
|
||||
" OR (cod_fiscal_gomag IS NOT NULL AND cod_fiscal_gomag != '' AND anaf_platitor_tva IS NOT NULL"
|
||||
" AND ((UPPER(cod_fiscal_gomag) LIKE 'RO%' AND anaf_platitor_tva = 0)"
|
||||
" OR (UPPER(cod_fiscal_gomag) NOT LIKE 'RO%' AND anaf_platitor_tva = 1))))"
|
||||
)
|
||||
else:
|
||||
data_clauses.append("UPPER(status) = ?")
|
||||
data_params.append(status_filter.upper())
|
||||
@@ -751,9 +756,12 @@ async def get_orders(page: int = 1, per_page: int = 50,
|
||||
cursor = await db.execute(f"SELECT COUNT(*) FROM orders {uninv_old_where}", base_params)
|
||||
uninvoiced_old = (await cursor.fetchone())[0]
|
||||
|
||||
# Diffs count: orders with ANAF adjustments or address mismatches
|
||||
# Diffs count: orders with ANAF adjustments, address mismatches, or TVA mismatch
|
||||
diffs_clauses = list(base_clauses) + [
|
||||
"(anaf_cod_fiscal_adjusted = 1 OR anaf_denumire_mismatch = 1 OR address_mismatch = 1)"
|
||||
"(anaf_cod_fiscal_adjusted = 1 OR anaf_denumire_mismatch = 1 OR address_mismatch = 1"
|
||||
" OR (cod_fiscal_gomag IS NOT NULL AND cod_fiscal_gomag != '' AND anaf_platitor_tva IS NOT NULL"
|
||||
" AND ((UPPER(cod_fiscal_gomag) LIKE 'RO%' AND anaf_platitor_tva = 0)"
|
||||
" OR (UPPER(cod_fiscal_gomag) NOT LIKE 'RO%' AND anaf_platitor_tva = 1))))"
|
||||
]
|
||||
diffs_where = "WHERE " + " AND ".join(diffs_clauses)
|
||||
cursor = await db.execute(f"SELECT COUNT(*) FROM orders {diffs_where}", base_params)
|
||||
|
||||
Reference in New Issue
Block a user