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 DateandEnd Date(no time selection required).
🔧 Improvements¶
- Backend:
sync_ledgernow accepts typeddatetimeparameters andprocess_ledger_reportserializes them to ISO strings for the SP-API ingestion flow. - Fixed a pandas import scoping issue in the ledger processing path so
pandasis available before validation runs. - Frontend: moved the manual sync modal into the current
FBAArticlestab (FBAArticles.jsx) and converted the date fields totype="date"with clearer labels.
Database migration & ledger + stock-movements integration¶
- DB migration: added a new
last_inbound_dateTIMESTAMPcolumn onrepricer_articlesto persist the most recent inbound event per article. Seedocker/postgres/updates/add_last_inbound_date_to_repricer_articles.sqlfor the exact migration (usesALTER 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_dateduring 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_datecolumn. -
Plenty stock-movements sync: added a Plenty-side batch flow to derive inbound dates directly from Plenty stock movements and keep
last_inbound_datecurrent: 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/movementsendpoints via the batch API, parses each per-item result, and returns a mapping of(itemId, variationId)→ the firstcreatedAtdatetime found wherequantityis positive (parsed to a Pythondatetime, 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_movementsto fetch movements for many pairs at once, - for each article updates
repricer_articles.last_inbound_dateonly 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).
- resolves articles to
-
Behavior notes: the Plenty-based flow uses the first positive
quantityentry'screatedAtper 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_datestores 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_dateto avoid reprocessing older inbound events and to drive inbound-aware decisions.
🐛 Bug Fixes¶
- Fixed an
UnboundLocalErrorcaused by late import ofpandasin 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; useStart Date/End Datetype="date"inputs and submit handling.docker/postgres/updates/add_last_inbound_date_to_repricer_articles.sql— DB migration to addlast_inbound_datecolumn torepricer_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— addbatch_get_stock_movementsto fetch and parse stock movements in batch.backend/service_multi-repricer/app/api/v1/endpoints/repricer_articles.py— addsync_latest_inbound_dateswhich consumes Plenty results and updatesrepricer_articles.last_inbound_date.