js-gei 1.1.0 → 1.1.2

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 (57) hide show
  1. package/dist/js-gei.es.js +36987 -1084
  2. package/dist/js-gei.umd.js +64 -2
  3. package/package.json +6 -2
  4. package/src/Evaluator/CodeLogic/CodeLogicBaseService.ts +33 -0
  5. package/src/Evaluator/CodeLogic/CodeLogicItemsService.ts +38 -0
  6. package/src/Evaluator/CodeLogic/CodeLogicVatsUIService.ts +135 -0
  7. package/src/Evaluator/ExpresionLogicService.ts +81 -50
  8. package/src/Evaluator/HelpersTables.ts +9 -4
  9. package/src/Evaluator/Parser/AddLeadZerosParse.ts +1 -1
  10. package/src/Evaluator/Parser/AppearParse.ts +2 -2
  11. package/src/Evaluator/Parser/BaseParse.ts +1 -1
  12. package/src/Evaluator/Parser/CalcDateParse.ts +1 -1
  13. package/src/Evaluator/Parser/CheckParse.ts +7 -4
  14. package/src/Evaluator/Parser/CleanParse.ts +1 -1
  15. package/src/Evaluator/Parser/CodeListCheckParse.ts +50 -0
  16. package/src/Evaluator/Parser/CommaParser.ts +2 -2
  17. package/src/Evaluator/Parser/ConcatParse.ts +1 -1
  18. package/src/Evaluator/Parser/CountParse.ts +2 -2
  19. package/src/Evaluator/Parser/DateTimeFormatParse.ts +4 -3
  20. package/src/Evaluator/Parser/EmptyParse.ts +22 -7
  21. package/src/Evaluator/Parser/ExistParse.ts +2 -2
  22. package/src/Evaluator/Parser/ExtractParse.ts +89 -0
  23. package/src/Evaluator/Parser/FromCodeListParse.ts +109 -0
  24. package/src/Evaluator/Parser/IfParse.ts +3 -2
  25. package/src/Evaluator/Parser/InDetailParse.ts +7 -9
  26. package/src/Evaluator/Parser/InListParse.ts +1 -1
  27. package/src/Evaluator/Parser/LenParse.ts +39 -0
  28. package/src/Evaluator/Parser/LiteralValueParse.ts +2 -2
  29. package/src/Evaluator/Parser/LogicalOperatorParse.ts +2 -2
  30. package/src/Evaluator/Parser/MonthParse.ts +41 -0
  31. package/src/Evaluator/Parser/NoEvalParse.ts +17 -0
  32. package/src/Evaluator/Parser/OnlyExpressionParse.ts +1 -1
  33. package/src/Evaluator/Parser/OperatorParse.ts +2 -2
  34. package/src/Evaluator/Parser/RegistryCheckParse.ts +51 -0
  35. package/src/Evaluator/Parser/StartsParse.ts +1 -1
  36. package/src/Evaluator/Parser/SubstrParse.ts +1 -1
  37. package/src/Evaluator/Parser/SumParse.ts +2 -2
  38. package/src/Evaluator/Parser/TimeParse.ts +92 -0
  39. package/src/Evaluator/Parser/ToNullParse.ts +62 -0
  40. package/src/Evaluator/Parser/TotalMinutesParse.ts +95 -0
  41. package/src/Evaluator/Parser/TrimParse.ts +1 -1
  42. package/src/Evaluator/Parser/UpperLoverParse.ts +1 -1
  43. package/src/Evaluator/Parser/UseFirstParse.ts +1 -1
  44. package/src/Evaluator/Parser/ValueFromObjParse.ts +2 -2
  45. package/src/Evaluator/Parser/ValueParse.ts +3 -3
  46. package/src/Evaluator/Parser/YearParse.ts +34 -0
  47. package/src/HelperSessionStorage.ts +5 -1
  48. package/src/Interfaces/SchemaStruct.ts +4 -2
  49. package/src/Lib/axios-1.4.0.min.js +2 -0
  50. package/src/Lib/jsonrpc-2.0.js +874 -0
  51. package/src/Lib/jsonrpc-2.0.js.bak +874 -0
  52. package/src/Structure/InvoiceObj.ts +96 -33
  53. package/src/Structure/RecordArray.ts +27 -10
  54. package/src/Structure/RecordSingle.ts +216 -87
  55. package/src/Structure/TableLevel.ts +34 -4
  56. package/src/main.ts +265 -18
  57. package/src/Evaluator/Parser/ToNullParser.ts +0 -0
