rerobe-js-orm 4.9.11 → 4.9.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,6 +10,7 @@ export default class ReceiptXmlHelpers {
10
10
  private static variantLabelForReceipt;
11
11
  static formatLineItemXML(lineItem: any): string;
12
12
  static buildReceiptContentXML(receiptData: any): string;
13
+ static buildReportReceiptXML(data: any): string;
13
14
  private static decodeXML;
14
15
  private static parseAttrs;
15
16
  static parseReceiptXml(xml: string): ReceiptPreviewLine[];
@@ -231,6 +231,88 @@ class ReceiptXmlHelpers {
231
231
  receipt += '</epos-print>';
232
232
  return receipt;
233
233
  }
234
+ // Render an X/Z daily report (X-rapport / Z-rapport) as ePOS-Print XML, so the
235
+ // report prints on the same thermal printer — and renders in the same receipt
236
+ // simulator (ReceiptPaper) — as sales receipts. Pure; driven entirely by `data`:
237
+ // { reportType: 'X'|'Z', merchantName, organizationNumber, storeAddress,
238
+ // terminalName, date, sequenceNumber, receiptCount, totalSales, netTotal,
239
+ // vatRates: { '25': '32,00 kr', ... }, controlCode?, controlUnitSerial? }
240
+ static buildReportReceiptXML(data) {
241
+ var _a;
242
+ const d = data || {};
243
+ const isZ = String(d.reportType || d.type || '')
244
+ .toUpperCase()
245
+ .includes('Z');
246
+ const label = isZ ? 'Z-RAPPORT' : 'X-RAPPORT';
247
+ const divider = '----------------------------------------';
248
+ const hasSeq = d.sequenceNumber !== undefined && d.sequenceNumber !== null && d.sequenceNumber !== '';
249
+ let receipt = '<epos-print xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print">';
250
+ receipt += '<text align="center"/>';
251
+ receipt += '<text font="font_a" width="2" height="2">';
252
+ receipt += this.escapeXML(d.merchantName || '');
253
+ receipt += '</text><feed/>';
254
+ if (d.organizationNumber) {
255
+ receipt += '<text font="font_a" width="1" height="1">';
256
+ receipt += `Org.nr: ${this.escapeXML(d.organizationNumber)}`;
257
+ receipt += '</text><feed/>';
258
+ }
259
+ receipt += '<feed/>';
260
+ if (d.storeAddress) {
261
+ receipt += '<text font="font_a" width="1" height="1">';
262
+ receipt += this.escapeXML(d.storeAddress);
263
+ receipt += '</text><feed/>';
264
+ }
265
+ receipt += '<text font="font_a" width="2" height="2">';
266
+ receipt += hasSeq ? `${label} # ${this.escapeXML(d.sequenceNumber)}` : label;
267
+ receipt += '</text><feed/>';
268
+ if (d.date) {
269
+ receipt += '<text font="font_a" width="1" height="1">';
270
+ receipt += this.escapeXML(d.date);
271
+ receipt += '</text><feed/>';
272
+ }
273
+ receipt += '<feed/>';
274
+ receipt += `<text>${divider}</text><feed/>`;
275
+ receipt += '<text font="font_a" width="1" height="1">';
276
+ receipt += `Antal kvitton: ${this.escapeXML(String((_a = d.receiptCount) !== null && _a !== void 0 ? _a : 0))}`;
277
+ receipt += '</text><feed/>';
278
+ receipt += `<text>${divider}</text><feed/>`;
279
+ receipt += '<text font="font_a" width="1" height="1" em="true">';
280
+ receipt += `Forsaljning: ${this.escapeXML(d.totalSales || '0,00 kr')}`;
281
+ receipt += '</text><feed/>';
282
+ if (d.vatRates && typeof d.vatRates === 'object') {
283
+ Object.entries(d.vatRates).forEach(([rate, value]) => {
284
+ const r = parseFloat(String(rate).trim());
285
+ receipt += '<text font="font_a" width="1" height="1">';
286
+ receipt += `Moms ${this.escapeXML(String(r))}%: ${this.escapeXML(String(value))}`;
287
+ receipt += '</text><feed/>';
288
+ });
289
+ }
290
+ if (d.netTotal) {
291
+ receipt += '<text font="font_a" width="1" height="1">';
292
+ receipt += `Netto: ${this.escapeXML(d.netTotal)}`;
293
+ receipt += '</text><feed/>';
294
+ }
295
+ receipt += '<feed/>';
296
+ receipt += `<text>${divider}</text><feed/>`;
297
+ if (d.controlCode) {
298
+ receipt += '<text font="font_a" width="1" height="1">';
299
+ receipt += `Kontrollkod: ${this.escapeXML(d.controlCode)}`;
300
+ receipt += '</text><feed/>';
301
+ }
302
+ if (d.terminalName) {
303
+ receipt += '<text font="font_a" width="1" height="1">';
304
+ receipt += `Terminal: ${this.escapeXML(d.terminalName)}`;
305
+ receipt += '</text><feed/>';
306
+ }
307
+ if (d.controlUnitSerial) {
308
+ receipt += '<text font="font_a" width="1" height="1">';
309
+ receipt += `Kontrollenhet: ${this.escapeXML(d.controlUnitSerial)}`;
310
+ receipt += '</text><feed/>';
311
+ }
312
+ receipt += '<cut type="feed"/>';
313
+ receipt += '</epos-print>';
314
+ return receipt;
315
+ }
234
316
  // Decode the 5 XML entities escapeXML produces, back to their characters.
235
317
  // `&amp;` is decoded last so `&amp;lt;` round-trips to `&lt;`, not `<`.
236
318
  static decodeXML(text) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "4.9.11",
3
+ "version": "4.9.12",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",