@softwear/latestcollectioncore 1.0.119 → 1.0.121

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/edifact.d.ts CHANGED
@@ -2,7 +2,7 @@ import { MarkedSkuI, DocumentItemI } from './types';
2
2
  declare const _default: {
3
3
  skusToPricat: (skus: MarkedSkuI[], fromGLN: string, toGLN: string, supplierGLN: string, refID: number, date: string) => any[];
4
4
  pricatToCsv: (pricat: any) => string;
5
- itemsToOrdRsp: (items: DocumentItemI[], fromGLN: string, toGLN: string, supplierGLN: string, refID: number, date: string, orderNumber: string) => any[];
5
+ itemsToOrdRsp: (items: DocumentItemI[], fromGLN: string, toGLN: string, supplierGLN: string, deliveryGLN: string, refID: number, date: string, orderNumber: string) => any[];
6
6
  ordRspToCsv: (order: any) => string;
7
7
  };
8
8
  export default _default;
package/dist/edifact.js CHANGED
@@ -67,28 +67,6 @@ const pricatToCsv = function (pricat) {
67
67
  const env = pricat[0];
68
68
  const envValues = ['"ENV"', env.SenderGLN, env.RecipientGLN, env.InterchangeReference, 0, '"FUEB 5.00"', null, null, null, null, null];
69
69
  const envString = envValues.join(',') + '\n';
70
- //
71
- //
72
- //
73
- //
74
- //
75
- //
76
- //
77
- //
78
- //
79
- //
80
- //
81
- //
82
- //
83
- //
84
- //
85
- //
86
- //
87
- //
88
- //
89
- //
90
- //
91
- //
92
70
  const hdr = pricat[1];
93
71
  const hdrValues = [
94
72
  '"HDR"',
@@ -141,41 +119,6 @@ const pricatToCsv = function (pricat) {
141
119
  ];
142
120
  const hdrString = hdrValues.join(',') + '\n';
143
121
  const grpString = `"GRP","3",,"91",\n`;
144
- //
145
- // These comment lines are added to align the linenumbers in the texteditor with positionnumbers in the documentation of Fashion United PRICAT 5.00
146
- // This makes it easier to verify if a given value is alligned in the collect position
147
- //
148
- //
149
- //
150
- //
151
- //
152
- //
153
- //
154
- //
155
- //
156
- //
157
- //
158
- //
159
- //
160
- //
161
- //
162
- //
163
- //
164
- //
165
- //
166
- //
167
- //
168
- //
169
- //
170
- //
171
- //
172
- //
173
- //
174
- //
175
- //
176
- //
177
- //
178
- //
179
122
  const lines = [];
180
123
  pricat
181
124
  .filter((r) => r.Tag == 'LIN')
@@ -334,7 +277,7 @@ const pricatToCsv = function (pricat) {
334
277
  const linString = lines.join('\n');
335
278
  return envString + hdrString + grpString + linString;
336
279
  };
337
- const itemsToOrdRsp = function (items, fromGLN, toGLN, supplierGLN, refID, date, orderNumber) {
280
+ const itemsToOrdRsp = function (items, fromGLN, toGLN, supplierGLN, deliveryGLN, refID, date, orderNumber) {
338
281
  const order = [];
339
282
  if (typeof fromGLN != 'string' || fromGLN.length != 13)
340
283
  return [];
@@ -360,10 +303,13 @@ const itemsToOrdRsp = function (items, fromGLN, toGLN, supplierGLN, refID, date,
360
303
  HeaderCurrency: '"EUR"',
361
304
  SupplierGLN: supplierGLN,
362
305
  BuyerGLN: toGLN,
306
+ DocumentDate: date,
307
+ DeliveryPartyGLN: deliveryGLN,
363
308
  };
364
309
  order.push(env);
365
310
  order.push(hdr);
366
311
  let lineNumber = 1;
312
+ let totalQty = 0;
367
313
  items.forEach((item) => {
368
314
  const lin = {
369
315
  LineTag: 'LIN',
@@ -374,8 +320,14 @@ const itemsToOrdRsp = function (items, fromGLN, toGLN, supplierGLN, refID, date,
374
320
  ConfirmedQuantity: item.qty,
375
321
  PurchasePriceNet: item.price,
376
322
  };
323
+ totalQty += item.qty;
377
324
  order.push(lin);
378
325
  });
326
+ order.push({
327
+ ControlTag: 'CNT',
328
+ TotalNumberOfPositions: lineNumber - 1,
329
+ TotalQty: totalQty,
330
+ });
379
331
  return order;
380
332
  };
381
333
  const ordRspToCsv = function (order) {
@@ -390,7 +342,7 @@ const ordRspToCsv = function (order) {
390
342
  `"${hdr.DocumentType}"`,
391
343
  `"${hdr.DocumentFunction}"`,
392
344
  `"${hdr.DocumentNumber}"`,
393
- null,
345
+ `${hdr.DocumentDate}`,
394
346
  null,
395
347
  null,
396
348
  null,
@@ -426,6 +378,7 @@ const ordRspToCsv = function (order) {
426
378
  null,
427
379
  null,
428
380
  null,
381
+ hdr.DeliveryPartyGLN,
429
382
  null,
430
383
  null,
431
384
  null,
@@ -443,8 +396,7 @@ const ordRspToCsv = function (order) {
443
396
  null,
444
397
  null,
445
398
  null,
446
- null,
447
- null,
399
+ hdr.DeliveryPartyGLN,
448
400
  null,
449
401
  null,
450
402
  null,
@@ -501,6 +453,7 @@ const ordRspToCsv = function (order) {
501
453
  r.LineNumber,
502
454
  1,
503
455
  r.GTIN,
456
+ '"EAN"',
504
457
  null,
505
458
  null,
506
459
  null,
@@ -516,6 +469,7 @@ const ordRspToCsv = function (order) {
516
469
  null,
517
470
  null,
518
471
  null,
472
+ null,
519
473
  r.PurchasePriceNet,
520
474
  null,
521
475
  null,
@@ -543,7 +497,10 @@ const ordRspToCsv = function (order) {
543
497
  ];
544
498
  lines.push(linValues.join(','));
545
499
  });
546
- const linString = lines.join('\n');
547
- return envString + hdrString + linString;
500
+ const linString = lines.join('\n') + '\n';
501
+ const cntRecord = order.filter((r) => r.ControlTag == 'CNT')[0];
502
+ const cntValues = ['"CNT"', null, null, null, null, null, null, cntRecord.TotalNumberOfPositions, cntRecord.TotalQty];
503
+ const cntString = cntValues.join(',');
504
+ return envString + hdrString + linString + cntString;
548
505
  };
549
506
  exports.default = { skusToPricat, pricatToCsv, itemsToOrdRsp, ordRspToCsv };
@@ -0,0 +1 @@
1
+ export default function ensureArray(object: any): Array<any>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ * Ensure that an object is an array. If so, return object, else return a one-element array with the object
5
+ */
6
+ function ensureArray(object) {
7
+ if (!Array.isArray(object))
8
+ return [object];
9
+ return object;
10
+ }
11
+ exports.default = ensureArray;
package/dist/index.d.ts CHANGED
@@ -1,16 +1,17 @@
1
+ export { default as articleStatus } from './articleStatus';
1
2
  export { default as buildPropertyMappingFn } from './buildPropertyMappingFn';
2
3
  export { default as deepCopy } from './deepCopy';
3
4
  export { default as ean13 } from './ean13';
4
- export { default as isean13 } from './isean13';
5
+ export { default as edifact } from './edifact';
6
+ export { default as ensureArray } from './ensureArray';
7
+ export { default as findSkuByBarcode } from './findSkuByBarcode';
5
8
  export { default as getPreferedPropertyMappings } from './getPreferedPropertyMappings';
6
9
  export { default as hashBrand } from './hashBrand';
7
10
  export { default as hasOnlyDigits } from './hasOnlyDigits';
8
- export { default as sizeToMap } from './sizeToMap';
9
- export { default as findSkuByBarcode } from './findSkuByBarcode';
11
+ export { default as isean13 } from './isean13';
12
+ export { default as pivotTable } from './pivotTable';
10
13
  export { default as round2 } from './round2';
14
+ export { default as sizeToMap } from './sizeToMap';
11
15
  export { default as transaction } from './transaction';
12
- export { default as articleStatus } from './articleStatus';
13
- export { default as pivotTable } from './pivotTable';
14
- export { default as edifact } from './edifact';
15
16
  export * from './types';
16
17
  export * from './consts';
package/dist/index.js CHANGED
@@ -17,34 +17,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.edifact = exports.pivotTable = exports.articleStatus = exports.transaction = exports.round2 = exports.findSkuByBarcode = exports.sizeToMap = exports.hasOnlyDigits = exports.hashBrand = exports.getPreferedPropertyMappings = exports.isean13 = exports.ean13 = exports.deepCopy = exports.buildPropertyMappingFn = void 0;
20
+ exports.transaction = exports.sizeToMap = exports.round2 = exports.pivotTable = exports.isean13 = exports.hasOnlyDigits = exports.hashBrand = exports.getPreferedPropertyMappings = exports.findSkuByBarcode = exports.ensureArray = exports.edifact = exports.ean13 = exports.deepCopy = exports.buildPropertyMappingFn = exports.articleStatus = void 0;
21
+ var articleStatus_1 = require("./articleStatus");
22
+ Object.defineProperty(exports, "articleStatus", { enumerable: true, get: function () { return __importDefault(articleStatus_1).default; } });
21
23
  var buildPropertyMappingFn_1 = require("./buildPropertyMappingFn");
22
24
  Object.defineProperty(exports, "buildPropertyMappingFn", { enumerable: true, get: function () { return __importDefault(buildPropertyMappingFn_1).default; } });
23
25
  var deepCopy_1 = require("./deepCopy");
24
26
  Object.defineProperty(exports, "deepCopy", { enumerable: true, get: function () { return __importDefault(deepCopy_1).default; } });
25
27
  var ean13_1 = require("./ean13");
26
28
  Object.defineProperty(exports, "ean13", { enumerable: true, get: function () { return __importDefault(ean13_1).default; } });
27
- var isean13_1 = require("./isean13");
28
- Object.defineProperty(exports, "isean13", { enumerable: true, get: function () { return __importDefault(isean13_1).default; } });
29
+ var edifact_1 = require("./edifact");
30
+ Object.defineProperty(exports, "edifact", { enumerable: true, get: function () { return __importDefault(edifact_1).default; } });
31
+ var ensureArray_1 = require("./ensureArray");
32
+ Object.defineProperty(exports, "ensureArray", { enumerable: true, get: function () { return __importDefault(ensureArray_1).default; } });
33
+ var findSkuByBarcode_1 = require("./findSkuByBarcode");
34
+ Object.defineProperty(exports, "findSkuByBarcode", { enumerable: true, get: function () { return __importDefault(findSkuByBarcode_1).default; } });
29
35
  var getPreferedPropertyMappings_1 = require("./getPreferedPropertyMappings");
30
36
  Object.defineProperty(exports, "getPreferedPropertyMappings", { enumerable: true, get: function () { return __importDefault(getPreferedPropertyMappings_1).default; } });
31
37
  var hashBrand_1 = require("./hashBrand");
32
38
  Object.defineProperty(exports, "hashBrand", { enumerable: true, get: function () { return __importDefault(hashBrand_1).default; } });
33
39
  var hasOnlyDigits_1 = require("./hasOnlyDigits");
34
40
  Object.defineProperty(exports, "hasOnlyDigits", { enumerable: true, get: function () { return __importDefault(hasOnlyDigits_1).default; } });
35
- var sizeToMap_1 = require("./sizeToMap");
36
- Object.defineProperty(exports, "sizeToMap", { enumerable: true, get: function () { return __importDefault(sizeToMap_1).default; } });
37
- var findSkuByBarcode_1 = require("./findSkuByBarcode");
38
- Object.defineProperty(exports, "findSkuByBarcode", { enumerable: true, get: function () { return __importDefault(findSkuByBarcode_1).default; } });
41
+ var isean13_1 = require("./isean13");
42
+ Object.defineProperty(exports, "isean13", { enumerable: true, get: function () { return __importDefault(isean13_1).default; } });
43
+ var pivotTable_1 = require("./pivotTable");
44
+ Object.defineProperty(exports, "pivotTable", { enumerable: true, get: function () { return __importDefault(pivotTable_1).default; } });
39
45
  var round2_1 = require("./round2");
40
46
  Object.defineProperty(exports, "round2", { enumerable: true, get: function () { return __importDefault(round2_1).default; } });
47
+ var sizeToMap_1 = require("./sizeToMap");
48
+ Object.defineProperty(exports, "sizeToMap", { enumerable: true, get: function () { return __importDefault(sizeToMap_1).default; } });
41
49
  var transaction_1 = require("./transaction");
42
50
  Object.defineProperty(exports, "transaction", { enumerable: true, get: function () { return __importDefault(transaction_1).default; } });
43
- var articleStatus_1 = require("./articleStatus");
44
- Object.defineProperty(exports, "articleStatus", { enumerable: true, get: function () { return __importDefault(articleStatus_1).default; } });
45
- var pivotTable_1 = require("./pivotTable");
46
- Object.defineProperty(exports, "pivotTable", { enumerable: true, get: function () { return __importDefault(pivotTable_1).default; } });
47
- var edifact_1 = require("./edifact");
48
- Object.defineProperty(exports, "edifact", { enumerable: true, get: function () { return __importDefault(edifact_1).default; } });
49
51
  __exportStar(require("./types"), exports);
50
52
  __exportStar(require("./consts"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softwear/latestcollectioncore",
3
- "version": "1.0.119",
3
+ "version": "1.0.121",
4
4
  "description": "Core functions for LatestCollections applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/edifact.ts CHANGED
@@ -62,28 +62,6 @@ const pricatToCsv = function (pricat: any): string {
62
62
  const envValues = ['"ENV"', env.SenderGLN, env.RecipientGLN, env.InterchangeReference, 0, '"FUEB 5.00"', null, null, null, null, null]
63
63
  const envString = envValues.join(',') + '\n'
64
64
 
65
- //
66
- //
67
- //
68
- //
69
- //
70
- //
71
- //
72
- //
73
- //
74
- //
75
- //
76
- //
77
- //
78
- //
79
- //
80
- //
81
- //
82
- //
83
- //
84
- //
85
- //
86
- //
87
65
  const hdr = pricat[1]
88
66
  const hdrValues = [
89
67
  '"HDR"',
@@ -135,44 +113,7 @@ const pricatToCsv = function (pricat: any): string {
135
113
  null,
136
114
  ]
137
115
  const hdrString = hdrValues.join(',') + '\n'
138
-
139
116
  const grpString = `"GRP","3",,"91",\n`
140
- //
141
- // These comment lines are added to align the linenumbers in the texteditor with positionnumbers in the documentation of Fashion United PRICAT 5.00
142
- // This makes it easier to verify if a given value is alligned in the collect position
143
- //
144
- //
145
- //
146
- //
147
- //
148
- //
149
- //
150
- //
151
- //
152
- //
153
- //
154
- //
155
- //
156
- //
157
- //
158
- //
159
- //
160
- //
161
- //
162
- //
163
- //
164
- //
165
- //
166
- //
167
- //
168
- //
169
- //
170
- //
171
- //
172
- //
173
- //
174
- //
175
-
176
117
  const lines = [] as string[]
177
118
  pricat
178
119
  .filter((r) => r.Tag == 'LIN')
@@ -334,7 +275,16 @@ const pricatToCsv = function (pricat: any): string {
334
275
  return envString + hdrString + grpString + linString
335
276
  }
336
277
 
337
- const itemsToOrdRsp = function (items: DocumentItemI[], fromGLN: string, toGLN: string, supplierGLN: string, refID: number, date: string, orderNumber: string) {
278
+ const itemsToOrdRsp = function (
279
+ items: DocumentItemI[],
280
+ fromGLN: string,
281
+ toGLN: string,
282
+ supplierGLN: string,
283
+ deliveryGLN: string,
284
+ refID: number,
285
+ date: string,
286
+ orderNumber: string
287
+ ) {
338
288
  const order = [] as any[]
339
289
 
340
290
  if (typeof fromGLN != 'string' || fromGLN.length != 13) return []
@@ -354,11 +304,14 @@ const itemsToOrdRsp = function (items: DocumentItemI[], fromGLN: string, toGLN:
354
304
  HeaderCurrency: '"EUR"',
355
305
  SupplierGLN: supplierGLN,
356
306
  BuyerGLN: toGLN,
307
+ DocumentDate: date,
308
+ DeliveryPartyGLN: deliveryGLN,
357
309
  }
358
310
 
359
311
  order.push(env)
360
312
  order.push(hdr)
361
313
  let lineNumber = 1
314
+ let totalQty = 0
362
315
  items.forEach((item) => {
363
316
  const lin = {
364
317
  LineTag: 'LIN',
@@ -369,8 +322,14 @@ const itemsToOrdRsp = function (items: DocumentItemI[], fromGLN: string, toGLN:
369
322
  ConfirmedQuantity: item.qty,
370
323
  PurchasePriceNet: item.price,
371
324
  }
325
+ totalQty += item.qty
372
326
  order.push(lin)
373
327
  })
328
+ order.push({
329
+ ControlTag: 'CNT',
330
+ TotalNumberOfPositions: lineNumber - 1,
331
+ TotalQty: totalQty,
332
+ })
374
333
  return order
375
334
  }
376
335
 
@@ -386,7 +345,7 @@ const ordRspToCsv = function (order: any): string {
386
345
  `"${hdr.DocumentType}"`,
387
346
  `"${hdr.DocumentFunction}"`,
388
347
  `"${hdr.DocumentNumber}"`,
389
- null,
348
+ `${hdr.DocumentDate}`,
390
349
  null,
391
350
  null,
392
351
  null,
@@ -422,6 +381,7 @@ const ordRspToCsv = function (order: any): string {
422
381
  null,
423
382
  null,
424
383
  null,
384
+ hdr.DeliveryPartyGLN,
425
385
  null,
426
386
  null,
427
387
  null,
@@ -439,8 +399,7 @@ const ordRspToCsv = function (order: any): string {
439
399
  null,
440
400
  null,
441
401
  null,
442
- null,
443
- null,
402
+ hdr.DeliveryPartyGLN,
444
403
  null,
445
404
  null,
446
405
  null,
@@ -498,6 +457,7 @@ const ordRspToCsv = function (order: any): string {
498
457
  r.LineNumber,
499
458
  1,
500
459
  r.GTIN,
460
+ '"EAN"',
501
461
  null,
502
462
  null,
503
463
  null,
@@ -513,6 +473,7 @@ const ordRspToCsv = function (order: any): string {
513
473
  null,
514
474
  null,
515
475
  null,
476
+ null,
516
477
  r.PurchasePriceNet,
517
478
  null,
518
479
  null,
@@ -542,8 +503,11 @@ const ordRspToCsv = function (order: any): string {
542
503
  lines.push(linValues.join(','))
543
504
  })
544
505
 
545
- const linString = lines.join('\n')
546
- return envString + hdrString + linString
506
+ const linString = lines.join('\n') + '\n'
507
+ const cntRecord = order.filter((r) => r.ControlTag == 'CNT')[0]
508
+ const cntValues = ['"CNT"', null, null, null, null, null, null, cntRecord.TotalNumberOfPositions, cntRecord.TotalQty]
509
+ const cntString = cntValues.join(',')
510
+ return envString + hdrString + linString + cntString
547
511
  }
548
512
 
549
513
  export default { skusToPricat, pricatToCsv, itemsToOrdRsp, ordRspToCsv }
@@ -0,0 +1,7 @@
1
+ /*
2
+ * Ensure that an object is an array. If so, return object, else return a one-element array with the object
3
+ */
4
+ export default function ensureArray(object: any): Array<any> {
5
+ if (!Array.isArray(object)) return [object]
6
+ return object
7
+ }
package/src/index.ts CHANGED
@@ -1,16 +1,17 @@
1
+ export { default as articleStatus } from './articleStatus'
1
2
  export { default as buildPropertyMappingFn } from './buildPropertyMappingFn'
2
3
  export { default as deepCopy } from './deepCopy'
3
4
  export { default as ean13 } from './ean13'
4
- export { default as isean13 } from './isean13'
5
+ export { default as edifact } from './edifact'
6
+ export { default as ensureArray } from './ensureArray'
7
+ export { default as findSkuByBarcode } from './findSkuByBarcode'
5
8
  export { default as getPreferedPropertyMappings } from './getPreferedPropertyMappings'
6
9
  export { default as hashBrand } from './hashBrand'
7
10
  export { default as hasOnlyDigits } from './hasOnlyDigits'
8
- export { default as sizeToMap } from './sizeToMap'
9
- export { default as findSkuByBarcode } from './findSkuByBarcode'
11
+ export { default as isean13 } from './isean13'
12
+ export { default as pivotTable } from './pivotTable'
10
13
  export { default as round2 } from './round2'
14
+ export { default as sizeToMap } from './sizeToMap'
11
15
  export { default as transaction } from './transaction'
12
- export { default as articleStatus } from './articleStatus'
13
- export { default as pivotTable } from './pivotTable'
14
- export { default as edifact } from './edifact'
15
16
  export * from './types'
16
17
  export * from './consts'
@@ -159,7 +159,7 @@ describe('edifact ordrsp', () => {
159
159
  expect(itemsToOrdRsp([], '1234567890123', 123, '1122334455667', 3.14, '20240101', 'ORD-12345')).to.be.deep.equal([])
160
160
  })
161
161
  it('should return a Json version of an edifact ordrsp when items are passed', () => {
162
- expect(itemsToOrdRsp(testOrderItems, '1234567890123', '3210987654321', '1122334455667', 12345, '20240315', 'ORD-12345')).to.be.deep.equal([
162
+ expect(itemsToOrdRsp(testOrderItems, '1234567890123', '3210987654321', '1122334455667', '1231231231231', 12345, '20240315', 'ORD-12345')).to.be.deep.equal([
163
163
  { Tag: 'ENV', SenderGLN: '1234567890123', RecipientGLN: '3210987654321', InterchangeReference: 12345 },
164
164
  {
165
165
  Tag: 'HDR',
@@ -170,20 +170,28 @@ describe('edifact ordrsp', () => {
170
170
  HeaderCurrency: '"EUR"',
171
171
  SupplierGLN: '1122334455667',
172
172
  BuyerGLN: '3210987654321',
173
+ DocumentDate: '20240315',
174
+ DeliveryPartyGLN: '1231231231231',
173
175
  },
174
176
  { LineTag: 'LIN', LineNumber: 1, ActionCode: '"1"', GTIN: '5400977135395', OrderedQuantity: 3, ConfirmedQuantity: 3, PurchasePriceNet: 37.25 },
175
177
  { LineTag: 'LIN', LineNumber: 2, ActionCode: '"1"', GTIN: '5400977135326', OrderedQuantity: 2, ConfirmedQuantity: 2, PurchasePriceNet: 37.1 },
178
+ {
179
+ ControlTag: 'CNT',
180
+ TotalNumberOfPositions: 2,
181
+ TotalQty: 5,
182
+ },
176
183
  ])
177
184
  })
178
185
  it('should perform csv conversion for a FashionUnited 5.00 ordrsp', () => {
179
- const order = itemsToOrdRsp(testOrderItems, '1234567890123', '3210987654321', '1122334455667', 12345, '20240315', 'ORD-12345')
186
+ const order = itemsToOrdRsp(testOrderItems, '1234567890123', '3210987654321', '1122334455667', '1231231231231', 12345, '20240315', 'ORD-12345')
180
187
  const csv = ordRspToCsv(order).split('\n')
181
188
  expect(ordRspToCsv([])).to.be.deep.equal('')
182
189
  expect(csv[0]).to.be.deep.equal('"ENV",1234567890123,3210987654321,12345,0,"FUEB 5.00",,,,,')
183
190
  expect(csv[1]).to.be.deep.equal(
184
- '"HDR","231","29","12345",,,,,,,,,"ORD-12345",,,,,,,,,"EUR",1122334455667,,,,,,,,,3210987654321,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,'
191
+ '"HDR","231","29","12345",20240315,,,,,,,,"ORD-12345",,,,,,,,,"EUR",1122334455667,,,,,,,,,3210987654321,,,,,,,,,1231231231231,,,,,,,,,,,,,,,,,,1231231231231,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,'
185
192
  )
186
- expect(csv[2]).to.be.deep.equal('"LIN",1,1,5400977135395,,,,,,3,,3,,,,,,,,37.25,,,,,,,,,,,,,,,,,,,,,,,')
187
- expect(csv[3]).to.be.deep.equal('"LIN",2,1,5400977135326,,,,,,2,,2,,,,,,,,37.1,,,,,,,,,,,,,,,,,,,,,,,')
193
+ expect(csv[2]).to.be.deep.equal('"LIN",1,1,5400977135395,"EAN",,,,,,3,,3,,,,,,,,,37.25,,,,,,,,,,,,,,,,,,,,,,,')
194
+ expect(csv[3]).to.be.deep.equal('"LIN",2,1,5400977135326,"EAN",,,,,,2,,2,,,,,,,,,37.1,,,,,,,,,,,,,,,,,,,,,,,')
195
+ expect(csv[4]).to.be.deep.equal('"CNT",,,,,,,2,5')
188
196
  })
189
197
  })
@@ -0,0 +1,20 @@
1
+ const { ensureArray } = require('../dist/index')
2
+ const { expect } = require('chai')
3
+
4
+ const input = { foo: { foo: 'bar' }, fooArray: [3.14, 'foo'] }
5
+ describe('ensureArray function', function () {
6
+ it('should return an array as is', function () {
7
+ expect(ensureArray([1, 2, 3])).to.deep.eq([1, 2, 3])
8
+ expect(ensureArray([])).to.deep.eq([])
9
+ })
10
+ it('should return any other inport as an array containing that input', function () {
11
+ expect(ensureArray({ my: 'object' })).to.deep.eq([{ my: 'object' }])
12
+ expect(ensureArray('1234')).to.deep.eq(['1234'])
13
+ expect(ensureArray(3.14)).to.deep.eq([3.14])
14
+ })
15
+ it('should return an array with a reference to the input object if input is an object', function () {
16
+ const a = ensureArray(input)
17
+ input.foo.foo = 'foo'
18
+ expect(a).to.deep.eq([input])
19
+ })
20
+ })