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

@@ -168,12 +168,15 @@ async def test_save_orders_batch_overwrite():
# ===========================================================================
# mark_order_deleted_in_roa — must purge items
# mark_order_deleted_in_roa — preserves items so detail view stays useful
# ===========================================================================
@pytest.mark.asyncio
async def test_mark_order_deleted_removes_items():
"""Soft-delete must remove order_items (no ghost rows)."""
async def test_mark_order_deleted_preserves_items():
"""Soft-delete keeps order_items so the detail view shows what was ordered.
On 'Reimporta', add_order_items replaces them (DELETE+INSERT inside _safe_upsert_order_items).
"""
await _seed_order("ORD-DEL")
await sqlite_service.add_order_items("ORD-DEL", [
_item("SKU1", qty=5), _item("SKU2", qty=3),
@@ -182,8 +185,10 @@ async def test_mark_order_deleted_removes_items():
await sqlite_service.mark_order_deleted_in_roa("ORD-DEL")
# Items purged
assert await _items_for("ORD-DEL") == []
# Items preserved — detail view can still display them alongside "Comanda stearsa din ROA"
items = await _items_for("ORD-DEL")
assert len(items) == 2
assert {i["sku"] for i in items} == {"SKU1", "SKU2"}
# Orders row still present with DELETED_IN_ROA status (not hard-deleted)
db = await sqlite_service.get_sqlite()