@softwear/latestcollectioncore 1.0.74 → 1.0.75
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 +2 -0
- package/dist/index.js +5 -1
- package/dist/round2.d.ts +1 -0
- package/dist/round2.js +11 -0
- package/dist/transaction.d.ts +92 -0
- package/dist/transaction.js +219 -0
- package/dist/types.d.ts +45 -1
- package/dist/types.js +24 -1
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/round2.ts +7 -0
- package/src/transaction.ts +254 -0
- package/src/types.ts +48 -0
- package/test/round2.spec.js +20 -0
- package/test/transaction.spec.js +215 -0
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);
|
package/dist/round2.d.ts
ADDED
|
@@ -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
|
@@ -225,4 +225,48 @@ declare enum mappingStrategyE {
|
|
|
225
225
|
CLEAN = "clean",
|
|
226
226
|
MARK = "markMissingMapping"
|
|
227
227
|
}
|
|
228
|
-
|
|
228
|
+
declare enum transactionTypeE {
|
|
229
|
+
START_STOCK = "0",
|
|
230
|
+
RECEIVING = "1",
|
|
231
|
+
SALE = "2",
|
|
232
|
+
TRANSIT = "3",
|
|
233
|
+
CHANGE = "4",
|
|
234
|
+
RETURN_SUPPLIER = "5",
|
|
235
|
+
RETURN_CUSTOMER = "6",
|
|
236
|
+
CREDIT_INVOICE = "7",
|
|
237
|
+
RE_VALUATION = "8",
|
|
238
|
+
START_SHELF_STOCK = "10",
|
|
239
|
+
PURCHASE_ORDER = "14",
|
|
240
|
+
PURCHASE_ORDER_COMPLETE = "15",
|
|
241
|
+
MINIMUM_STOCK = "18",
|
|
242
|
+
PRE_SOLD = "93",
|
|
243
|
+
PICK_LIST = "94",
|
|
244
|
+
PRE_PICK_LIST = "95",
|
|
245
|
+
ORDER = "96",
|
|
246
|
+
PRE_ORDER = "97",
|
|
247
|
+
OFFER = "98"
|
|
248
|
+
}
|
|
249
|
+
interface dbTransactionI {
|
|
250
|
+
type: transactionTypeE;
|
|
251
|
+
ean: string;
|
|
252
|
+
wh: string;
|
|
253
|
+
agent?: string;
|
|
254
|
+
customer?: string;
|
|
255
|
+
docnr: string;
|
|
256
|
+
time: number;
|
|
257
|
+
vector: number[];
|
|
258
|
+
}
|
|
259
|
+
interface TransactionI {
|
|
260
|
+
type: transactionTypeE;
|
|
261
|
+
ean: string;
|
|
262
|
+
wh: string;
|
|
263
|
+
agent?: string;
|
|
264
|
+
customer?: string;
|
|
265
|
+
docnr: string;
|
|
266
|
+
time: number;
|
|
267
|
+
qty: number;
|
|
268
|
+
sellprice: number;
|
|
269
|
+
vat?: number;
|
|
270
|
+
buyprice: number;
|
|
271
|
+
}
|
|
272
|
+
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
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,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
|
@@ -240,6 +240,51 @@ enum mappingStrategyE {
|
|
|
240
240
|
MARK = 'markMissingMapping',
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
+
enum transactionTypeE {
|
|
244
|
+
START_STOCK = '0',
|
|
245
|
+
RECEIVING = '1',
|
|
246
|
+
SALE = '2',
|
|
247
|
+
TRANSIT = '3',
|
|
248
|
+
CHANGE = '4',
|
|
249
|
+
RETURN_SUPPLIER = '5',
|
|
250
|
+
RETURN_CUSTOMER = '6',
|
|
251
|
+
CREDIT_INVOICE = '7',
|
|
252
|
+
RE_VALUATION = '8',
|
|
253
|
+
START_SHELF_STOCK = '10',
|
|
254
|
+
PURCHASE_ORDER = '14',
|
|
255
|
+
PURCHASE_ORDER_COMPLETE = '15',
|
|
256
|
+
MINIMUM_STOCK = '18',
|
|
257
|
+
PRE_SOLD = '93',
|
|
258
|
+
PICK_LIST = '94',
|
|
259
|
+
PRE_PICK_LIST = '95',
|
|
260
|
+
ORDER = '96',
|
|
261
|
+
PRE_ORDER = '97',
|
|
262
|
+
OFFER = '98',
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
interface dbTransactionI {
|
|
266
|
+
type: transactionTypeE
|
|
267
|
+
ean: string
|
|
268
|
+
wh: string
|
|
269
|
+
agent?: string
|
|
270
|
+
customer?: string
|
|
271
|
+
docnr: string
|
|
272
|
+
time: number
|
|
273
|
+
vector: number[]
|
|
274
|
+
}
|
|
275
|
+
interface TransactionI {
|
|
276
|
+
type: transactionTypeE
|
|
277
|
+
ean: string
|
|
278
|
+
wh: string
|
|
279
|
+
agent?: string
|
|
280
|
+
customer?: string
|
|
281
|
+
docnr: string
|
|
282
|
+
time: number
|
|
283
|
+
qty: number
|
|
284
|
+
sellprice: number
|
|
285
|
+
vat?: number
|
|
286
|
+
buyprice: number
|
|
287
|
+
}
|
|
243
288
|
export {
|
|
244
289
|
RowI,
|
|
245
290
|
StockTransferSelectionI,
|
|
@@ -258,4 +303,7 @@ export {
|
|
|
258
303
|
BrandSettingI,
|
|
259
304
|
mappingStrategyE,
|
|
260
305
|
subscriptionE,
|
|
306
|
+
dbTransactionI,
|
|
307
|
+
TransactionI,
|
|
308
|
+
transactionTypeE,
|
|
261
309
|
}
|
|
@@ -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
|
+
})
|