feat(settings): add GoMag API config, Oracle dropdowns, compact 2x2 layout
- Remove ID_GESTIUNE from config (unused) - Add GoMag API settings (key, shop, days_back, limit) to SQLite — editable without restart - sync_service reads GoMag settings from SQLite before download - gomag_client.download_orders accepts api_key/api_shop/limit overrides - New GET /api/settings/sectii and /api/settings/politici endpoints for Oracle dropdowns (nom_sectii.sectie, crm_politici_preturi.nume_lista_preturi) - id_pol, id_sectie, transport_id_pol, discount_id_pol now use select dropdowns - order_reader extracts discount_vat from GoMag JSON discounts[].vat - import_service uses GoMag discount_vat as primary, settings as fallback - settings.html redesigned to compact 2x2 grid (GoMag API | Import ROA / Transport | Discount) - settings.js v2: loadDropdowns() sequential before loadSettings() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -57,6 +57,7 @@ class OrderData:
|
||||
total: float = 0.0
|
||||
delivery_cost: float = 0.0
|
||||
discount_total: float = 0.0
|
||||
discount_vat: Optional[str] = None
|
||||
payment_name: str = ""
|
||||
delivery_name: str = ""
|
||||
source_file: str = ""
|
||||
@@ -160,11 +161,14 @@ def _parse_order(order_id: str, data: dict, source_file: str) -> OrderData:
|
||||
# Parse delivery cost
|
||||
delivery_cost = float(delivery.get("total", 0) or 0) if isinstance(delivery, dict) else 0.0
|
||||
|
||||
# Parse discount total (sum of all discount values)
|
||||
# Parse discount total (sum of all discount values) and VAT from first discount item
|
||||
discount_total = 0.0
|
||||
discount_vat = None
|
||||
for d in data.get("discounts", []):
|
||||
if isinstance(d, dict):
|
||||
discount_total += float(d.get("value", 0) or 0)
|
||||
if discount_vat is None and d.get("vat") is not None:
|
||||
discount_vat = str(d["vat"])
|
||||
|
||||
return OrderData(
|
||||
id=str(data.get("id", order_id)),
|
||||
@@ -178,6 +182,7 @@ def _parse_order(order_id: str, data: dict, source_file: str) -> OrderData:
|
||||
total=float(data.get("total", 0) or 0),
|
||||
delivery_cost=delivery_cost,
|
||||
discount_total=discount_total,
|
||||
discount_vat=discount_vat,
|
||||
payment_name=str(payment.get("name", "")) if isinstance(payment, dict) else "",
|
||||
delivery_name=str(delivery.get("name", "")) if isinstance(delivery, dict) else "",
|
||||
source_file=source_file
|
||||
|
||||
Reference in New Issue
Block a user