feat(sync): add delivery cost, discount tracking and import settings
Parse delivery.total and discounts[] from GoMag JSON into new delivery_cost/discount_total fields. Add app_settings table for configuring transport/discount CODMAT codes. When configured, transport and discount are appended as extra articles in the Oracle import JSON. Reorder Total column in dashboard/logs tables and show transport/discount breakdown in order detail modals. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,12 @@ class ScheduleConfig(BaseModel):
|
||||
interval_minutes: int = 5
|
||||
|
||||
|
||||
class AppSettingsUpdate(BaseModel):
|
||||
transport_codmat: str = ""
|
||||
transport_vat: str = "21"
|
||||
discount_codmat: str = ""
|
||||
|
||||
|
||||
# API endpoints
|
||||
@router.post("/api/sync/start")
|
||||
async def start_sync(background_tasks: BackgroundTasks):
|
||||
@@ -429,3 +435,23 @@ async def update_schedule(config: ScheduleConfig):
|
||||
async def get_schedule():
|
||||
"""Get current scheduler status."""
|
||||
return scheduler_service.get_scheduler_status()
|
||||
|
||||
|
||||
@router.get("/api/settings")
|
||||
async def get_app_settings():
|
||||
"""Get application settings."""
|
||||
settings = await sqlite_service.get_app_settings()
|
||||
return {
|
||||
"transport_codmat": settings.get("transport_codmat", ""),
|
||||
"transport_vat": settings.get("transport_vat", "21"),
|
||||
"discount_codmat": settings.get("discount_codmat", ""),
|
||||
}
|
||||
|
||||
|
||||
@router.put("/api/settings")
|
||||
async def update_app_settings(config: AppSettingsUpdate):
|
||||
"""Update application settings."""
|
||||
await sqlite_service.set_app_setting("transport_codmat", config.transport_codmat)
|
||||
await sqlite_service.set_app_setting("transport_vat", config.transport_vat)
|
||||
await sqlite_service.set_app_setting("discount_codmat", config.discount_codmat)
|
||||
return {"success": True}
|
||||
|
||||
Reference in New Issue
Block a user