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: include primary file from paperless

Brad Barbinc7aa6698b61d
diff --git a/packages/integrations/src/paperless-parts/lib/utils.ts b/packages/integrations/src/paperless-parts/lib/utils.ts
index c02a763d20..e17f04be46 100644
--- a/packages/integrations/src/paperless-parts/lib/utils.ts
+++ b/packages/integrations/src/paperless-parts/lib/utils.ts
@@ -1277,22 +1277,33 @@ export async function insertOrderLines(
insertedLinesCount++;
// Now process supporting files with the actual line ID
- if (
- !orderItem.export_controlled &&
- (orderItem.filename || component.supporting_files?.length)
- ) {
- console.log("orderItem.filename");
- console.log(orderItem.filename);
+ if (!orderItem.export_controlled) {
try {
console.log(
`Processing supporting files for line ${lineId} (component ${component.part_uuid})`
);
+ let supportingFiles = [
+ {
+ filename: orderItem.filename,
+ url: component.part_url,
+ },
+ ];
+
+ if (component.supporting_files) {
+ const validSupportingFiles = (
+ component.supporting_files as unknown as Array<{
+ filename?: string;
+ url?: string;
+ }>
+ ).filter((file): file is { filename: string; url: string } =>
+ Boolean(file.filename && file.url)
+ );
+ supportingFiles.push(...validSupportingFiles);
+ }
+
await processSupportingFiles(carbon, {
- supportingFiles: component.supporting_files as Array<{
- filename?: string;
- url?: string;
- }>,
+ supportingFiles,
companyId,
lineId, // Use the actual line ID
sourceDocumentType: "Sales Order",