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,669 @@
1
+
2
+ import { SchemaStruct } from '../Interfaces/SchemaStruct';
3
+ import { InvoiceObj } from '../Structure/InvoiceObj';
4
+ import { RecordSingle } from '../Structure/RecordSingle';
5
+ import { BaseParse } from './Parser/BaseParse';
6
+ import { OnlyExpressionParse } from './Parser/OnlyExpressionParse';
7
+ import { LiteralValueParse } from './Parser/LiteralValueParse';
8
+ import { ValueFromObjParse } from './Parser/ValueFromObjParse';
9
+ import { CommaParser } from './Parser/CommaParser';
10
+ import { OperatorParser } from './Parser/OperatorParse';
11
+ import { LogicalOperatorParser } from './Parser/LogicalOperatorParse';
12
+ import { AddLeadZerosParse } from "./Parser/AddLeadZerosParse";
13
+ import { AppearParse } from "./Parser/AppearParse";
14
+ import { IfParse } from "./Parser/IfParse";
15
+ import { SumParse } from "./Parser/SumParse";
16
+
17
+ import { CalcDateParse } from "./Parser/CalcDateParse";
18
+ import { UpperLowerParse } from "./Parser/UpperLoverParse";
19
+ import { INListParser } from "./Parser/InListParse";
20
+ import { InDetailParse } from "./Parser/InDetailParse";
21
+ import { StartsParse } from "./Parser/StartsParse";
22
+ import { SubstrParse } from "./Parser/SubstrParse";
23
+ import { CountParse } from "./Parser/CountParse";
24
+ import { ExistParser } from "./Parser/ExistParse";
25
+ import { EmptyParse } from "./Parser/EmptyParse";
26
+ import { ConcatParse } from "./Parser/ConcatParse";
27
+ import { CheckParse } from "./Parser/CheckParse";
28
+ import { TrimParse } from "./Parser/TrimParse";
29
+ import { ValueParse } from './Parser/ValueParse';
30
+
31
+ export class ExpresionLogicService {
32
+
33
+ constructor() { }
34
+ public static _suportedFunctions:any =
35
+ {
36
+ "sum(":SumParse,
37
+ "if(":IfParse,
38
+ "addleadzeros(":AddLeadZerosParse,
39
+ "appear(":AppearParse,
40
+ "calcdate(":CalcDateParse,
41
+ "upper(":UpperLowerParse,
42
+ "lower(":UpperLowerParse,
43
+ "inlist(":INListParser,
44
+ "notinlist(":INListParser,
45
+ "indetail(":InDetailParse,
46
+ "notindetail(":InDetailParse,
47
+ "starts(":StartsParse,
48
+ "substr(":SubstrParse,
49
+ "count(":CountParse,
50
+ "check(":CheckParse,
51
+ "concat(":ConcatParse,
52
+ "empty(":EmptyParse,
53
+ "exists(":ExistParser,
54
+ "notexists(":ExistParser,
55
+ "trim(":TrimParse,
56
+ "value(":ValueParse,
57
+ };
58
+ public static GetExpressions(
59
+ valueExpression:string, parrent:BaseParse|null):BaseParse[]|null
60
+ {
61
+
62
+ let _exprtessions:any = [];
63
+ var cursor = 0;
64
+ var currentLit = "";
65
+ while (valueExpression.length > 0)
66
+ {
67
+ if (!this.HasFunctionInside(valueExpression) && valueExpression.indexOf(",")==-1)
68
+ {
69
+ _exprtessions.push(new OnlyExpressionParse(valueExpression));
70
+ break;
71
+ }
72
+ if (valueExpression.substring(cursor, cursor+1) == "(")
73
+ {
74
+ var index = this.FindEnd(valueExpression);
75
+ if (index == -1)
76
+ {
77
+ throw "Unbalanced brackets!!!! Expression:"+valueExpression;
78
+ }
79
+ if (currentLit!="")
80
+ {
81
+ _exprtessions.push(new LiteralValueParse(currentLit));
82
+ currentLit = "";
83
+ }
84
+ _exprtessions.push(new OnlyExpressionParse(valueExpression.substring(0, index + 1)));
85
+ if (index < valueExpression.length)
86
+ {
87
+ valueExpression = valueExpression.substring(index + 1);
88
+ }
89
+ else
90
+ {
91
+ valueExpression = "";
92
+ }
93
+
94
+ continue;
95
+ }
96
+
97
+ if (valueExpression.startsWith("N.%"))
98
+ {
99
+ if (currentLit!="")
100
+ {
101
+ _exprtessions.push(new LiteralValueParse(currentLit));
102
+ currentLit = "";
103
+ }
104
+ var indexNext = valueExpression.substring(3).indexOf("%") + 1;
105
+ _exprtessions.push(new ValueFromObjParse(valueExpression.substring(2, indexNext+3), true));
106
+ valueExpression = valueExpression.substring(indexNext + 3);
107
+ continue;
108
+ }
109
+
110
+ if (valueExpression.substring(0, 1) == "%")
111
+ {
112
+ if (currentLit!="")
113
+ {
114
+ _exprtessions.push(new LiteralValueParse(currentLit));
115
+ currentLit = "";
116
+ }
117
+ var indexNext = valueExpression.substring(1).indexOf("%") + 1;
118
+ _exprtessions.push(new ValueFromObjParse(valueExpression.substring(0, indexNext + 1),false));
119
+ valueExpression = valueExpression.substring(indexNext + 1);
120
+ continue;
121
+ }
122
+
123
+
124
+
125
+ if (valueExpression.substring(cursor, cursor+1) == ",")
126
+ {
127
+ if (currentLit!="")
128
+ {
129
+ _exprtessions.push(new OnlyExpressionParse(currentLit));
130
+ currentLit = "";
131
+ }
132
+ _exprtessions.push(new CommaParser(valueExpression.substring(0, 1),""));
133
+ if (1 < valueExpression.length)
134
+ {
135
+ valueExpression = valueExpression.substring(1);
136
+ }
137
+ else
138
+ {
139
+ valueExpression = "";
140
+ }
141
+
142
+ continue;
143
+ }
144
+ var br = false;
145
+ BaseParse.operators.forEach(o=>{
146
+ if (valueExpression.startsWith(o))
147
+ {
148
+ if (currentLit!="")
149
+ {
150
+ _exprtessions.push(new OnlyExpressionParse(currentLit)); currentLit = "";
151
+ }
152
+ _exprtessions.push(new OperatorParser(valueExpression.substring(0, o.length)));
153
+ valueExpression = valueExpression.substring(o.length);
154
+ br = true; return;
155
+ }
156
+ })
157
+
158
+ if (br)
159
+ {
160
+ continue;
161
+ }
162
+ for(let j=0;j<BaseParse.logicaloperators.length;j++)
163
+ {
164
+ let o=BaseParse.logicaloperators[j];
165
+ if (valueExpression.startsWith(o))
166
+ {
167
+ if (currentLit!="")
168
+ {
169
+ _exprtessions.push(new OnlyExpressionParse(currentLit)); currentLit = "";
170
+ }
171
+ _exprtessions.push(new LogicalOperatorParser(valueExpression.substring(0, o.length)));
172
+ valueExpression = valueExpression.substring(o.length);
173
+ br = true;
174
+ break;
175
+ }
176
+ }
177
+
178
+ if (br)
179
+ {
180
+ continue;
181
+ }
182
+ var foundFun = false;
183
+ let valueExpTemp=valueExpression.toLowerCase();
184
+
185
+ var supKeys=Object.keys(ExpresionLogicService._suportedFunctions);
186
+ for(let j=0;j<supKeys.length;j++)
187
+ {
188
+ let key=supKeys[j];
189
+ if (valueExpTemp.startsWith(key))
190
+ {
191
+ if (currentLit!="")
192
+ {
193
+ _exprtessions.push(new OnlyExpressionParse(currentLit));
194
+ currentLit = "";
195
+ }
196
+ var index = this.FindEnd(valueExpression);
197
+ if (index == -1)
198
+ {
199
+ throw "Unbalanced brackets!!!! Expression:"+valueExpression;
200
+ }
201
+ let instance=Reflect.construct(ExpresionLogicService._suportedFunctions[key],[valueExpression.substring(0, index + 1),key]);
202
+ _exprtessions.push(instance );
203
+
204
+
205
+ if (index < valueExpression.length)
206
+ {
207
+ valueExpression = valueExpression.substring(index + 1);
208
+ }
209
+ else
210
+ {
211
+ valueExpression = "";
212
+ }
213
+ foundFun = true;
214
+ break;
215
+ }
216
+ }
217
+
218
+ if (foundFun)
219
+ {
220
+ continue;
221
+ }
222
+
223
+ currentLit += valueExpression.substring(0, 1);
224
+ valueExpression = valueExpression.substring(1);
225
+ }
226
+ if (currentLit!="")
227
+ {
228
+ _exprtessions.push(new OnlyExpressionParse(currentLit));
229
+ currentLit = "";
230
+ }
231
+ return _exprtessions;
232
+ }
233
+ public static HasFunctionInside( valueExp:string|null):boolean
234
+ {
235
+ if (valueExp == null||valueExp=="")
236
+ {
237
+ return false;
238
+ }
239
+ var founded=false;
240
+ const valueExpTemp=valueExp.toLowerCase();
241
+ Object.keys(ExpresionLogicService._suportedFunctions).forEach(element => {
242
+ if(valueExpTemp.indexOf(element)!=-1)
243
+ {
244
+ founded= true;
245
+ return;
246
+ }
247
+ });
248
+
249
+ return founded;
250
+ }
251
+ public static StartsWithFunction( valueExp:string):boolean
252
+ {
253
+ const valueExpTemp=valueExp.toLowerCase();
254
+ var founded=false;
255
+ Object.keys(ExpresionLogicService._suportedFunctions).forEach(element => {
256
+ if(valueExpTemp.startsWith(element))
257
+ {
258
+ founded= true;
259
+ return;
260
+ }
261
+ });
262
+
263
+ return founded;
264
+ }
265
+ public static FindEnd( expresion:string):number
266
+ {
267
+ var bC = 0;
268
+ var bO = 0;
269
+ for (var i = 0; i < expresion.length; i++)
270
+ {
271
+ if (expresion.substring(i, i+1) == "(")
272
+ {
273
+ bO++;
274
+ }
275
+ else if (expresion.substring(i, i+1) == ")")
276
+ {
277
+ bC++;
278
+ }
279
+ if (bO > 0 && bO == bC)
280
+ {
281
+ return i;
282
+ }
283
+ }
284
+ return -1;
285
+ }
286
+ public static ConcatValues( t:BaseParse[], obj:InvoiceObj, critm:RecordSingle, record:any, item:SchemaStruct)
287
+ {
288
+ if (t.length == 1)
289
+ {
290
+ return t[0].Evaluate(obj, critm, record, item);
291
+ }
292
+ let sb = "";
293
+ for(let i=0;i<t.length;i++)
294
+ {
295
+ let value=t[i].Evaluate(obj,critm,record,item);
296
+ if(typeof value =="number")
297
+ {
298
+ sb+=value.toString();
299
+ }
300
+ else if(value instanceof Date)
301
+ {
302
+ sb+=value.toISOString();
303
+ }
304
+ else
305
+ {
306
+ sb+=value;
307
+ }
308
+ }
309
+
310
+ return sb;
311
+ }
312
+
313
+
314
+
315
+ static CastToTypeNet(item:SchemaStruct,value:any):any
316
+ {
317
+ let outptValue = null;
318
+ if (value==null)
319
+ {
320
+ return null;
321
+ }
322
+ switch (item.TypeNET)
323
+ {
324
+ case "decimal":
325
+ {
326
+ outptValue=parseFloat(value);
327
+ break;
328
+ }
329
+ case "int":
330
+ {
331
+
332
+ outptValue=parseInt(value);
333
+ break;
334
+ break;
335
+ }
336
+ case "bool":
337
+ {
338
+
339
+ if(this.toString().toLowerCase()=="true")
340
+ {
341
+ outptValue==true;
342
+ }
343
+ else if(this.toString().toLowerCase()=="false")
344
+ {
345
+ outptValue==false;
346
+ }
347
+ else{
348
+ outptValue=value;
349
+ }
350
+ break;
351
+ }
352
+ default:
353
+ {
354
+ outptValue = value;
355
+ break;
356
+ }
357
+ }
358
+ return outptValue;
359
+ }
360
+ static ParseAndFillExpression( valueExp:string,item:SchemaStruct, obj:InvoiceObj, citm:RecordSingle, record:any, tryEvaluate:boolean , init:boolean):any
361
+ {
362
+ var value = ExpresionLogicService.ParseExpressionAndReturnValue(valueExp, obj, item, citm, 0);
363
+ console.log(item.FieldName+" "+item.ValueExpression+" "+value);
364
+ if (value != null)
365
+ {
366
+ if ((tryEvaluate || item.TypeNET == "decimal" || item.TypeNET == "int"))
367
+ {
368
+ try
369
+ {
370
+ if (value == "0/0")
371
+ {
372
+ citm.Record[item.FieldName]=0;
373
+ return 0;
374
+ }
375
+ if (value == "*(-1)")
376
+ {
377
+ return null;
378
+ }
379
+
380
+
381
+ var ret = eval(value);
382
+ console.log(item.FieldName+" "+item.ValueExpression+" RET: "+value);
383
+
384
+ return ret;
385
+
386
+ }
387
+ catch (ex)
388
+ {
389
+ if (init)
390
+ {
391
+ console.log(item.FieldName+" "+item.ValueExpression+" Err: "+0);
392
+ return 0;
393
+ }
394
+ else
395
+ {
396
+
397
+ var val= ExpresionLogicService.CastToTypeNet(item,value);
398
+ console.log(item.FieldName+" "+item.ValueExpression+" Err: "+val);
399
+ return val;
400
+ }
401
+ }
402
+ }
403
+ else
404
+ {
405
+ var val= ExpresionLogicService.CastToTypeNet(item,value);
406
+
407
+ console.log(item.FieldName+" "+item.ValueExpression+" Ret: "+val);
408
+ return val;
409
+
410
+ }
411
+ }
412
+ else
413
+ {
414
+ console.log(item.FieldName+" "+item.ValueExpression+" Value: "+value);
415
+ return value;
416
+
417
+ }
418
+ }
419
+
420
+ public static ParseExpressionAndReturnValue( valueExp:string|null,obj:InvoiceObj,item:SchemaStruct,citm:RecordSingle,level:number):string|null
421
+ {
422
+ if(valueExp==null)
423
+ {
424
+ return null;
425
+ }
426
+ let returned:BaseParse[]|null = null;
427
+ try
428
+ {
429
+ returned = ExpresionLogicService.GetExpressions(valueExp, null);
430
+
431
+ }
432
+ catch (ec)
433
+ {
434
+ debugger
435
+ }
436
+ if (returned == null)
437
+ {
438
+ return null;
439
+ }
440
+ if (!(returned[0] instanceof OnlyExpressionParse))
441
+ {
442
+
443
+ }
444
+ var record = citm.Record;
445
+ let sb:string = "";
446
+ if (returned.length == 1)
447
+ {
448
+ var value = returned[0].Evaluate(obj, citm, record, item);
449
+ if (value == null)
450
+ {
451
+ return null;
452
+ }
453
+ if (value instanceof Date)
454
+ {
455
+ if (item.TypeDDD == "Date")
456
+ {
457
+ return BaseParse.getIsoDate(value);
458
+ }
459
+ else if (item.TypeDDD == "DateTime")
460
+ {
461
+ return BaseParse.getIsoDateTime(value);
462
+ }
463
+ }
464
+ else if (typeof value == "number")
465
+ {
466
+ return value.toString();
467
+ }
468
+ return value.toString(); ;
469
+ }
470
+ return ExpresionLogicService.ConcatValues(returned, obj, citm, record, item)?.toString();
471
+
472
+
473
+ }
474
+
475
+
476
+ public static ValueExpresion( item:SchemaStruct, valueExpression:string, obj:InvoiceObj, citm:RecordSingle)
477
+ {
478
+ if (valueExpression == "null")
479
+ {
480
+ return null;
481
+ }
482
+ if (!valueExpression.startsWith("%") && !valueExpression.endsWith("%"))
483
+ {
484
+ return valueExpression;
485
+ }
486
+
487
+ let tabelAndKey:string = "";
488
+ try
489
+ {
490
+ tabelAndKey = valueExpression.substring(1, valueExpression.length - 1);
491
+ }
492
+ catch ( ex)
493
+ {
494
+ if (item != null)
495
+ {
496
+ throw item.FieldName + " " + item.ValueExpression + " Expression:" + valueExpression + ex;
497
+ }
498
+ throw valueExpression + ex;
499
+ }
500
+
501
+
502
+
503
+ var split = tabelAndKey.split("." );
504
+ var prefix = split[0];
505
+ switch (prefix)
506
+ {
507
+ /*case "V":
508
+ {
509
+ return obj.GetValues(split[1]);
510
+ }
511
+ */
512
+ case "E":
513
+ {
514
+ /*const tableName = split[1];
515
+ const field = split[2];
516
+ if (tableName.toLowerCase()=="eu_aorg")
517
+ {
518
+ return obj.service.aboutOrganisation[field];
519
+ }
520
+ else if (tableName.toLowerCase()=="eu_scr")
521
+ {
522
+ return obj.service.aboutOrganisation["_countryRecord"][field];
523
+ }
524
+ else if (tableName.toLowerCase()=="session")
525
+ {
526
+ var startpath= obj.service.sessionInfo;
527
+
528
+ for (var i = 2; i < split.length; i++)
529
+ {
530
+ if(startpath[split[i]]!=null)
531
+ {
532
+ startpath=startpath[split[i]];
533
+ }
534
+ else
535
+ {
536
+ return null;
537
+ }
538
+ }
539
+ return startpath;
540
+ }
541
+
542
+ else
543
+ {
544
+ return "";
545
+ }*/
546
+
547
+ }
548
+ case "S":
549
+ {
550
+ /*if(obj.service.settings==null||obj.service.settings[split[1]]==null)
551
+ {
552
+ throw "Can't find setting for "+split[1];
553
+ }
554
+ var settingRecord=obj.service.settings[split[1]];
555
+ return settingRecord["Value"];
556
+ */
557
+
558
+ }
559
+
560
+ default:
561
+ {
562
+ if (split.length == 2)
563
+ {
564
+ var table = split[0];
565
+ var key = split[1];
566
+
567
+ if (table == citm?.Parent?.Tablename)
568
+ {
569
+ var value1 = ExpresionLogicService.ReturnFromObject(citm.Record, key);
570
+ if ( value1["found"]===true)
571
+ {
572
+ return value1["return"];
573
+ }
574
+ }
575
+
576
+ var tableLevel = obj.FindTableLevel(table);
577
+ if (tableLevel != null)
578
+ {
579
+
580
+ if (tableLevel.Record!=null)
581
+ {
582
+ var record = tableLevel.Record;
583
+ var value1 = ExpresionLogicService.ReturnFromObject(record.Record, key);
584
+ if ( value1["found"]===true)
585
+ {
586
+ return value1["return"];
587
+ }
588
+
589
+
590
+ if (value1["found"]===false && key == "InvIssueDate")
591
+ {
592
+ return null;
593
+ }
594
+ if (value1["found"]===false && key.indexOf("__")!=-1)
595
+ {
596
+
597
+ var value2 = ExpresionLogicService.ReturnFromObject(record.Record, key);
598
+ if ( value2["found"]===true)
599
+ {
600
+ return value2["return"];
601
+ }
602
+ }
603
+ if (value2["found"]===false && key != "Mode")
604
+ {
605
+ throw "Can't evaluate "+valueExpression+" key:"+item.FieldName+"";
606
+ }
607
+
608
+ return null;
609
+ }
610
+ else if (tableLevel.Records!=null)
611
+ {
612
+ var records = tableLevel.Records;
613
+ var candidates = records.Records.filter(x => x == citm);
614
+
615
+ if (candidates.length>0)
616
+ {
617
+ var recordC = candidates[0];
618
+ var recordA = recordC.Record;
619
+ var value1 = ExpresionLogicService.ReturnFromObject(recordA, key);
620
+ if ( value1["found"]===true)
621
+ {
622
+ return value1["return"];
623
+ }
624
+
625
+ if (value1["found"]===false && key.indexOf("__")!=-1)
626
+ {
627
+
628
+ var value2 = ExpresionLogicService.ReturnFromObject(recordC.Record, key);
629
+ if ( value2["found"]===true)
630
+ {
631
+ return value2["return"];
632
+ }
633
+ }
634
+
635
+ throw "Can't evaluate "+valueExpression+" key:"+item.FieldName;
636
+
637
+ }
638
+
639
+ }
640
+
641
+ }
642
+ }
643
+ break;
644
+ }
645
+ }
646
+
647
+
648
+ return null;
649
+
650
+ }
651
+ private static ReturnFromObject(record:any, key:string ):any
652
+ {
653
+ if (Object.keys(record).indexOf(key)==-1)
654
+ {
655
+ return {"found":false,"return":null}
656
+
657
+ }
658
+ if (record[key]==null )
659
+ {
660
+ return {"found":true,"return":null}
661
+ }
662
+ if (record[key] instanceof Date)
663
+ {
664
+ return {"found":true,"return":record[key]}
665
+
666
+ }
667
+ return {"found":true,"return":record[key].toString()}
668
+ }
669
+ }