@softwear/latestcollectioncore 1.0.74 → 1.0.76

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/index.d.ts CHANGED
@@ -7,5 +7,7 @@ export { default as hashBrand } from './hashBrand';
7
7
  export { default as hasOnlyDigits } from './hasOnlyDigits';
8
8
  export { default as sizeToMap } from './sizeToMap';
9
9
  export { default as findSkuByBarcode } from './findSkuByBarcode';
10
+ export { default as round2 } from './round2';
11
+ export { default as transaction } from './transaction';
10
12
  export * from './types';
11
13
  export * from './consts';
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ 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.findSkuByBarcode = exports.sizeToMap = exports.hasOnlyDigits = exports.hashBrand = exports.getPreferedPropertyMappings = exports.isean13 = exports.ean13 = exports.deepCopy = exports.buildPropertyMappingFn = void 0;
20
+ exports.transaction = exports.round2 = exports.findSkuByBarcode = exports.sizeToMap = exports.hasOnlyDigits = exports.hashBrand = exports.getPreferedPropertyMappings = exports.isean13 = exports.ean13 = exports.deepCopy = exports.buildPropertyMappingFn = void 0;
21
21
  var buildPropertyMappingFn_1 = require("./buildPropertyMappingFn");
22
22
  Object.defineProperty(exports, "buildPropertyMappingFn", { enumerable: true, get: function () { return __importDefault(buildPropertyMappingFn_1).default; } });
23
23
  var deepCopy_1 = require("./deepCopy");
@@ -36,5 +36,9 @@ var sizeToMap_1 = require("./sizeToMap");
36
36
  Object.defineProperty(exports, "sizeToMap", { enumerable: true, get: function () { return __importDefault(sizeToMap_1).default; } });
37
37
  var findSkuByBarcode_1 = require("./findSkuByBarcode");
38
38
  Object.defineProperty(exports, "findSkuByBarcode", { enumerable: true, get: function () { return __importDefault(findSkuByBarcode_1).default; } });
39
+ var round2_1 = require("./round2");
40
+ Object.defineProperty(exports, "round2", { enumerable: true, get: function () { return __importDefault(round2_1).default; } });
41
+ var transaction_1 = require("./transaction");
42
+ Object.defineProperty(exports, "transaction", { enumerable: true, get: function () { return __importDefault(transaction_1).default; } });
39
43
  __exportStar(require("./types"), exports);
40
44
  __exportStar(require("./consts"), exports);
