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.

fix: resolve production Postgres/Stripe errors from the logs (#1664)

Sid57af1c8b9590
diff --git a/apps/erp/app/modules/quality/quality.service.ts b/apps/erp/app/modules/quality/quality.service.ts
index 92af64762a..19f7d477fe 100644
--- a/apps/erp/app/modules/quality/quality.service.ts
+++ b/apps/erp/app/modules/quality/quality.service.ts
@@ -1130,17 +1130,12 @@ export async function getQualityDocumentsList(
id: string;
name: string;
version: number;
- processId: string;
status: string;
- }>(
- client,
- "qualityDocument",
- "id, name, version, processId, status",
- (query) =>
- query
- .eq("companyId", companyId)
- .order("name", { ascending: true })
- .order("version", { ascending: false })
+ }>(client, "qualityDocument", "id, name, version, status", (query) =>
+ query
+ .eq("companyId", companyId)
+ .order("name", { ascending: true })
+ .order("version", { ascending: false })
);
}
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteExplorer.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteExplorer.tsx
index 4adff0ec40..02f1669c4e 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteExplorer.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteExplorer.tsx
@@ -101,9 +101,12 @@ export default function QuoteExplorer({ methods }: QuoteExplorerProps) {
taxPercent: quoteData?.customer?.taxPercent ?? 0
};
+ const modelPaths = (quoteData?.lines ?? [])
+ .map((d) => d.modelPath)
+ .filter(Boolean);
useRealtime(
"modelUpload",
- `modelPath=in.(${quoteData?.lines.map((d) => d.modelPath).join(",")})`
+ modelPaths.length ? `modelPath=in.(${modelPaths.join(",")})` : undefined
);
const newQuoteLineDisclosure = useDisclosure();
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderExplorer.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderExplorer.tsx
index c77d87456a..7ccad18e21 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderExplorer.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderExplorer.tsx
@@ -160,9 +160,12 @@ export default function SalesOrderExplorer() {
? true
: salesOrderData?.salesOrder?.status !== "Draft";
+ const modelPaths = (salesOrderData?.lines ?? [])
+ .map((d) => d.modelPath)
+ .filter(Boolean);
useRealtime(
"modelUpload",
- `modelPath=in.(${salesOrderData?.lines.map((d) => d.modelPath).join(",")})`
+ modelPaths.length ? `modelPath=in.(${modelPaths.join(",")})` : undefined
);
const onDeleteLine = (line: SalesOrderLine) => {
diff --git a/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQExplorer.tsx b/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQExplorer.tsx
index 7f9fce66b9..6964c5f1a0 100644
--- a/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQExplorer.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQExplorer.tsx
@@ -58,9 +58,12 @@ export default function SalesRFQExplorer() {
}>(path.to.salesRfq(rfqId));
const permissions = usePermissions();
+ const modelPaths = (salesRfqData?.lines ?? [])
+ .map((d) => d.modelPath)
+ .filter(Boolean);
useRealtime(
"modelUpload",
- `modelPath=in.(${salesRfqData?.lines.map((d) => d.modelPath).join(",")})`
+ modelPaths.length ? `modelPath=in.(${modelPaths.join(",")})` : undefined
);
const newSalesRFQLineDisclosure = useDisclosure();
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json b/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json
index 79647020b6..375ed2d41a 100644
--- a/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json
+++ b/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json
@@ -1054,7 +1054,7 @@
{"name":"quality_getQualityActions","classification":"READ","paramCount":3,"schema":"04eded31eebb","response":"76d10ad61a21","injectAuth":"companyId","permission":"quality:view","paginates":true},
{"name":"quality_getQualityDocument","classification":"READ","paramCount":1,"schema":"3797626bd17e","response":"a8b2d87af029","injectAuth":"companyId","permission":"quality:view","paginates":false},
{"name":"quality_getQualityDocuments","classification":"READ","paramCount":1,"schema":"75e0e9e0be40","response":"8bb4ab685129","injectAuth":"companyId","permission":"quality:view","paginates":true},
- {"name":"quality_getQualityDocumentsList","classification":"READ","paramCount":0,"schema":"efddc7bd8bbc","response":"fe6a24448aaa","injectAuth":"companyId","permission":"quality:view","paginates":false},
+ {"name":"quality_getQualityDocumentsList","classification":"READ","paramCount":0,"schema":"efddc7bd8bbc","response":"f0df86b695e6","injectAuth":"companyId","permission":"quality:view","paginates":false},
{"name":"quality_getQualityDocumentSteps","classification":"READ","paramCount":1,"schema":"6d79e6870690","response":"55202747c3b2","injectAuth":"companyId","permission":"quality:view","paginates":false},
{"name":"quality_getQualityDocumentVersions","classification":"READ","paramCount":2,"schema":"89111eab017d","response":"63e52c70cbef","injectAuth":"companyId","permission":"quality:view","paginates":false},
{"name":"quality_getQualityFiles","classification":"READ","paramCount":1,"schema":"3797626bd17e","response":"c8f657a900dd","injectAuth":"companyId","permission":"quality:view","paginates":false},
diff --git a/packages/locale/locales/hi/erp.po b/packages/locale/locales/hi/erp.po
index 22db1ad458..c4ab0bdc2d 100644
--- a/packages/locale/locales/hi/erp.po
+++ b/packages/locale/locales/hi/erp.po
@@ -17753,7 +17753,6 @@ msgid "This invitation to join {0} has expired. You can request a new invite to
msgstr "यह आमंत्रण {0} में शामिल होने के लिए समाप्त हो गया है। आप अपने ईमेल पर भेजने के लिए नया आमंत्रण का अनुरोध कर सकते हैं।"
msgid "This invoice has no usable due date — choose one for Stripe."
-msgstr "इस चालान की कोई उपयोग योग्य देय तारीख नहीं है — Stripe के लिए एक चुनें।"
msgstr "इस चालान का कोई उपयोगी नियत तिथि नहीं है — Stripe के लिए एक चुनें।"
msgid "This invoice will be billed to the Stripe customer already linked to this Carbon customer. To change its details, edit it in the Stripe dashboard."
diff --git a/packages/locale/locales/ko/erp.po b/packages/locale/locales/ko/erp.po
index 97a8801dda..6aaf84c0db 100644
--- a/packages/locale/locales/ko/erp.po
+++ b/packages/locale/locales/ko/erp.po
@@ -17753,7 +17753,6 @@ msgid "This invitation to join {0} has expired. You can request a new invite to
msgstr "이 {0}에 가입하라는 초대가 만료되었습니다. 새 초대를 이메일로 보내달라고 요청할 수 있습니다."
msgid "This invoice has no usable due date — choose one for Stripe."
-msgstr "이 송장에는 사용 가능한 만기일이 없습니다 — Stripe용으로 선택하세요."
msgstr "이 송장에는 사용 가능한 마감일이 없습니다 — Stripe를 위해 하나를 선택하세요."
msgid "This invoice will be billed to the Stripe customer already linked to this Carbon customer. To change its details, edit it in the Stripe dashboard."
diff --git a/packages/locale/locales/pl/erp.po b/packages/locale/locales/pl/erp.po
index 8b01984acf..f47aa4ddc5 100644
--- a/packages/locale/locales/pl/erp.po
+++ b/packages/locale/locales/pl/erp.po
@@ -16292,7 +16292,6 @@ msgid "Stripe already has a customer with this email"
msgstr "Stripe już ma klienta z tym adresem e-mail"
msgid "Stripe Due Date"
-msgstr "Termin płatności Stripe"
msgstr "Pasek daty terminu"
msgid "Stripe emails the invoice to the customer, so an address is required. This will also be saved to the contact in Carbon."
@@ -17754,7 +17753,6 @@ msgid "This invitation to join {0} has expired. You can request a new invite to
msgstr "To zaproszenie do dołączenia do {0} wygasło. Możesz poprosić o wysłanie nowego zaproszenia na Twoją wiadomość e-mail."
msgid "This invoice has no usable due date — choose one for Stripe."
-msgstr "Ta faktura nie ma użytecznego terminu płatności — wybierz jeden dla Stripe."
msgstr "Ta faktura nie ma użytecznego terminu — wybierz jeden dla Stripe."
msgid "This invoice will be billed to the Stripe customer already linked to this Carbon customer. To change its details, edit it in the Stripe dashboard."
diff --git a/packages/locale/locales/ru/erp.po b/packages/locale/locales/ru/erp.po
index 542a5f9c44..0da69c3ba3 100644
--- a/packages/locale/locales/ru/erp.po
+++ b/packages/locale/locales/ru/erp.po
@@ -16289,7 +16289,6 @@ msgid "Stripe"
msgstr "Stripe"
msgid "Stripe already has a customer with this email"
-msgstr "Stripe уже имеет клиента с этим адресом электронной почты"
msgstr "В Stripe уже есть покупатель с этим адресом электронной почты"
msgid "Stripe Due Date"
@@ -17754,7 +17753,6 @@ msgid "This invitation to join {0} has expired. You can request a new invite to
msgstr "Приглашение присоединиться к {0} истекло. Вы можете запросить отправку нового приглашения на вашу электронную почту."
msgid "This invoice has no usable due date — choose one for Stripe."
-msgstr "У этого счета нет полезной даты выполнения — выберите один для Stripe."
msgstr "Эта Счет-фактура не имеет пригодной даты Срока выполнения — выберите одну для Stripe."
msgid "This invoice will be billed to the Stripe customer already linked to this Carbon customer. To change its details, edit it in the Stripe dashboard."
diff --git a/packages/locale/locales/tr/erp.po b/packages/locale/locales/tr/erp.po
index ded9f7afeb..1220bdf461 100644
--- a/packages/locale/locales/tr/erp.po
+++ b/packages/locale/locales/tr/erp.po
@@ -17753,7 +17753,6 @@ msgid "This invitation to join {0} has expired. You can request a new invite to
msgstr "{0} grubuna katılma davetinizin süresi doldu. Yeni bir davet talebinde bulunabilirsiniz ve bu e-postanıza gönderilir."
msgid "This invoice has no usable due date — choose one for Stripe."
-msgstr "Bu fatura kullanılabilir bir son tarih yok — Stripe için birini seçin."
msgstr "Bu faturanın kullanılabilir bir son tarihi yok — Stripe için birini seçin."
msgid "This invoice will be billed to the Stripe customer already linked to this Carbon customer. To change its details, edit it in the Stripe dashboard."
diff --git a/packages/stripe/src/stripe.server.ts b/packages/stripe/src/stripe.server.ts
index 42bec20d6f..19658aee70 100644
--- a/packages/stripe/src/stripe.server.ts
+++ b/packages/stripe/src/stripe.server.ts
@@ -709,8 +709,14 @@ export async function updateSubscriptionQuantityForCompany(companyId: string) {
// Update the quantity on the first subscription item
const subscriptionItemId = subscription?.items.data[0]?.id ?? "";
+ // A paused subscription (pause_collection set) rejects any update that would
+ // create prorated invoice items. Keep the seat count in sync for when it
+ // resumes by skipping proration in that case; unpaused subs keep the default.
+ const isPaused = !!subscription.pause_collection;
+
await stripe.subscriptionItems.update(subscriptionItemId, {
- quantity: activeUserCount
+ quantity: activeUserCount,
+ ...(isPaused ? { proration_behavior: "none" as const } : {})
});
log.debug("Updated Stripe subscription quantity", {