Files
gomag-vending/scripts/reset_sqlite.py
Claude Agent 3d73d9e422 add: scripts for invoice-order matching and SKU discovery
Analysis scripts to match GoMag orders with Oracle invoices by
date/client/total, then compare line items by price to discover
SKU → id_articol mappings. Generates SQL for nom_articole codmat
updates and CSV for ARTICOLE_TERTI repackaging/set mappings.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 12:01:51 +00:00

43 lines
1.2 KiB
Python

"""Reset imported orders in SQLite back to SKIPPED after Oracle deletion"""
import sys, sqlite3
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
db = sqlite3.connect(r'C:\gomag-vending\api\data\import.db')
c = db.cursor()
# Show before
c.execute("SELECT order_number, customer_name, id_comanda, status FROM orders WHERE status = 'IMPORTED'")
rows = c.fetchall()
print(f"Orders to reset: {len(rows)}")
for r in rows:
print(f" {r[0]} | {r[1]} | id_comanda={r[2]} | {r[3]}")
# Reset
c.execute("""
UPDATE orders SET
status = 'SKIPPED',
id_comanda = NULL,
id_partener = NULL,
id_adresa_facturare = NULL,
id_adresa_livrare = NULL,
error_message = NULL,
factura_serie = NULL,
factura_numar = NULL,
factura_total_fara_tva = NULL,
factura_total_tva = NULL,
factura_total_cu_tva = NULL,
factura_data = NULL,
invoice_checked_at = NULL
WHERE status = 'IMPORTED'
""")
print(f"\nReset: {c.rowcount} orders → SKIPPED")
db.commit()
# Verify
c.execute("SELECT status, COUNT(*) FROM orders GROUP BY status")
print("\nStatus after reset:")
for r in c.fetchall():
print(f" {r[0]:20s} {r[1]}")
db.close()