@softwear/latestcollectioncore 1.0.189 → 1.0.190

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.
package/dist/reports.d.ts CHANGED
@@ -23,6 +23,12 @@ export interface PdfImageAsset {
23
23
  export interface GenPdfOptions {
24
24
  onAlert?: (alert: GenPdfAlert) => void;
25
25
  translate?: (key: string) => string;
26
+ /**
27
+ * Called for layout fields with `format: 'currency'`. Receives the raw string from `source` (e.g. `"123.45"`).
28
+ * Return the exact string to draw. Callers normally pass a closure created next to `genPDF` so it can read
29
+ * `printBuffer`, tenant currency, locale, etc. If omitted, defaults to a euro prefix plus two decimals (`€ 123.45`).
30
+ */
31
+ formatCurrency?: (rawAmountString: string) => string;
26
32
  resolveLogoUrl?: () => string | undefined;
27
33
  isCustomPdfFont?: (fontFamily: string) => boolean;
28
34
  getPdfFontDefinition?: (fontFamily: string) => PdfFontDefinition | undefined;
package/dist/reports.js CHANGED
@@ -299,8 +299,10 @@ function drawSimpleObject(x, y, doc, object, printBuffer, width, height, options
299
299
  (_a = options.onAlert) === null || _a === void 0 ? void 0 : _a.call(options, { header: 'fieldnotfound', body: object.source, type: 'warning', timeout: 10000 });
300
300
  text = '';
301
301
  }
302
- if (object.format == 'currency')
303
- text = String.fromCharCode(128) + ' ' + parseFloat(text).toFixed(2);
302
+ if (object.format == 'currency') {
303
+ const raw = text;
304
+ text = options.formatCurrency ? options.formatCurrency(raw) : '€ ' + parseFloat(raw).toFixed(2);
305
+ }
304
306
  }
305
307
  // Manipulate case as specified in object
306
308
  if ((object.type === 'text' || object.type === 'field') && object.case === 1)
@@ -508,11 +510,7 @@ addObjectToPDF = function (originX, originY, doc, object, printBuffer, paperSize
508
510
  const layoutYtenths = originY + object.y;
509
511
  const rawPrintOnlyAtStartOffset = printOnlyAtStartContainersOffset !== null && printOnlyAtStartContainersOffset !== void 0 ? printOnlyAtStartContainersOffset : 0;
510
512
  /** Must consult current page on every read: `addPage` can move to page 2+ mid-invocation while this call stays open. */
511
- const effectivePrintOnlyAtStartContainersOffsetNow = () => containerChain.length === 0 &&
512
- rawPrintOnlyAtStartOffset > 0 &&
513
- getCurrentPageNumber(doc, context) === 1
514
- ? rawPrintOnlyAtStartOffset
515
- : 0;
513
+ const effectivePrintOnlyAtStartContainersOffsetNow = () => (containerChain.length === 0 && rawPrintOnlyAtStartOffset > 0 && getCurrentPageNumber(doc, context) === 1 ? rawPrintOnlyAtStartOffset : 0);
516
514
  const x = layoutXtenths / 10;
517
515
  const y = (layoutYtenths + effectivePrintOnlyAtStartContainersOffsetNow()) / 10;
518
516
  const width = object.width / 10;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softwear/latestcollectioncore",
3
- "version": "1.0.189",
3
+ "version": "1.0.190",
4
4
  "description": "Core functions for LatestCollections applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",