fsanyoto commited on
Commit
c4810fa
·
verified ·
1 Parent(s): cdb06e5

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
- "current": "2bc6edf7a",
3
  "releases": []
4
  }
 
1
  {
2
+ "current": "1652782e2",
3
  "releases": []
4
  }
VERSION CHANGED
@@ -1 +1 @@
1
- 2bc6edf7a
 
1
+ 1652782e2
platform/modules/amazon_profit.py CHANGED
@@ -734,7 +734,13 @@ def receipt_costs(con, product_ids=None):
734
 
735
  def read_cost_history(st):
736
  """Read saved observations strictly so a failed read cannot replace history."""
737
- doc = st._read_strict(COST_HISTORY_KEY) or {}
 
 
 
 
 
 
738
  required = {"observation_id", "product_id", "move_id", "receipt", "date", "quantity",
739
  "purchase_unit_cost", "landed_unit_cost", "unit_cost", "source"}
740
  if (not isinstance(doc, dict) or doc.get("version", 1) != 1
@@ -790,6 +796,7 @@ def odoo_channel_margins(con, start, end):
790
  "FROM sale_order_line l JOIN sale_order o ON o.id=l.order_id "
791
  "JOIN res_partner p ON p.id=o.partner_id WHERE o.state IN ('sale','done') "
792
  "AND o.team_id IN (5,6) AND upper(p.name) NOT LIKE '%GIFTWARE DEALS%' "
 
793
  "AND left(CAST(o.date_order AS VARCHAR),10) BETWEEN ? AND ? GROUP BY l.product_id",
794
  [start, end]).fetchall()
