js-gei 1.0.0

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.
Files changed (71) hide show
  1. package/Evaluator/ExpresionLogicService.ts +669 -0
  2. package/Evaluator/Parser/AddLeadZerosParse.ts +70 -0
  3. package/Evaluator/Parser/AppearParse.ts +67 -0
  4. package/Evaluator/Parser/BaseParse.ts +93 -0
  5. package/Evaluator/Parser/CalcDateParse.ts +73 -0
  6. package/Evaluator/Parser/CheckParse.ts +99 -0
  7. package/Evaluator/Parser/CommaParser.ts +17 -0
  8. package/Evaluator/Parser/ConcatParse.ts +34 -0
  9. package/Evaluator/Parser/CountParse.ts +26 -0
  10. package/Evaluator/Parser/EmptyParse.ts +41 -0
  11. package/Evaluator/Parser/ExistParse.ts +69 -0
  12. package/Evaluator/Parser/IfParse.ts +388 -0
  13. package/Evaluator/Parser/IfStategment.ts +345 -0
  14. package/Evaluator/Parser/InDetailParse.ts +109 -0
  15. package/Evaluator/Parser/InListParse.ts +57 -0
  16. package/Evaluator/Parser/LiteralValueParse.ts +36 -0
  17. package/Evaluator/Parser/LogicalOperatorParse.ts +16 -0
  18. package/Evaluator/Parser/OnlyExpressionParse.ts +137 -0
  19. package/Evaluator/Parser/OperatorParse.ts +17 -0
  20. package/Evaluator/Parser/StartsParse.ts +36 -0
  21. package/Evaluator/Parser/SubstrParse.ts +110 -0
  22. package/Evaluator/Parser/SumParse.ts +15 -0
  23. package/Evaluator/Parser/ToNullParser.ts +0 -0
  24. package/Evaluator/Parser/TrimParse.ts +30 -0
  25. package/Evaluator/Parser/UpperLoverParse.ts +41 -0
  26. package/Evaluator/Parser/ValueFromObjParse.ts +37 -0
  27. package/Evaluator/Parser/ValueParse.ts +61 -0
  28. package/HelperSessionStorage.ts +13 -0
  29. package/Interfaces/SchemaStruct.ts +28 -0
  30. package/Library/jsonrpc-2.0.js +869 -0
  31. package/Structure/InvoiceObj.ts +691 -0
  32. package/Structure/RecordArray.ts +145 -0
  33. package/Structure/RecordSingle.ts +1076 -0
  34. package/Structure/TableLevel.ts +248 -0
  35. package/dist/Evaluator/ExpresionLogicService.js +505 -0
  36. package/dist/Evaluator/Parser/AddLeadZerosParse.js +55 -0
  37. package/dist/Evaluator/Parser/AppearParse.js +48 -0
  38. package/dist/Evaluator/Parser/BaseParse.js +89 -0
  39. package/dist/Evaluator/Parser/CalcDateParse.js +54 -0
  40. package/dist/Evaluator/Parser/CheckParse.js +80 -0
  41. package/dist/Evaluator/Parser/CommaParser.js +13 -0
  42. package/dist/Evaluator/Parser/ConcatParse.js +29 -0
  43. package/dist/Evaluator/Parser/CountParse.js +23 -0
  44. package/dist/Evaluator/Parser/EmptyParse.js +35 -0
  45. package/dist/Evaluator/Parser/ExistParse.js +57 -0
  46. package/dist/Evaluator/Parser/IfParse.js +296 -0
  47. package/dist/Evaluator/Parser/IfStategment.js +287 -0
  48. package/dist/Evaluator/Parser/InDetailParse.js +79 -0
  49. package/dist/Evaluator/Parser/InListParse.js +40 -0
  50. package/dist/Evaluator/Parser/LiteralValueParse.js +26 -0
  51. package/dist/Evaluator/Parser/LogicalOperatorParse.js +13 -0
  52. package/dist/Evaluator/Parser/OnlyExpressionParse.js +106 -0
  53. package/dist/Evaluator/Parser/OperatorParse.js +13 -0
  54. package/dist/Evaluator/Parser/StartsParse.js +30 -0
  55. package/dist/Evaluator/Parser/SubstrParse.js +83 -0
  56. package/dist/Evaluator/Parser/SumParse.js +13 -0
  57. package/dist/Evaluator/Parser/ToNullParser.js +1 -0
  58. package/dist/Evaluator/Parser/TrimParse.js +25 -0
  59. package/dist/Evaluator/Parser/UpperLoverParse.js +32 -0
  60. package/dist/Evaluator/Parser/ValueFromObjParse.js +29 -0
  61. package/dist/Evaluator/Parser/ValueParse.js +59 -0
  62. package/dist/HelperSessionStorage.js +12 -0
  63. package/dist/Interfaces/SchemaStruct.js +2 -0
  64. package/dist/Structure/InvoiceObj.js +610 -0
  65. package/dist/Structure/RecordArray.js +102 -0
  66. package/dist/Structure/RecordSingle.js +950 -0
  67. package/dist/Structure/TableLevel.js +162 -0
  68. package/dist/index.js +19 -0
  69. package/index.ts +20 -0
  70. package/package.json +20 -0
  71. package/tsconfig.json +103 -0
