@softwear/latestcollectioncore 1.0.189 → 1.0.191

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;
@@ -267,8 +267,8 @@ const buildTransaction = function (transaction) {
267
267
  dbTransaction.sellprice = transaction.sellprice;
268
268
  if (transaction.vat !== undefined)
269
269
  dbTransaction.vat = transaction.vat;
270
- if (transaction.customer)
271
- dbTransaction.customer = transaction.customer;
270
+ if (transaction.custnr)
271
+ dbTransaction.custnr = transaction.custnr;
272
272
  if (transaction.agent)
273
273
  dbTransaction.agent = transaction.agent;
274
274
  // if (transaction.type == transactionTypeE.START_SHELF_STOCK) dbTransaction.type = transactionTypeE.START_STOCK
package/dist/types.d.ts CHANGED
@@ -265,7 +265,7 @@ interface dbTransactionI {
265
265
  ean: string;
266
266
  wh: string;
267
267
  agent?: string;
268
- customer?: string;
268
+ custnr?: string;
269
269
  docnr: string;
270
270
  time: number;
271
271
  vector?: number[];
@@ -281,7 +281,7 @@ interface TransactionI {
281
281
  ean: string;
282
282
  wh: string;
283
283
  agent?: string;
284
- customer?: string;
284
+ custnr?: string;
285
285
  docnr: string;
286
286
  time: number;
287
287
  qty: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softwear/latestcollectioncore",
3
- "version": "1.0.189",
3
+ "version": "1.0.191",
4
4
  "description": "Core functions for LatestCollections applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -282,7 +282,7 @@ const buildTransaction = function (transaction: TransactionI): dbTransactionI |
282
282
  if (transaction.buyprice !== undefined) dbTransaction.buyprice = transaction.buyprice
283
283
  if (transaction.sellprice !== undefined) dbTransaction.sellprice = transaction.sellprice
284
284
  if (transaction.vat !== undefined) dbTransaction.vat = transaction.vat
285
- if (transaction.customer) dbTransaction.customer = transaction.customer
285
+ if (transaction.custnr) dbTransaction.custnr = transaction.custnr
286
286
  if (transaction.agent) dbTransaction.agent = transaction.agent
287
287
  // if (transaction.type == transactionTypeE.START_SHELF_STOCK) dbTransaction.type = transactionTypeE.START_STOCK
288
288
 
package/src/types.ts CHANGED
@@ -282,7 +282,7 @@ interface dbTransactionI {
282
282
  ean: string
283
283
  wh: string
284
284
  agent?: string
285
- customer?: string
285
+ custnr?: string
286
286
  docnr: string
287
287
  time: number
288
288
  vector?: number[]
@@ -298,7 +298,7 @@ interface TransactionI {
298
298
  ean: string
299
299
  wh: string
300
300
  agent?: string
301
- customer?: string
301
+ custnr?: string
302
302
  docnr: string
303
303
  time: number
304
304
  qty: number
@@ -23,7 +23,7 @@ describe('#Transactions', () => {
23
23
  wh: '51',
24
24
  time: 314159265,
25
25
  qty: 123,
26
- customer: '123',
26
+ custnr: '123',
27
27
  agent: '01',
28
28
  sellprice: 19.95,
29
29
  buyprice: 9.95,
@@ -40,7 +40,7 @@ describe('#Transactions', () => {
40
40
  buyprice: 9.95,
41
41
  sellprice: 19.95,
42
42
  vat: 21,
43
- customer: '123',
43
+ custnr: '123',
44
44
  agent: '01',
45
45
  docnr: '51-123',
46
46
  })