From 3fb95c16172c5c75054e9f6e2ed6e7016bea1256 Mon Sep 17 00:00:00 2001 From: SekiDesu01 Date: Tue, 23 Jun 2026 17:05:35 -0400 Subject: [PATCH] modified: blueprints/inventory.py modified: blueprints/sync_server.py modified: core/sync.py --- blueprints/inventory.py | 3 +++ blueprints/sync_server.py | 2 ++ core/sync.py | 2 ++ 3 files changed, 7 insertions(+) diff --git a/blueprints/inventory.py b/blueprints/inventory.py index 1f86491..1ac7de1 100644 --- a/blueprints/inventory.py +++ b/blueprints/inventory.py @@ -88,6 +88,7 @@ def delete(barcode): cache_dir = current_app.config['CACHE_DIR'] with get_db_connection() as conn: + conn.execute('INSERT INTO sync_deletions (entity_type, entity_uuid) VALUES (?, ?)', ('product', barcode)) conn.execute('DELETE FROM products WHERE barcode = ?', (barcode,)) conn.commit() @@ -133,6 +134,8 @@ def bulk_delete(): try: with get_db_connection() as conn: + for barcode in barcodes: + conn.execute('INSERT INTO sync_deletions (entity_type, entity_uuid) VALUES (?, ?)', ('product', barcode)) conn.execute(f'DELETE FROM products WHERE barcode IN ({",".join(["?"]*len(barcodes))})', barcodes) conn.commit() diff --git a/blueprints/sync_server.py b/blueprints/sync_server.py index 7ec5a17..6cb466d 100644 --- a/blueprints/sync_server.py +++ b/blueprints/sync_server.py @@ -44,6 +44,8 @@ def sync_push(): conn.execute("DELETE FROM expenses WHERE uuid = ?", (eu,)) elif et == 'sale': conn.execute("DELETE FROM sales WHERE uuid = ?", (eu,)) + elif et == 'product': + conn.execute("DELETE FROM products WHERE barcode = ?", (eu,)) # 2. Sales for sale in data.get('sales', []): diff --git a/core/sync.py b/core/sync.py index 177c1ac..607c2b1 100644 --- a/core/sync.py +++ b/core/sync.py @@ -219,6 +219,8 @@ class SyncManager: conn.execute("DELETE FROM expenses WHERE uuid = ?", (eu,)) elif et == 'sale': conn.execute("DELETE FROM sales WHERE uuid = ?", (eu,)) + elif et == 'product': + conn.execute("DELETE FROM products WHERE barcode = ?", (eu,)) # Debtors (upsert by uuid) pulled_debtors = 0