@softwear/latestcollectioncore 1.0.168 → 1.0.170
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/transaction.js +9 -2
- package/package.json +1 -1
- package/src/transaction.ts +5 -2
- package/test/transaction.spec.js +122 -429
package/dist/transaction.js
CHANGED
|
@@ -247,7 +247,7 @@ const buildVector = function (transaction) {
|
|
|
247
247
|
*
|
|
248
248
|
* Build a BI transaction object
|
|
249
249
|
*
|
|
250
|
-
*
|
|
250
|
+
* Build transaction metadata; vector is deprecated, now only used intrnally by articleStatus but no longer needed in the schema
|
|
251
251
|
*/
|
|
252
252
|
const buildTransaction = function (transaction) {
|
|
253
253
|
if (!Object.values(types_1.transactionTypeE).includes(transaction.type))
|
|
@@ -258,8 +258,15 @@ const buildTransaction = function (transaction) {
|
|
|
258
258
|
wh: transaction.wh,
|
|
259
259
|
docnr: transaction.docnr,
|
|
260
260
|
time: transaction.time,
|
|
261
|
-
vector: [].slice.call(buildVector(transaction)),
|
|
262
261
|
};
|
|
262
|
+
if (transaction.qty !== undefined)
|
|
263
|
+
dbTransaction.qty = transaction.qty;
|
|
264
|
+
if (transaction.buyprice !== undefined)
|
|
265
|
+
dbTransaction.buyprice = transaction.buyprice;
|
|
266
|
+
if (transaction.sellprice !== undefined)
|
|
267
|
+
dbTransaction.sellprice = transaction.sellprice;
|
|
268
|
+
if (transaction.vat !== undefined)
|
|
269
|
+
dbTransaction.vat = transaction.vat;
|
|
263
270
|
if (transaction.customer)
|
|
264
271
|
dbTransaction.customer = transaction.customer;
|
|
265
272
|
if (transaction.agent)
|
package/package.json
CHANGED
package/src/transaction.ts
CHANGED
|
@@ -267,7 +267,7 @@ const buildVector = function (transaction: TransactionI): Float64Array {
|
|
|
267
267
|
*
|
|
268
268
|
* Build a BI transaction object
|
|
269
269
|
*
|
|
270
|
-
*
|
|
270
|
+
* Build transaction metadata; vector is deprecated, now only used intrnally by articleStatus but no longer needed in the schema
|
|
271
271
|
*/
|
|
272
272
|
const buildTransaction = function (transaction: TransactionI): dbTransactionI | undefined {
|
|
273
273
|
if (!Object.values(transactionTypeE).includes(transaction.type)) return undefined
|
|
@@ -277,8 +277,11 @@ const buildTransaction = function (transaction: TransactionI): dbTransactionI |
|
|
|
277
277
|
wh: transaction.wh,
|
|
278
278
|
docnr: transaction.docnr,
|
|
279
279
|
time: transaction.time,
|
|
280
|
-
vector: [].slice.call(buildVector(transaction)) as number[],
|
|
281
280
|
}
|
|
281
|
+
if (transaction.qty !== undefined) dbTransaction.qty = transaction.qty
|
|
282
|
+
if (transaction.buyprice !== undefined) dbTransaction.buyprice = transaction.buyprice
|
|
283
|
+
if (transaction.sellprice !== undefined) dbTransaction.sellprice = transaction.sellprice
|
|
284
|
+
if (transaction.vat !== undefined) dbTransaction.vat = transaction.vat
|
|
282
285
|
if (transaction.customer) dbTransaction.customer = transaction.customer
|
|
283
286
|
if (transaction.agent) dbTransaction.agent = transaction.agent
|
|
284
287
|
if (transaction.type == transactionTypeE.START_SHELF_STOCK) dbTransaction.type = transactionTypeE.START_STOCK
|
package/test/transaction.spec.js
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
const core = require('../dist/index')
|
|
2
|
-
// Tests disabled - uncomment below to enable
|
|
3
|
-
// return
|
|
4
2
|
const buildTransaction = core.transaction.buildTransaction
|
|
3
|
+
const buildVector = core.transaction.buildVector
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
const normalizeTransaction = (transaction) => {
|
|
8
|
-
if (!transaction) return transaction
|
|
9
|
-
return {
|
|
10
|
-
...transaction,
|
|
11
|
-
vector: transaction.vector ? Array.from(transaction.vector) : transaction.vector,
|
|
12
|
-
}
|
|
13
|
-
}
|
|
5
|
+
const normalizeVector = (vector) => Array.from(vector)
|
|
14
6
|
|
|
15
7
|
describe('#Transactions', () => {
|
|
16
8
|
describe('#buildTransaction', () => {
|
|
@@ -18,463 +10,164 @@ describe('#Transactions', () => {
|
|
|
18
10
|
const transaction = buildTransaction({})
|
|
19
11
|
expect(transaction).toEqual(undefined)
|
|
20
12
|
})
|
|
21
|
-
|
|
13
|
+
|
|
14
|
+
it('should return undefined when called with an illegal type', () => {
|
|
22
15
|
const transaction = buildTransaction({ type: 666 })
|
|
23
16
|
expect(transaction).toEqual(undefined)
|
|
24
17
|
})
|
|
25
|
-
it('should return correct transaction for a type 1 (=receiving) transaction', () => {
|
|
26
|
-
const transaction = normalizeTransaction(
|
|
27
|
-
buildTransaction({ type: '1', ean: '1234567890128', wh: '51', time: 314159265, qty: 123, sellprice: 0, buyprice: 9.95, vat: 21, docnr: 'REC-1' })
|
|
28
|
-
)
|
|
29
|
-
expect(transaction).toEqual({
|
|
30
|
-
type: '1',
|
|
31
|
-
ean: '1234567890128',
|
|
32
|
-
wh: '51',
|
|
33
|
-
time: 314159265,
|
|
34
|
-
docnr: 'REC-1',
|
|
35
|
-
vector: [123, 123, 1223.85, 123, 1223.85, 0, 123, 1223.85],
|
|
36
|
-
})
|
|
37
|
-
})
|
|
38
18
|
|
|
39
|
-
it('should return
|
|
40
|
-
const transaction =
|
|
41
|
-
buildTransaction({
|
|
42
|
-
type: '2',
|
|
43
|
-
ean: '1234567890128',
|
|
44
|
-
wh: '51',
|
|
45
|
-
time: 314159265,
|
|
46
|
-
qty: 123,
|
|
47
|
-
customer: '123',
|
|
48
|
-
agent: '01',
|
|
49
|
-
sellprice: 19.95,
|
|
50
|
-
buyprice: 9.95,
|
|
51
|
-
vat: 21,
|
|
52
|
-
docnr: '51-123',
|
|
53
|
-
})
|
|
54
|
-
)
|
|
55
|
-
expect(transaction).toEqual({
|
|
19
|
+
it('should return transaction metadata without generating vector', () => {
|
|
20
|
+
const transaction = buildTransaction({
|
|
56
21
|
type: '2',
|
|
57
22
|
ean: '1234567890128',
|
|
58
23
|
wh: '51',
|
|
59
24
|
time: 314159265,
|
|
25
|
+
qty: 123,
|
|
60
26
|
customer: '123',
|
|
61
27
|
agent: '01',
|
|
28
|
+
sellprice: 19.95,
|
|
29
|
+
buyprice: 9.95,
|
|
30
|
+
vat: 21,
|
|
62
31
|
docnr: '51-123',
|
|
63
|
-
vector: [
|
|
64
|
-
123,
|
|
65
|
-
-123,
|
|
66
|
-
-1223.85,
|
|
67
|
-
-123,
|
|
68
|
-
-1223.85,
|
|
69
|
-
0,
|
|
70
|
-
0,
|
|
71
|
-
0,
|
|
72
|
-
123,
|
|
73
|
-
2453.85,
|
|
74
|
-
2027.98,
|
|
75
|
-
123 * 9.95,
|
|
76
|
-
0,
|
|
77
|
-
0,
|
|
78
|
-
0,
|
|
79
|
-
0,
|
|
80
|
-
0,
|
|
81
|
-
0,
|
|
82
|
-
0,
|
|
83
|
-
0,
|
|
84
|
-
0,
|
|
85
|
-
0,
|
|
86
|
-
0,
|
|
87
|
-
0,
|
|
88
|
-
0,
|
|
89
|
-
0,
|
|
90
|
-
0,
|
|
91
|
-
0,
|
|
92
|
-
0,
|
|
93
|
-
0,
|
|
94
|
-
0,
|
|
95
|
-
0,
|
|
96
|
-
0,
|
|
97
|
-
0,
|
|
98
|
-
0,
|
|
99
|
-
0,
|
|
100
|
-
0,
|
|
101
|
-
0,
|
|
102
|
-
0,
|
|
103
|
-
0,
|
|
104
|
-
0,
|
|
105
|
-
0,
|
|
106
|
-
0,
|
|
107
|
-
0,
|
|
108
|
-
0,
|
|
109
|
-
],
|
|
110
|
-
})
|
|
111
|
-
})
|
|
112
|
-
it('should return correct transaction for a type 3 (=transit) transaction', () => {
|
|
113
|
-
const transaction = normalizeTransaction(
|
|
114
|
-
buildTransaction({
|
|
115
|
-
type: '3',
|
|
116
|
-
ean: '1234567890128',
|
|
117
|
-
wh: '51',
|
|
118
|
-
time: 314159265,
|
|
119
|
-
qty: 123,
|
|
120
|
-
buyprice: 9.95,
|
|
121
|
-
vat: 21,
|
|
122
|
-
docnr: '51-123',
|
|
123
|
-
})
|
|
124
|
-
)
|
|
125
|
-
expect(transaction).toEqual({
|
|
126
|
-
type: '3',
|
|
127
|
-
ean: '1234567890128',
|
|
128
|
-
wh: '51',
|
|
129
|
-
time: 314159265,
|
|
130
|
-
docnr: '51-123',
|
|
131
|
-
vector: [123, 123, 1223.85, 123, 1223.85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 9.95],
|
|
132
|
-
})
|
|
133
|
-
})
|
|
134
|
-
it('should return correct transaction for a type 4 (=change) transaction', () => {
|
|
135
|
-
const transaction = normalizeTransaction(
|
|
136
|
-
buildTransaction({
|
|
137
|
-
type: '4',
|
|
138
|
-
ean: '1234567890128',
|
|
139
|
-
wh: '51',
|
|
140
|
-
time: 314159265,
|
|
141
|
-
qty: 123,
|
|
142
|
-
buyprice: 9.95,
|
|
143
|
-
vat: 21,
|
|
144
|
-
docnr: '51-123',
|
|
145
|
-
})
|
|
146
|
-
)
|
|
147
|
-
expect(transaction).toEqual({
|
|
148
|
-
type: '4',
|
|
149
|
-
ean: '1234567890128',
|
|
150
|
-
wh: '51',
|
|
151
|
-
time: 314159265,
|
|
152
|
-
docnr: '51-123',
|
|
153
|
-
vector: [123, 123, 1223.85, 123, 1223.85, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 9.95],
|
|
154
|
-
})
|
|
155
|
-
})
|
|
156
|
-
it('should return correct transaction for a type 0 (=beginstock) transaction', () => {
|
|
157
|
-
const transaction = normalizeTransaction(
|
|
158
|
-
buildTransaction({
|
|
159
|
-
type: '0',
|
|
160
|
-
ean: '1234567890128',
|
|
161
|
-
wh: '51',
|
|
162
|
-
time: 314159265,
|
|
163
|
-
qty: 123,
|
|
164
|
-
buyprice: 9.95,
|
|
165
|
-
vat: 21,
|
|
166
|
-
docnr: '51-123',
|
|
167
|
-
})
|
|
168
|
-
)
|
|
169
|
-
expect(transaction).toEqual({
|
|
170
|
-
type: '0',
|
|
171
|
-
ean: '1234567890128',
|
|
172
|
-
wh: '51',
|
|
173
|
-
time: 314159265,
|
|
174
|
-
docnr: '51-123',
|
|
175
|
-
vector: [123, 123, 1223.85, 123, 1223.85, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 9.95],
|
|
176
|
-
})
|
|
177
|
-
})
|
|
178
|
-
it('should return correct transaction for a type 8 (=revaluation) transaction', () => {
|
|
179
|
-
const transaction = normalizeTransaction(
|
|
180
|
-
buildTransaction({
|
|
181
|
-
type: '8',
|
|
182
|
-
ean: '1234567890128',
|
|
183
|
-
wh: '51',
|
|
184
|
-
time: 314159265,
|
|
185
|
-
qty: 123,
|
|
186
|
-
buyprice: 9.95,
|
|
187
|
-
vat: 21,
|
|
188
|
-
docnr: '51-123',
|
|
189
|
-
})
|
|
190
|
-
)
|
|
191
|
-
expect(transaction).toEqual({
|
|
192
|
-
type: '8',
|
|
193
|
-
ean: '1234567890128',
|
|
194
|
-
wh: '51',
|
|
195
|
-
time: 314159265,
|
|
196
|
-
docnr: '51-123',
|
|
197
|
-
vector: [123, 0, 1223.85, 0, 1223.85, 123 * 9.95],
|
|
198
32
|
})
|
|
199
|
-
})
|
|
200
|
-
it('should return correct transaction for a type 10 (=start shelf stock) transaction', () => {
|
|
201
|
-
const transaction = normalizeTransaction(
|
|
202
|
-
buildTransaction({
|
|
203
|
-
type: '10',
|
|
204
|
-
ean: '1234567890128',
|
|
205
|
-
wh: '51',
|
|
206
|
-
time: 314159265,
|
|
207
|
-
qty: 123,
|
|
208
|
-
buyprice: 9.95,
|
|
209
|
-
vat: 21,
|
|
210
|
-
docnr: '51-123',
|
|
211
|
-
})
|
|
212
|
-
)
|
|
213
|
-
expect(transaction).toEqual({
|
|
214
|
-
type: '0',
|
|
215
|
-
ean: '1234567890128',
|
|
216
|
-
wh: '51',
|
|
217
|
-
time: 314159265,
|
|
218
|
-
docnr: '51-123',
|
|
219
|
-
vector: [123, 0, 0, 123, 123 * 9.95],
|
|
220
|
-
})
|
|
221
|
-
})
|
|
222
|
-
it('should return correct transaction for a type 14 (=purchaseorder) transaction', () => {
|
|
223
|
-
const transaction = normalizeTransaction(
|
|
224
|
-
buildTransaction({
|
|
225
|
-
type: '14',
|
|
226
|
-
ean: '1234567890128',
|
|
227
|
-
wh: '51',
|
|
228
|
-
time: 314159265,
|
|
229
|
-
qty: 123,
|
|
230
|
-
buyprice: 9.95,
|
|
231
|
-
vat: 21,
|
|
232
|
-
docnr: '51-123',
|
|
233
|
-
})
|
|
234
|
-
)
|
|
235
|
-
expect(transaction).toEqual({
|
|
236
|
-
type: '14',
|
|
237
|
-
ean: '1234567890128',
|
|
238
|
-
wh: '51',
|
|
239
|
-
time: 314159265,
|
|
240
|
-
docnr: '51-123',
|
|
241
|
-
vector: [123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 9.95],
|
|
242
|
-
})
|
|
243
|
-
})
|
|
244
33
|
|
|
245
|
-
it('should return correct transaction for a type 15 (=completed purchaseorder) transaction', () => {
|
|
246
|
-
const transaction = normalizeTransaction(
|
|
247
|
-
buildTransaction({
|
|
248
|
-
type: '15',
|
|
249
|
-
ean: '1234567890128',
|
|
250
|
-
wh: '51',
|
|
251
|
-
time: 314159265,
|
|
252
|
-
qty: 123,
|
|
253
|
-
buyprice: 9.95,
|
|
254
|
-
vat: 21,
|
|
255
|
-
docnr: '51-123',
|
|
256
|
-
})
|
|
257
|
-
)
|
|
258
34
|
expect(transaction).toEqual({
|
|
259
|
-
type: '
|
|
260
|
-
ean: '1234567890128',
|
|
261
|
-
wh: '51',
|
|
262
|
-
time: 314159265,
|
|
263
|
-
docnr: '51-123',
|
|
264
|
-
vector: [123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 9.95],
|
|
265
|
-
})
|
|
266
|
-
})
|
|
267
|
-
|
|
268
|
-
it('should return correct transaction for a type 18 (=minimum stock) transaction', () => {
|
|
269
|
-
const transaction = normalizeTransaction(
|
|
270
|
-
buildTransaction({
|
|
271
|
-
type: '18',
|
|
272
|
-
ean: '1234567890128',
|
|
273
|
-
wh: '51',
|
|
274
|
-
time: 314159265,
|
|
275
|
-
qty: 123,
|
|
276
|
-
buyprice: 9.95,
|
|
277
|
-
vat: 21,
|
|
278
|
-
docnr: '51-123',
|
|
279
|
-
})
|
|
280
|
-
)
|
|
281
|
-
expect(transaction).toEqual({
|
|
282
|
-
type: '18',
|
|
283
|
-
ean: '1234567890128',
|
|
284
|
-
wh: '51',
|
|
285
|
-
time: 314159265,
|
|
286
|
-
docnr: '51-123',
|
|
287
|
-
vector: [123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 9.95],
|
|
288
|
-
})
|
|
289
|
-
})
|
|
290
|
-
|
|
291
|
-
it('should return correct transaction for a type 96 (=order) transaction', () => {
|
|
292
|
-
const transaction = normalizeTransaction(
|
|
293
|
-
buildTransaction({
|
|
294
|
-
type: '96',
|
|
295
|
-
ean: '1234567890128',
|
|
296
|
-
wh: '51',
|
|
297
|
-
time: 314159265,
|
|
298
|
-
qty: 123,
|
|
299
|
-
buyprice: 9.95,
|
|
300
|
-
sellprice: 19.95,
|
|
301
|
-
vat: 21,
|
|
302
|
-
docnr: '51-123',
|
|
303
|
-
})
|
|
304
|
-
)
|
|
305
|
-
expect(transaction).toEqual({
|
|
306
|
-
type: '96',
|
|
307
|
-
ean: '1234567890128',
|
|
308
|
-
wh: '51',
|
|
309
|
-
time: 314159265,
|
|
310
|
-
docnr: '51-123',
|
|
311
|
-
vector: [123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 19.95, 123 * 9.95],
|
|
312
|
-
})
|
|
313
|
-
})
|
|
314
|
-
|
|
315
|
-
it('should return correct transaction for a type 97 (=reorder) transaction', () => {
|
|
316
|
-
const transaction = normalizeTransaction(
|
|
317
|
-
buildTransaction({
|
|
318
|
-
type: '97',
|
|
319
|
-
ean: '1234567890128',
|
|
320
|
-
wh: '51',
|
|
321
|
-
time: 314159265,
|
|
322
|
-
qty: 123,
|
|
323
|
-
buyprice: 9.95,
|
|
324
|
-
sellprice: 19.95,
|
|
325
|
-
vat: 21,
|
|
326
|
-
docnr: '51-123',
|
|
327
|
-
})
|
|
328
|
-
)
|
|
329
|
-
expect(transaction).toEqual({
|
|
330
|
-
type: '97',
|
|
35
|
+
type: '2',
|
|
331
36
|
ean: '1234567890128',
|
|
332
37
|
wh: '51',
|
|
333
38
|
time: 314159265,
|
|
39
|
+
qty: 123,
|
|
40
|
+
buyprice: 9.95,
|
|
41
|
+
sellprice: 19.95,
|
|
42
|
+
vat: 21,
|
|
43
|
+
customer: '123',
|
|
44
|
+
agent: '01',
|
|
334
45
|
docnr: '51-123',
|
|
335
|
-
vector: [123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 19.95, 123 * 9.95],
|
|
336
46
|
})
|
|
47
|
+
expect(transaction.vector).toBe(undefined)
|
|
337
48
|
})
|
|
338
49
|
|
|
339
|
-
it('should
|
|
340
|
-
const transaction =
|
|
341
|
-
|
|
342
|
-
type: '94',
|
|
343
|
-
ean: '1234567890128',
|
|
344
|
-
wh: '51',
|
|
345
|
-
time: 314159265,
|
|
346
|
-
qty: 123,
|
|
347
|
-
buyprice: 9.95,
|
|
348
|
-
sellprice: 19.95,
|
|
349
|
-
vat: 21,
|
|
350
|
-
docnr: '51-123',
|
|
351
|
-
})
|
|
352
|
-
)
|
|
353
|
-
expect(transaction).toEqual({
|
|
354
|
-
type: '94',
|
|
50
|
+
it('should map type 10 to type 0 and still not generate vector', () => {
|
|
51
|
+
const transaction = buildTransaction({
|
|
52
|
+
type: '10',
|
|
355
53
|
ean: '1234567890128',
|
|
356
54
|
wh: '51',
|
|
357
55
|
time: 314159265,
|
|
56
|
+
qty: 123,
|
|
57
|
+
buyprice: 9.95,
|
|
58
|
+
vat: 21,
|
|
358
59
|
docnr: '51-123',
|
|
359
|
-
// Type 94 (PICK_LIST) does NOT set QTY_SHELF_STOCK or AMOUNT_SHELF_STOCK
|
|
360
|
-
// Picklists reduce shelfStock, which is handled by subtracting QTY_PICKLIST in postAgg
|
|
361
|
-
vector: [123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 19.95, 123 * 9.95],
|
|
362
60
|
})
|
|
363
|
-
})
|
|
364
61
|
|
|
365
|
-
it('should return correct transaction for a type 95 (=consignment) transaction', () => {
|
|
366
|
-
const transaction = normalizeTransaction(
|
|
367
|
-
buildTransaction({
|
|
368
|
-
type: '95',
|
|
369
|
-
ean: '1234567890128',
|
|
370
|
-
wh: '51',
|
|
371
|
-
time: 314159265,
|
|
372
|
-
qty: 123,
|
|
373
|
-
buyprice: 9.95,
|
|
374
|
-
sellprice: 19.95,
|
|
375
|
-
vat: 21,
|
|
376
|
-
docnr: '51-123',
|
|
377
|
-
})
|
|
378
|
-
)
|
|
379
62
|
expect(transaction).toEqual({
|
|
380
|
-
type: '
|
|
63
|
+
type: '0',
|
|
381
64
|
ean: '1234567890128',
|
|
382
65
|
wh: '51',
|
|
383
66
|
time: 314159265,
|
|
67
|
+
qty: 123,
|
|
68
|
+
buyprice: 9.95,
|
|
69
|
+
vat: 21,
|
|
384
70
|
docnr: '51-123',
|
|
385
|
-
// Type 95 (CONSIGNMENT) does NOT set QTY_SHELF_STOCK or AMOUNT_SHELF_STOCK
|
|
386
|
-
// Consignment reduce shelfStock, which is handled by subtracting QTY_CONSIGNMENT in postAgg
|
|
387
|
-
vector: [123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 19.95, 123 * 9.95],
|
|
388
71
|
})
|
|
72
|
+
expect(transaction.vector).toBe(undefined)
|
|
389
73
|
})
|
|
74
|
+
})
|
|
390
75
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
})
|
|
404
|
-
)
|
|
405
|
-
expect(transaction).toEqual({
|
|
406
|
-
type: '6',
|
|
407
|
-
ean: '1234567890128',
|
|
408
|
-
wh: '51',
|
|
409
|
-
time: 314159265,
|
|
410
|
-
docnr: '51-123',
|
|
411
|
-
vector: [
|
|
412
|
-
123,
|
|
413
|
-
123,
|
|
414
|
-
123 * 9.95,
|
|
415
|
-
123,
|
|
416
|
-
123 * 9.95,
|
|
417
|
-
0,
|
|
418
|
-
0,
|
|
419
|
-
0,
|
|
420
|
-
0,
|
|
421
|
-
0,
|
|
422
|
-
0,
|
|
423
|
-
0,
|
|
424
|
-
0,
|
|
425
|
-
0,
|
|
426
|
-
0,
|
|
427
|
-
0,
|
|
428
|
-
0,
|
|
429
|
-
0,
|
|
430
|
-
0,
|
|
431
|
-
0,
|
|
432
|
-
0,
|
|
433
|
-
0,
|
|
434
|
-
0,
|
|
435
|
-
0,
|
|
436
|
-
0,
|
|
437
|
-
0,
|
|
438
|
-
0,
|
|
439
|
-
0,
|
|
440
|
-
0,
|
|
441
|
-
0,
|
|
442
|
-
0,
|
|
443
|
-
0,
|
|
444
|
-
0,
|
|
445
|
-
0,
|
|
446
|
-
0,
|
|
447
|
-
0,
|
|
448
|
-
0,
|
|
449
|
-
123,
|
|
450
|
-
123 * 19.95,
|
|
451
|
-
123 * 9.95,
|
|
76
|
+
describe('#buildVector', () => {
|
|
77
|
+
const vectorCases = [
|
|
78
|
+
{
|
|
79
|
+
label: 'type 1 (=receiving)',
|
|
80
|
+
input: { type: '1', ean: '1234567890128', wh: '51', time: 314159265, qty: 123, sellprice: 0, buyprice: 9.95, vat: 21, docnr: 'REC-1' },
|
|
81
|
+
expected: [123, 123, 1223.85, 123, 1223.85, 0, 123, 1223.85],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
label: 'type 2 (=sale)',
|
|
85
|
+
input: { type: '2', ean: '1234567890128', wh: '51', time: 314159265, qty: 123, sellprice: 19.95, buyprice: 9.95, vat: 21, docnr: '51-123' },
|
|
86
|
+
expected: [
|
|
87
|
+
123, -123, -1223.85, -123, -1223.85, 0, 0, 0, 123, 2453.85, 2027.98, 123 * 9.95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
452
88
|
],
|
|
453
|
-
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
label: 'type 3 (=transit)',
|
|
92
|
+
input: { type: '3', ean: '1234567890128', wh: '51', time: 314159265, qty: 123, buyprice: 9.95, vat: 21, docnr: '51-123' },
|
|
93
|
+
expected: [123, 123, 1223.85, 123, 1223.85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 9.95],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
label: 'type 4 (=change)',
|
|
97
|
+
input: { type: '4', ean: '1234567890128', wh: '51', time: 314159265, qty: 123, buyprice: 9.95, vat: 21, docnr: '51-123' },
|
|
98
|
+
expected: [123, 123, 1223.85, 123, 1223.85, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 9.95],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
label: 'type 0 (=beginstock)',
|
|
102
|
+
input: { type: '0', ean: '1234567890128', wh: '51', time: 314159265, qty: 123, buyprice: 9.95, vat: 21, docnr: '51-123' },
|
|
103
|
+
expected: [123, 123, 1223.85, 123, 1223.85, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 9.95],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
label: 'type 8 (=revaluation)',
|
|
107
|
+
input: { type: '8', ean: '1234567890128', wh: '51', time: 314159265, qty: 123, buyprice: 9.95, vat: 21, docnr: '51-123' },
|
|
108
|
+
expected: [123, 0, 1223.85, 0, 1223.85, 123 * 9.95],
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
label: 'type 10 (=start shelf stock)',
|
|
112
|
+
input: { type: '10', ean: '1234567890128', wh: '51', time: 314159265, qty: 123, buyprice: 9.95, vat: 21, docnr: '51-123' },
|
|
113
|
+
expected: [123, 0, 0, 123, 123 * 9.95],
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
label: 'type 14 (=purchaseorder)',
|
|
117
|
+
input: { type: '14', ean: '1234567890128', wh: '51', time: 314159265, qty: 123, buyprice: 9.95, vat: 21, docnr: '51-123' },
|
|
118
|
+
expected: [123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 9.95],
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
label: 'type 15 (=completed purchaseorder)',
|
|
122
|
+
input: { type: '15', ean: '1234567890128', wh: '51', time: 314159265, qty: 123, buyprice: 9.95, vat: 21, docnr: '51-123' },
|
|
123
|
+
expected: [123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 9.95],
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
label: 'type 18 (=minimum stock)',
|
|
127
|
+
input: { type: '18', ean: '1234567890128', wh: '51', time: 314159265, qty: 123, buyprice: 9.95, vat: 21, docnr: '51-123' },
|
|
128
|
+
expected: [123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 9.95],
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
label: 'type 96 (=order)',
|
|
132
|
+
input: { type: '96', ean: '1234567890128', wh: '51', time: 314159265, qty: 123, buyprice: 9.95, sellprice: 19.95, vat: 21, docnr: '51-123' },
|
|
133
|
+
expected: [123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 19.95, 123 * 9.95],
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
label: 'type 97 (=reorder)',
|
|
137
|
+
input: { type: '97', ean: '1234567890128', wh: '51', time: 314159265, qty: 123, buyprice: 9.95, sellprice: 19.95, vat: 21, docnr: '51-123' },
|
|
138
|
+
expected: [123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 19.95, 123 * 9.95],
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
label: 'type 94 (=picklist)',
|
|
142
|
+
input: { type: '94', ean: '1234567890128', wh: '51', time: 314159265, qty: 123, buyprice: 9.95, sellprice: 19.95, vat: 21, docnr: '51-123' },
|
|
143
|
+
expected: [123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 19.95, 123 * 9.95],
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
label: 'type 95 (=consignment)',
|
|
147
|
+
input: { type: '95', ean: '1234567890128', wh: '51', time: 314159265, qty: 123, buyprice: 9.95, sellprice: 19.95, vat: 21, docnr: '51-123' },
|
|
148
|
+
expected: [123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 19.95, 123 * 9.95],
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
label: 'type 6 (=b2b return to customer)',
|
|
152
|
+
input: { type: '6', ean: '1234567890128', wh: '51', time: 314159265, qty: 123, buyprice: 9.95, sellprice: 19.95, vat: 21, docnr: '51-123' },
|
|
153
|
+
expected: [
|
|
154
|
+
123, 123, 123 * 9.95, 123, 123 * 9.95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 19.95, 123 * 9.95,
|
|
155
|
+
],
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
label: 'type 7 (=credit invoice)',
|
|
159
|
+
input: { type: '7', ean: '1234567890128', wh: '51', time: 314159265, qty: 123, buyprice: 9.95, sellprice: 19.95, vat: 21, docnr: '51-123' },
|
|
160
|
+
expected: [123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123 * 19.95],
|
|
161
|
+
},
|
|
162
|
+
]
|
|
163
|
+
|
|
164
|
+
it.each(vectorCases)('should return correct vector for $label', ({ input, expected }) => {
|
|
165
|
+
expect(normalizeVector(buildVector(input))).toEqual(expected)
|
|
454
166
|
})
|
|
455
167
|
|
|
456
|
-
it('should return
|
|
457
|
-
const
|
|
458
|
-
|
|
459
|
-
type: '7',
|
|
460
|
-
ean: '1234567890128',
|
|
461
|
-
wh: '51',
|
|
462
|
-
time: 314159265,
|
|
463
|
-
qty: 123,
|
|
464
|
-
buyprice: 9.95,
|
|
465
|
-
sellprice: 19.95,
|
|
466
|
-
vat: 21,
|
|
467
|
-
docnr: '51-123',
|
|
468
|
-
})
|
|
469
|
-
)
|
|
470
|
-
expect(transaction).toEqual({
|
|
471
|
-
type: '7',
|
|
472
|
-
ean: '1234567890128',
|
|
473
|
-
wh: '51',
|
|
474
|
-
time: 314159265,
|
|
475
|
-
docnr: '51-123',
|
|
476
|
-
vector: [123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123 * 19.95],
|
|
477
|
-
})
|
|
168
|
+
it('should return empty vector for unknown type', () => {
|
|
169
|
+
const vector = buildVector({ type: '666' })
|
|
170
|
+
expect(normalizeVector(vector)).toEqual([])
|
|
478
171
|
})
|
|
479
172
|
})
|
|
480
173
|
})
|