This commit is contained in:
seb
2026-10-15 00:30:23 +02:00
parent bdd7ebf5b8
commit 8c55f899b5
27 changed files with 136 additions and 46 deletions

View File

@@ -2,6 +2,7 @@ import PDFDocument from 'pdfkit';
import { getStore } from '../db/store.js';
import * as dbOrder from '../db/order.js';
import { emit } from '../api/sse.js';
import { formatAttachment } from '../util/manifestAttachment.js';
/**
* Formats a Date or date string to German format DD.MM.YYYY.
@@ -786,13 +787,15 @@ export async function createAndAttachManifestPdf(googleAuthId, companyId, manife
const safeNumber = String(manifest.number || manifest.id).replace(/[^a-zA-Z0-9._-]/g, '_');
const filename = `${config.filenamePrefix}-${safeNumber}.pdf`;
const attachment = await store.manifestattachment.add(googleAuthId, manifest.id, {
const rawAttachment = await store.manifestattachment.add(googleAuthId, manifest.id, {
mimetype: 'application/pdf',
name: filename,
content: pdfBuffer,
meta: { type: `${type}_pdf` },
});
const attachment = await formatAttachment(rawAttachment);
emit(type, { companyId });
return { manifest, attachment, pdfBuffer, filename };