1.5.8
⚙️ Patch 1.5.8 — FBM: multi‑SKU support, migration, sync robustness & UI updates¶
🚀 Summary¶
- Database: FBM details model migrated from a strict 1:1 mapping to 1:N by introducing a numeric
idprimary key onfbm_detailsso oneRepricerArticlecan have multipleFBMDetailsrows. - Backend: Sync and API updates to support multiple FBM entries per article, safer Plenty variation sync (dedupe, additional SKUs) and a new endpoint to update a single FBM entry by id.
- Frontend: FBM UI refactor to display multiple FBM entries per article, per‑entry edit dialog, and seller SKU search.
✨ New Features¶
- DB migration: Added
docker/postgres/updates/add_id_to_fbm_details.sqlwhich drops the old primary key constraint and adds anid SERIAL PRIMARY KEYcolumn tofbm_detailsso multiple rows can be attached to a single article. - API: Added
PUT /articles/fbm/{fbm_id}to update a single FBM entry by its numeric id. This enables editing per‑FBM entry without touching other siblings. - UI:
FBMArticlesnow showsfbmas a list. The expanded article view renders each FBM entry as its own card with its own international pricing table and an Edit button that opens a per‑entry dialog. - Search: New "Search Seller SKU" field to filter articles by
fbm.seller_skualongside the existing SKU search.
🔧 Improvements¶
- Sync robustness:
process_sync_variation_skusnow: - Fetches variant SKUs and additional SKUs, filters by target market (e.g., Amazon marketId=4), and deduplicates results.
- Requeries
FBMDetailsafter async Plenty API calls to avoid detached ORM instances and to ensure safe updates. - When a matching
FBMDetailsrow is missing, creates a new row and clones sensible config from an existing reference detail (margin rules, international pricing, flags). - Frontend:
EditFbmDetailsDialognow targets an individualfbmDetailand calls the newupdateFbmDetailsByIdservice, avoiding ambiguous updates to the parent article'sfbmblob. - UX: Seller SKUs are displayed as chips in the article list for quick scanning; the table uses the best candidate
primaryFbm(prefers matchingarticle.sku) for status/price columns.
🐛 Bug Fixes¶
- Fixed
DetachedInstanceErrorduring background sync by avoiding use of pre‑fetched ORM instances acrossawaitpoints;FBMDetailsrows are reloaded under the same session before mutation. - Restored correct margin rule lookup in the UI by ensuring the
MarginRuleDialogreadsmargin_rule_idfrom the selectedfbmDetail. - Prevented seller SKU collisions by checking existing SKUs before appending additional SKUs to the results set.
- Fixed runtime TypeError in
EditFbaDetailsDialogby guarding against null entries infba.international_pricing. Some country entries can be null; the dialog now checksdetails && !details.errorbefore readingdetails.erroror bounds, preventing crashes when editing FBA details.
📁 Files changed¶
docker/postgres/updates/add_id_to_fbm_details.sql— Migration script to addidas primary key onfbm_details.backend/service_multi-repricer/app/api/v1/endpoints/fbm_articles.py— Main refactor: multi‑SKU sync, additional SKUs handling, requery FBMDetails to avoid detached instances, fallback creation logic for missing FBM entries.backend/service_multi-repricer/app/crud/repricer_article.py— Addedget_fbm_by_idhelper used by the API.backend/service_multi-repricer/app/api/v1/endpoints/repricer_articles.py— AddedPUT /articles/fbm/{fbm_id}endpoint (placed before/{sku}/fbmto avoid route ambiguity).frontend/src/services/api/multi/repricer.js— AddedupdateFbmDetailsById(fbmId, data)service that callsPUT /articles/fbm/{id}.frontend/src/pages/MultiRepricer/Tabs/FBM/FBMArticles.jsx— Large UI changes: treatfbmas an array, expanded per‑entry cards, per‑entry edit dialog, seller SKU search, chips in list, margin dialog fix.frontend/src/pages/MultiRepricer/Tabs/FBA/FBAArticles.jsx— GuardedEditFbaDetailsDialogagainst nullinternational_pricingentries to avoid runtime TypeError when iterating country details.docs/docs/patchnotes/1.5/1.5.8.md— This patchnotes entry.
Migration notes¶
- The SQL migration
docker/postgres/updates/add_id_to_fbm_details.sqlperforms: - Drop the existing primary key constraint on
fbm_details(if it exists and referencesarticle_id). -
Add an
id SERIAL PRIMARY KEYcolumn so each FBM row can be uniquely identified. -
Run database migrations as part of your normal release process. Because the migration only adds a new column and primary key, it is reversible by removing the column and restoring the previous constraint, but test on a staging snapshot first.