@@ -0,0 +1,50 @@
1
+ import type { 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
+
7
+ export class CodeListCheckParse extends BaseParse {
8
+ public Table:string = ""
9
+ public Field:string = ""
10
+ public ValueExpress:string = ""
11
+
12
+ public constructor( valueExpression:string,funname:string)
13
+ {
14
+ super(valueExpression,funname);
15
+ var split = this.Expression.split(",");
16
+ this.Table = split[0];
17
+ this.Field = split[1];
18
+ this.ValueExpress = split[2];
19
+ }
20
+
21
+ public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
22
+ var express = new ValueFromObjParse(this.ValueExpress,false);
23
+ var val = express.Evaluate(obj, critm, record, item);
24
+
25
+ if(val==null)
26
+ {
27
+ return null;
28
+ }
29
+
30
+ try
31
+ {
32
+ if(obj.CodeListCache==null||obj.CodeListCache[this.Table]==null)
33
+ {
34
+ throw new Error("CodeListCheck parse - CodeList "+this.Table+" not found in cache!");
35
+ }
36
+ var tableLevel=obj.CodeListCache[this.Table];
37
+ var candidates=tableLevel.filter((rec:any)=>rec[this.Field]?.toString()==val?.toString());
38
+ if(candidates.length>0)
39
+ {
40
+ return true;
41
+ }
42
+
43
+ }
44
+ catch (ex)
45
+ {
46
+ throw new Error("CodeListCheck parse - Error obtaining record from CodeList! Reason: " + ex);
47
+ }
48
+ return false;
49
+ }
50
+ }
@@ -1,5 +1,5 @@
1
1
 
2
- import { SchemaStruct } from "../../Interfaces/SchemaStruct";
2
+ import type{ SchemaStruct } from "../../Interfaces/SchemaStruct";
3
3
  import { InvoiceObj } from "../../Structure/InvoiceObj";
4
4
  import { RecordSingle } from "../../Structure/RecordSingle";
5
5
  import { BaseParse } from "./BaseParse";
@@ -11,7 +11,7 @@ export class CommaParser extends BaseParse {
11
11
  super(valueExpression,funname);
12
12
  }
13
13
 
14
- public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
14
+ public Evaluate(_obj: InvoiceObj, _critm: RecordSingle, _record: any, _item: SchemaStruct):any {
15
15
  return this.Expression;
16
16
  }
17
17
  }
@@ -1,4 +1,4 @@
1
- import { SchemaStruct } from "../../Interfaces/SchemaStruct";
1
+ import type{ SchemaStruct } from "../../Interfaces/SchemaStruct";
2
2
  import { InvoiceObj } from "../../Structure/InvoiceObj";
3
3
  import { RecordSingle } from "../../Structure/RecordSingle";
4
4
  import { BaseParse } from "./BaseParse";
@@ -1,4 +1,4 @@
1
- import { SchemaStruct } from "../../Interfaces/SchemaStruct";
1
+ import type{ SchemaStruct } from "../../Interfaces/SchemaStruct";
2
2
  import { InvoiceObj } from "../../Structure/InvoiceObj";
3
3
  import { RecordSingle } from "../../Structure/RecordSingle";
4
4
  import { BaseParse } from "./BaseParse";
@@ -11,7 +11,7 @@ export class CountParse extends BaseParse {
11
11
  this.Table=this.Expression;
12
12
  }
13
13
 
