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,345 @@
1
+ import { RecordSingle } from "../../Structure/RecordSingle";
2
+
3
+ export class IfStategment {
4
+ private operators:string[] = [ "<=", ">=", "!=", "<>", "==", "<", ">","=" ];
5
+ public LeftSide:string|null=null;;
6
+ public RightSide:string|null=null;;
7
+ public OneSide:string|null=null;;
8
+ public Operator :string|null=null;;
9
+
10
+ // public constructor(ifSt:string)
11
+ // {
12
+ // for (var op in this.operators)
13
+ // {
14
+
15
+ // if (ifSt.indexOf(this.operators[op])!=-1)
16
+ // {
17
+ // this.Operator = this.operators[op]; break;
18
+ // }
19
+ // }
20
+ // if(this.Operator==null)
21
+ // {
22
+ // throw "Can't find operator";
23
+ // }
24
+ // var split = ifSt.split(this.Operator);
25
+ // if (split.length == 2)
26
+ // {
27
+ // this.LeftSide = split[0];
28
+ // this.RightSide = split[1];
29
+ // }
30
+ // else if (split.length == 1)
31
+ // {
32
+ // this.OneSide = split[0];
33
+ // }
34
+ // }
35
+
36
+ public constructor(ifSt:string)
37
+ {
38
+ for (var op in this.operators)
39
+ {
40
+
41
+ if (ifSt.indexOf(this.operators[op])!=-1)
42
+ {
43
+ this.Operator = this.operators[op]; break;
44
+ }
45
+ }
46
+ if(this.Operator==null)
47
+ {
48
+ this.OneSide = ifSt;
49
+ return;
50
+ }
51
+ var split = ifSt.split(this.Operator);
52
+ if (split.length == 2)
53
+ {
54
+ this.LeftSide = split[0];
55
+ this.RightSide = split[1];
56
+ }
57
+ else if (split.length == 1)
58
+ {
59
+ this.OneSide = split[0];
60
+ }
61
+ }
62
+
63
+ private CastToDecimal(side:string|null, citm:RecordSingle )
64
+ {
65
+
66
+ if (side ==null||side == "null")
67
+ {
68
+ return null;
69
+ }
70
+ if (side.startsWith("N."))
71
+ {
72
+ side = side.substring(2);
73
+ }
74
+ let value = null;
75
+ if (side.startsWith("%") && side.endsWith("%"))
76
+ {
77
+ value =citm.ValueExpresion(side);
78
+ }
79
+ else
80
+ {
81
+ value = side;
82
+ }
83
+ if (typeof value === 'number')
84
+ {
85
+ return value;
86
+ }
87
+ let valStr = null;
88
+ if (typeof value === 'string')
89
+ {
90
+ valStr = value;
91
+ }
92
+ if (valStr==null||valStr=="")
93
+ {
94
+ return 0;
95
+ }
96
+ try{
97
+ return parseFloat(valStr);
98
+ }
99
+ catch(e)
100
+ {
101
+ return 0;
102
+ }
103
+
104
+
105
+ }
106
+ private TryParse(exp:string|null)
107
+ {
108
+
109
+ if(exp==null)
110
+ {
111
+ return false;
112
+ }
113
+ const reg = /^-?\d*\.?\d*$/
114
+ const rege = new RegExp(reg)
115
+ if(!rege.test(exp))
116
+ {
117
+ return false;
118
+ }
119
+ try{
120
+ parseFloat(exp);
121
+ return true;
122
+ }
123
+ catch(e)
124
+ {
125
+ return false;
126
+ }
127
+ }
128
+ public Validate( citm:RecordSingle ):boolean
129
+ {
130
+ // if (this.OneSide!=null)
131
+ // {
132
+ // var oneSide = citm.ValueExpresion(this.OneSide); ;
133
+ // if (typeof oneSide === "boolean")
134
+ // {
135
+ // if(true)
136
+ // {
137
+ // // console.log("OneSide:"+oneSide);
138
+ // }
139
+ // return oneSide;
140
+ // }
141
+
142
+ // throw "Unsupported validation";
143
+
144
+ // }
145
+
146
+ if (this.OneSide!=null)
147
+ {
148
+ var oneSide = citm.ValueExpresion(this.OneSide); ;
149
+ if(oneSide==null)
150
+ {
151
+ return false;
152
+ }
153
+ if (typeof oneSide === "boolean")
154
+ {
155
+ if(true)
156
+ {
157
+ // console.log("OneSide:"+oneSide);
158
+ }
159
+ return oneSide;
160
+ }
161
+ else if(typeof oneSide === "string")
162
+ {
163
+ if(oneSide!=null)
164
+ {
165
+ if(oneSide.toLocaleLowerCase()=="true")
166
+ {
167
+ return true;
168
+ }
169
+ if(oneSide.toLocaleLowerCase()=="false")
170
+ {
171
+ return false;
172
+ }
173
+ throw "Unsupported validation:Value:"+oneSide;
174
+ }
175
+ throw "Unsupported validation expression("+this.OneSide+") returned null!";
176
+ }
177
+
178
+ throw "Unsupported validation";
179
+
180
+ }
181
+
182
+ if (
183
+ (this.LeftSide?.startsWith("N.") || this.TryParse(citm.ValueExpresion(this.LeftSide))
184
+ || this.LeftSide == "null") &&
185
+ (this.RightSide?.startsWith("N.") || this.TryParse(citm.ValueExpresion(this.RightSide))
186
+ || this.RightSide == "null"))
187
+ {
188
+ let leftSide = this.CastToDecimal(this.LeftSide, citm);
189
+ let rightSide = this.CastToDecimal(this.RightSide, citm);
190
+ if(leftSide==null||rightSide==null)
191
+ {
192
+ let returnValue=false;
193
+ switch (this.Operator)
194
+ {
195
+
196
+ case "!=":
197
+ case "<>":
198
+ {
199
+ returnValue= leftSide != rightSide;
200
+ break;
201
+ }
202
+
203
+ case "==":
204
+ case "=":
205
+ {
206
+ returnValue= leftSide == rightSide;
207
+ break;
208
+ }
209
+ default:
210
+ {
211
+ throw "Operator "+this.Operator+" not supported on condition decimal and decimal";
212
+ }
213
+ }
214
+ if(true)
215
+ {
216
+ // console.log(leftSide+" "+ this.Operator+" "+rightSide+" "+returnValue);
217
+ }
218
+ return returnValue;
219
+ }
220
+ else
221
+ {
222
+ let returnValue=false;
223
+ switch (this.Operator)
224
+ {
225
+ case ">=":
226
+ {
227
+ returnValue= leftSide >= rightSide;
228
+ break;
229
+ }
230
+ case "<=":
231
+ {
232
+ returnValue= leftSide <= rightSide;
233
+ break;
234
+ }
235
+ case "!=":
236
+ case "<>":
237
+ {
238
+ returnValue=leftSide != rightSide;
239
+ break;
240
+ }
241
+ case "<":
242
+ {
243
+ returnValue= leftSide < rightSide;
244
+ break;
245
+ }
246
+ case ">":
247
+ {
248
+ returnValue= leftSide > rightSide;
249
+ break;
250
+ }
251
+ case "==":
252
+ case "=":
253
+ {
254
+ returnValue=leftSide == rightSide;
255
+ break;
256
+ }
257
+ default:
258
+ {
259
+ throw "Operator "+this.Operator+" not supported on condition decimal and decimal";
260
+ }
261
+ }
262
+ if(true)
263
+ {
264
+ // console.log(this.LeftSide+" "+ this.Operator+" "+this.RightSide);
265
+ // console.log(leftSide+" "+ this.Operator+" "+rightSide+" =N "+returnValue);
266
+ }
267
+ return returnValue;
268
+ }
269
+
270
+ }
271
+ else
272
+ {
273
+
274
+ let leftSide = citm.ValueExpresion(this.LeftSide); ;
275
+ let rightSide = citm.ValueExpresion(this.RightSide);
276
+
277
+ if((typeof leftSide ==="boolean"||leftSide==null)&&(typeof rightSide ==="boolean"||rightSide==null))
278
+ {
279
+ let returnValue=false;
280
+ switch (this.Operator)
281
+ {
282
+ case "!=":
283
+ case "<>":
284
+ {
285
+ returnValue=leftSide != rightSide;
286
+ break;
287
+ }
288
+ case "==":
289
+ case "=":
290
+ {
291
+ returnValue=leftSide == rightSide;
292
+ break;
293
+ }
294
+ default:
295
+ {
296
+ throw "Operator "+this.Operator+" not supported on condition boolean and boolean";
297
+ }
298
+ }
299
+ if(true)
300
+ {
301
+ // console.log(this.LeftSide+" "+ this.Operator+" "+this.RightSide);
302
+ // console.log(leftSide+" "+ this.Operator+" "+rightSide+" = "+returnValue);
303
+ }
304
+ return returnValue;
305
+ }
306
+ if ((typeof leftSide === "string" || leftSide == null) &&
307
+ (typeof rightSide === "string" || rightSide == null))
308
+ {
309
+
310
+
311
+ let returnValue=false;
312
+ switch (this.Operator)
313
+ {
314
+ case "!=":
315
+ case "<>":
316
+ {
317
+ returnValue=leftSide != rightSide;
318
+ break;
319
+ }
320
+ case "==":
321
+ case "=":
322
+ {
323
+ returnValue=leftSide == rightSide;
324
+ break;
325
+ }
326
+ default:
327
+ {
328
+ throw "Operator "+this.Operator+" not supported on condition string and string";
329
+ }
330
+ }
331
+ if(true)
332
+ {
333
+ // console.log(this.LeftSide+" "+ this.Operator+" "+this.RightSide);
334
+ // console.log(leftSide+" "+ this.Operator+" "+rightSide+" = "+returnValue);
335
+ }
336
+ return returnValue;
337
+ }
338
+
339
+ }
340
+ // debugger
341
+ throw "Unsupported validation";
342
+
343
+
344
+ }
345
+ }
@@ -0,0 +1,109 @@
1
+ import { SchemaStruct } from "../../Interfaces/SchemaStruct";
2
+ import { InvoiceObj } from "../../Structure/InvoiceObj";
3
+ import { RecordSingle } from "../../Structure/RecordSingle";
4
+ import { BaseParse } from "./BaseParse";
5
+ import { ExpresionLogicService } from "../ExpresionLogicService";
6
+
7
+ export class InDetailParse extends BaseParse {
8
+
9
+ public Negate:boolean=false;
10
+ public TableAndField:string="";
11
+ public Table:string="";
12
+ public Field:string="";
13
+ public aviableValues:string[]=[];
14
+ public constructor( valueExpression:string,funname:string)
15
+ {
16
+ super(valueExpression,funname);
17
+ if (this.Expression == null)
18
+ {
19
+ return;
20
+ }
21
+ if (!this.Expression.startsWith("("))
22
+ {
23
+ return;
24
+ }
25
+
26
+ var index = ExpresionLogicService.FindEnd(this.Expression);
27
+
28
+ var set = this.Expression.substring(1, index );
29
+
30
+ this.TableAndField = this.Expression.substring(index + 2);
31
+ if(this.TableAndField==null||this.TableAndField=="")
32
+ {
33
+ throw "Invalid expresion InDetail - table.field is empty!";
34
+ }
35
+ if (set==null||set=="")
36
+ {
37
+ throw "Invalid expresion InDetail - set of values is empty!";
38
+ }
39
+ var split = this.TableAndField.split("." );
40
+ if(split.length==2)
41
+ {
42
+ this.Table = split[0];
43
+ this.Field = split[1];
44
+ }
45
+ else
46
+ {
47
+ throw "Invalid expresion InDetail - table.field not in correction format!";
48
+ }
49
+
50
+ this.aviableValues = set.split( ",");
51
+ if (funname?.toLowerCase()=="notindetail(")
52
+ {
53
+ this.Negate = true;
54
+ }
55
+ }
56
+
57
+ public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
58
+ // var tableLevel = obj.FindTableLevel(this.Table, critm.Parent, critm);todo
59
+ var tableLevel = obj.FindTableLevel(this.Table);
60
+ if (tableLevel==null)
61
+ {
62
+ return false;
63
+ }
64
+
65
+
66
+ if(tableLevel.Records !=null)
67
+ {
68
+ var array= tableLevel.Records.Records;
69
+ if(!this.Negate)
70
+ {
71
+ for(var i=0;i<tableLevel.Records.Records.length;i++)
72
+ {
73
+ let single=tableLevel.Records.Records[i];
74
+ if (single.Record[this.Field] == null)
75
+ {
76
+ continue;
77
+ }
78
+ let cand:any[] = this.aviableValues.filter((x)=>x==single.Record[this.Field].toString());
79
+ if(cand.length>0)
80
+ {
81
+ return true;
82
+ }
83
+ }
84
+ return false;
85
+
86
+ }
87
+ else
88
+ {
89
+ for(var i=0;i<tableLevel.Records.Records.length;i++)
90
+ {
91
+ let single=tableLevel.Records.Records[i];
92
+ if (single.Record[this.Field] == null)
93
+ {
94
+ continue;
95
+ }
96
+ let cand:any[] = this.aviableValues.filter((x)=>x!=single.Record[this.Field].toString());
97
+ if(cand.length>0)
98
+ {
99
+ return true;
100
+ }
101
+ }
102
+ return false;
103
+
104
+ }
105
+ }
106
+
107
+ }
108
+ }
109
+
@@ -0,0 +1,57 @@
1
+ import { SchemaStruct } from "../../Interfaces/SchemaStruct";
2
+ import { InvoiceObj } from "../../Structure/InvoiceObj";
3
+ import { RecordSingle } from "../../Structure/RecordSingle";
4
+ import { BaseParse } from "./BaseParse";
5
+ import { ValueFromObjParse } from "./ValueFromObjParse";
6
+ import { ExpresionLogicService } from "../ExpresionLogicService";
7
+
8
+ export class INListParser extends BaseParse {
9
+
10
+ public Negate:boolean=false;
11
+ public FieldSet:string=""
12
+
13
+ public aviableValues:string[] = [];
14
+ public constructor( valueExpression:string,funname:string)
15
+ {
16
+ super(valueExpression,funname);
17
+ if(this.Expression == null)
18
+ {
19
+ return;
20
+ }
21
+ if(!this.Expression.startsWith("("))
22
+ {
23
+ return;
24
+ }
25
+
26
+ var index = ExpresionLogicService.FindEnd(this.Expression);
27
+
28
+ var set = this.Expression.substring(1, index );
29
+
30
+ this.FieldSet = this.Expression.substring(index + 2);
31
+
32
+
33
+
34
+
35
+
36
+ this.aviableValues = set.split(",");
37
+ if(funname?.toLowerCase()=="notinlist(")
38
+ {
39
+ this.Negate = true;
40
+ }
41
+ }
42
+
43
+ public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
44
+ var val = new ValueFromObjParse(this.FieldSet,false);
45
+ var evalValue = val.Evaluate(obj, critm, record, item);
46
+ if(evalValue == null||this.aviableValues.length==0)
47
+ {
48
+ return false;
49
+ }
50
+ var cand= this.aviableValues.indexOf(evalValue.toString());
51
+ if(this.Negate)
52
+ {
53
+ return cand==-1;
54
+ }
55
+ return cand!=-1;
56
+ }
57
+ }
@@ -0,0 +1,36 @@
1
+ import { SchemaStruct } from "../../Interfaces/SchemaStruct";
2
+ import { InvoiceObj } from "../../Structure/InvoiceObj";
3
+ import { RecordSingle } from "../../Structure/RecordSingle";
4
+ import { BaseParse } from "./BaseParse";
5
+
6
+ export class LiteralValueParse extends BaseParse {
7
+
8
+
9
+ public constructor( valueExpression:string)
10
+ {
11
+ super(valueExpression,null);
12
+
13
+ }
14
+
15
+ public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
16
+ if(this.Expression=="null")
17
+ {
18
+ return null;
19
+ }
20
+ if (this.Expression.startsWith("N."))
21
+ {
22
+ if (typeof this.Expression == "string")
23
+ {
24
+ try{
25
+ return parseFloat(this.Expression);
26
+ }
27
+ catch(ex)
28
+ {
29
+ throw "Value "+this.Expression+" can't be transformed to numeric!"
30
+ }
31
+
32
+ }
33
+ }
34
+ return this.Expression;
35
+ }
36
+ }
@@ -0,0 +1,16 @@
1
+ import { SchemaStruct } from "../../Interfaces/SchemaStruct";
2
+ import { InvoiceObj } from "../../Structure/InvoiceObj";
3
+ import { RecordSingle } from "../../Structure/RecordSingle";
4
+ import { BaseParse } from "./BaseParse";
5
+
6
+ export class LogicalOperatorParser extends BaseParse {
7
+
8
+ public constructor( valueExpression:string)
9
+ {
10
+ super(valueExpression,null);
11
+ }
12
+
13
+ public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
14
+ return this.Expression;
15
+ }
16
+ }
@@ -0,0 +1,137 @@
1
+
2
+ import { SchemaStruct } from "../../Interfaces/SchemaStruct";
3
+ import { InvoiceObj } from "../../Structure/InvoiceObj";
4
+ import { RecordSingle } from "../../Structure/RecordSingle";
5
+ import { BaseParse } from "./BaseParse";
6
+ import { OperatorParser } from "./OperatorParse";
7
+ import { LiteralValueParse } from "./LiteralValueParse";
8
+ import { ValueFromObjParse } from "./ValueFromObjParse";
9
+ import { ExpresionLogicService } from "../ExpresionLogicService";
10
+
11
+ export class OnlyExpressionParse extends BaseParse {
12
+
13
+ private static _literalValues:string[] = ["(", ")"] ;
14
+ public subParse:BaseParse[] =[];
15
+ public constructor( valueExpression:string)
16
+ {
17
+ super(valueExpression,null);
18
+ var list:BaseParse[]=[];
19
+ var currentLit = "";
20
+ while(valueExpression.length>0)
21
+ {
22
+ var br = false;
23
+ for(let i=0;i<BaseParse.operators.length;i++)
24
+ {
25
+ let o=BaseParse.operators[i];
26
+ if (valueExpression.startsWith(o))
27
+ {
28
+ list.push(new OperatorParser(valueExpression.substring(0, o.length)));
29
+ valueExpression = valueExpression.substring(o.length);
30
+ br = true;
31
+ break; ;
32
+ }
33
+ }
34
+
35
+ if (br)
36
+ {
37
+ continue;
38
+ }
39
+ if (["%","(",")"].indexOf(valueExpression.substring(0, 1)) ==-1&&!ExpresionLogicService.StartsWithFunction(valueExpression))
40
+ {
41
+ currentLit += valueExpression.substring(0, 1);
42
+ valueExpression = valueExpression.substring(1);
43
+ continue;
44
+ }
45
+
46
+ if(currentLit!="")
47
+ {
48
+ list.push(new LiteralValueParse(currentLit));
49
+ currentLit = "";
50
+ }
51
+ if (valueExpression.startsWith("N.%"))
52
+ {
53
+ var indexNext = valueExpression.substring(3).indexOf("%") + 1;
54
+ list.push(new ValueFromObjParse(valueExpression.substring(2, indexNext -1),true));
55
+ valueExpression = valueExpression.substring(indexNext + 1);
56
+ continue;
57
+ }
58
+
59
+ if (valueExpression.startsWith("%"))
60
+ {
61
+ var indexNext = valueExpression.substring(1).indexOf("%")+1;
62
+ list.push(new ValueFromObjParse(valueExpression.substring(0, indexNext + 1),false));
63
+ valueExpression = valueExpression.substring(indexNext + 1);
64
+ continue;
65
+ }
66
+ var foundFun = false;
67
+ const keys=Object.keys(ExpresionLogicService._suportedFunctions);
68
+ for(let i=0;i<keys.length;i++)
69
+ {
70
+ let key=keys[i];
71
+ if (valueExpression.startsWith(key))
72
+ {
73
+ if (currentLit!="")
74
+ {
75
+ list.push(new OnlyExpressionParse(currentLit));
76
+ currentLit = "";
77
+ }
78
+ var index = ExpresionLogicService.FindEnd(valueExpression);
79
+ if (index == -1)
80
+ {
81
+ throw "Unbalanced brackets!!!! Expression:"+valueExpression;
82
+ }
83
+ let instance=Reflect.construct(ExpresionLogicService._suportedFunctions[key],[valueExpression.substring(0, index + 1),key]);
84
+ list.push(instance as BaseParse );
85
+
86
+ if (index < valueExpression.length)
87
+ {
88
+ valueExpression = valueExpression.substring(index + 1);
89
+ }
90
+ else
91
+ {
92
+ valueExpression = "";
93
+ }
94
+ foundFun = true;
95
+ break;
96
+ }
97
+ }
98
+
99
+ if (foundFun)
100
+ {
101
+ continue;
102
+ }
103
+ var found = false;
104
+ for(let i=0;i<OnlyExpressionParse._literalValues.length;i++)
105
+ {
106
+ var val=OnlyExpressionParse._literalValues[i];
107
+ if (valueExpression.substring(0, 1) == val)
108
+ {
109
+ list.push(new LiteralValueParse(val));
110
+ valueExpression = valueExpression.substring(1);
111
+ found = true;
112
+ break;
113
+ }
114
+ }
115
+
116
+ if(found)
117
+ {
118
+ continue;
119
+ }
120
+ }
121
+ if (currentLit!="")
122
+ {
123
+ list.push(new LiteralValueParse(currentLit));
124
+
125
+ }
126
+ this.subParse = list;
127
+ }
128
+
129
+ public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
130
+ if(this.subParse.length==1)
131
+ {
132
+ return this.subParse[0].Evaluate(obj, critm, record, item);
133
+ }
134
+
135
+ return ExpresionLogicService.ConcatValues(this.subParse,obj,critm,record, item);
136
+ }
137
+ }