u
This commit is contained in:
@@ -8,7 +8,7 @@ import { pngToZpl } from '../../services/zplService.js';
|
||||
import { notifyAgentJob } from '../agent/index.js';
|
||||
import { emit } from '../sse.js';
|
||||
import { applyZplCopies } from './zpljob.js';
|
||||
import { interpolateString } from './article/shared.js';
|
||||
import { interpolateString, interpolateObjects } from './article/shared.js';
|
||||
|
||||
// #region Helpers
|
||||
|
||||
@@ -590,16 +590,15 @@ export function register(app, basePath = '') {
|
||||
// Resolve sample article for placeholder interpolation
|
||||
let article = null;
|
||||
if (req.body?.sku) {
|
||||
try {
|
||||
const result = await articleDb.getBySku(req.user.id, req.body.sku);
|
||||
article = result?.article;
|
||||
} catch {
|
||||
// ignore
|
||||
const skuStr = String(req.body.sku).trim();
|
||||
const result = await articleDb.getBySku(req.user.id, skuStr);
|
||||
if (!result?.article) {
|
||||
return res.status(404).json({ error: 'Article not found' });
|
||||
}
|
||||
}
|
||||
if (!article) {
|
||||
article = result.article;
|
||||
} else {
|
||||
article = {
|
||||
name: req.body?.name || template?.name || 'Musterartikel',
|
||||
name: template?.name || 'Musterartikel',
|
||||
sku: 'TEST-12345',
|
||||
prices: [{ net: 19.99, taxRate: 19 }],
|
||||
eans: ['4012345678901'],
|
||||
@@ -625,16 +624,7 @@ export function register(app, basePath = '') {
|
||||
objects = [];
|
||||
}
|
||||
|
||||
const interpolatedObjects = objects.map((obj) => {
|
||||
const cloned = { ...obj };
|
||||
if (typeof cloned.text === 'string') {
|
||||
cloned.text = interpolateString(cloned.text, article);
|
||||
}
|
||||
if (typeof cloned.code === 'string') {
|
||||
cloned.code = interpolateString(cloned.code, article);
|
||||
}
|
||||
return cloned;
|
||||
});
|
||||
const interpolatedObjects = interpolateObjects(objects, article);
|
||||
|
||||
const printPayload = await renderLabel({
|
||||
width: width || 448,
|
||||
|
||||
Reference in New Issue
Block a user