Skip to content

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 id primary key on fbm_details so one RepricerArticle can have multiple FBMDetails rows.
  • 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.sql which drops the old primary key constraint and adds an id SERIAL PRIMARY KEY column to fbm_details so 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: FBMArticles now shows fbm as 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_sku alongside the existing SKU search.

🔧 Improvements

  • Sync robustness: process_sync_variation_skus now:
  • Fetches variant SKUs and additional SKUs, filters by target market (e.g., Amazon marketId=4), and deduplicates results.
  • Requeries FBMDetails after async Plenty API calls to avoid detached ORM instances and to ensure safe updates.
  • When a matching FBMDetails row is missing, creates a new row and clones sensible config from an existing reference detail (margin rules, international pricing, flags).
  • Frontend: EditFbmDetailsDialog now targets an individual fbmDetail and calls the new updateFbmDetailsById service, avoiding ambiguous updates to the parent article's fbm blob.
  • UX: Seller SKUs are displayed as chips in the article list for quick scanning; the table uses the best candidate primaryFbm (prefers matching article.sku) for status/price columns.

🐛 Bug Fixes

  • Fixed DetachedInstanceError during background sync by avoiding use of pre‑fetched ORM instances across await points; FBMDetails rows are reloaded under the same session before mutation.
  • Restored correct margin rule lookup in the UI by ensuring the MarginRuleDialog reads margin_rule_id from the selected fbmDetail.
  • Prevented seller SKU collisions by checking existing SKUs before appending additional SKUs to the results set.
  • Fixed runtime TypeError in EditFbaDetailsDialog by guarding against null entries in fba.international_pricing. Some country entries can be null; the dialog now checks details && !details.error before reading details.error or bounds, preventing crashes when editing FBA details.

📁 Files changed

  • docker/postgres/updates/add_id_to_fbm_details.sql — Migration script to add id as primary key on fbm_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 — Added get_fbm_by_id helper used by the API.
  • backend/service_multi-repricer/app/api/v1/endpoints/repricer_articles.py — Added PUT /articles/fbm/{fbm_id} endpoint (placed before /{sku}/fbm to avoid route ambiguity).
  • frontend/src/services/api/multi/repricer.js — Added updateFbmDetailsById(fbmId, data) service that calls PUT /articles/fbm/{id}.
  • frontend/src/pages/MultiRepricer/Tabs/FBM/FBMArticles.jsx — Large UI changes: treat fbm as 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 — Guarded EditFbaDetailsDialog against null international_pricing entries 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.sql performs:
  • Drop the existing primary key constraint on fbm_details (if it exists and references article_id).
  • Add an id SERIAL PRIMARY KEY column 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.