fix(orders): preserve order_items on mark_order_deleted_in_roa

Detail view for DELETED_IN_ROA orders showed "Niciun articol" because
the soft-delete helper hard-deleted order_items. Now items stay in
SQLite so the detail page displays the original GoMag order alongside
"Comanda stearsa din ROA". On 'Reimporta', add_order_items already
replaces them via DELETE+INSERT inside _safe_upsert_order_items.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-05-07 13:06:13 +00:00
parent ab20856cd6
commit 32974e3b85
2 changed files with 15 additions and 7 deletions

View File

@@ -1288,10 +1288,13 @@ async def clear_order_invoice(order_number: str):
async def mark_order_deleted_in_roa(order_number: str):
"""Mark an order as deleted in ROA — clears id_comanda, invoice cache, and stale items."""
"""Mark an order as deleted in ROA — clears id_comanda + invoice cache.
order_items are preserved so the detail view can still show what was
originally ordered. On 'Reimporta', add_order_items replaces them.
"""
db = await get_sqlite()
try:
await db.execute("DELETE FROM order_items WHERE order_number = ?", (order_number,))
await db.execute(f"""
UPDATE orders SET
status = '{OrderStatus.DELETED_IN_ROA.value}',