14
- public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
14
+ public Evaluate(obj: InvoiceObj, _critm: RecordSingle, _record: any, _item: SchemaStruct):any {
15
15
  if(this.Table=="")
16
16
  {
17
17
  throw "Function count don't have defined table!";
@@ -1,4 +1,5 @@
1
- import { SchemaStruct } from "../../Interfaces/SchemaStruct";
1
+ import { format } from 'date-fns';
2
+ import type{ SchemaStruct } from "../../Interfaces/SchemaStruct";
2
3
  import { InvoiceObj } from "../../Structure/InvoiceObj";
3
4
  import { RecordSingle } from "../../Structure/RecordSingle";
4
5
  import { ExpresionLogicService } from "../ExpresionLogicService";
@@ -75,7 +76,7 @@ export class DateTimeFormat extends BaseParse {
75
76
  }
76
77
  formatDateTimeEval= formatEval.ToString();
77
78
  }
78
- //todo
79
- return null;
79
+
80
+ return format(sourceDateTime, formatDateTimeEval);
80
81
  }
81
82
  }
@@ -1,4 +1,4 @@
1
- import { SchemaStruct } from "../../Interfaces/SchemaStruct";
1
+ import type{ SchemaStruct } from "../../Interfaces/SchemaStruct";
2
2
  import { InvoiceObj } from "../../Structure/InvoiceObj";
3
3
  import { RecordSingle } from "../../Structure/RecordSingle";
4
4
  import { BaseParse } from "./BaseParse";
@@ -6,10 +6,15 @@ import { OnlyExpressionParse } from "./OnlyExpressionParse";
6
6
  import { ExpresionLogicService } from "../ExpresionLogicService";
7
7
 