@@ -0,0 +1 @@
1
+ export default function (value: string | number): number;
package/dist/round2.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function default_1(value) {
4
+ const type = typeof value;
5
+ if (type != 'string' && type != 'number')
6
+ return 0;
7
+ if (typeof value == 'string')
8
+ value = parseFloat(value);
9
+ return Math.round((value + Number.EPSILON) * 100) / 100;
10
+ }
11
+ exports.default = default_1;
@@ -0,0 +1,92 @@
1
+ import { dbTransactionI, TransactionI } from './types';
2
+ declare const _default: {
3
+ transactionVector: {
4
+ QTY_TRANSACTION: number;
5
+ QTY_STOCK: number;
6
+ AMOUNT_STOCK: number;
7
+ QTY_SHELF_STOCK: number;
8
+ AMOUNT_SHELF_STOCK: number;
9
+ AMOUNT_REVALUATE: number;
10
+ QTY_RECIEVED: number;
11
+ AMOUNT_RECIEVED: number;
12
+ QTY_SOLD: number;
13
+ AMOUNT_SOLD: number;
14
+ AMOUNT_SOLD_EXCL: number;
15
+ COSTPRICE_SOLD: number;
16
+ QTY_CHANGE: number;
17
+ AMOUNT_CHANGE: number;
18
+ QTY_TRANSIT: number;
19
+ AMOUNT_TRANSIT: number;
20
+ QTY_PO: number;
21
+ AMOUNT_PO: number;
22
+ QTY_PO_COMPLETE: number;
23
+ AMOUNT_PO_COMPLETE: number;
24
+ QTY_MINIMUM_STOCK: number;
25
+ AMOUNT_MINIMUM_STOCK: number;
26
+ QTY_CONSIGNMENT: number;
27
+ AMOUNT_CONSIGNMENT: number;
28
+ COSTPRICE_CONSIGNMENT: number;
29
+ };
30
+ buildTransaction: (transaction: TransactionI) => dbTransactionI | undefined;
31
+ };
32
+ export default _default;
33
+ /**
34
+ TODO:
35
+
36
+ FOXPRO CODE STILL TO CONVERT FOR WHOLESALE
37
+
38
+ CASE _trtype == 96 && TRANSACTION_ORDER
39
+ replace ;
40
+ n_ordered with qty, ;
41
+ a_ordered with qty* _price, ;
42
+ c_ordered with qty* _cost
43
+ CASE _trtype == 93 && TRANSACTION_PRESOLD
44
+ replace ;
45
+ n_stock with -qty, ;
46
+ a_stock with -qty* _cost, ;
47
+ n_sstock with -qty, ;
48
+ a_sstock with -qty* _cost, ;
49
+ n_presold with qty, ;
50
+ a_presold with qty* _price,;
51
+ c_presold with qty* _cost
52
+ CASE _trtype == 97 && TRANSACTION_PREORDER
53
+ replace ;
54
+ n_preord with qty, ;
55
+ a_preord with qty* _price, ;
56
+ c_preord with qty* _cost
57
+ CASE _trtype == 94 && TRANSACTION_PICKLIST
58
+ replace ;
59
+ n_sstock with -qty, ;
60
+ a_sstock with -qty* _cost, ;
61
+ n_picked with qty, ;
62
+ a_picked with qty* _price, ;
63
+ c_picked with qty* _cost
64
+ CASE _trtype == 95 && TRANSACTION_PREPICKLIST
65
+ replace ;
66
+ n_sstock with -qty, ;
67
+ a_sstock with -qty* _cost, ;
68
+ n_prepick with qty, ;
69
+ a_prepick with qty* _price, ;
70
+ c_prepick with qty* _cost
71
+ CASE _trtype == 5 && TRANSACTION_RETURN_SUPPLIER
72
+ replace ;
73
+ n_stock with -qty, ;
74
+ a_stock with -qty* _cost, ;
75
+ n_sstock with -qty, ;
76
+ a_sstock with -qty* _cost, ;
77
+ n_recieved with -qty, ;
78
+ a_recieved with -qty* _cost
79
+ CASE _trtype == 6 && TRANSACTION_RETURN_CUSTOMER [C ]
80
+ replace ;
81
+ n_stock with qty, ;
82
+ a_stock with qty* _cost, ;
83
+ n_sstock with qty, ;
84
+ a_sstock with qty* _cost, ;
85
+ n_return with qty, ;
86
+ a_return with qty* _price, ;
87
+ c_return with qty* _cost
88
+
89
+ CASE _trtype == 7 && TRANSACTION_CREDIT [CK]
90
+ replace ;
91
+ a_return with qty* _price
92
+ */
@@ -0,0 +1,219 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const types_1 = require("./types");
4
+ const index_1 = require("./index");
5
+ // fields in Vector
6
+ const transactionVector = {
7
+ QTY_TRANSACTION: 0,
8
+ QTY_STOCK: 1,
9
+ AMOUNT_STOCK: 2,
10
+ QTY_SHELF_STOCK: 3,
11
+ AMOUNT_SHELF_STOCK: 4,
12
+ AMOUNT_REVALUATE: 5,
13
+ QTY_RECIEVED: 6,
14
+ AMOUNT_RECIEVED: 7,
15
+ QTY_SOLD: 8,
16
+ AMOUNT_SOLD: 9,
17
+ AMOUNT_SOLD_EXCL: 10,
18
+ COSTPRICE_SOLD: 11,
19
+ QTY_CHANGE: 12,
20
+ AMOUNT_CHANGE: 13,
21
+ QTY_TRANSIT: 14,
22
+ AMOUNT_TRANSIT: 15,
23
+ QTY_PO: 16,
24
+ AMOUNT_PO: 17,
25
+ QTY_PO_COMPLETE: 18,
26
+ AMOUNT_PO_COMPLETE: 19,
27
+ QTY_MINIMUM_STOCK: 20,
28
+ AMOUNT_MINIMUM_STOCK: 21,
29
+ QTY_CONSIGNMENT: 22,
30
+ AMOUNT_CONSIGNMENT: 23,
31
+ COSTPRICE_CONSIGNMENT: 24,
32
+ };
33
+ // destructure constants for ease of use locally in this file
34
+ const { QTY_TRANSACTION, QTY_STOCK, AMOUNT_STOCK, QTY_SHELF_STOCK, AMOUNT_SHELF_STOCK, AMOUNT_REVALUATE, QTY_RECIEVED, AMOUNT_RECIEVED, QTY_SOLD, AMOUNT_SOLD, AMOUNT_SOLD_EXCL, COSTPRICE_SOLD, QTY_CHANGE, AMOUNT_CHANGE, QTY_TRANSIT, AMOUNT_TRANSIT, QTY_PO, AMOUNT_PO, QTY_PO_COMPLETE, AMOUNT_PO_COMPLETE, QTY_MINIMUM_STOCK, AMOUNT_MINIMUM_STOCK, QTY_CONSIGNMENT, AMOUNT_CONSIGNMENT, COSTPRICE_CONSIGNMENT, } = transactionVector;
35
+ /**
36
+ *
37
+ * Build a BI transaction object
38
+ *
39
+ * Populate appropriate fields in vector based on the type of transaction
40
+ */
41
+ const buildTransaction = function (transaction) {
42
+ if (!Object.values(types_1.transactionTypeE).includes(transaction.type))
43
+ return undefined;
44
+ const dbTransaction = {
45
+ type: transaction.type,
46
+ ean: transaction.ean,
47
+ wh: transaction.wh,
48
+ docnr: transaction.docnr,
49
+ time: transaction.time,
50
+ vector: [],
51
+ };
52
+ if (transaction.customer)
53
+ dbTransaction.customer = transaction.customer;
54
+ if (transaction.agent)
55
+ dbTransaction.agent = transaction.agent;
56
+ if (transaction.type == types_1.transactionTypeE.RECEIVING) {
57
+ const vector = new Array(AMOUNT_RECIEVED + 1);
58
+ vector.fill(0);
59
+ vector[QTY_TRANSACTION] = transaction.qty;
60
+ vector[QTY_STOCK] = transaction.qty;
61
+ vector[AMOUNT_STOCK] = (0, index_1.round2)(transaction.buyprice * transaction.qty);
62
+ vector[QTY_SHELF_STOCK] = transaction.qty;
63
+ vector[AMOUNT_SHELF_STOCK] = (0, index_1.round2)(transaction.buyprice * transaction.qty);
64
+ vector[QTY_RECIEVED] = transaction.qty;
65
+ vector[AMOUNT_RECIEVED] = (0, index_1.round2)(transaction.buyprice * transaction.qty);
66
+ dbTransaction.vector = vector;
67
+ return dbTransaction;
68
+ }
69
+ if (transaction.type == types_1.transactionTypeE.SALE) {
70
+ const vector = new Array(COSTPRICE_SOLD + 1);
71
+ vector.fill(0);
72
+ vector[QTY_TRANSACTION] = transaction.qty;
73
+ vector[QTY_STOCK] = -transaction.qty;
74
+ vector[AMOUNT_STOCK] = (0, index_1.round2)(-transaction.buyprice * transaction.qty);
75
+ vector[QTY_SHELF_STOCK] = -transaction.qty;
76
+ vector[AMOUNT_SHELF_STOCK] = (0, index_1.round2)(-transaction.buyprice * transaction.qty);
77
+ vector[QTY_SOLD] = transaction.qty;
78
+ vector[AMOUNT_SOLD] = (0, index_1.round2)(transaction.sellprice * transaction.qty);
79
+ vector[AMOUNT_SOLD_EXCL] = (0, index_1.round2)((transaction.sellprice / ((100 + (transaction.vat || 0)) / 100)) * transaction.qty);
80
+ vector[COSTPRICE_SOLD] = (0, index_1.round2)(transaction.buyprice * transaction.qty);
81
+ dbTransaction.vector = vector;
82
+ return dbTransaction;
83
+ }
84
+ if (transaction.type == types_1.transactionTypeE.TRANSIT) {
85
+ const vector = new Array(AMOUNT_TRANSIT + 1);
86
+ vector.fill(0);
87
+ vector[QTY_TRANSACTION] = transaction.qty;
88
+ vector[QTY_STOCK] = transaction.qty;
89
+ vector[AMOUNT_STOCK] = (0, index_1.round2)(transaction.buyprice * transaction.qty);
90
+ vector[QTY_SHELF_STOCK] = transaction.qty;
91
+ vector[AMOUNT_SHELF_STOCK] = (0, index_1.round2)(transaction.buyprice * transaction.qty);
92
+ vector[QTY_TRANSIT] = transaction.qty;
93
+ vector[AMOUNT_TRANSIT] = (0, index_1.round2)(transaction.buyprice * transaction.qty);
94
+ dbTransaction.vector = vector;
95
+ return dbTransaction;
96
+ }
97
+ if (transaction.type == types_1.transactionTypeE.CHANGE || transaction.type == types_1.transactionTypeE.START_STOCK) {
98
+ const vector = new Array(AMOUNT_CHANGE + 1);
99
+ vector.fill(0);
100
+ vector[QTY_TRANSACTION] = transaction.qty;
101
+ vector[QTY_STOCK] = transaction.qty;
102
+ vector[AMOUNT_STOCK] = (0, index_1.round2)(transaction.buyprice * transaction.qty);
103
+ vector[QTY_SHELF_STOCK] = transaction.qty;
104
+ vector[AMOUNT_SHELF_STOCK] = (0, index_1.round2)(transaction.buyprice * transaction.qty);
105
+ vector[QTY_CHANGE] = transaction.qty;
106
+ vector[AMOUNT_CHANGE] = (0, index_1.round2)(transaction.buyprice * transaction.qty);
107
+ dbTransaction.vector = vector;
108
+ return dbTransaction;
109
+ }
110
+ if (transaction.type == types_1.transactionTypeE.RE_VALUATION) {
111
+ const vector = new Array(AMOUNT_REVALUATE + 1);
112
+ vector.fill(0);
113
+ vector[QTY_TRANSACTION] = transaction.qty;
114
+ vector[AMOUNT_STOCK] = (0, index_1.round2)(transaction.buyprice * transaction.qty);
115
+ vector[AMOUNT_SHELF_STOCK] = (0, index_1.round2)(transaction.buyprice * transaction.qty);
116
+ vector[AMOUNT_REVALUATE] = (0, index_1.round2)(transaction.buyprice * transaction.qty);
117
+ dbTransaction.vector = vector;
118
+ return dbTransaction;
119
+ }
120
+ if (transaction.type == types_1.transactionTypeE.START_SHELF_STOCK) {
121
+ dbTransaction.type = types_1.transactionTypeE.START_STOCK;
122
+ const vector = new Array(AMOUNT_SHELF_STOCK + 1);
123
+ vector.fill(0);
124
+ vector[QTY_TRANSACTION] = transaction.qty;
125
+ vector[QTY_SHELF_STOCK] = transaction.qty;
126
+ vector[AMOUNT_SHELF_STOCK] = (0, index_1.round2)(transaction.buyprice * transaction.qty);
127
+ dbTransaction.vector = vector;
128
+ return dbTransaction;
129
+ }
130
+ if (transaction.type == types_1.transactionTypeE.PURCHASE_ORDER) {
131
+ const vector = new Array(AMOUNT_PO + 1);
132
+ vector.fill(0);
133
+ vector[QTY_TRANSACTION] = transaction.qty;
134
+ vector[QTY_PO] = transaction.qty;
135
+ vector[AMOUNT_PO] = (0, index_1.round2)(transaction.buyprice * transaction.qty);
136
+ dbTransaction.vector = vector;
137
+ return dbTransaction;
138
+ }
139
+ if (transaction.type == types_1.transactionTypeE.PURCHASE_ORDER_COMPLETE) {
140
+ const vector = new Array(AMOUNT_PO_COMPLETE + 1);
141
+ vector.fill(0);
142
+ vector[QTY_TRANSACTION] = transaction.qty;
143
+ vector[QTY_PO_COMPLETE] = transaction.qty;
144
+ vector[AMOUNT_PO_COMPLETE] = (0, index_1.round2)(transaction.buyprice * transaction.qty);
145
+ dbTransaction.vector = vector;
146
+ return dbTransaction;
147
+ }
148
+ if (transaction.type == types_1.transactionTypeE.MINIMUM_STOCK) {
149
+ const vector = new Array(AMOUNT_MINIMUM_STOCK + 1);
150
+ vector.fill(0);
151
+ vector[QTY_TRANSACTION] = transaction.qty;
152
+ vector[QTY_MINIMUM_STOCK] = transaction.qty;
153
+ vector[AMOUNT_MINIMUM_STOCK] = (0, index_1.round2)(transaction.buyprice * transaction.qty);
154
+ dbTransaction.vector = vector;
155
+ return dbTransaction;
156
+ }
157
+ return undefined;
158
+ };
159
+ exports.default = { transactionVector, buildTransaction };
160
+ /**
161
+ TODO:
162
+
163
+ FOXPRO CODE STILL TO CONVERT FOR WHOLESALE
164
+
165
+ CASE _trtype == 96 && TRANSACTION_ORDER
166
+ replace ;
167
+ n_ordered with qty, ;
168
+ a_ordered with qty* _price, ;
169
+ c_ordered with qty* _cost
170
+ CASE _trtype == 93 && TRANSACTION_PRESOLD
171
+ replace ;
172
+ n_stock with -qty, ;
173
+ a_stock with -qty* _cost, ;
174
+ n_sstock with -qty, ;
175
+ a_sstock with -qty* _cost, ;
176
+ n_presold with qty, ;
177
+ a_presold with qty* _price,;
178
+ c_presold with qty* _cost
179
+ CASE _trtype == 97 && TRANSACTION_PREORDER
180
+ replace ;
181
+ n_preord with qty, ;
182
+ a_preord with qty* _price, ;
183
+ c_preord with qty* _cost
184
+ CASE _trtype == 94 && TRANSACTION_PICKLIST
185
+ replace ;
186
+ n_sstock with -qty, ;
187
+ a_sstock with -qty* _cost, ;
188
+ n_picked with qty, ;
189
+ a_picked with qty* _price, ;
190
+ c_picked with qty* _cost
191
+ CASE _trtype == 95 && TRANSACTION_PREPICKLIST
192
+ replace ;
193
+ n_sstock with -qty, ;
194
+ a_sstock with -qty* _cost, ;
195
+ n_prepick with qty, ;
196
+ a_prepick with qty* _price, ;
197
+ c_prepick with qty* _cost
198
+ CASE _trtype == 5 && TRANSACTION_RETURN_SUPPLIER
199
+ replace ;
200
+ n_stock with -qty, ;
201
+ a_stock with -qty* _cost, ;
202
+ n_sstock with -qty, ;
203
+ a_sstock with -qty* _cost, ;
204
+ n_recieved with -qty, ;
205
+ a_recieved with -qty* _cost
206
+ CASE _trtype == 6 && TRANSACTION_RETURN_CUSTOMER [C ]
207
+ replace ;
208
+ n_stock with qty, ;
209
+ a_stock with qty* _cost, ;
210
+ n_sstock with qty, ;
211
+ a_sstock with qty* _cost, ;
212
+ n_return with qty, ;
213
+ a_return with qty* _price, ;
214
+ c_return with qty* _cost
215
+
216
+ CASE _trtype == 7 && TRANSACTION_CREDIT [CK]
217
+ replace ;
218
+ a_return with qty* _price
219
+ */
package/dist/types.d.ts CHANGED
@@ -162,6 +162,7 @@ interface ColorI {
162
162
  interface ProductI {
163
163
  ATTRIBUTES: object;
164
164
  COLORS: Array<ColorI>;
165
+ DUPLICATES?: unknown;
165
166
  IMAGES?: unknown;
166
167
  INDEX: object;
167
168
  MATRIX?: MatrixI;
@@ -225,4 +226,48 @@ declare enum mappingStrategyE {
225
226
  CLEAN = "clean",
226
227
  MARK = "markMissingMapping"
227
228
  }
228
- export { RowI, StockTransferSelectionI, MarkedSkuI, vatCategoryE, tagTypeE, SkuI, GroupI, ProductI, ImageI, AttributeI, ColorI, MatrixI, StockTransferDataI, StockTransferMatrixI, BrandSettingI, mappingStrategyE, subscriptionE, };
229
+ declare enum transactionTypeE {
230
+ START_STOCK = "0",
231
+ RECEIVING = "1",
232
+ SALE = "2",
233
+ TRANSIT = "3",
234
+ CHANGE = "4",
235
+ RETURN_SUPPLIER = "5",
236
+ RETURN_CUSTOMER = "6",
237
+ CREDIT_INVOICE = "7",
238
+ RE_VALUATION = "8",
239
+ START_SHELF_STOCK = "10",
240
+ PURCHASE_ORDER = "14",
241
+ PURCHASE_ORDER_COMPLETE = "15",
242
+ MINIMUM_STOCK = "18",
243
+ PRE_SOLD = "93",
244
+ PICK_LIST = "94",
245
+ PRE_PICK_LIST = "95",
246
+ ORDER = "96",
247
+ PRE_ORDER = "97",
248
+ OFFER = "98"
249
+ }
250
+ interface dbTransactionI {
251
+ type: transactionTypeE;
252
+ ean: string;
253
+ wh: string;
254
+ agent?: string;
255
+ customer?: string;
256
+ docnr: string;
257
+ time: number;
258
+ vector: number[];
259
+ }
260
+ interface TransactionI {
261
+ type: transactionTypeE;
262
+ ean: string;
263
+ wh: string;
264
+ agent?: string;
265
+ customer?: string;
266
+ docnr: string;
267
+ time: number;
268
+ qty: number;
269
+ sellprice: number;
270
+ vat?: number;
271
+ buyprice: number;
272
+ }
273
+ export { RowI, StockTransferSelectionI, MarkedSkuI, vatCategoryE, tagTypeE, SkuI, GroupI, ProductI, ImageI, AttributeI, ColorI, MatrixI, StockTransferDataI, StockTransferMatrixI, BrandSettingI, mappingStrategyE, subscriptionE, dbTransactionI, TransactionI, transactionTypeE, };
package/dist/types.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.subscriptionE = exports.mappingStrategyE = exports.tagTypeE = exports.vatCategoryE = void 0;
3
+ exports.transactionTypeE = exports.subscriptionE = exports.mappingStrategyE = exports.tagTypeE = exports.vatCategoryE = void 0;
4
4
  var subscriptionE;
5
5
  (function (subscriptionE) {
6
6
  subscriptionE["DATA_ONLY"] = "data_only";
@@ -31,3 +31,26 @@ var mappingStrategyE;
31
31
  mappingStrategyE["MARK"] = "markMissingMapping";
32
32
  })(mappingStrategyE || (mappingStrategyE = {}));
33
33
  exports.mappingStrategyE = mappingStrategyE;
34
+ var transactionTypeE;
35
+ (function (transactionTypeE) {
36
+ transactionTypeE["START_STOCK"] = "0";
37
+ transactionTypeE["RECEIVING"] = "1";
38
+ transactionTypeE["SALE"] = "2";
39
+ transactionTypeE["TRANSIT"] = "3";
40
+ transactionTypeE["CHANGE"] = "4";
41
+ transactionTypeE["RETURN_SUPPLIER"] = "5";
42
+ transactionTypeE["RETURN_CUSTOMER"] = "6";
43
+ transactionTypeE["CREDIT_INVOICE"] = "7";
44
+ transactionTypeE["RE_VALUATION"] = "8";
45
+ transactionTypeE["START_SHELF_STOCK"] = "10";
46
+ transactionTypeE["PURCHASE_ORDER"] = "14";
47
+ transactionTypeE["PURCHASE_ORDER_COMPLETE"] = "15";
48
+ transactionTypeE["MINIMUM_STOCK"] = "18";
49
+ transactionTypeE["PRE_SOLD"] = "93";
50
+ transactionTypeE["PICK_LIST"] = "94";
51
+ transactionTypeE["PRE_PICK_LIST"] = "95";
52
+ transactionTypeE["ORDER"] = "96";
53
+ transactionTypeE["PRE_ORDER"] = "97";
54
+ transactionTypeE["OFFER"] = "98";
55
+ })(transactionTypeE || (transactionTypeE = {}));
56
+ exports.transactionTypeE = transactionTypeE;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softwear/latestcollectioncore",
3
- "version": "1.0.74",
3
+ "version": "1.0.76",
4
4
  "description": "Core functions for LatestCollections applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -7,5 +7,7 @@ export { default as hashBrand } from './hashBrand'
7
7
  export { default as hasOnlyDigits } from './hasOnlyDigits'
8
8
  export { default as sizeToMap } from './sizeToMap'
9
9
  export { default as findSkuByBarcode } from './findSkuByBarcode'
10
+ export { default as round2 } from './round2'
11
+ export { default as transaction } from './transaction'
10
12
  export * from './types'
11
13
  export * from './consts'
package/src/round2.ts ADDED
@@ -0,0 +1,7 @@
1
+ export default function (value: string | number): number {
2
+ const type = typeof value
3
+ if (type != 'string' && type != 'number') return 0
4
+
5
+ if (typeof value == 'string') value = parseFloat(value)
6
+ return Math.round((value + Number.EPSILON) * 100) / 100
7
+ }
@@ -0,0 +1,254 @@
1
+ import { dbTransactionI, TransactionI, transactionTypeE } from './types'
2
+ import { round2 } from './index'
3
+
4
+ // fields in Vector
5
+ const transactionVector = {
6
+ QTY_TRANSACTION: 0,
7
+ QTY_STOCK: 1,
8
+ AMOUNT_STOCK: 2,
9
+ QTY_SHELF_STOCK: 3,
10
+ AMOUNT_SHELF_STOCK: 4,
11
+ AMOUNT_REVALUATE: 5,
12
+ QTY_RECIEVED: 6,
13
+ AMOUNT_RECIEVED: 7,
14
+ QTY_SOLD: 8,
15
+ AMOUNT_SOLD: 9,
16
+ AMOUNT_SOLD_EXCL: 10,
17
+ COSTPRICE_SOLD: 11,
18
+ QTY_CHANGE: 12,
19
+ AMOUNT_CHANGE: 13,
20
+ QTY_TRANSIT: 14,
21
+ AMOUNT_TRANSIT: 15,
22
+ QTY_PO: 16,
23
+ AMOUNT_PO: 17,
24
+ QTY_PO_COMPLETE: 18,
25
+ AMOUNT_PO_COMPLETE: 19,
26
+ QTY_MINIMUM_STOCK: 20,
27
+ AMOUNT_MINIMUM_STOCK: 21,
28
+ QTY_CONSIGNMENT: 22,
29
+ AMOUNT_CONSIGNMENT: 23,
30
+ COSTPRICE_CONSIGNMENT: 24,
31
+ }
32
+ // destructure constants for ease of use locally in this file
33
+ const {
34
+ QTY_TRANSACTION,
35
+ QTY_STOCK,
36
+ AMOUNT_STOCK,
37
+ QTY_SHELF_STOCK,
38
+ AMOUNT_SHELF_STOCK,
39
+ AMOUNT_REVALUATE,
40
+ QTY_RECIEVED,
41
+ AMOUNT_RECIEVED,
42
+ QTY_SOLD,
43
+ AMOUNT_SOLD,
44
+ AMOUNT_SOLD_EXCL,
45
+ COSTPRICE_SOLD,
46
+ QTY_CHANGE,
47
+ AMOUNT_CHANGE,
48
+ QTY_TRANSIT,
49
+ AMOUNT_TRANSIT,
50
+ QTY_PO,
51
+ AMOUNT_PO,
52
+ QTY_PO_COMPLETE,
53
+ AMOUNT_PO_COMPLETE,
54
+ QTY_MINIMUM_STOCK,
55
+ AMOUNT_MINIMUM_STOCK,
56
+ QTY_CONSIGNMENT,
57
+ AMOUNT_CONSIGNMENT,
58
+ COSTPRICE_CONSIGNMENT,
59
+ } = transactionVector
60
+
61
+ /**
62
+ *
63
+ * Build a BI transaction object
64
+ *
65
+ * Populate appropriate fields in vector based on the type of transaction
66
+ */
67
+ const buildTransaction = function (transaction: TransactionI): dbTransactionI | undefined {
68
+ if (!Object.values(transactionTypeE).includes(transaction.type)) return undefined
69
+ const dbTransaction: dbTransactionI = {
70
+ type: transaction.type,
71
+ ean: transaction.ean,
72
+ wh: transaction.wh,
73
+ docnr: transaction.docnr,
74
+ time: transaction.time,
75
+ vector: [],
76
+ }
77
+ if (transaction.customer) dbTransaction.customer = transaction.customer
78
+ if (transaction.agent) dbTransaction.agent = transaction.agent
79
+
80
+ if (transaction.type == transactionTypeE.RECEIVING) {
81
+ const vector = new Array(AMOUNT_RECIEVED + 1)
82
+ vector.fill(0)
83
+ vector[QTY_TRANSACTION] = transaction.qty
84
+ vector[QTY_STOCK] = transaction.qty
85
+ vector[AMOUNT_STOCK] = round2(transaction.buyprice * transaction.qty)
86
+ vector[QTY_SHELF_STOCK] = transaction.qty
87
+ vector[AMOUNT_SHELF_STOCK] = round2(transaction.buyprice * transaction.qty)
88
+ vector[QTY_RECIEVED] = transaction.qty
89
+ vector[AMOUNT_RECIEVED] = round2(transaction.buyprice * transaction.qty)
90
+ dbTransaction.vector = vector
91
+ return dbTransaction
92
+ }
93
+
94
+ if (transaction.type == transactionTypeE.SALE) {
95
+ const vector = new Array(COSTPRICE_SOLD + 1)
96
+ vector.fill(0)
97
+ vector[QTY_TRANSACTION] = transaction.qty
98
+ vector[QTY_STOCK] = -transaction.qty
99
+ vector[AMOUNT_STOCK] = round2(-transaction.buyprice * transaction.qty)
100
+ vector[QTY_SHELF_STOCK] = -transaction.qty
101
+ vector[AMOUNT_SHELF_STOCK] = round2(-transaction.buyprice * transaction.qty)
102
+ vector[QTY_SOLD] = transaction.qty
103
+ vector[AMOUNT_SOLD] = round2(transaction.sellprice * transaction.qty)
104
+ vector[AMOUNT_SOLD_EXCL] = round2((transaction.sellprice / ((100 + (transaction.vat || 0)) / 100)) * transaction.qty)
105
+ vector[COSTPRICE_SOLD] = round2(transaction.buyprice * transaction.qty)
106
+ dbTransaction.vector = vector
107
+ return dbTransaction
108
+ }
109
+
110
+ if (transaction.type == transactionTypeE.TRANSIT) {
111
+ const vector = new Array(AMOUNT_TRANSIT + 1)
112
+ vector.fill(0)
113
+ vector[QTY_TRANSACTION] = transaction.qty
114
+ vector[QTY_STOCK] = transaction.qty
115
+ vector[AMOUNT_STOCK] = round2(transaction.buyprice * transaction.qty)
116
+ vector[QTY_SHELF_STOCK] = transaction.qty
117
+ vector[AMOUNT_SHELF_STOCK] = round2(transaction.buyprice * transaction.qty)
118
+ vector[QTY_TRANSIT] = transaction.qty
119
+ vector[AMOUNT_TRANSIT] = round2(transaction.buyprice * transaction.qty)
120
+ dbTransaction.vector = vector
121
+ return dbTransaction
122
+ }
123
+
124
+ if (transaction.type == transactionTypeE.CHANGE || transaction.type == transactionTypeE.START_STOCK) {
125
+ const vector = new Array(AMOUNT_CHANGE + 1)
126
+ vector.fill(0)
127
+ vector[QTY_TRANSACTION] = transaction.qty
128
+ vector[QTY_STOCK] = transaction.qty
129
+ vector[AMOUNT_STOCK] = round2(transaction.buyprice * transaction.qty)
130
+ vector[QTY_SHELF_STOCK] = transaction.qty
131
+ vector[AMOUNT_SHELF_STOCK] = round2(transaction.buyprice * transaction.qty)
132
+ vector[QTY_CHANGE] = transaction.qty
133
+ vector[AMOUNT_CHANGE] = round2(transaction.buyprice * transaction.qty)
134
+ dbTransaction.vector = vector
135
+ return dbTransaction
136
+ }
137
+
138
+ if (transaction.type == transactionTypeE.RE_VALUATION) {
139
+ const vector = new Array(AMOUNT_REVALUATE + 1)
140
+ vector.fill(0)
141
+ vector[QTY_TRANSACTION] = transaction.qty
142
+ vector[AMOUNT_STOCK] = round2(transaction.buyprice * transaction.qty)
143
+ vector[AMOUNT_SHELF_STOCK] = round2(transaction.buyprice * transaction.qty)
144
+ vector[AMOUNT_REVALUATE] = round2(transaction.buyprice * transaction.qty)
145
+ dbTransaction.vector = vector
146
+ return dbTransaction
147
+ }
148
+
149
+ if (transaction.type == transactionTypeE.START_SHELF_STOCK) {
150
+ dbTransaction.type = transactionTypeE.START_STOCK
151
+
152
+ const vector = new Array(AMOUNT_SHELF_STOCK + 1)
153
+ vector.fill(0)
154
+ vector[QTY_TRANSACTION] = transaction.qty
155
+ vector[QTY_SHELF_STOCK] = transaction.qty
156
+ vector[AMOUNT_SHELF_STOCK] = round2(transaction.buyprice * transaction.qty)
157
+ dbTransaction.vector = vector
158
+ return dbTransaction
159
+ }
160
+
161
+ if (transaction.type == transactionTypeE.PURCHASE_ORDER) {
162
+ const vector = new Array(AMOUNT_PO + 1)
163
+ vector.fill(0)
164
+ vector[QTY_TRANSACTION] = transaction.qty
165
+ vector[QTY_PO] = transaction.qty
166
+ vector[AMOUNT_PO] = round2(transaction.buyprice * transaction.qty)
167
+ dbTransaction.vector = vector
168
+ return dbTransaction
169
+ }
170
+
171
+ if (transaction.type == transactionTypeE.PURCHASE_ORDER_COMPLETE) {
172
+ const vector = new Array(AMOUNT_PO_COMPLETE + 1)
173
+ vector.fill(0)
174
+ vector[QTY_TRANSACTION] = transaction.qty
175
+ vector[QTY_PO_COMPLETE] = transaction.qty
176
+ vector[AMOUNT_PO_COMPLETE] = round2(transaction.buyprice * transaction.qty)
177
+ dbTransaction.vector = vector
178
+ return dbTransaction
179
+ }
180
+
181
+ if (transaction.type == transactionTypeE.MINIMUM_STOCK) {
182
+ const vector = new Array(AMOUNT_MINIMUM_STOCK + 1)
183
+ vector.fill(0)
184
+ vector[QTY_TRANSACTION] = transaction.qty
185
+ vector[QTY_MINIMUM_STOCK] = transaction.qty
186
+ vector[AMOUNT_MINIMUM_STOCK] = round2(transaction.buyprice * transaction.qty)
187
+ dbTransaction.vector = vector
188
+ return dbTransaction
189
+ }
190
+
191
+ return undefined
192
+ }
193
+ export default { transactionVector, buildTransaction }
194
+
195
+ /**
196
+ TODO:
197
+
198
+ FOXPRO CODE STILL TO CONVERT FOR WHOLESALE
199
+
200
+ CASE _trtype == 96 && TRANSACTION_ORDER
201
+ replace ;
202
+ n_ordered with qty, ;
203
+ a_ordered with qty* _price, ;
204
+ c_ordered with qty* _cost
205
+ CASE _trtype == 93 && TRANSACTION_PRESOLD
206
+ replace ;
207
+ n_stock with -qty, ;
208
+ a_stock with -qty* _cost, ;
209
+ n_sstock with -qty, ;
210
+ a_sstock with -qty* _cost, ;
211
+ n_presold with qty, ;
212
+ a_presold with qty* _price,;
213
+ c_presold with qty* _cost
214
+ CASE _trtype == 97 && TRANSACTION_PREORDER
215
+ replace ;
216
+ n_preord with qty, ;
217
+ a_preord with qty* _price, ;
218
+ c_preord with qty* _cost
219
+ CASE _trtype == 94 && TRANSACTION_PICKLIST
220
+ replace ;
221
+ n_sstock with -qty, ;
222
+ a_sstock with -qty* _cost, ;
223
+ n_picked with qty, ;
224
+ a_picked with qty* _price, ;
225
+ c_picked with qty* _cost
226
+ CASE _trtype == 95 && TRANSACTION_PREPICKLIST
227
+ replace ;
228
+ n_sstock with -qty, ;
229
+ a_sstock with -qty* _cost, ;
230
+ n_prepick with qty, ;
231
+ a_prepick with qty* _price, ;
232
+ c_prepick with qty* _cost
233
+ CASE _trtype == 5 && TRANSACTION_RETURN_SUPPLIER
234
+ replace ;
235
+ n_stock with -qty, ;
236
+ a_stock with -qty* _cost, ;
237
+ n_sstock with -qty, ;
238
+ a_sstock with -qty* _cost, ;
239
+ n_recieved with -qty, ;
240
+ a_recieved with -qty* _cost
241
+ CASE _trtype == 6 && TRANSACTION_RETURN_CUSTOMER [C ]
242
+ replace ;
243
+ n_stock with qty, ;
244
+ a_stock with qty* _cost, ;
245
+ n_sstock with qty, ;
246
+ a_sstock with qty* _cost, ;
247
+ n_return with qty, ;
248
+ a_return with qty* _price, ;
249
+ c_return with qty* _cost
250
+
251
+ CASE _trtype == 7 && TRANSACTION_CREDIT [CK]
252
+ replace ;
253
+ a_return with qty* _price
254
+ */
package/src/types.ts CHANGED
@@ -174,6 +174,7 @@ interface ColorI {
174
174
  interface ProductI {
175
175
  ATTRIBUTES: object
176
176
  COLORS: Array<ColorI>
177
+ DUPLICATES?: unknown
177
178
  IMAGES?: unknown
178
179
  INDEX: object
179
180
  MATRIX?: MatrixI
@@ -240,6 +241,51 @@ enum mappingStrategyE {
240
241
  MARK = 'markMissingMapping',
241
242
  }
242
243
 
244
+ enum transactionTypeE {
245
+ START_STOCK = '0',
246
+ RECEIVING = '1',
247
+ SALE = '2',
248
+ TRANSIT = '3',
249
+ CHANGE = '4',
250
+ RETURN_SUPPLIER = '5',
251
+ RETURN_CUSTOMER = '6',
252
+ CREDIT_INVOICE = '7',
253
+ RE_VALUATION = '8',
254
+ START_SHELF_STOCK = '10',
255
+ PURCHASE_ORDER = '14',
256
+ PURCHASE_ORDER_COMPLETE = '15',
257
+ MINIMUM_STOCK = '18',
258
+ PRE_SOLD = '93',
259
+ PICK_LIST = '94',
260
+ PRE_PICK_LIST = '95',
261
+ ORDER = '96',
262
+ PRE_ORDER = '97',
263
+ OFFER = '98',
264
+ }
265
+
266
+ interface dbTransactionI {
267
+ type: transactionTypeE
268
+ ean: string
269
+ wh: string
270
+ agent?: string
271
+ customer?: string
272
+ docnr: string
273
+ time: number
274
+ vector: number[]
275
+ }
276
+ interface TransactionI {
277
+ type: transactionTypeE
278
+ ean: string
279
+ wh: string
280
+ agent?: string
281
+ customer?: string
282
+ docnr: string
283
+ time: number
284
+ qty: number
285
+ sellprice: number
286
+ vat?: number
287
+ buyprice: number
288
+ }
243
289
  export {
244
290
  RowI,
245
291
  StockTransferSelectionI,
@@ -258,4 +304,7 @@ export {
258
304
  BrandSettingI,
259
305
  mappingStrategyE,
260
306
  subscriptionE,
307
+ dbTransactionI,
308
+ TransactionI,
309
+ transactionTypeE,
261
310
  }
@@ -0,0 +1,20 @@
1
+ const { round2 } = require('../dist/index')
2
+ const { expect } = require('chai')
3
+
4
+ describe('round2 function', function () {
5
+ it('should return a number rounded to two decimal places', function () {
6
+ expect(round2(3)).to.equal(3)
7
+ })
8
+ it('should return a number rounded to two decimal places', function () {
9
+ expect(round2(3.14159265359)).to.equal(3.14)
10
+ })
11
+ it('should return a number rounded to two decimal places', function () {
12
+ expect(round2('3.14159265359')).to.equal(3.14)
13
+ })
14
+ it('should return a 0 for illegal input', function () {
15
+ expect(round2(round2)).to.equal(0)
16
+ })
17
+ it('should return a 0 for illegal input', function () {
18
+ expect(round2(true)).to.equal(0)
19
+ })
20
+ })
@@ -0,0 +1,215 @@
1
+ const core = require('../dist/index')
2
+ const { expect } = require('chai')
3
+
4
+ const buildTransaction = core.transaction.buildTransaction
5
+ describe('#Transactionss', () => {
6
+ describe('#buildTransaction', () => {
7
+ it('should return undefined when called without parameters', () => {
8
+ const transaction = buildTransaction({})
9
+ expect(transaction).to.be.deep.equal(undefined)
10
+ })
11
+ it('should return undefined when called with and illegal type', () => {
12
+ const transaction = buildTransaction({ type: 666 })
13
+ expect(transaction).to.be.deep.equal(undefined)
14
+ })
15
+ it('should return correct transaction for a type 1 (=receiving) transaction', () => {
16
+ const transaction = buildTransaction({ type: '1', ean: '1234567890128', wh: '51', time: 314159265, qty: 123, sellprice: 0, buyprice: 9.95, vat: 21, docnr: 'REC-1' })
17
+ expect(transaction).to.be.deep.equal({
18
+ type: '1',
19
+ ean: '1234567890128',
20
+ wh: '51',
21
+ time: 314159265,
22
+ docnr: 'REC-1',
23
+ vector: [123, 123, 1223.85, 123, 1223.85, 0, 123, 1223.85],
24
+ })
25
+ })
26
+
27
+ it('should return correct transaction for a type 2 (=sale) transaction', () => {
28
+ const transaction = buildTransaction({
29
+ type: '2',
30
+ ean: '1234567890128',
31
+ wh: '51',
32
+ time: 314159265,
33
+ qty: 123,
34
+ customer: '123',
35
+ agent: '01',
36
+ sellprice: 19.95,
37
+ buyprice: 9.95,
38
+ vat: 21,
39
+ docnr: '51-123',
40
+ })
41
+ expect(transaction).to.be.deep.equal({
42
+ type: '2',
43
+ ean: '1234567890128',
44
+ wh: '51',
45
+ time: 314159265,
46
+ customer: '123',
47
+ agent: '01',
48
+ docnr: '51-123',
49
+ vector: [123, -123, -1223.85, -123, -1223.85, 0, 0, 0, 123, 2453.85, 2027.98, 123 * 9.95],
50
+ })
51
+ })
52
+ it('should return correct transaction for a type 3 (=transit) transaction', () => {
53
+ const transaction = buildTransaction({
54
+ type: '3',
55
+ ean: '1234567890128',
56
+ wh: '51',
57
+ time: 314159265,
58
+ qty: 123,
59
+ buyprice: 9.95,
60
+ vat: 21,
61
+ docnr: '51-123',
62
+ })
63
+ expect(transaction).to.be.deep.equal({
64
+ type: '3',
65
+ ean: '1234567890128',
66
+ wh: '51',
67
+ time: 314159265,
68
+ docnr: '51-123',
69
+ vector: [123, 123, 1223.85, 123, 1223.85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 9.95],
70
+ })
71
+ })
72
+ it('should return correct transaction for a type 4 (=change) transaction', () => {
73
+ const transaction = buildTransaction({
74
+ type: '4',
75
+ ean: '1234567890128',
76
+ wh: '51',
77
+ time: 314159265,
78
+ qty: 123,
79
+ buyprice: 9.95,
80
+ vat: 21,
81
+ docnr: '51-123',
82
+ })
83
+ expect(transaction).to.be.deep.equal({
84
+ type: '4',
85
+ ean: '1234567890128',
86
+ wh: '51',
87
+ time: 314159265,
88
+ docnr: '51-123',
89
+ vector: [123, 123, 1223.85, 123, 1223.85, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 9.95],
90
+ })
91
+ })
92
+ it('should return correct transaction for a type 0 (=beginstock) transaction', () => {
93
+ const transaction = buildTransaction({
94
+ type: '0',
95
+ ean: '1234567890128',
96
+ wh: '51',
97
+ time: 314159265,
98
+ qty: 123,
99
+ buyprice: 9.95,
100
+ vat: 21,
101
+ docnr: '51-123',
102
+ })
103
+ expect(transaction).to.be.deep.equal({
104
+ type: '0',
105
+ ean: '1234567890128',
106
+ wh: '51',
107
+ time: 314159265,
108
+ docnr: '51-123',
109
+ vector: [123, 123, 1223.85, 123, 1223.85, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 9.95],
110
+ })
111
+ })
112
+ it('should return correct transaction for a type 8 (=revaluation) transaction', () => {
113
+ const transaction = buildTransaction({
114
+ type: '8',
115
+ ean: '1234567890128',
116
+ wh: '51',
117
+ time: 314159265,
118
+ qty: 123,
119
+ buyprice: 9.95,
120
+ vat: 21,
121
+ docnr: '51-123',
122
+ })
123
+ expect(transaction).to.be.deep.equal({
124
+ type: '8',
125
+ ean: '1234567890128',
126
+ wh: '51',
127
+ time: 314159265,
128
+ docnr: '51-123',
129
+ vector: [123, 0, 1223.85, 0, 1223.85, 123 * 9.95],
130
+ })
131
+ })
132
+ it('should return correct transaction for a type 10 (=start shelf stock) transaction', () => {
133
+ const transaction = buildTransaction({
134
+ type: '10',
135
+ ean: '1234567890128',
136
+ wh: '51',
137
+ time: 314159265,
138
+ qty: 123,
139
+ buyprice: 9.95,
140
+ vat: 21,
141
+ docnr: '51-123',
142
+ })
143
+ expect(transaction).to.be.deep.equal({
144
+ type: '0',
145
+ ean: '1234567890128',
146
+ wh: '51',
147
+ time: 314159265,
148
+ docnr: '51-123',
149
+ vector: [123, 0, 0, 123, 123 * 9.95],
150
+ })
151
+ })
152
+ it('should return correct transaction for a type 14 (=purchaseorder) transaction', () => {
153
+ const transaction = buildTransaction({
154
+ type: '14',
155
+ ean: '1234567890128',
156
+ wh: '51',
157
+ time: 314159265,
158
+ qty: 123,
159
+ buyprice: 9.95,
160
+ vat: 21,
161
+ docnr: '51-123',
162
+ })
163
+ expect(transaction).to.be.deep.equal({
164
+ type: '14',
165
+ ean: '1234567890128',
166
+ wh: '51',
167
+ time: 314159265,
168
+ docnr: '51-123',
169
+ vector: [123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 9.95],
170
+ })
171
+ })
172
+
173
+ it('should return correct transaction for a type 15 (=completed purchaseorder) transaction', () => {
174
+ const transaction = buildTransaction({
175
+ type: '15',
176
+ ean: '1234567890128',
177
+ wh: '51',
178
+ time: 314159265,
179
+ qty: 123,
180
+ buyprice: 9.95,
181
+ vat: 21,
182
+ docnr: '51-123',
183
+ })
184
+ expect(transaction).to.be.deep.equal({
185
+ type: '15',
186
+ ean: '1234567890128',
187
+ wh: '51',
188
+ time: 314159265,
189
+ docnr: '51-123',
190
+ vector: [123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 123 * 9.95],
191
+ })
192
+ })
193
+
194
+ it('should return correct transaction for a type 18 (=minimum stock) transaction', () => {
195
+ const transaction = buildTransaction({
196
+ type: '18',
197
+ ean: '1234567890128',
198
+ wh: '51',
199
+ time: 314159265,
200
+ qty: 123,
201
+ buyprice: 9.95,
202
+ vat: 21,
203
+ docnr: '51-123',
204
+ })
205
+ expect(transaction).to.be.deep.equal({
206
+ type: '18',
207
+ ean: '1234567890128',
208
+ wh: '51',
209
+ time: 314159265,
210
+ docnr: '51-123',
211
+ 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],
212
+ })
213
+ })
214
+ })
215
+ })