Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat: add route for radan csv

Brad Barbina0e1c24f588a
diff --git a/apps/erp/app/routes/api+/integrations.radan.$version[.]csv.ts b/apps/erp/app/routes/api+/integrations.radan.$version[.]csv.ts
new file mode 100644
index 0000000000..2119323540
--- /dev/null
+++ b/apps/erp/app/routes/api+/integrations.radan.$version[.]csv.ts
@@ -0,0 +1,37 @@
+import { getCarbonServiceRole } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import type { LoaderFunctionArgs } from "@vercel/remix";
+import { json } from "@vercel/remix";
+
+export async function loader({ request, params }: LoaderFunctionArgs) {
+ const { companyId } = await requirePermissions(request, {});
+
+ const serviceRole = getCarbonServiceRole();
+
+ if (!params.version) {
+ return json(
+ { success: false, error: "Version is required" },
+ { status: 400 }
+ );
+ }
+
+ if (params.version === "v1") {
+ const result = await serviceRole.rpc("radan_v1", {
+ company_id: companyId,
+ });
+
+ if (result.error) {
+ return json(
+ { success: false, error: result.error.message },
+ { status: 500 }
+ );
+ }
+
+ return json({ success: true, data: result.data });
+ }
+
+ return json({
+ success: false,
+ error: `version ${params.version} is invalid`,
+ });
+}
diff --git a/apps/erp/app/routes/x+/purchasing+/_index.tsx b/apps/erp/app/routes/x+/purchasing+/_index.tsx
index 00bbf0ae0c..1afa5cd5a2 100644
--- a/apps/erp/app/routes/x+/purchasing+/_index.tsx
+++ b/apps/erp/app/routes/x+/purchasing+/_index.tsx
@@ -104,14 +104,16 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
)
.in("status", OPEN_PURCHASE_ORDER_STATUSES)
- .eq("companyId", companyId),
+ .eq("companyId", companyId)
+ .limit(10),
client
.from("purchaseInvoice")
.select("id, invoiceId, status, supplierId, assignee, createdAt", {
count: "exact",
})
.in("status", OPEN_INVOICE_STATUSES)
- .eq("companyId", companyId),
+ .eq("companyId", companyId)
+ .limit(10),
client
.from("supplierQuote")
.select(
@@ -121,7 +123,8 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
)
.in("status", OPEN_SUPPLIER_QUOTE_STATUSES)
- .eq("companyId", companyId),
+ .eq("companyId", companyId)
+ .limit(10),
]);
return defer({
diff --git a/apps/erp/app/routes/x+/sales+/_index.tsx b/apps/erp/app/routes/x+/sales+/_index.tsx
index d4e615b0b2..b1c8aff997 100644
--- a/apps/erp/app/routes/x+/sales+/_index.tsx
+++ b/apps/erp/app/routes/x+/sales+/_index.tsx
@@ -94,21 +94,24 @@ export async function loader({ request }: LoaderFunctionArgs) {
count: "exact",
})
.in("status", OPEN_SALES_ORDER_STATUSES)
- .eq("companyId", companyId),
+ .eq("companyId", companyId)
+ .limit(10),
client
.from("quote")
.select("id, quoteId, status, customerId, assignee, createdAt", {
count: "exact",
})
.in("status", OPEN_QUOTE_STATUSES)
- .eq("companyId", companyId),
+ .eq("companyId", companyId)
+ .limit(10),
client
.from("salesRfq")
.select("id, rfqId, status, customerId, assignee, createdAt", {
count: "exact",
})
.in("status", OPEN_RFQ_STATUSES)
- .eq("companyId", companyId),
+ .eq("companyId", companyId)
+ .limit(10),
]);
return defer({
diff --git a/packages/database/supabase/migrations/20250827201650_radan-v1.sql b/packages/database/supabase/migrations/20250827201650_radan-v1.sql
new file mode 100644
index 0000000000..e69de29bb2