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: error handling for line item docs

Sidwebworks69305c09275b
diff --git a/apps/erp/app/modules/purchasing/purchasing.service.ts b/apps/erp/app/modules/purchasing/purchasing.service.ts
index 2c6e3268d6..98420a3528 100644
--- a/apps/erp/app/modules/purchasing/purchasing.service.ts
+++ b/apps/erp/app/modules/purchasing/purchasing.service.ts
@@ -551,6 +551,14 @@ export async function getSupplierInteractionDocuments(
.from("private")
.list(`${companyId}/supplier-interaction/${interactionId}`);
+ if (result.error) {
+ console.error(
+ "Failed to list supplier interaction documents",
+ result.error
+ );
+ return [];
+ }
+
return (
result.data?.map((f) => ({ ...f, bucket: "supplier-interaction" })) ?? []
);
@@ -565,9 +573,19 @@ export async function getSupplierInteractionLineDocuments(
.from("private")
.list(`${companyId}/supplier-interaction-line/${lineId}`);
+ if (result.error) {
+ console.error(
+ "Failed to list supplier interaction line documents",
+ result.error
+ );
+ return [];
+ }
+
return (
- result.data?.map((f) => ({ ...f, bucket: "supplier-interaction-line" })) ??
- []
+ result.data?.map((f) => ({
+ ...f,
+ bucket: "supplier-interaction-line"
+ })) ?? []
);
}
diff --git a/apps/erp/app/modules/sales/sales.service.ts b/apps/erp/app/modules/sales/sales.service.ts
index a81a8d48bf..bfb8c01f51 100644
--- a/apps/erp/app/modules/sales/sales.service.ts
+++ b/apps/erp/app/modules/sales/sales.service.ts
@@ -725,6 +725,11 @@ export async function getOpportunityDocuments(
.from("private")
.list(`${companyId}/opportunity/${opportunityId}`);
+ if (result.error) {
+ console.error("Failed to list opportunity documents", result.error);
+ return [];
+ }
+
return result.data?.map((f) => ({ ...f, bucket: "opportunity" })) ?? [];
}
@@ -740,9 +745,19 @@ export async function getOpportunityLineDocuments(
.list(`${companyId}/opportunity-line/${lineId}`),
itemId
? client.storage.from("private").list(`${companyId}/parts/${itemId}`)
- : Promise.resolve({ data: [] })
+ : Promise.resolve({ data: [] as any[], error: null })
]);
+ if (opportunityLineResult.error) {
+ console.error(
+ "Failed to list opportunity line documents",
+ opportunityLineResult.error
+ );
+ }
+ if (itemResult.error) {
+ console.error("Failed to list item documents", itemResult.error);
+ }
+
const opportunityLineDocs =
opportunityLineResult.data?.map((f) => ({
...f,