@@ -0,0 +1,505 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpresionLogicService = void 0;
4
+ const BaseParse_1 = require("./Parser/BaseParse");
5
+ const OnlyExpressionParse_1 = require("./Parser/OnlyExpressionParse");
6
+ const LiteralValueParse_1 = require("./Parser/LiteralValueParse");
7
+ const ValueFromObjParse_1 = require("./Parser/ValueFromObjParse");
8
+ const CommaParser_1 = require("./Parser/CommaParser");
9
+ const OperatorParse_1 = require("./Parser/OperatorParse");
10
+ const LogicalOperatorParse_1 = require("./Parser/LogicalOperatorParse");
11
+ const AddLeadZerosParse_1 = require("./Parser/AddLeadZerosParse");
12
+ const AppearParse_1 = require("./Parser/AppearParse");
13
+ const IfParse_1 = require("./Parser/IfParse");
14
+ const SumParse_1 = require("./Parser/SumParse");
15
+ const CalcDateParse_1 = require("./Parser/CalcDateParse");
16
+ const UpperLoverParse_1 = require("./Parser/UpperLoverParse");
17
+ const InListParse_1 = require("./Parser/InListParse");
18
+ const InDetailParse_1 = require("./Parser/InDetailParse");
19
+ const StartsParse_1 = require("./Parser/StartsParse");
20
+ const SubstrParse_1 = require("./Parser/SubstrParse");
21
+ const CountParse_1 = require("./Parser/CountParse");
22
+ const ExistParse_1 = require("./Parser/ExistParse");
23
+ const EmptyParse_1 = require("./Parser/EmptyParse");
24
+ const ConcatParse_1 = require("./Parser/ConcatParse");
25
+ const CheckParse_1 = require("./Parser/CheckParse");
26
+ const TrimParse_1 = require("./Parser/TrimParse");
27
+ const ValueParse_1 = require("./Parser/ValueParse");
28
+ class ExpresionLogicService {
29
+ constructor() { }
30
+ static GetExpressions(valueExpression, parrent) {
31
+ let _exprtessions = [];
32
+ var cursor = 0;
33
+ var currentLit = "";
34
+ while (valueExpression.length > 0) {
35
+ if (!this.HasFunctionInside(valueExpression) && valueExpression.indexOf(",") == -1) {
36
+ _exprtessions.push(new OnlyExpressionParse_1.OnlyExpressionParse(valueExpression));
37
+ break;
38
+ }
39
+ if (valueExpression.substring(cursor, cursor + 1) == "(") {
40
+ var index = this.FindEnd(valueExpression);
41
+ if (index == -1) {
42
+ throw "Unbalanced brackets!!!! Expression:" + valueExpression;
43
+ }
44
+ if (currentLit != "") {
45
+ _exprtessions.push(new LiteralValueParse_1.LiteralValueParse(currentLit));
46
+ currentLit = "";
47
+ }
48
+ _exprtessions.push(new OnlyExpressionParse_1.OnlyExpressionParse(valueExpression.substring(0, index + 1)));
49
+ if (index < valueExpression.length) {
50
+ valueExpression = valueExpression.substring(index + 1);
51
+ }
52
+ else {
53
+ valueExpression = "";
54
+ }
55
+ continue;
56
+ }
57
+ if (valueExpression.startsWith("N.%")) {
58
+ if (currentLit != "") {
59
+ _exprtessions.push(new LiteralValueParse_1.LiteralValueParse(currentLit));
60
+ currentLit = "";
61
+ }
62
+ var indexNext = valueExpression.substring(3).indexOf("%") + 1;
63
+ _exprtessions.push(new ValueFromObjParse_1.ValueFromObjParse(valueExpression.substring(2, indexNext + 3), true));
64
+ valueExpression = valueExpression.substring(indexNext + 3);
65
+ continue;
66
+ }
67
+ if (valueExpression.substring(0, 1) == "%") {
68
+ if (currentLit != "") {
69
+ _exprtessions.push(new LiteralValueParse_1.LiteralValueParse(currentLit));
70
+ currentLit = "";
71
+ }
72
+ var indexNext = valueExpression.substring(1).indexOf("%") + 1;
73
+ _exprtessions.push(new ValueFromObjParse_1.ValueFromObjParse(valueExpression.substring(0, indexNext + 1), false));
74
+ valueExpression = valueExpression.substring(indexNext + 1);
75
+ continue;
76
+ }
77
+ if (valueExpression.substring(cursor, cursor + 1) == ",") {
78
+ if (currentLit != "") {
79
+ _exprtessions.push(new OnlyExpressionParse_1.OnlyExpressionParse(currentLit));
80
+ currentLit = "";
81
+ }
82
+ _exprtessions.push(new CommaParser_1.CommaParser(valueExpression.substring(0, 1), ""));
83
+ if (1 < valueExpression.length) {
84
+ valueExpression = valueExpression.substring(1);
85
+ }
86
+ else {
87
+ valueExpression = "";
88
+ }
89
+ continue;
90
+ }
91
+ var br = false;
92
+ BaseParse_1.BaseParse.operators.forEach(o => {
93
+ if (valueExpression.startsWith(o)) {
94
+ if (currentLit != "") {
95
+ _exprtessions.push(new OnlyExpressionParse_1.OnlyExpressionParse(currentLit));
96
+ currentLit = "";
97
+ }
98
+ _exprtessions.push(new OperatorParse_1.OperatorParser(valueExpression.substring(0, o.length)));
99
+ valueExpression = valueExpression.substring(o.length);
100
+ br = true;
101
+ return;
102
+ }
103
+ });
104
+ if (br) {
105
+ continue;
106
+ }
107
+ for (let j = 0; j < BaseParse_1.BaseParse.logicaloperators.length; j++) {
108
+ let o = BaseParse_1.BaseParse.logicaloperators[j];
109
+ if (valueExpression.startsWith(o)) {
110
+ if (currentLit != "") {
111
+ _exprtessions.push(new OnlyExpressionParse_1.OnlyExpressionParse(currentLit));
112
+ currentLit = "";
113
+ }
114
+ _exprtessions.push(new LogicalOperatorParse_1.LogicalOperatorParser(valueExpression.substring(0, o.length)));
115
+ valueExpression = valueExpression.substring(o.length);
116
+ br = true;
117
+ break;
118
+ }
119
+ }
120
+ if (br) {
121
+ continue;
122
+ }
123
+ var foundFun = false;
124
+ let valueExpTemp = valueExpression.toLowerCase();
125
+ var supKeys = Object.keys(ExpresionLogicService._suportedFunctions);
126
+ for (let j = 0; j < supKeys.length; j++) {
127
+ let key = supKeys[j];
128
+ if (valueExpTemp.startsWith(key)) {
129
+ if (currentLit != "") {
130
+ _exprtessions.push(new OnlyExpressionParse_1.OnlyExpressionParse(currentLit));
131
+ currentLit = "";
132
+ }
133
+ var index = this.FindEnd(valueExpression);
134
+ if (index == -1) {
135
+ throw "Unbalanced brackets!!!! Expression:" + valueExpression;
136
+ }
137
+ let instance = Reflect.construct(ExpresionLogicService._suportedFunctions[key], [valueExpression.substring(0, index + 1), key]);
138
+ _exprtessions.push(instance);
139
+ if (index < valueExpression.length) {
140
+ valueExpression = valueExpression.substring(index + 1);
141
+ }
142
+ else {
143
+ valueExpression = "";
144
+ }
145
+ foundFun = true;
146
+ break;
147
+ }
148
+ }
149
+ if (foundFun) {
150
+ continue;
151
+ }
152
+ currentLit += valueExpression.substring(0, 1);
153
+ valueExpression = valueExpression.substring(1);
154
+ }
155
+ if (currentLit != "") {
156
+ _exprtessions.push(new OnlyExpressionParse_1.OnlyExpressionParse(currentLit));
157
+ currentLit = "";
158
+ }
159
+ return _exprtessions;
160
+ }
161
+ static HasFunctionInside(valueExp) {
162
+ if (valueExp == null || valueExp == "") {
163
+ return false;
164
+ }
165
+ var founded = false;
166
+ const valueExpTemp = valueExp.toLowerCase();
167
+ Object.keys(ExpresionLogicService._suportedFunctions).forEach(element => {
168
+ if (valueExpTemp.indexOf(element) != -1) {
169
+ founded = true;
170
+ return;
171
+ }
172
+ });
173
+ return founded;
174
+ }
175
+ static StartsWithFunction(valueExp) {
176
+ const valueExpTemp = valueExp.toLowerCase();
177
+ var founded = false;
178
+ Object.keys(ExpresionLogicService._suportedFunctions).forEach(element => {
179
+ if (valueExpTemp.startsWith(element)) {
180
+ founded = true;
181
+ return;
182
+ }
183
+ });
184
+ return founded;
185
+ }
186
+ static FindEnd(expresion) {
187
+ var bC = 0;
188
+ var bO = 0;
189
+ for (var i = 0; i < expresion.length; i++) {
190
+ if (expresion.substring(i, i + 1) == "(") {
191
+ bO++;
192
+ }
193
+ else if (expresion.substring(i, i + 1) == ")") {
194
+ bC++;
195
+ }
196
+ if (bO > 0 && bO == bC) {
197
+ return i;
198
+ }
199
+ }
200
+ return -1;
201
+ }
202
+ static ConcatValues(t, obj, critm, record, item) {
203
+ if (t.length == 1) {
204
+ return t[0].Evaluate(obj, critm, record, item);
205
+ }
206
+ let sb = "";
207
+ for (let i = 0; i < t.length; i++) {
208
+ let value = t[i].Evaluate(obj, critm, record, item);
209
+ if (typeof value == "number") {
210
+ sb += value.toString();
211
+ }
212
+ else if (value instanceof Date) {
213
+ sb += value.toISOString();
214
+ }
215
+ else {
216
+ sb += value;
217
+ }
218
+ }
219
+ return sb;
220
+ }
221
+ static CastToTypeNet(item, value) {
222
+ let outptValue = null;
223
+ if (value == null) {
224
+ return null;
225
+ }
226
+ switch (item.TypeNET) {
227
+ case "decimal":
228
+ {
229
+ outptValue = parseFloat(value);
230
+ break;
231
+ }
232
+ case "int":
233
+ {
234
+ outptValue = parseInt(value);
235
+ break;
236
+ break;
237
+ }
238
+ case "bool":
239
+ {
240
+ if (this.toString().toLowerCase() == "true") {
241
+ outptValue == true;
242
+ }
243
+ else if (this.toString().toLowerCase() == "false") {
244
+ outptValue == false;
245
+ }
246
+ else {
247
+ outptValue = value;
248
+ }
249
+ break;
250
+ }
251
+ default:
252
+ {
253
+ outptValue = value;
254
+ break;
255
+ }
256
+ }
257
+ return outptValue;
258
+ }
259
+ static ParseAndFillExpression(valueExp, item, obj, citm, record, tryEvaluate, init) {
260
+ var value = ExpresionLogicService.ParseExpressionAndReturnValue(valueExp, obj, item, citm, 0);
261
+ console.log(item.FieldName + " " + item.ValueExpression + " " + value);
262
+ if (value != null) {
263
+ if ((tryEvaluate || item.TypeNET == "decimal" || item.TypeNET == "int")) {
264
+ try {
265
+ if (value == "0/0") {
266
+ citm.Record[item.FieldName] = 0;
267
+ return 0;
268
+ }
269
+ if (value == "*(-1)") {
270
+ return null;
271
+ }
272
+ var ret = eval(value);
273
+ console.log(item.FieldName + " " + item.ValueExpression + " RET: " + value);
274
+ return ret;
275
+ }
276
+ catch (ex) {
277
+ if (init) {
278
+ console.log(item.FieldName + " " + item.ValueExpression + " Err: " + 0);
279
+ return 0;
280
+ }
281
+ else {
282
+ var val = ExpresionLogicService.CastToTypeNet(item, value);
283
+ console.log(item.FieldName + " " + item.ValueExpression + " Err: " + val);
284
+ return val;
285
+ }
286
+ }
287
+ }
288
+ else {
289
+ var val = ExpresionLogicService.CastToTypeNet(item, value);
290
+ console.log(item.FieldName + " " + item.ValueExpression + " Ret: " + val);
291
+ return val;
292
+ }
293
+ }
294
+ else {
295
+ console.log(item.FieldName + " " + item.ValueExpression + " Value: " + value);
296
+ return value;
297
+ }
298
+ }
299
+ static ParseExpressionAndReturnValue(valueExp, obj, item, citm, level) {
300
+ var _a;
301
+ if (valueExp == null) {
302
+ return null;
303
+ }
304
+ let returned = null;
305
+ try {
306
+ returned = ExpresionLogicService.GetExpressions(valueExp, null);
307
+ }
308
+ catch (ec) {
309
+ debugger;
310
+ }
311
+ if (returned == null) {
312
+ return null;
313
+ }
314
+ if (!(returned[0] instanceof OnlyExpressionParse_1.OnlyExpressionParse)) {
315
+ }
316
+ var record = citm.Record;
317
+ let sb = "";
318
+ if (returned.length == 1) {
319
+ var value = returned[0].Evaluate(obj, citm, record, item);
320
+ if (value == null) {
321
+ return null;
322
+ }
323
+ if (value instanceof Date) {
324
+ if (item.TypeDDD == "Date") {
325
+ return BaseParse_1.BaseParse.getIsoDate(value);
326
+ }
327
+ else if (item.TypeDDD == "DateTime") {
328
+ return BaseParse_1.BaseParse.getIsoDateTime(value);
329
+ }
330
+ }
331
+ else if (typeof value == "number") {
332
+ return value.toString();
333
+ }
334
+ return value.toString();
335
+ ;
336
+ }
337
+ return (_a = ExpresionLogicService.ConcatValues(returned, obj, citm, record, item)) === null || _a === void 0 ? void 0 : _a.toString();
338
+ }
339
+ static ValueExpresion(item, valueExpression, obj, citm) {
340
+ var _a;
341
+ if (valueExpression == "null") {
342
+ return null;
343
+ }
344
+ if (!valueExpression.startsWith("%") && !valueExpression.endsWith("%")) {
345
+ return valueExpression;
346
+ }
347
+ let tabelAndKey = "";
348
+ try {
349
+ tabelAndKey = valueExpression.substring(1, valueExpression.length - 1);
350
+ }
351
+ catch (ex) {
352
+ if (item != null) {
353
+ throw item.FieldName + " " + item.ValueExpression + " Expression:" + valueExpression + ex;
354
+ }
355
+ throw valueExpression + ex;
356
+ }
357
+ var split = tabelAndKey.split(".");
358
+ var prefix = split[0];
359
+ switch (prefix) {
360
+ /*case "V":
361
+ {
362
+ return obj.GetValues(split[1]);
363
+ }
364
+ */
365
+ case "E":
366
+ {
367
+ /*const tableName = split[1];
368
+ const field = split[2];
369
+ if (tableName.toLowerCase()=="eu_aorg")
370
+ {
371
+ return obj.service.aboutOrganisation[field];
372
+ }
373
+ else if (tableName.toLowerCase()=="eu_scr")
374
+ {
375
+ return obj.service.aboutOrganisation["_countryRecord"][field];
376
+ }
377
+ else if (tableName.toLowerCase()=="session")
378
+ {
379
+ var startpath= obj.service.sessionInfo;
380
+
381
+ for (var i = 2; i < split.length; i++)
382
+ {
383
+ if(startpath[split[i]]!=null)
384
+ {
385
+ startpath=startpath[split[i]];
386
+ }
387
+ else
388
+ {
389
+ return null;
390
+ }
391
+ }
392
+ return startpath;
393
+ }
394
+
395
+ else
396
+ {
397
+ return "";
398
+ }*/
399
+ }
400
+ case "S":
401
+ {
402
+ /*if(obj.service.settings==null||obj.service.settings[split[1]]==null)
403
+ {
404
+ throw "Can't find setting for "+split[1];
405
+ }
406
+ var settingRecord=obj.service.settings[split[1]];
407
+ return settingRecord["Value"];
408
+ */
409
+ }
410
+ default:
411
+ {
412
+ if (split.length == 2) {
413
+ var table = split[0];
414
+ var key = split[1];
415
+ if (table == ((_a = citm === null || citm === void 0 ? void 0 : citm.Parent) === null || _a === void 0 ? void 0 : _a.Tablename)) {
416
+ var value1 = ExpresionLogicService.ReturnFromObject(citm.Record, key);
417
+ if (value1["found"] === true) {
418
+ return value1["return"];
419
+ }
420
+ }
421
+ var tableLevel = obj.FindTableLevel(table);
422
+ if (tableLevel != null) {
423
+ if (tableLevel.Record != null) {
424
+ var record = tableLevel.Record;
425
+ var value1 = ExpresionLogicService.ReturnFromObject(record.Record, key);
426
+ if (value1["found"] === true) {
427
+ return value1["return"];
428
+ }
429
+ if (value1["found"] === false && key == "InvIssueDate") {
430
+ return null;
431
+ }
432
+ if (value1["found"] === false && key.indexOf("__") != -1) {
433
+ var value2 = ExpresionLogicService.ReturnFromObject(record.Record, key);
434
+ if (value2["found"] === true) {
435
+ return value2["return"];
436
+ }
437
+ }
438
+ if (value2["found"] === false && key != "Mode") {
439
+ throw "Can't evaluate " + valueExpression + " key:" + item.FieldName + "";
440
+ }
441
+ return null;
442
+ }
443
+ else if (tableLevel.Records != null) {
444
+ var records = tableLevel.Records;
445
+ var candidates = records.Records.filter(x => x == citm);
446
+ if (candidates.length > 0) {
447
+ var recordC = candidates[0];
448
+ var recordA = recordC.Record;
449
+ var value1 = ExpresionLogicService.ReturnFromObject(recordA, key);
450
+ if (value1["found"] === true) {
451
+ return value1["return"];
452
+ }
453
+ if (value1["found"] === false && key.indexOf("__") != -1) {
454
+ var value2 = ExpresionLogicService.ReturnFromObject(recordC.Record, key);
455
+ if (value2["found"] === true) {
456
+ return value2["return"];
457
+ }
458
+ }
459
+ throw "Can't evaluate " + valueExpression + " key:" + item.FieldName;
460
+ }
461
+ }
462
+ }
463
+ }
464
+ break;
465
+ }
466
+ }
467
+ return null;
468
+ }
469
+ static ReturnFromObject(record, key) {
470
+ if (Object.keys(record).indexOf(key) == -1) {
471
+ return { "found": false, "return": null };
472
+ }
473
+ if (record[key] == null) {
474
+ return { "found": true, "return": null };
475
+ }
476
+ if (record[key] instanceof Date) {
477
+ return { "found": true, "return": record[key] };
478
+ }
479
+ return { "found": true, "return": record[key].toString() };
480
+ }
481
+ }
482
+ exports.ExpresionLogicService = ExpresionLogicService;
483
+ ExpresionLogicService._suportedFunctions = {
484
+ "sum(": SumParse_1.SumParse,
485
+ "if(": IfParse_1.IfParse,
486
+ "addleadzeros(": AddLeadZerosParse_1.AddLeadZerosParse,
487
+ "appear(": AppearParse_1.AppearParse,
488
+ "calcdate(": CalcDateParse_1.CalcDateParse,
489
+ "upper(": UpperLoverParse_1.UpperLowerParse,
490
+ "lower(": UpperLoverParse_1.UpperLowerParse,
491
+ "inlist(": InListParse_1.INListParser,
492
+ "notinlist(": InListParse_1.INListParser,
493
+ "indetail(": InDetailParse_1.InDetailParse,
494
+ "notindetail(": InDetailParse_1.InDetailParse,
495
+ "starts(": StartsParse_1.StartsParse,
496
+ "substr(": SubstrParse_1.SubstrParse,
497
+ "count(": CountParse_1.CountParse,
498
+ "check(": CheckParse_1.CheckParse,
499
+ "concat(": ConcatParse_1.ConcatParse,
500
+ "empty(": EmptyParse_1.EmptyParse,
501
+ "exists(": ExistParse_1.ExistParser,
502
+ "notexists(": ExistParse_1.ExistParser,
503
+ "trim(": TrimParse_1.TrimParse,
504
+ "value(": ValueParse_1.ValueParse,
505
+ };
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddLeadZerosParse = void 0;
4
+ const BaseParse_1 = require("./BaseParse");
5
+ const CommaParser_1 = require("./CommaParser");
6
+ const ExpresionLogicService_1 = require("../ExpresionLogicService");
7
+ class AddLeadZerosParse extends BaseParse_1.BaseParse {
8
+ constructor(valueExpression, funname) {
9
+ super(valueExpression, funname);
10
+ this.value = [];
11
+ this.numOfZeros = [];
12
+ var dd = ExpresionLogicService_1.ExpresionLogicService.GetExpressions(this.Expression, this);
13
+ if (dd == null) {
14
+ return;
15
+ }
16
+ var candidates = dd.filter(x => x instanceof CommaParser_1.CommaParser);
17
+ if (candidates.length == 0) {
18
+ throw "No comma in AddLeadZeros function";
19
+ }
20
+ let list = [];
21
+ dd.forEach(d => {
22
+ if (d instanceof CommaParser_1.CommaParser) {
23
+ this.value = list;
24
+ list = [];
25
+ }
26
+ else {
27
+ list.push(d);
28
+ }
29
+ });
30
+ this.numOfZeros = list;
31
+ }
32
+ Evaluate(obj, critm, record, item) {
33
+ var valueEval = ExpresionLogicService_1.ExpresionLogicService.ConcatValues(this.value, obj, critm, record, item);
34
+ var numOfZerosEval = ExpresionLogicService_1.ExpresionLogicService.ConcatValues(this.numOfZeros, obj, critm, record, item);
35
+ if (valueEval == null || numOfZerosEval == null) {
36
+ return null;
37
+ }
38
+ let length = -1;
39
+ if (typeof numOfZerosEval == "number") {
40
+ length = numOfZerosEval;
41
+ }
42
+ else if (typeof numOfZerosEval == "string") {
43
+ length = parseInt(numOfZerosEval);
44
+ }
45
+ if (length == -1) {
46
+ throw "AddLeadZeros function can't be evaluated! expression: " + this.Expression;
47
+ }
48
+ var str = valueEval.ToString();
49
+ while (str.Length < length) {
50
+ str = "0" + str;
51
+ }
52
+ return str;
53
+ }
54
+ }
55
+ exports.AddLeadZerosParse = AddLeadZerosParse;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppearParse = void 0;
4
+ const BaseParse_1 = require("./BaseParse");
5
+ class AppearParse extends BaseParse_1.BaseParse {
6
+ constructor(valueExpression, funname) {
7
+ super(valueExpression, funname);
8
+ this.FieldName = "";
9
+ var split = this.Expression.split(".");
10
+ this.Table = split[0];
11
+ if (split.length > 1) {
12
+ this.FieldName = split[1];
13
+ }
14
+ }
15
+ Evaluate(obj, critm, record, item) {
16
+ var tablelevel = obj.FindTableLevel(this.Table);
17
+ if (tablelevel == null) {
18
+ return false;
19
+ }
20
+ let list = [];
21
+ ;
22
+ if (tablelevel.Record != null) {
23
+ list.push(tablelevel.Record);
24
+ }
25
+ else if (tablelevel.Records != null) {
26
+ var rec = tablelevel.Records;
27
+ if (rec.Records.length == 0) {
28
+ return false;
29
+ }
30
+ rec.Records.forEach(element => {
31
+ list.push(element);
32
+ });
33
+ }
34
+ if (list.length == 0) {
35
+ return false;
36
+ }
37
+ if (this.FieldName == "") {
38
+ return true;
39
+ }
40
+ for (var i = 0; i < list.length; i++) {
41
+ if (list[i].Record[this.FieldName] != null) {
42
+ return true;
43
+ }
44
+ }
45
+ return false;
46
+ }
47
+ }
48
+ exports.AppearParse = AppearParse;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseParse = void 0;
4
+ class BaseParse {
5
+ constructor(expression, funName) {
6
+ this.Expression = "";
7
+ this.FunName = null;
8
+ if (funName == null || funName == "") {
9
+ this.Expression = expression;
10
+ }
11
+ else {
12
+ this.Expression = expression.substring(funName.length, expression.length - 1);
13
+ this.FunName = funName;
14
+ }
15
+ }
16
+ static getIsoDateWithTime(date, time) {
17
+ if (date == null) {
18
+ return null;
19
+ }
20
+ if (typeof date == "string") {
21
+ return date;
22
+ }
23
+ return date.getFullYear() + "-" +
24
+ this.formatToTwoNumber(date.getMonth() + 1) + "-" +
25
+ this.formatToTwoNumber(date.getDate()) + time;
26
+ }
27
+ static getIsoDateTime(date) {
28
+ if (date == null) {
29
+ return null;
30
+ }
31
+ if (typeof (date) == "string") {
32
+ return date;
33
+ }
34
+ return date.getFullYear() + "-" +
35
+ this.formatToTwoNumber(date.getMonth() + 1) + "-" +
36
+ this.formatToTwoNumber(date.getDate()) + "T" +
37
+ this.formatToTwoNumber(date.getHours()) + ":" +
38
+ this.formatToTwoNumber(date.getMinutes()) + ":" +
39
+ this.formatToTwoNumber(date.getSeconds());
40
+ }
41
+ static parseDateTime(datetime) {
42
+ return new Date(datetime);
43
+ }
44
+ static parseDate(datetime) {
45
+ return new Date(datetime);
46
+ }
47
+ static formatToTwoNumber(num) {
48
+ if (num < 10) {
49
+ return "0" + num;
50
+ }
51
+ return num.toString();
52
+ }
53
+ static getIsoDate(date) {
54
+ if (date == null) {
55
+ return null;
56
+ }
57
+ if (typeof date == "string") {
58
+ return date;
59
+ }
60
+ return date.getFullYear() + "-" +
61
+ this.formatToTwoNumber(date.getMonth() + 1) + "-" +
62
+ this.formatToTwoNumber(date.getDate()) + "T00:00:00";
63
+ }
64
+ static roundUp(num, r) {
65
+ let negative = false;
66
+ if (num < 0) {
67
+ negative = true;
68
+ }
69
+ else {
70
+ negative = false;
71
+ }
72
+ ;
73
+ if (negative) {
74
+ num = num - 10 ** -13;
75
+ }
76
+ else {
77
+ num = num + 10 ** -13;
78
+ }
79
+ num = Math.abs(num);
80
+ let temp1 = Math.round(num * Math.pow(10, r)) / (Math.pow(10, r));
81
+ if (negative) {
82
+ return (-1) * temp1;
83
+ }
84
+ return temp1;
85
+ }
86
+ }
87
+ exports.BaseParse = BaseParse;
88
+ BaseParse.operators = ["<=", ">=", "!=", "<>", "==", "<", ">", "="];
89
+ BaseParse.logicaloperators = ["&&", "||"];