Skip to content

1.6.4

⚙️ Patch 1.6.4 — Transit stock valuation, exports and UI improvements

🚀 Summary

  • Add FIFO-based valuation for transit stock and expose transit metrics across API, exports and UI.
  • Improve query performance for total stock aggregation by consolidating conditional aggregations.
  • Surface transit and combined stock values in the frontend with lightweight caching and a force-reload control.

✨ Improvements

  • Backend: service_plenty now calculates transit_stock_value using the existing FIFO buy_price logic and stores it on the article snapshot alongside stock_value.
  • API: /total-stock-value now returns total_transit_stock_value, combined_stock_value, per-source transit values and unit counts. Historical daily values include transit metrics as well.
  • Performance: reduced number of DB queries in get_total_stock_value by using conditional CASE aggregations (single aggregated query per date instead of multiple per-source queries).
  • Exports: CSV/XLSX exports now include transit_value and combined stock value columns so reports reflect transit valuation.
  • Frontend: Stock overview and History dialog updated to display total_transit_stock_value, per-source transit_stock_value, combined_stock_value, and units; added localStorage caching for the stock summary and a small force-reload button to fetch fresh values.

🐛 Bug Fixes

  • Fixed cases where transit_stock_value could be omitted or treated as None in aggregation queries by wrapping calculations with coalesce.
  • Prevented missing-field errors in export and history rendering when older snapshots did not include transit metrics.

📁 Files changed

  • backend/service_plenty/app/api/v1/endpoints/plenty_stock.py — transit valuation, aggregated endpoint changes, history loop updated.
  • backend/service_plenty/app/api/v1/endpoints/plenty_article.py — exports (CSV/XLSX) updated to include transit and combined values.
  • frontend/src/pages/Plenty/Tabs/SubTabs/StockManagementSubTab.jsx — show total_transit_stock_value, combined value, caching and force-reload button.
  • frontend/src/pages/Plenty/Tabs/SubTabs/ArticlesManagementSubTab.jsx — history dialog and total-card updated to show transit values and units; history table shows per-source stock/transit breakdown.