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(data-warehouse): add 4 missing tables to the Alegra source (#120858)

Tom Owers9b2052425fed
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 9370c56295eb..50ffae1a8d83 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
@@ -409,10 +409,10 @@ Diffed against: <https://developer.alegra.com/reference>
- [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)
-- [ ] `Taxes (GET /api/v1/taxes)` — provides tax definitions and rates for invoice and item tax reports (medium)
+- [x] `Warehouse transfers (GET /api/v1/warehouse-transfers)` — tracks stock movement between warehouses (medium)
+- [x] `Purchase orders (GET /api/v1/purchase-orders)` — measures committed purchases before supplier bills arrive (medium)
+- [x] `Recurring invoices (GET /api/v1/recurring-invoices)` — measures scheduled recurring billing before invoices are generated (medium)
+- [x] `Taxes (GET /api/v1/taxes)` — provides tax definitions and rates for invoice and item tax reports (medium)
- [ ] `Journal entry balances (GET /api/v1/journals/entries-graph)` — provides accounting balances grouped by day or month for financial reports (medium)
Note: Read the official reference index and parsed embedded OpenAPI GET operations from the linked REST reference pages. All listed gaps use the documented v1 REST API. The existing payments table is already split into incoming and outgoing payments. MCP tool operations, payroll APIs, document uploads, and settings were excluded.
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.py
index d12956bb5f80..d60580ba7689 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
@@ -105,4 +105,53 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"items": "Adjusted items with quantity, direction (in or out), and unit cost.",
},
},
+ "warehouse_transfers": {
+ "description": "Stock movements of items from one warehouse to another.",
+ "docs_url": "https://developer.alegra.com/reference/transferencia-de-bodegas",
+ "columns": {
+ "id": "Unique identifier of the warehouse transfer.",
+ "date": "Warehouse transfer document date.",
+ "origin": "Warehouse that the items leave.",
+ "destination": "Warehouse that receives the items.",
+ "items": "Transferred items with their quantities.",
+ },
+ },
+ "purchase_orders": {
+ "description": "Purchase orders sent to suppliers before the supplier bills arrive.",
+ "docs_url": "https://developer.alegra.com/reference/listpurchaseorders",
+ "columns": {
+ "id": "Unique identifier of the purchase order.",
+ "date": "Purchase order document date.",
+ "dueDate": "Purchase order due date.",
+ "deliveryDate": "Expected delivery date of the order.",
+ "status": "Purchase order status: open, close, or void.",
+ "provider": "Supplier of the purchase order.",
+ "purchases": "Ordered items and expense categories with price, quantity, discount, and tax.",
+ },
+ },
+ "recurring_invoices": {
+ "description": "Schedules that create sales invoices for a client at a fixed interval.",
+ "docs_url": "https://developer.alegra.com/reference/facturas-recurrentes",
+ "columns": {
+ "id": "Unique identifier of the recurring invoice.",
+ "startDate": "Date of the first invoice in the schedule.",
+ "endDate": "Date of the last invoice in the schedule, or null when the schedule has no end.",
+ "repeatEvery": "Interval in months between generated invoices.",
+ "client": "Client that receives the generated invoices.",
+ "total": "Total amount of each generated invoice.",
+ "nextCreation": "Time when Alegra creates the next invoice.",
+ "lastCreation": "Time when Alegra created the most recent invoice.",
+ },
+ },
+ "taxes": {
+ "description": "Tax definitions and rates that apply to invoices, bills, and items.",
+ "docs_url": "https://developer.alegra.com/reference/impuestos",
+ "columns": {
+ "id": "Unique identifier of the tax.",
+ "name": "Name of the tax.",
+ "percentage": "Tax rate as a percentage.",
+ "type": "Tax type, such as IVA.",
+ "status": "Tax status: active or inactive.",
+ },
+ },
}
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.py
index 000e9bc62238..9ba32b9e71b5 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
@@ -44,6 +44,12 @@ ENDPOINTS: dict[str, AlegraEndpoint] = {
"inventory_adjustments": AlegraEndpoint(
path="inventory-adjustments", params={"order_field": "id", "order_direction": "ASC"}
),
+ # Warehouse transfers and taxes accept no sort parameters.
+ "warehouse_transfers": AlegraEndpoint(path="warehouse-transfers"),
+ "purchase_orders": AlegraEndpoint(path="purchase-orders", params={"order_field": "id", "order_direction": "ASC"}),
+ # Recurring invoices only sort by editable schedule fields, so keep the API default order.
+ "recurring_invoices": AlegraEndpoint(path="recurring-invoices"),
+ "taxes": AlegraEndpoint(path="taxes"),
}
# 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.py
index e3e12c97ed88..cd3fab49548b 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
@@ -108,16 +108,33 @@ def test_unknown_table_fails_before_network(
assert sent == []
-def test_bank_accounts_request_includes_inactive_accounts(
+ "schema_name, path, query",
+ [
+ (
+ "bank_accounts",
+ "/api/v1/bank-accounts",
+ {"order_field": ["id"], "order_direction": ["ASC"], "includeInactive": ["true"]},
+ ),
+ ("warehouse_transfers", "/api/v1/warehouse-transfers", {}),
+ ("purchase_orders", "/api/v1/purchase-orders", {"order_field": ["id"], "order_direction": ["ASC"]}),
+ ("recurring_invoices", "/api/v1/recurring-invoices", {}),
+ ("taxes", "/api/v1/taxes", {}),
+ ],
+)
+def test_endpoint_request_shape(
config: AlegraSourceConfig,
inputs: SourceInputs,
http_boundary: Callable[..., list[PreparedRequest]],
redis_boundary: dict[str, str],
+ schema_name: str,
+ path: str,
+ query: dict[str, list[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"}]
+ sent = http_boundary([(200, [{"id": "row-test", "status": "inactive"}])])
+ assert rows(response_for(config, replace(inputs, schema_name=schema_name))) == [
+ [{"id": "row-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"]
+ assert request_url.path == path
+ assert parse_qs(request_url.query) == {**query, "limit": ["30"], "start": ["0"]}