Skip to content

1.5.10

⚙️ Patch 1.5.10 — Ledger sync UI, FBA ledger typing & DB migration

🚀 Summary

  • Small release adding a manual Ledger sync UI, tightening backend typing for the FBA ledger flow, and a small DB migration to track inbound dates.

✨ New Features

  • Added a Sync Ledger Report action in the FBA admin UI that opens a compact dialog to trigger a manual Amazon Ledger SP-API sync.
  • Dialog uses native date-only inputs for Start Date and End Date (no time selection required).

🔧 Improvements

  • Backend: sync_ledger now accepts typed datetime parameters and process_ledger_report serializes them to ISO strings for the SP-API ingestion flow.
  • Fixed a pandas import scoping issue in the ledger processing path so pandas is available before validation runs.
  • Frontend: moved the manual sync modal into the current FBAArticles tab (FBAArticles.jsx) and converted the date fields to type="date" with clearer labels.

Database migration & ledger + stock-movements integration

  • DB migration: added a new last_inbound_date TIMESTAMP column on repricer_articles to persist the most recent inbound event per article. See docker/postgres/updates/add_last_inbound_date_to_repricer_articles.sql for the exact migration (uses ALTER TABLE ... ADD COLUMN IF NOT EXISTS last_inbound_date TIMESTAMP WITHOUT TIME ZONE;).
  • Ledger integration: the Amazon Ledger report is used to determine and update last_inbound_date during the ledger sync process. When a manual or scheduled ledger sync runs it:
  • queries the ledger report covering up to (and including) yesterday by default,
  • computes the most recent inbound event per repricer_article, and
  • writes that newest inbound timestamp into the last_inbound_date column.

  • Plenty stock-movements sync: added a Plenty-side batch flow to derive inbound dates directly from Plenty stock movements and keep last_inbound_date current:

  • Plenty_Manager.batch_get_stock_movements (backend/service_multi-repricer/app/services/plenty/plenty_manager.py) — new batch helper that calls Plenty's /rest/items/{itemId}/variations/{variationId}/stock/movements endpoints via the batch API, parses each per-item result, and returns a mapping of (itemId, variationId) → the first createdAt datetime found where quantity is positive (parsed to a Python datetime, tolerant of timezone offsets).
  • sync_latest_inbound_dates (backend/service_multi-repricer/app/api/v1/endpoints/repricer_articles.py) — new sync routine invoked during manual/cron syncs that:
    • resolves articles to (itemId, variationId) pairs,
    • calls batch_get_stock_movements to fetch movements for many pairs at once,
    • for each article updates repricer_articles.last_inbound_date only when the discovered inbound datetime is strictly newer than the stored value,
    • converts timezone-aware datetimes to naive timestamps before persisting (DB column is TIMESTAMP WITHOUT TIME ZONE).
  • Behavior notes: the Plenty-based flow uses the first positive quantity entry's createdAt per movement list as the inbound marker, and the DB stores only the newest inbound date per article (subsequent syncs overwrite older values).

  • Persistence policy: last_inbound_date stores only the latest inbound date per article and is overwritten on subsequent syncs with the newest found value; historical ledger or movement entries remain in source systems but are not stored as separate rows in this column.

  • Usage: downstream repricer and reporting logic can rely on last_inbound_date to avoid reprocessing older inbound events and to drive inbound-aware decisions.

🐛 Bug Fixes

  • Fixed an UnboundLocalError caused by late import of pandas in the ledger processing code.
  • Fixed UI scoping issues where an outdated tab component was referenced; the modal and submit handler now integrate correctly with FbaArticlesApi.syncLedger.

📁 Files changed

  • backend/service_multi-repricer/app/api/v1/endpoints/fba_articles.py — accept typed datetimes, fix pandas import scope, and format datetimes for SP-API calls.
  • frontend/src/pages/MultiRepricer/Tabs/FBA/FBAArticles.jsx — add "Sync Ledger Report" button and dialog; use Start Date/End Date type="date" inputs and submit handling.
  • docker/postgres/updates/add_last_inbound_date_to_repricer_articles.sql — DB migration to add last_inbound_date column to repricer_articles.
  • Misc: small API client and UI polish changes related to the ledger sync flow.
  • backend/service_multi-repricer/app/services/plenty/plenty_manager.py — add batch_get_stock_movements to fetch and parse stock movements in batch.
  • backend/service_multi-repricer/app/api/v1/endpoints/repricer_articles.py — add sync_latest_inbound_dates which consumes Plenty results and updates repricer_articles.last_inbound_date.