fix(shopping/loyalty): emit FNC1 codewords for Supercard

Coop Supercard uses GS1 Data Matrix — the payload contains FNC1
separators between fields, not literal 0x1D bytes. Enable bwip-js
parsefnc so ^FNC1 placeholders in the env value produce genuine
FNC1 codewords (codeword 232), matching the physical card and
letting checkout scanners parse the GS1 element string.
This commit is contained in:
2026-04-23 21:04:56 +02:00
parent 43ea2cca22
commit c73363e93d
2 changed files with 9 additions and 3 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "homepage", "name": "homepage",
"version": "1.47.1", "version": "1.47.2",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
+8 -2
View File
@@ -23,10 +23,15 @@ type CardSpec = {
filename: string; filename: string;
bcid: 'datamatrix' | 'code128'; bcid: 'datamatrix' | 'code128';
scale: number; scale: number;
parsefnc?: boolean;
}; };
const cards: CardSpec[] = [ const cards: CardSpec[] = [
{ envVar: 'SHOPPING_COOP_SUPERCARD_NUMBER', filename: 'supercard.svg', bcid: 'datamatrix', scale: 6 }, // Coop Supercard uses GS1 Data Matrix with FNC1 separators between fields.
// Put ^FNC1 in the env value wherever the real symbol has a separator
// (dmtxread -G prints them as 0x1D); parsefnc: true turns each ^FNC1 into
// a genuine FNC1 codeword so the regenerated code matches the card.
{ envVar: 'SHOPPING_COOP_SUPERCARD_NUMBER', filename: 'supercard.svg', bcid: 'datamatrix', scale: 6, parsefnc: true },
{ envVar: 'SHOPPING_MIGROS_CUMULUS_NUMBER', filename: 'cumulus.svg', bcid: 'code128', scale: 3 } { envVar: 'SHOPPING_MIGROS_CUMULUS_NUMBER', filename: 'cumulus.svg', bcid: 'code128', scale: 3 }
]; ];
@@ -48,7 +53,8 @@ for (const card of cards) {
scale: card.scale, scale: card.scale,
includetext: false, includetext: false,
paddingwidth: 8, paddingwidth: 8,
paddingheight: 8 paddingheight: 8,
...(card.parsefnc ? { parsefnc: true } : {})
}); });
writeFileSync(outPath, svg, 'utf8'); writeFileSync(outPath, svg, 'utf8');