8
8
  export class EmptyParse extends BaseParse {
9
- public valueExp:OnlyExpressionParse|null=null
9
+ public valueExp:OnlyExpressionParse|null=null;
10
+ private Negate:boolean=false;
10
11
  public constructor( valueExpression:string,funname:string)
11
12
  {
12
13
  super(valueExpression,funname);
14
+ if(funname.toLowerCase()=="nonempty(")
15
+ {
16
+ this.Negate=true;
17
+ }
13
18
  var dd = ExpresionLogicService.GetExpressions(this.Expression, this);
14
19
  if(dd==null)
15
20
  {
@@ -27,15 +32,25 @@ export class EmptyParse extends BaseParse {
27
32
 
28
33
  public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
29
34
  var value = this.valueExp?.Evaluate(obj, critm, record, item);
35
+ let result:boolean=false;
30
36
  if(value == null)
31
37
  {
32
- return true;
38
+ result=true;
33
39
  }
34
- if(typeof value =="string")
40
+ else
35
41
  {
36
- var v=value as string;
37
- return v == ""||v.trim()=="";
42
+ if(typeof value =="string")
43
+ {
44
+ var v=value as string;
45
+ result= v == ""||v.trim()=="";
46
+
47
+ }
48
+ else if(typeof value =="number")
49
+ {
50
+ var vN=value as number;
51
+ result= vN == 0;
52
+ }
38
53
  }
39
- return false;
54
+ return this.Negate ? !result : result;
40
55
  }
41
56
  }
@@ -1,4 +1,4 @@
1
- import { SchemaStruct } from "../../Interfaces/SchemaStruct";
1
+ import type{ SchemaStruct } from "../../Interfaces/SchemaStruct";
2
2
  import { InvoiceObj } from "../../Structure/InvoiceObj";
3
3
  import { RecordSingle } from "../../Structure/RecordSingle";
4
4
  import { BaseParse } from "./BaseParse";
@@ -30,7 +30,7 @@ export class ExistParser extends BaseParse {
30
30
  }
31
31
  }
32
32
 
33
- public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
33
+ public Evaluate(obj: InvoiceObj, critm: RecordSingle, _record: any, _item: SchemaStruct):any {
34
34
  if(this.Table==null)
35
35
  {
36
36
  throw "No table"
@@ -0,0 +1,89 @@
1
+ import type{ SchemaStruct } from "../../Interfaces/SchemaStruct";
2
+ import { InvoiceObj } from "../../Structure/InvoiceObj";
3
+ import { RecordSingle } from "../../Structure/RecordSingle";
4
+ import { BaseParse } from "./BaseParse";
5
+ import { CommaParser } from "./CommaParser";
6
+ import { ExpresionLogicService } from "../ExpresionLogicService";
7
+
8
+ export class ExtractParse extends BaseParse {
9
+ private valueParse:BaseParse[]|null = null;
10
+ private regexParse:BaseParse[]|null = null;
11
+ public constructor( valueExpression:string,funname:string)
12
+ {
13
+ super(valueExpression,funname);
14
+ let temp = ExpresionLogicService.GetExpressions(this.Expression, this);
15
+ if(temp==null)
16
+ {
17
+ throw new Error(`Error parsing Sum function: ${this.Expression}`);
18
+ }
19
+ var currentParse:BaseParse[]=[];
20
+ for(let i=0;i<temp.length;i++)
21
+ {
22
+ let t = temp[i];
23
+ if (t instanceof CommaParser)
24
+ {
25
+ if(this.valueParse==null)
26
+ {
27
+ this.valueParse = currentParse;
28
+ currentParse=[];
29
+ }
30
+ else if(this.regexParse==null)
31
+ {
32
+ throw new Error(`Clean function has too many parameters: ${this.Expression}`);
33
+ }
34
+ continue;
35
+ }
36
+ currentParse.push(t);
37
+ }
38
+ if (currentParse.length > 0)
39
+ {
40
+ if (this.valueParse == null)
41
+ {
42
+ this.valueParse = currentParse;
43
+ }
44
+ else
45
+ {
46
+ this.regexParse = currentParse;
47
+ }
48
+ currentParse = [];
49
+ }
50
+ if(this.regexParse==null||this.valueParse==null)
51
+ {
52
+ throw new Error(`Clean function has few parameters: ${this.Expression}`);
53
+ }
54
+ }
55
+
56
+ public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
57
+
58
+ if(this.valueParse==null)
59
+ {
60
+ return;
61
+ }
62
+ let value:any = null;
63
+ if(this.valueParse.length==1)
64
+ {
65
+ value = this.valueParse[0].Evaluate(obj, critm, record, item);
66
+ }
67
+ else
68
+ {
69
+ value=ExpresionLogicService.ConcatValues(this.valueParse, obj, critm, record, item);
70
+ }
71
+ if(this.regexParse==null)
72
+ {
73
+ return value;
74
+ }
75
+ var regex=ExpresionLogicService.ConcatValues(this.regexParse, obj, critm, record, item)?.ToString();
76
+
77
+ if(regex==null)
78
+ {
79
+ return value;
80
+ }
81
+ regex=regex+"/g";
82
+ var temp=value.match("/"+regex+"/g", "");
83
+ if(temp!=null&&temp.length>0)
84
+ {
85
+ return temp[0];
86
+ }
87
+ return null;
88
+ }
89
+ }
@@ -0,0 +1,109 @@
1
+ import { table } from "node:console";
2
+ import type { SchemaStruct } from "../../Interfaces/SchemaStruct";
3
+ import { InvoiceObj } from "../../Structure/InvoiceObj";
4
+ import { RecordSingle } from "../../Structure/RecordSingle";
5
+ import { ExpresionLogicService } from "../ExpresionLogicService";
6
+ import { BaseParse } from "./BaseParse";
7
+ import { CommaParser } from "./CommaParser";
8
+
9
+ export class FromCodeListParse extends BaseParse {
10
+ private codeListTableParse:BaseParse[]|null= null;
11
+ private codeListFieldParse:BaseParse[]|null = null;
12
+ private objectValueExpresionParse:BaseParse[]|null = null;
13
+ private codeListDestFieldParse:BaseParse[]|null = null;
14
+ public constructor( valueExpression:string,funname:string)
15
+ {
16
+ super(valueExpression,funname);
17
+ var dd = ExpresionLogicService.GetExpressions(this.Expression, this);
18
+ var currentList:BaseParse[] = [];
19
+ for (let i = 0; i < (dd?.length??0); i++)
20
+ {
21
+ const d= dd![i];
22
+ if (d instanceof CommaParser)
23
+ {
24
+ if (this.codeListTableParse == null)
25
+ {
26
+ this.codeListTableParse = currentList;
27
+ currentList = [];
28
+ continue;
29
+ }
30
+ else if (this.codeListFieldParse == null)
31
+ {
32
+ this.codeListFieldParse = currentList;
33
+ currentList = [];
34
+ continue;
35
+ }
36
+ else if (this.objectValueExpresionParse == null)
37
+ {
38
+ this.objectValueExpresionParse = currentList;
39
+ currentList = [] ;
40
+ continue;
41
+ }
42
+ else
43
+ {
44
+ throw Error("FromCodeList parse - Too many parameters!");
45
+ }
46
+ }
47
+ currentList.push(d);
48
+ }
49
+ if (currentList.length > 0)
50
+ {
51
+ if (this.objectValueExpresionParse != null && this.codeListDestFieldParse == null)
52
+ {
53
+ this.codeListDestFieldParse = currentList;
54
+ }
55
+ else
56
+ {
57
+ throw new Error("FromCodeList parse - Too few parameters!");
58
+ }
59
+
60
+ }
61
+ }
62
+
63
+ public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
64
+ var codeListTable = ExpresionLogicService.ConcatValues(this.codeListTableParse, obj, critm, record, item);
65
+ if (codeListTable?.toString()==null)
66
+ {
67
+ throw Error("FromCodeList parse - CodeList table is null or empty!");
68
+ }
69
+ var codeListField = ExpresionLogicService.ConcatValues(this.codeListFieldParse, obj, critm, record, item);
70
+ if (codeListField?.toString()==null)
71
+ {
72
+ throw new Error("FromCodeList parse - codeList field is null or empty!");
73
+ }
74
+ var objectValueExpresion = ExpresionLogicService.ConcatValues(this.objectValueExpresionParse, obj, critm, record, item);
75
+ if (objectValueExpresion?.toString()==null)
76
+ {
77
+ // throw new Exception("FromCodeList parse - objectValueExpresion is null or empty!");
78
+ }
79
+ var codeListDestField = ExpresionLogicService.ConcatValues(this.codeListDestFieldParse, obj, critm, record, item);
80
+ if (codeListDestField?.toString()==null)
81
+ {
82
+ throw new Error("FromCodeList parse - codeListDestField is null or empty!");
83
+ }
84
+
85
+ try
86
+ {
87
+ if(obj.CodeListCache==null||obj.CodeListCache[codeListTable.toString()]==null)
88
+ {
89
+ throw new Error("FromCodeList parse - CodeList "+codeListTable.toString()+" not found in cache!");
90
+ }
91
+ var tableLevel=obj.CodeListCache[codeListTable.toString()];
92
+ var candidates=tableLevel.filter((rec:any)=>rec[codeListField.toString()]?.toString()==objectValueExpresion?.toString());
93
+ if(candidates.length==0)
94
+ {
95
+ throw Error("FromCodeList parse - No records found in CodeList "+codeListTable.toString()+" for field "+codeListField.toString()+" and value "+objectValueExpresion?.toString());
96
+ }
97
+ if(candidates.length>1)
98
+ {
99
+ throw Error("FromCodeList parse - Multiple records found in CodeList "+codeListTable.toString()+" for field "+codeListField.toString()+" and value "+objectValueExpresion?.toString());
100
+ }
101
+ return candidates[0][codeListDestField.toString()]?.toString()??null;
102
+
103
+ }
104
+ catch (ex)
105
+ {
106
+ throw new Error("FromCodeList parse - Error obtaining record from CodeList! Reason: " + ex);
107
+ }
108
+ }
109
+ }
@@ -1,4 +1,4 @@
1
- import { SchemaStruct } from "../../Interfaces/SchemaStruct";
1
+ import type{ SchemaStruct } from "../../Interfaces/SchemaStruct";
2
2
  import { InvoiceObj } from "../../Structure/InvoiceObj";
3
3
  import { RecordSingle } from "../../Structure/RecordSingle";
4
4
  import { BaseParse } from "./BaseParse";
@@ -57,7 +57,7 @@ export class IfParse extends BaseParse {
57
57
  condition.push(c.Expression);
58
58
  continue;
59
59
  }
60
-
60
+ result.push(c);
61
61
  }
