1.2.3
🚀 New Features¶
- Added per-item fee estimation using Amazon SP-API Fees Estimate (ProductFees). Fee estimates are stored on each order item as
fee_estimate_amountandfee_estimate_currency.
🔧 Improvements¶
- Record per-item shipping price returned by Amazon order items as
shipping_price_amountandshipping_price_currency. fetch_amazon_order_lines()now collectsItemPriceandShippingPrice, deduplicates ASINs and requests fee estimates in batches (with retry/backoff) and enriches every returned order line with fee estimate data.- Added helper
_fetch_fee_estimates()to query the Fees Estimate endpoint (OptionalFulfillmentProgram=FBA_EFN) in batches. - Added
get_cancelled_orders()andget_all_marketplace_cancelled_orders()to the SP-API client and purge cancelled orders (last 14 days) after sync runs.
🐛 Bug Fixes¶
- After syncing Amazon orders we now check for cancelled orders in the recent window and delete corresponding
amazon_ordersrows to avoid keeping items that were cancelled after being created as Pending/Unshipped.
SQL¶
-
shipping_fee_amazon_orders.sql
-
DB schema additions (nullable columns added to
amazon_orderstable via SQLModel): shipping_price_amount(FLOAT NULL)shipping_price_currency(TEXT NULL)fee_estimate_amount(FLOAT NULL)fee_estimate_currency(TEXT NULL)
Run your migration tool or apply the generated SQL (shipping_fee_amazon_orders.sql) to add the columns before deploying.
Files changed:
app/services/amazon/spapi_client.py— added fee-estimate helper, shipping price extraction, ProductFees usage, and cancelled-order helpers.app/models/amazon_credentials.py— addedshipping_price_*andfee_estimate_*fields toAmazonOrderLine.app/schemas/amazon_credentials.py— added corresponding nullable columns toAmazonOrderLineRecord(SQLModel).