fix(anaf): deduplicate TVA/CUI badges, remove address from DIFFS filter
CUI adjustment (RO prefix change) already implies TVA mismatch, so suppress redundant TVA badge when CUI badge is shown. Remove address_mismatch from DIFFS pill count since it's not an ANAF difference. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -698,8 +698,9 @@ async def get_orders(page: int = 1, per_page: int = 50,
|
||||
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"
|
||||
"(anaf_cod_fiscal_adjusted = 1 OR anaf_denumire_mismatch = 1"
|
||||
" OR (cod_fiscal_gomag IS NOT NULL AND cod_fiscal_gomag != '' AND anaf_platitor_tva IS NOT NULL"
|
||||
" AND anaf_cod_fiscal_adjusted != 1"
|
||||
" 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))))"
|
||||
)
|
||||
@@ -756,10 +757,11 @@ 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, address mismatches, or TVA mismatch
|
||||
# Diffs count: orders with ANAF adjustments or TVA mismatch (not address)
|
||||
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 (cod_fiscal_gomag IS NOT NULL AND cod_fiscal_gomag != '' AND anaf_platitor_tva IS NOT NULL"
|
||||
" AND anaf_cod_fiscal_adjusted != 1"
|
||||
" 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))))"
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user