62
62
  if(result.length>0)
63
63
  {
@@ -351,6 +351,7 @@ export class IfParse extends BaseParse {
351
351
  private evaluateCondition(result:boolean|null):boolean{
352
352
  if(result==null)
353
353
  {
354
+ debugger
354
355
  throw "Can't eval "+this.Expression+"!";
355
356
  }
356
357
  return result;
@@ -1,4 +1,4 @@
1
- import { SchemaStruct } from "../../Interfaces/SchemaStruct";
1
+ import type{ SchemaStruct } from "../../Interfaces/SchemaStruct";
2
2
  import { InvoiceObj } from "../../Structure/InvoiceObj";
3
3
  import { RecordSingle } from "../../Structure/RecordSingle";
4
4
  import { BaseParse } from "./BaseParse";
@@ -54,23 +54,21 @@ export class InDetailParse extends BaseParse {
54
54
  }
55
55
  }
56
56
 
57
- public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
58
- // var tableLevel = obj.FindTableLevel(this.Table, critm.Parent, critm);todo
57
+ public Evaluate(obj: InvoiceObj, _critm: RecordSingle, _record: any, _item: SchemaStruct):any {
58
+
59
59
  var tableLevel = obj.FindTableLevel(this.Table);
60
60
  if (tableLevel==null)
61
61
  {
62
62
  return false;
63
63
  }
64
-
65
-
66
64
  if(tableLevel.Records !=null)
67
65
  {
68
66
  var array= tableLevel.Records.Records;
69
67
  if(!this.Negate)
70
68
  {
71
- for(var i=0;i<tableLevel.Records.Records.length;i++)
69
+ for(var i=0;i<array.length;i++)
72
70
  {
73
- let single=tableLevel.Records.Records[i];
71
+ let single=array[i];
74
72
  if (single.Record[this.Field] == null)
75
73
  {
76
74
  continue;
@@ -86,9 +84,9 @@ export class InDetailParse extends BaseParse {
86
84
  }
87
85
  else
88
86
  {
89
- for(var i=0;i<tableLevel.Records.Records.length;i++)
87
+ for(var i=0;i<array.length;i++)
90
88
  {
91
- let single=tableLevel.Records.Records[i];
89
+ let single=array[i];
92
90
  if (single.Record[this.Field] == null)
93
91
  {
94
92
  continue;
@@ -1,4 +1,4 @@
1
- import { SchemaStruct } from "../../Interfaces/SchemaStruct";
1
+ import type{ SchemaStruct } from "../../Interfaces/SchemaStruct";
2
2
  import { InvoiceObj } from "../../Structure/InvoiceObj";
3
3
  import { RecordSingle } from "../../Structure/RecordSingle";
4
4
  import { BaseParse } from "./BaseParse";
@@ -0,0 +1,39 @@
1
+ import type{ SchemaStruct } from "../../Interfaces/SchemaStruct";
2
+ import { InvoiceObj } from "../../Structure/InvoiceObj";
3
+ import { RecordSingle } from "../../Structure/RecordSingle";
4
+ import { ExpresionLogicService } from "../ExpresionLogicService";
5
+ import { BaseParse } from "./BaseParse";
6
+ import { ValueFromObjParse } from "./ValueFromObjParse";
7
+
8
+ export class LenParse extends BaseParse {
9
+ public constructor( valueExpression:string,funname:string)
10
+ {
11
+ super(valueExpression,funname);
12
+ }
13
+
14
+ public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
15
+
16
+ var express = ExpresionLogicService.GetExpressions(this.Expression, this);
17
+
18
+ if (express?.length == 1)
19
+ {
20
+ var value = express[0].Evaluate(obj, critm, record, item);
21
+
22
+ if (typeof(value)=="string")
23
+ {
24
+ return value.length;
25
+ }
26
+ throw Error("LEN function accepts only string parameters.");
27
+ }
28
+ else
29
+ {
30
+ var value = ExpresionLogicService.ConcatValues(express, obj, critm,record, item);
31
+
32
+ if (typeof(value)=="string")
33
+ {
34
+ return value.length;
35
+ }
36
+ throw Error("LEN function accepts only string parameters.");
37
+ }
38
+ }
39
+ }
@@ -1,4 +1,4 @@
1
- import { SchemaStruct } from "../../Interfaces/SchemaStruct";
1
+ import type{ SchemaStruct } from "../../Interfaces/SchemaStruct";
2
2
  import { InvoiceObj } from "../../Structure/InvoiceObj";
3
3
  import { RecordSingle } from "../../Structure/RecordSingle";
4
4
  import { BaseParse } from "./BaseParse";
@@ -12,7 +12,7 @@ export class LiteralValueParse extends BaseParse {
12
12
 
13
13
  }
14
14
 
15
- public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
15
+ public Evaluate(_obj: InvoiceObj, _critm: RecordSingle, _record: any, _item: SchemaStruct):any {
16
16
  if(this.Expression=="null")
17
17
  {
18
18
  return null;
@@ -1,4 +1,4 @@
1
- import { SchemaStruct } from "../../Interfaces/SchemaStruct";
1
+ import type{ SchemaStruct } from "../../Interfaces/SchemaStruct";
2
2
  import { InvoiceObj } from "../../Structure/InvoiceObj";
3
3
  import { RecordSingle } from "../../Structure/RecordSingle";
4
4
  import { BaseParse } from "./BaseParse";
@@ -10,7 +10,7 @@ export class LogicalOperatorParser extends BaseParse {
10
10
  super(valueExpression,null);
11
11
  }
12
12
 
13
- public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
13
+ public Evaluate(_obj: InvoiceObj, _critm: RecordSingle, _record: any, _item: SchemaStruct):any {
14
14
  return this.Expression;
15
15
  }
16
16
  }
@@ -0,0 +1,41 @@
1
+ import type{ 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
+
7
+ export class MonthParse extends BaseParse {
8
+ public constructor( valueExpression:string,funname:string)
9
+ {
10
+ super(valueExpression,funname);
11
+ }
12
+
13
+ public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
14
+
15
+ var express = new ValueFromObjParse(this.Expression,false);
16
+ var value=express.Evaluate(obj,critm,record,item);
17
+
18
+ var temp:Date|null=null;
19
+ if (value instanceof Date)
20
+ {
21
+ temp = value;
22
+ }
23
+ else if (typeof(value)=="string")
24
+ {
25
+
26
+ temp = new Date(value.toString());
27
+ }
28
+ if(temp==null)
29
+ {
30
+ throw new Error("Can't convert "+value+" isn't datetime!");
31
+ }
32
+ return this.GetMonth(temp.getMonth() + 1);
33
+ }
34
+ private GetMonth(value:number):string{
35
+ if(value>=10)
36
+ {
37
+ return value.toString();
38
+ }
39
+ return "0"+value.toString();
40
+ }
41
+ }
@@ -0,0 +1,17 @@
1
+ import type{ SchemaStruct } from "../../Interfaces/SchemaStruct";
2
+ import { InvoiceObj } from "../../Structure/InvoiceObj";
3
+ import { RecordSingle } from "../../Structure/RecordSingle";
4
+ import { BaseParse } from "./BaseParse";
5
+
6
+
7
+ export class NoEvalParse extends BaseParse {
8
+ public constructor( valueExpression:string,funname:string)
9
+ {
10
+ super(valueExpression,funname);
11
+ }
12
+
13
+ public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
14
+
15
+ return this.Expression;
16
+ }
17
+ }
@@ -1,5 +1,5 @@
1
1
 
2
- import { SchemaStruct } from "../../Interfaces/SchemaStruct";
2
+ import type{ SchemaStruct } from "../../Interfaces/SchemaStruct";
3
3
  import { InvoiceObj } from "../../Structure/InvoiceObj";
4
4
  import { RecordSingle } from "../../Structure/RecordSingle";
5
5
  import { BaseParse } from "./BaseParse";
@@ -1,5 +1,5 @@
1
1
 
2
- import { SchemaStruct } from "../../Interfaces/SchemaStruct";
2
+ import type{ SchemaStruct } from "../../Interfaces/SchemaStruct";
3
3
  import { InvoiceObj } from "../../Structure/InvoiceObj";
4
4
  import { RecordSingle } from "../../Structure/RecordSingle";
5
5
  import { BaseParse } from "./BaseParse";
@@ -11,7 +11,7 @@ export class OperatorParser extends BaseParse {
11
11
  super(valueExpression,null);
12
12
  }
13
13
 
14
- public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
14
+ public Evaluate(_obj: InvoiceObj, _critm: RecordSingle, _record: any, _item: SchemaStruct):any {
15
15
  return this.Expression;
16
16
  }
17
17
  }
@@ -0,0 +1,51 @@
1
+ import type{ SchemaStruct } from "../../Interfaces/SchemaStruct";
2
+ import { InvoiceObj } from "../../Structure/InvoiceObj";
3
+ import { RecordSingle } from "../../Structure/RecordSingle";
4
+ import { ExpresionLogicService } from "../ExpresionLogicService";
5
+ import { BaseParse } from "./BaseParse";
6
+
7
+
8
+ export class RegistryCheckParse extends BaseParse {
9
+ public Table:string="";
10
+ public FieldName:string="";
11
+ public Negate:boolean=false;
12
+
13
+ public constructor( valueExpression:string,funname:string)
14
+ {
15
+ super(valueExpression,funname);
16
+
17
+ }
18
+
19
+ public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
20
+ if(item.ValidValuesRegistry==null)
21
+ {
22
+ throw ("SchemaStruct "+item.Alias+" don't have valid values registry defined.");
23
+ }
24
+ var expressionString = this.Expression;
25
+ if(expressionString==null||expressionString=="")
26
+ {
27
+ expressionString = "%"+item.TableName+"."+item.FieldName+"%";
28
+ }
29
+ var express = ExpresionLogicService.GetExpressions(expressionString, this);
30
+ var value = ExpresionLogicService.ConcatValues(express, obj, critm, record, item);
31
+ if(value==null)
32
+ {
33
+ return null;
34
+ }
35
+ var candidate=item.ValidValuesRegistry.filter((x: { Name: string;Code:string; }) =>
36
+ x.Code.toLowerCase().includes(value.toLowerCase())
37
+ );
38
+ if(candidate!=null&&candidate.length>0)
39
+ {
40
+ return candidate[0].Name;
41
+ }
42
+ candidate = candidate=item.ValidValuesRegistry.filter((x: { Name: string;Code:string; }) =>
43
+ x.Name.toLowerCase().includes(value.toLowerCase()));
44
+ if (candidate != null&&candidate.length>0 )
45
+ {
46
+ return candidate[0].Code;
47
+ }
48
+ //or let previus value?
49
+ return null;
50
+ }
51
+ }
@@ -1,4 +1,4 @@
1
- import { SchemaStruct } from "../../Interfaces/SchemaStruct";
1
+ import type { SchemaStruct } from "../../Interfaces/SchemaStruct";
2
2
  import { InvoiceObj } from "../../Structure/InvoiceObj";
3
3
  import { RecordSingle } from "../../Structure/RecordSingle";
4
4
  import { BaseParse } from "./BaseParse";