Muster-Workflow: Mustertext wählen, Adresse aufs Kuvert, Platzhalter füllen
- Produktion-Muster-Dialog: benannten Mustertext (muster_texts) wählen; Platzhalter ([[Vorname]]/[[Nachname]]/[[Ort]]/[[Strasse]]/[[PLZ]]/[[Land]]) aus der Anfrage- Adresse automatisch füllen; Text vor dem Anlegen bearbeitbar; „Adresse aufs Kuvert" (Standard an) mit Format/Template-Wahl. - manual-print: erzeugt optional zusätzlich ein Kuvert (Umschlag-Job) mit der Adresse. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -746,7 +746,7 @@ const handler = (router, { services, getSchema, logger }) => {
|
||||
letters.push({
|
||||
index: nr, type: 'postcard', text: combined, format: briefFormat, font,
|
||||
realisticHandwriting: realistisch, placeholders: platzhalterVon(e, i),
|
||||
fontScale: fsLetter, senderScale: Number(body.envelope_sender_scale) || 1,
|
||||
fontScale: fsLetter, senderScale: Number(body.envelope_sender_scale) || 1, recipientScale: fsEnv,
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -1241,12 +1241,23 @@ const handler = (router, { services, getSchema, logger }) => {
|
||||
const font = ['tilda', 'alva', 'ellie'].includes(body.font) ? body.font : 'tilda';
|
||||
const format = TEST_FORMAT[body.format] || 'a4';
|
||||
|
||||
// Kuvert (Adresse aus der Anfrage) optional mitdrucken.
|
||||
const ENV_FMT = { dinlang: 'din_lang', c6: 'c6' };
|
||||
const envAddr = clean(String(body.envelope || '')).trim();
|
||||
const wantsEnv = !!(envAddr && body.envelope_template);
|
||||
const envFormat = ENV_FMT[body.envelope_format] || 'din_lang';
|
||||
|
||||
const letters = [{ index: 1, type: 'letter', text: clean(String(body.text)), format, font, realisticHandwriting: body.realistic !== false }];
|
||||
if (wantsEnv) {
|
||||
letters.push({ index: 1, type: 'envelope', envelopeType: 'recipient', text: envAddr, format: envFormat, font, realisticHandwriting: body.realistic !== false });
|
||||
}
|
||||
|
||||
const gen = await fetch(`${BACKEND_URL}/api/order/generate`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-API-Token': BACKEND_TOKEN },
|
||||
body: JSON.stringify({
|
||||
orderNumber: ref,
|
||||
letters: [{ index: 1, type: 'letter', text: clean(String(body.text)), format, font, realisticHandwriting: body.realistic !== false }],
|
||||
letters,
|
||||
metadata: { rawText: String(body.text) },
|
||||
}),
|
||||
});
|
||||
@@ -1265,10 +1276,17 @@ const handler = (router, { services, getSchema, logger }) => {
|
||||
machine: body.machine, template: body.template, type: 'brief', status: 'queued', output_ref: ref, priority: prio,
|
||||
format: body.format || 'a4', format_label: LETTER_LABEL[body.format] || body.format || 'A4',
|
||||
});
|
||||
// Zweiter Job für das Kuvert (gleicher Ausgabeordner, Typ umschlag).
|
||||
if (wantsEnv) {
|
||||
await svc('jobs').createOne({
|
||||
machine: body.machine, template: body.envelope_template, type: 'umschlag', status: 'queued', output_ref: ref, priority: prio,
|
||||
format: body.envelope_format || 'dinlang', format_label: ENV_LABEL[body.envelope_format] || 'Kuvert',
|
||||
});
|
||||
}
|
||||
if (body.offer_request) {
|
||||
try { await svc('offer_requests').updateOne(body.offer_request, { status: 'in_bearbeitung' }); } catch { /* nicht kritisch */ }
|
||||
}
|
||||
return res.json({ ok: true, ref, job, mode: prio ? 'direct' : 'queue', busy });
|
||||
return res.json({ ok: true, ref, job, mode: prio ? 'direct' : 'queue', busy, kuvert: wantsEnv });
|
||||
} catch (err) {
|
||||
logger.error(`[skrift-orders] manual-print: ${err.stack || err.message}`);
|
||||
return res.status(500).json({ error: 'Manueller Druck fehlgeschlagen.' });
|
||||
|
||||
Reference in New Issue
Block a user