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.

docs: add example for generating a sales invoice report

Brad Barbinf73bb6a1d399
diff --git a/scripts/govcloud-test.ts b/scripts/govcloud-test.ts
index d96559411a..0d1be0b814 100644
--- a/scripts/govcloud-test.ts
+++ b/scripts/govcloud-test.ts
@@ -15,6 +15,6 @@ dotenv.config();
console.log({ data, error });
} catch (err) {
- console.error("Error reading file or uploading:", err);
+ console.error("Error:", err);
}
})();
diff --git a/scripts/sales-invoice-report.ts b/scripts/sales-invoice-report.ts
new file mode 100644
index 0000000000..41db52117a
--- /dev/null
+++ b/scripts/sales-invoice-report.ts
@@ -0,0 +1,36 @@
+import { createClient } from "@supabase/supabase-js";
+import fs from "fs";
+const companyId = "********************";
+const apiKey = "crbn_******************";
+const publicApiKey =
+ "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNxb2ppamlpamtuaGJneW9nbWx1Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjM2MDU0MzksImV4cCI6MjAzOTE4MTQzOX0.JMzLs9Y4Y4kQ-jhQHrSqgNyHSZgrkwzBd1PwPbVPtbQ";
+
+const carbon = createClient("https://api.carbon.ms", publicApiKey, {
+ global: {
+ headers: {
+ "carbon-key": apiKey,
+ },
+ },
+});
+
+(async () => {
+ const { data, error } = await carbon
+ .from("salesInvoice")
+ .select(
+ "*, salesInvoiceLine(*), salesInvoiceShipment(*), customer!salesInvoice_customerId_fkey(name, tags)"
+ )
+ .eq("companyId", companyId)
+ .limit(1000)
+ .order("createdAt", { ascending: false });
+
+ if (data) {
+ fs.writeFileSync(
+ "sales-invoice-report.json",
+ JSON.stringify(data, null, 2)
+ );
+ }
+
+ if (error) {
+ console.error(error);
+ }
+})();