: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(data-warehouse): add alegra bank account, category, warehouse and adjustment tables (#116116)
Tom Owers20c7c61d2ed5
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.mdindex 21eea951d175..5e1788760bbb 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@@ -400,10 +400,10 @@ Today (9): `bills`, `contacts`, `credit_notes`, `debit_notes`, `estimates`, `incDiffed against: <https://developer.alegra.com/reference>-- [ ] `Bank accounts (GET /api/v1/bank-accounts)` — resolves payment account IDs and supports reports by bank account (high)-- [ ] `Warehouses (GET /api/v1/warehouses)` — resolves warehouse IDs in item inventory for reports by location (high)-- [ ] `Item categories (GET /api/v1/item-categories)` — provides category metadata for grouping synced items and sales (high)-- [ ] `Inventory adjustments (GET /api/v1/inventory-adjustments)` — explains stock corrections and inventory gains or losses (medium)+- [x] `Bank accounts (GET /api/v1/bank-accounts)` — resolves payment account IDs and supports reports by bank account (high)+- [x] `Warehouses (GET /api/v1/warehouses)` — resolves warehouse IDs in item inventory for reports by location (high)+- [x] `Item categories (GET /api/v1/item-categories)` — provides category metadata for grouping synced items and sales (high)+- [x] `Inventory adjustments (GET /api/v1/inventory-adjustments)` — explains stock corrections and inventory gains or losses (medium)- [ ] `Warehouse transfers (GET /api/v1/warehouse-transfers)` — tracks stock movement between warehouses (medium)- [ ] `Purchase orders (GET /api/v1/purchase-orders)` — measures committed purchases before supplier bills arrive (medium)- [ ] `Recurring invoices (GET /api/v1/recurring-invoices)` — measures scheduled recurring billing before invoices are generated (medium)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/alegra/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/alegra/canonical_descriptions.pyindex 5e29b4f494d7..d12956bb5f80 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/alegra/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/alegra/canonical_descriptions.py@@ -67,4 +67,42 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"docs_url": "https://developer.alegra.com/reference/get_debit-notes","columns": {"id": "Unique identifier of the debit note.", "date": "Debit note document date."},},+ "bank_accounts": {+ "description": "Bank, cash, and credit card accounts used to receive and make payments.",+ "docs_url": "https://developer.alegra.com/reference/listbankaccounts",+ "columns": {+ "id": "Unique identifier of the bank account.",+ "type": "Account type, such as bank, credit-card, or cash.",+ "status": "Account status: active or inactive.",+ "initialBalance": "Opening balance of the account.",+ "initialBalanceDate": "Date of the opening balance.",+ },+ },+ "item_categories": {+ "description": "Categories used to group products and services.",+ "docs_url": "https://developer.alegra.com/reference/get_item-categories",+ "columns": {+ "id": "Unique identifier of the item category.",+ "status": "Category status: active or inactive.",+ },+ },+ "warehouses": {+ "description": "Warehouses that hold item inventory.",+ "docs_url": "https://developer.alegra.com/reference/get_warehouses",+ "columns": {+ "id": "Unique identifier of the warehouse.",+ "isDefault": "Whether this is the company's default warehouse.",+ "status": "Warehouse status: active or inactive.",+ },+ },+ "inventory_adjustments": {+ "description": "Manual stock corrections that add or remove item quantities in a warehouse.",+ "docs_url": "https://developer.alegra.com/reference/get_inventory-adjustments",+ "columns": {+ "id": "Unique identifier of the inventory adjustment.",+ "date": "Inventory adjustment document date.",+ "warehouse": "Warehouse where the adjustment applies.",+ "items": "Adjusted items with quantity, direction (in or out), and unit cost.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/alegra/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/alegra/settings.pyindex 3e8c4eb0a3a3..000e9bc62238 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/alegra/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/alegra/settings.py@@ -34,6 +34,16 @@ ENDPOINTS: dict[str, AlegraEndpoint] = {"estimates": AlegraEndpoint(path="estimates", params={"order_field": "id", "order_direction": "ASC"}),"credit_notes": AlegraEndpoint(path="credit-notes"),"debit_notes": AlegraEndpoint(path="debit-notes"),+ # Alegra omits inactive bank accounts unless asked, but payments still reference them.+ "bank_accounts": AlegraEndpoint(+ path="bank-accounts", params={"order_field": "id", "order_direction": "ASC", "includeInactive": "true"}+ ),+ # Item categories only sort by the editable name, so keep the API default order.+ "item_categories": AlegraEndpoint(path="item-categories"),+ "warehouses": AlegraEndpoint(path="warehouses", params={"order_field": "id", "order_direction": "ASC"}),+ "inventory_adjustments": AlegraEndpoint(+ path="inventory-adjustments", params={"order_field": "id", "order_direction": "ASC"}+ ),}# Document dates can be edited, and server-side date filters have not been verified against a live account.diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/alegra/tests/test_alegra.py b/products/warehouse_sources/backend/temporal/data_imports/sources/alegra/tests/test_alegra.pyindex 177dc7a9f321..e3e12c97ed88 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/alegra/tests/test_alegra.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/alegra/tests/test_alegra.py@@ -106,3 +106,18 @@ def test_unknown_table_fails_before_network(with pytest.raises(UnknownResourceError):response_for(config, replace(inputs, schema_name="missing_table"))assert sent == []+++def test_bank_accounts_request_includes_inactive_accounts(+ config: AlegraSourceConfig,+ inputs: SourceInputs,+ http_boundary: Callable[..., list[PreparedRequest]],+ redis_boundary: dict[str, str],+) -> None:+ sent = http_boundary([(200, [{"id": "bank-test", "status": "inactive"}])])+ assert rows(response_for(config, replace(inputs, schema_name="bank_accounts"))) == [+ [{"id": "bank-test", "status": "inactive"}]+ ]+ request_url = urlsplit(sent[0].url or "")+ assert request_url.path == "/api/v1/bank-accounts"+ assert parse_qs(request_url.query)["includeInactive"] == ["true"]