795
  return {int(pid): {"profit": None if missing else float(profit),
@@ -2087,7 +2094,8 @@ def refresh(st, con, *, period=None, thin=None, by="", cost_reader=None, today=N
2087
  computed = unverified(computed, sentence)
2088
  report.update(write_rows(st, computed), merged=merged,
2089
  decisions={k: decisions[k] for k in ("confirmed", "rejected")})
2090
- rows = [dict(_raw_row(values), sku=sku, velocity_30d=(metrics.get(sku) or {}).get("velocity_30d"))
 
2091
  for sku, values in computed.items()]
2092
 
2093
  by_grain = {}
 
734
 
735
  def read_cost_history(st):
736
  """Read saved observations strictly so a failed read cannot replace history."""
737
+ # A TenantRuntime has no _read_strict of its own: read through its backend's, under its key.
738
+ reader = getattr(st, "_read_strict", None)
739
+ if reader is None and callable(getattr(st, "_store", None)) and callable(getattr(st, "store_key", None)):
740
+ strict = getattr(st._store(), "_read_strict", None)
741
+ if callable(strict):
742
+ reader = lambda name: strict(st.store_key(name)) # noqa: E731
743
+ doc = (reader(COST_HISTORY_KEY) if reader else st.get(COST_HISTORY_KEY, fresh=True)) or {}
744
  required = {"observation_id", "product_id", "move_id", "receipt", "date", "quantity",
745
  "purchase_unit_cost", "landed_unit_cost", "unit_cost", "source"}
746
  if (not isinstance(doc, dict) or doc.get("version", 1) != 1
 
796
  "FROM sale_order_line l JOIN sale_order o ON o.id=l.order_id "
797
  "JOIN res_partner p ON p.id=o.partner_id WHERE o.state IN ('sale','done') "
798
  "AND o.team_id IN (5,6) AND upper(p.name) NOT LIKE '%GIFTWARE DEALS%' "
799
+ "AND l.product_id IS NOT NULL "
800
  "AND left(CAST(o.date_order AS VARCHAR),10) BETWEEN ? AND ? GROUP BY l.product_id",
801
  [start, end]).fetchall()
802
  return {int(pid): {"profit": None if missing else float(profit),
 
2094
  computed = unverified(computed, sentence)
2095
  report.update(write_rows(st, computed), merged=merged,
2096
  decisions={k: decisions[k] for k in ("confirmed", "rejected")})
2097
+ rows = [dict(_raw_row(values), sku=sku, velocity_30d=(metrics.get(sku) or {}).get("velocity_30d"),
2098
+ fnsku=(metrics.get(sku) or {}).get("fnsku"))
2099
  for sku, values in computed.items()]
2100
 
2101
  by_grain = {}
platform/modules/amazon_sku_metrics.py CHANGED
@@ -411,6 +411,7 @@ def sku_metrics(con, *, start, end, skus, today) -> dict[str, dict]:
411
  cover = _f(p.get("days")) if p else None
412
  if cover is None and available is not None:
413
  cover = _ratio(available * 30, velocity)
 
414
  row.update(fba_on_hand=_int(available), inbound_units=_int(p.get("inbound")) if p else None,
415
  velocity_30d=velocity, days_of_cover=_int(cover))
416
  row["return_units"] = None if returns is None else _int(returns.get(sku) or 0)
@@ -476,6 +477,16 @@ def rollup(rows: list[dict], *, key: str) -> list[dict]:
476
  acos=_ratio(row["ad_spend"], row["ad_sales"]), roas=_ratio(row["ad_sales"], row["ad_spend"]),
477
  margin=_ratio(row["net_profit"], row["net_sales"]) if row["net_profit"] is not None else None,
478
  ads_note="" if any(c.get("ads_note") == "" for c in children) else NO_ADS_NOTE)
 
 
 
 
 
 
 
 
 
 
479
  velocity = row["velocity_30d"]
480
  cover = _ratio(row["fba_on_hand"], velocity / 30) if row["fba_on_hand"] is not None and velocity else None
481
  row["days_of_cover"] = _int(cover)
 
411
  cover = _f(p.get("days")) if p else None
412
  if cover is None and available is not None:
413
  cover = _ratio(available * 30, velocity)
414
+ row["fnsku"] = _text(p.get("fnsku")) if p else None
415
  row.update(fba_on_hand=_int(available), inbound_units=_int(p.get("inbound")) if p else None,
416
  velocity_30d=velocity, days_of_cover=_int(cover))
417
  row["return_units"] = None if returns is None else _int(returns.get(sku) or 0)
 
477
  acos=_ratio(row["ad_spend"], row["ad_sales"]), roas=_ratio(row["ad_sales"], row["ad_spend"]),
478
  margin=_ratio(row["net_profit"], row["net_sales"]) if row["net_profit"] is not None else None,
479
  ads_note="" if any(c.get("ads_note") == "" for c in children) else NO_ADS_NOTE)
480
+ # Two seller SKUs on one FNSKU report the same inventory pool, so stock counts once per FNSKU.
481
+ pools = {}
482
+ for c in children:
483
+ pool = _text(c.get("fnsku")) or _text(c.get("sku"))
484
+ if pool and pool not in pools:
485
+ pools[pool] = (_f(c.get("fba_on_hand")), _f(c.get("inbound_units")))
486
+ on_hand = _sum(h for h, _i in pools.values())
487
+ inbound = _sum(i for _h, i in pools.values())
488
+ row["fba_on_hand"] = _int(on_hand) if on_hand is not None else None
489
+ row["inbound_units"] = _int(inbound) if inbound is not None else None
490
  velocity = row["velocity_30d"]
491
  cover = _ratio(row["fba_on_hand"], velocity / 30) if row["fba_on_hand"] is not None and velocity else None
492
  row["days_of_cover"] = _int(cover)
web/public/AIOS_DEPLOY_RECEIPT CHANGED
@@ -1 +1 @@
1
- 997b2217057eb3c8d9d4f307cdab5ab0e0c8df2027bccfcaedf78173b384d8f3
 
1
+ bff3dd5bb59425db27f32f0d12a240b076d4ebeb8928dab6bf6e619ab13a9a80