fix: remove label cut lines and zero-pad printed dates
The dashed rectangle drawn around every label slot (a cut/crop line)
wasn't needed and is gone, along with the width/height params that
existed only to draw it. Dates on the label (bottling date, MHD) now
use { day: '2-digit', month: '2-digit' } so single-digit values print
with a leading zero (05.03.2026, not 5.3.2026) - the default 'numeric'
formatting was dropping it.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
1 parent
1054a845ef
commit
ac45514356
1 file changed
+9
-20
@@ -29,8 +29,15 @@ interface SheetLayout {
|
||||
gapYMm: number;
|
||||
}
|
||||
|
||||
// '2-digit' forces a leading zero for day/month (e.g. "05.03.2026") - the
|
||||
// default 'numeric' formatting drops it ("5.3.2026"), which is what the MHD
|
||||
// on a printed label was showing.
|
||||
function formatDate(date: Date): string {
|
||||
return date.toLocaleDateString('de-DE');
|
||||
return date.toLocaleDateString('de-DE', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
});
|
||||
}
|
||||
|
||||
// Prisma stores `elements` as a plain Json column; the shape is only ever
|
||||
@@ -352,21 +359,11 @@ export class LabelTemplatesService {
|
||||
elements,
|
||||
centerX - w / 2,
|
||||
centerY - h / 2,
|
||||
w,
|
||||
h,
|
||||
qrCodeBuffer,
|
||||
);
|
||||
doc.restore();
|
||||
} else {
|
||||
this.drawLabel(
|
||||
doc,
|
||||
elements,
|
||||
originX,
|
||||
originY,
|
||||
slotW,
|
||||
slotH,
|
||||
qrCodeBuffer,
|
||||
);
|
||||
this.drawLabel(doc, elements, originX, originY, qrCodeBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,16 +376,8 @@ export class LabelTemplatesService {
|
||||
elements: LabelElement[],
|
||||
originX: number,
|
||||
originY: number,
|
||||
widthPt: number,
|
||||
heightPt: number,
|
||||
qrCodeBuffer: Buffer | null,
|
||||
): void {
|
||||
doc
|
||||
.rect(originX, originY, widthPt, heightPt)
|
||||
.dash(2, { space: 2 })
|
||||
.stroke('#999999')
|
||||
.undash();
|
||||
|
||||
for (const element of elements) {
|
||||
this.drawElement(doc, element, originX, originY, qrCodeBuffer);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user