fix(sync): sticky exclusion for DELETED_IN_ROA orders

Orders deleted via "Sterge" button were re-imported on the next sync
because classify step only checked Oracle (sters=0), not SQLite status.
Adds a filter step after cancellation handling that drops orders
already marked DELETED_IN_ROA before validation. "Reimporta" remains
the explicit override.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-05-07 12:57:32 +00:00
parent 956667086d
commit ab20856cd6
3 changed files with 165 additions and 0 deletions

View File

@@ -1253,6 +1253,19 @@ async def get_all_imported_orders() -> list:
await db.close()
async def get_deleted_in_roa_order_numbers() -> set[str]:
"""Return set of order_numbers marked DELETED_IN_ROA (sticky-excluded from auto-sync)."""
db = await get_sqlite()
try:
cursor = await db.execute(
f"SELECT order_number FROM orders WHERE status = '{OrderStatus.DELETED_IN_ROA.value}'"
)
rows = await cursor.fetchall()
return {r[0] for r in rows}
finally:
await db.close()
async def clear_order_invoice(order_number: str):
"""Clear cached invoice data when invoice was deleted in ROA."""
db = await get_sqlite()