Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(warehouse_sources): add katana order row and production tables (#113312)

Tom Owers2fb36d9c738f
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
index 19c284cad175..3b688afe9dc8 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
@@ -4716,11 +4716,11 @@ Today (18): `customers`, `inventory`, `inventory_movements`, `locations`, `manuf
Diffed against: <https://api.katanamrp.com/v1/openapi.json>
-- [ ] `sales_order_rows` — line items behind sales_orders — required for any revenue-by-product or product-mix analysis (high)
-- [ ] `purchase_order_rows` — line items behind purchase_orders, with quantities and purchase prices (high)
+- [x] `sales_order_rows` — line items behind sales_orders — required for any revenue-by-product or product-mix analysis (high)
+- [x] `purchase_order_rows` — line items behind purchase_orders, with quantities and purchase prices (high)
- [ ] `bom_rows` — bill-of-materials linking products/variants to the materials they consume (high)
-- [ ] `manufacturing_order_recipe_rows` — actual ingredient consumption per manufacturing order — yield and material-variance analysis (high)
-- [ ] `manufacturing_order_productions` — completed production output per manufacturing order; manufacturing_orders alone only carries planned state (high)
+- [x] `manufacturing_order_recipe_rows` — actual ingredient consumption per manufacturing order — yield and material-variance analysis (high)
+- [x] `manufacturing_order_productions` — completed production output per manufacturing order; manufacturing_orders alone only carries planned state (high)
- [ ] `sales_order_fulfillments` — shipment/fulfillment records — the transition from order to delivered (high)
- [ ] `sales_return_rows` — line items behind sales_returns, needed to attribute returns to products (medium)
- [ ] `manufacturing_order_operation_rows` — per-operation timings and assigned operators, for throughput and labor cost (medium)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/katana/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/katana/canonical_descriptions.py
index ce2325be134a..4ec3f202853f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/katana/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/katana/canonical_descriptions.py
@@ -128,6 +128,84 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"updated_at": "Timestamp when the order was last updated.",
},
},
+ "sales_order_rows": {
+ "description": "Line items on sales orders: the variant sold, quantity, price and discount per row.",
+ "docs_url": f"{_DOCS}/getallsalesorderrows",
+ "columns": {
+ "id": "Unique identifier for the sales order row.",
+ "sales_order_id": "Sales order the row belongs to.",
+ "variant_id": "Variant sold on this row.",
+ "quantity": "Quantity ordered.",
+ "price_per_unit": "Price per unit in the order currency.",
+ "price_per_unit_in_base_currency": "Price per unit converted to the factory's base currency.",
+ "total_discount": "Total discount applied to the row.",
+ "total": "Row total in the order currency.",
+ "total_in_base_currency": "Row total converted to the factory's base currency.",
+ "tax_rate_id": "Tax rate applied to the row.",
+ "location_id": "Location the row is fulfilled from.",
+ "product_availability": "Stock availability of the product for this row.",
+ "linked_manufacturing_order_id": "Manufacturing order created to fulfil this row, if any.",
+ "created_at": "Timestamp when the row was created.",
+ "updated_at": "Timestamp when the row was last updated.",
+ "deleted_at": "Timestamp when the row was deleted, if deleted.",
+ },
+ },
+ "purchase_order_rows": {
+ "description": "Line items on purchase orders: the variant bought, quantity, purchase price and receipt dates.",
+ "docs_url": f"{_DOCS}/getallpurchaseorderrows",
+ "columns": {
+ "id": "Unique identifier for the purchase order row.",
+ "purchase_order_id": "Purchase order the row belongs to.",
+ "variant_id": "Variant purchased on this row.",
+ "quantity": "Quantity ordered, in the purchase unit of measure.",
+ "purchase_uom": "Unit of measure used when purchasing.",
+ "purchase_uom_conversion_rate": "Conversion rate from the purchase unit to the stock unit.",
+ "price_per_unit": "Purchase price per unit in the order currency.",
+ "price_per_unit_in_base_currency": "Purchase price per unit converted to the factory's base currency.",
+ "total": "Row total in the order currency.",
+ "total_in_base_currency": "Row total converted to the factory's base currency.",
+ "landed_cost": "Landed cost of the row, including distributed additional costs.",
+ "currency": "Currency of the row.",
+ "arrival_date": "Expected arrival date of the row.",
+ "received_date": "Date the row was received.",
+ "location_id": "Location receiving the row.",
+ "created_at": "Timestamp when the row was created.",
+ "updated_at": "Timestamp when the row was last updated.",
+ "deleted_at": "Timestamp when the row was deleted, if deleted.",
+ },
+ },
+ "manufacturing_order_recipe_rows": {
+ "description": "Ingredients of manufacturing orders, with planned and actual consumption per row.",
+ "docs_url": f"{_DOCS}/getallmanufacturingorderreciperows",
+ "columns": {
+ "id": "Unique identifier for the recipe row.",
+ "manufacturing_order_id": "Manufacturing order the ingredient belongs to.",
+ "variant_id": "Ingredient variant consumed.",
+ "planned_quantity_per_unit": "Planned ingredient quantity per unit of product.",
+ "total_actual_quantity": "Actual total quantity of the ingredient used.",
+ "ingredient_availability": "Stock availability of the ingredient.",
+ "ingredient_expected_date": "Date the ingredient is expected to be available.",
+ "cost": "Cost of the ingredient consumption.",
+ "created_at": "Timestamp when the row was created.",
+ "updated_at": "Timestamp when the row was last updated.",
+ "deleted_at": "Timestamp when the row was deleted, if deleted.",
+ },
+ },
+ "manufacturing_order_productions": {
+ "description": "Completed production runs of manufacturing orders, including partial completions.",
+ "docs_url": f"{_DOCS}/getallmanufacturingorderproductions",
+ "columns": {
+ "id": "Unique identifier for the production.",
+ "manufacturing_order_id": "Manufacturing order the production belongs to.",
+ "quantity": "Quantity of product produced.",
+ "production_date": "Date the production was recorded.",
+ "ingredients": "Ingredient consumption recorded for this production.",
+ "operations": "Operation time and cost recorded for this production.",
+ "created_at": "Timestamp when the production was created.",
+ "updated_at": "Timestamp when the production was last updated.",
+ "deleted_at": "Timestamp when the production was deleted, if deleted.",
+ },
+ },
"sales_returns": {
"description": "Returns raised against sales orders, with refund and restock status.",
"docs_url": f"{_DOCS}/getallsalesreturns",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/katana/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/katana/settings.py
index b1ee6015359d..c1cb2dfc3ee2 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/katana/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/katana/settings.py
@@ -54,6 +54,23 @@ KATANA_ENDPOINTS: dict[str, KatanaEndpointConfig] = {
"sales_returns": KatanaEndpointConfig(
name="sales_returns", path="/sales_returns", incremental_fields=_UPDATED_AND_CREATED
),
+ # --- Order line items ---
+ "sales_order_rows": KatanaEndpointConfig(
+ name="sales_order_rows", path="/sales_order_rows", incremental_fields=_UPDATED_AND_CREATED
+ ),
+ "purchase_order_rows": KatanaEndpointConfig(
+ name="purchase_order_rows", path="/purchase_order_rows", incremental_fields=_UPDATED_AND_CREATED
+ ),
+ "manufacturing_order_recipe_rows": KatanaEndpointConfig(
+ name="manufacturing_order_recipe_rows",
+ path="/manufacturing_order_recipe_rows",
+ incremental_fields=_UPDATED_AND_CREATED,
+ ),
+ "manufacturing_order_productions": KatanaEndpointConfig(
+ name="manufacturing_order_productions",
+ path="/manufacturing_order_productions",
+ incremental_fields=_UPDATED_AND_CREATED,
+ ),
# --- Stock movements ---
"stock_adjustments": KatanaEndpointConfig(
name="stock_adjustments", path="/stock_adjustments", incremental_fields=_UPDATED_AND_CREATED
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/katana/tests/test_katana.py b/products/warehouse_sources/backend/temporal/data_imports/sources/katana/tests/test_katana.py
index a3c95adeeddf..78102da7ccab 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/katana/tests/test_katana.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/katana/tests/test_katana.py
@@ -344,6 +344,8 @@ class TestKatanaSourceResponse:
("inventory", ["variant_id", "location_id"], None),
("price_lists", ["id"], None),
("inventory_movements", ["id"], "created_at"),
+ ("sales_order_rows", ["id"], "created_at"),
+ ("manufacturing_order_productions", ["id"], "created_at"),
]
)
def test_source_response_shape(self, endpoint: str, expected_pk: list[str], partition_key: str | None) -> None: