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 weekly background job for deleting churned companies

Brad Barbinbfc072421957
diff --git a/apps/erp/app/modules/quality/ui/Calibrations/GaugeCalibrationRecordsTable.tsx b/apps/erp/app/modules/quality/ui/Calibrations/GaugeCalibrationRecordsTable.tsx
index 299f214c47..6bc4d0c55b 100644
--- a/apps/erp/app/modules/quality/ui/Calibrations/GaugeCalibrationRecordsTable.tsx
+++ b/apps/erp/app/modules/quality/ui/Calibrations/GaugeCalibrationRecordsTable.tsx
@@ -404,7 +404,7 @@ const GaugeCalibrationRecordsTable = memo(
deleteDisclosure.onClose();
}}
name={`record for ${
- selectedGaugeCalibrationRecord.gaugeId ?? "gauge"
+ selectedGaugeCalibrationRecord.gaugeReadableId ?? "gauge"
}`}
text="Are you sure you want to delete this record?"
/>
diff --git a/apps/erp/app/routes/api+/settings.bypass.ts b/apps/erp/app/routes/api+/settings.bypass.ts
new file mode 100644
index 0000000000..5736c6342f
--- /dev/null
+++ b/apps/erp/app/routes/api+/settings.bypass.ts
@@ -0,0 +1,12 @@
+import { STRIPE_BYPASS_COMPANY_IDS } from "@carbon/auth";
+import { json } from "@vercel/remix";
+
+export async function loader() {
+ if (STRIPE_BYPASS_COMPANY_IDS) {
+ const bypassList = STRIPE_BYPASS_COMPANY_IDS.split(",").map((id: string) =>
+ id.trim()
+ );
+ return json({ bypassList });
+ }
+ return json({ bypassList: [] });
+}
diff --git a/packages/jobs/trigger/weekly.ts b/packages/jobs/trigger/weekly.ts
new file mode 100644
index 0000000000..3a39358a45
--- /dev/null
+++ b/packages/jobs/trigger/weekly.ts
@@ -0,0 +1,41 @@
+import { getCarbonServiceRole } from "@carbon/auth";
+import { schedules } from "@trigger.dev/sdk/v3";
+import { Edition } from "../../utils/src/types.ts";
+
+const serviceRole = getCarbonServiceRole();
+
+export const weekly = schedules.task({
+ id: "weekly",
+ // Run every Sunday at 9pm
+ cron: "0 21 * * 0",
+ run: async () => {
+ console.log(`📅 Starting weekly tasks: ${new Date().toISOString()}`);
+
+ try {
+ if (process.env.CARBON_EDITION === Edition.Cloud || true) {
+ const bypassUrl = `${process.env.VERCEL_URL}/api/settings/bypass`;
+ const bypassResponse = await fetch(bypassUrl);
+ if (!bypassResponse.ok) {
+ console.error(
+ `Failed to fetch bypass list: ${bypassResponse.statusText}`
+ );
+ return;
+ }
+ const bypassData = (await bypassResponse.json()) as {
+ bypassList?: string[];
+ };
+ const bypassList = bypassData.bypassList ?? [];
+
+ console.log(`Bypass list: ${bypassList}`);
+ }
+
+ console.log(`📅 Weekly tasks completed: ${new Date().toISOString()}`);
+ } catch (error) {
+ console.error(
+ `Unexpected error in weekly tasks: ${
+ error instanceof Error ? error.message : String(error)
+ }`
+ );
+ }
+ },
+});