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.
- package/Evaluator/ExpresionLogicService.ts +669 -0
- package/Evaluator/Parser/AddLeadZerosParse.ts +70 -0
- package/Evaluator/Parser/AppearParse.ts +67 -0
- package/Evaluator/Parser/BaseParse.ts +93 -0
- package/Evaluator/Parser/CalcDateParse.ts +73 -0
- package/Evaluator/Parser/CheckParse.ts +99 -0
- package/Evaluator/Parser/CommaParser.ts +17 -0
- package/Evaluator/Parser/ConcatParse.ts +34 -0
- package/Evaluator/Parser/CountParse.ts +26 -0
- package/Evaluator/Parser/EmptyParse.ts +41 -0
- package/Evaluator/Parser/ExistParse.ts +69 -0
- package/Evaluator/Parser/IfParse.ts +388 -0
- package/Evaluator/Parser/IfStategment.ts +345 -0
- package/Evaluator/Parser/InDetailParse.ts +109 -0
- package/Evaluator/Parser/InListParse.ts +57 -0
- package/Evaluator/Parser/LiteralValueParse.ts +36 -0
- package/Evaluator/Parser/LogicalOperatorParse.ts +16 -0
- package/Evaluator/Parser/OnlyExpressionParse.ts +137 -0
- package/Evaluator/Parser/OperatorParse.ts +17 -0
- package/Evaluator/Parser/StartsParse.ts +36 -0
- package/Evaluator/Parser/SubstrParse.ts +110 -0
- package/Evaluator/Parser/SumParse.ts +15 -0
- package/Evaluator/Parser/ToNullParser.ts +0 -0
- package/Evaluator/Parser/TrimParse.ts +30 -0
- package/Evaluator/Parser/UpperLoverParse.ts +41 -0
- package/Evaluator/Parser/ValueFromObjParse.ts +37 -0
- package/Evaluator/Parser/ValueParse.ts +61 -0
- package/HelperSessionStorage.ts +13 -0
- package/Interfaces/SchemaStruct.ts +28 -0
- package/Library/jsonrpc-2.0.js +869 -0
- package/Structure/InvoiceObj.ts +691 -0
- package/Structure/RecordArray.ts +145 -0
- package/Structure/RecordSingle.ts +1076 -0
- package/Structure/TableLevel.ts +248 -0
- package/dist/Evaluator/ExpresionLogicService.js +505 -0
- package/dist/Evaluator/Parser/AddLeadZerosParse.js +55 -0
- package/dist/Evaluator/Parser/AppearParse.js +48 -0
- package/dist/Evaluator/Parser/BaseParse.js +89 -0
- package/dist/Evaluator/Parser/CalcDateParse.js +54 -0
- package/dist/Evaluator/Parser/CheckParse.js +80 -0
- package/dist/Evaluator/Parser/CommaParser.js +13 -0
- package/dist/Evaluator/Parser/ConcatParse.js +29 -0
- package/dist/Evaluator/Parser/CountParse.js +23 -0
- package/dist/Evaluator/Parser/EmptyParse.js +35 -0
- package/dist/Evaluator/Parser/ExistParse.js +57 -0
- package/dist/Evaluator/Parser/IfParse.js +296 -0
- package/dist/Evaluator/Parser/IfStategment.js +287 -0
- package/dist/Evaluator/Parser/InDetailParse.js +79 -0
- package/dist/Evaluator/Parser/InListParse.js +40 -0
- package/dist/Evaluator/Parser/LiteralValueParse.js +26 -0
- package/dist/Evaluator/Parser/LogicalOperatorParse.js +13 -0
- package/dist/Evaluator/Parser/OnlyExpressionParse.js +106 -0
- package/dist/Evaluator/Parser/OperatorParse.js +13 -0
- package/dist/Evaluator/Parser/StartsParse.js +30 -0
- package/dist/Evaluator/Parser/SubstrParse.js +83 -0
- package/dist/Evaluator/Parser/SumParse.js +13 -0
- package/dist/Evaluator/Parser/ToNullParser.js +1 -0
- package/dist/Evaluator/Parser/TrimParse.js +25 -0
- package/dist/Evaluator/Parser/UpperLoverParse.js +32 -0
- package/dist/Evaluator/Parser/ValueFromObjParse.js +29 -0
- package/dist/Evaluator/Parser/ValueParse.js +59 -0
- package/dist/HelperSessionStorage.js +12 -0
- package/dist/Interfaces/SchemaStruct.js +2 -0
- package/dist/Structure/InvoiceObj.js +610 -0
- package/dist/Structure/RecordArray.js +102 -0
- package/dist/Structure/RecordSingle.js +950 -0
- package/dist/Structure/TableLevel.js +162 -0
- package/dist/index.js +19 -0
- package/index.ts +20 -0
- package/package.json +20 -0
- package/tsconfig.json +103 -0
|
@@ -0,0 +1,70 @@
|
|
|
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 { CommaParser } from "./CommaParser";
|
|
6
|
+
import { ExpresionLogicService } from "../ExpresionLogicService";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export class AddLeadZerosParse extends BaseParse {
|
|
10
|
+
|
|
11
|
+
public value:BaseParse[]=[];
|
|
12
|
+
public numOfZeros: BaseParse[]=[]
|
|
13
|
+
public constructor( valueExpression:string,funname:string)
|
|
14
|
+
{
|
|
15
|
+
super(valueExpression,funname);
|
|
16
|
+
var dd = ExpresionLogicService.GetExpressions(this.Expression, this);
|
|
17
|
+
if(dd==null)
|
|
18
|
+
{
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
var candidates = dd.filter(x=>x instanceof CommaParser)
|
|
22
|
+
if(candidates.length==0)
|
|
23
|
+
{
|
|
24
|
+
throw "No comma in AddLeadZeros function";
|
|
25
|
+
}
|
|
26
|
+
let list:BaseParse[] = [];
|
|
27
|
+
|
|
28
|
+
dd.forEach(d=>{
|
|
29
|
+
if(d instanceof CommaParser)
|
|
30
|
+
{
|
|
31
|
+
this.value = list; list=[];
|
|
32
|
+
}
|
|
33
|
+
else
|
|
34
|
+
{
|
|
35
|
+
list.push(d);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
this.numOfZeros = list;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
|
|
44
|
+
var valueEval = ExpresionLogicService.ConcatValues(this.value, obj, critm, record, item);
|
|
45
|
+
var numOfZerosEval = ExpresionLogicService.ConcatValues(this.numOfZeros, obj, critm, record, item);
|
|
46
|
+
if(valueEval==null|| numOfZerosEval == null)
|
|
47
|
+
{
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
let length:number = -1;
|
|
51
|
+
if(typeof numOfZerosEval =="number")
|
|
52
|
+
{
|
|
53
|
+
length = numOfZerosEval;
|
|
54
|
+
}
|
|
55
|
+
else if(typeof numOfZerosEval =="string")
|
|
56
|
+
{
|
|
57
|
+
length=parseInt(numOfZerosEval);
|
|
58
|
+
}
|
|
59
|
+
if(length==-1)
|
|
60
|
+
{
|
|
61
|
+
throw "AddLeadZeros function can't be evaluated! expression: "+this.Expression;
|
|
62
|
+
}
|
|
63
|
+
var str = valueEval.ToString();
|
|
64
|
+
while(str.Length<length)
|
|
65
|
+
{
|
|
66
|
+
str = "0" + str;
|
|
67
|
+
}
|
|
68
|
+
return str;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
|
|
7
|
+
export class AppearParse extends BaseParse {
|
|
8
|
+
|
|
9
|
+
public Table:string;
|
|
10
|
+
public FieldName:string="";
|
|
11
|
+
public constructor( valueExpression:string,funname:string)
|
|
12
|
+
{
|
|
13
|
+
super(valueExpression,funname);
|
|
14
|
+
var split=this.Expression.split("." );
|
|
15
|
+
this.Table = split[0];
|
|
16
|
+
if(split.length > 1)
|
|
17
|
+
{
|
|
18
|
+
this.FieldName = split[1];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
|
|
23
|
+
var tablelevel = obj.FindTableLevel(this.Table);
|
|
24
|
+
if(tablelevel == null)
|
|
25
|
+
{
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
let list:RecordSingle[]=[];;
|
|
29
|
+
if(tablelevel.Record!=null)
|
|
30
|
+
{
|
|
31
|
+
|
|
32
|
+
list.push(tablelevel.Record);
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
else if (tablelevel.Records !=null)
|
|
36
|
+
{
|
|
37
|
+
var rec = tablelevel.Records ;
|
|
38
|
+
if(rec.Records.length==0)
|
|
39
|
+
{
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
rec.Records.forEach(element=>{
|
|
43
|
+
list.push(element);
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
if(list.length==0)
|
|
49
|
+
{
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
if (this.FieldName=="")
|
|
53
|
+
{
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
for(var i=0;i<list.length;i++)
|
|
57
|
+
{
|
|
58
|
+
if(list[i].Record[this.FieldName]!=null)
|
|
59
|
+
{
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return false ;
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { SchemaStruct } from "../../Interfaces/SchemaStruct";
|
|
2
|
+
import { InvoiceObj } from "../../Structure/InvoiceObj";
|
|
3
|
+
import { RecordSingle } from "../../Structure/RecordSingle";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export abstract class BaseParse {
|
|
7
|
+
public static operators:string[] =[ "<=", ">=", "!=", "<>", "==", "<", ">", "=" ];
|
|
8
|
+
public static logicaloperators:string[] = [ "&&", "||" ];
|
|
9
|
+
|
|
10
|
+
public Expression:string="";
|
|
11
|
+
public FunName:string|null= null;
|
|
12
|
+
|
|
13
|
+
public constructor(expression:string, funName:string|null)
|
|
14
|
+
{
|
|
15
|
+
if (funName==null||funName=="")
|
|
16
|
+
{
|
|
17
|
+
this.Expression = expression;
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
else
|
|
21
|
+
{
|
|
22
|
+
this.Expression = expression.substring(funName.length, expression.length-1);
|
|
23
|
+
this.FunName = funName;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
public abstract Evaluate(obj:InvoiceObj, critm:RecordSingle, record:any, item:SchemaStruct):any;
|
|
29
|
+
public static getIsoDateWithTime(date: Date, time: string): string | null {
|
|
30
|
+
if (date == null) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
if (typeof date == "string") {
|
|
34
|
+
return date;
|
|
35
|
+
}
|
|
36
|
+
return date.getFullYear() + "-" +
|
|
37
|
+
this.formatToTwoNumber(date.getMonth() + 1) + "-" +
|
|
38
|
+
this.formatToTwoNumber(date.getDate()) + time;
|
|
39
|
+
}
|
|
40
|
+
public static getIsoDateTime(date: Date) {
|
|
41
|
+
if (date == null) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
if (typeof (date) == "string") {
|
|
45
|
+
return date;
|
|
46
|
+
}
|
|
47
|
+
return date.getFullYear() + "-" +
|
|
48
|
+
this.formatToTwoNumber(date.getMonth() + 1) + "-" +
|
|
49
|
+
this.formatToTwoNumber(date.getDate()) + "T" +
|
|
50
|
+
this.formatToTwoNumber(date.getHours()) + ":" +
|
|
51
|
+
this.formatToTwoNumber(date.getMinutes()) + ":" +
|
|
52
|
+
this.formatToTwoNumber(date.getSeconds());
|
|
53
|
+
}
|
|
54
|
+
public static parseDateTime(datetime: string) {
|
|
55
|
+
return new Date(datetime);
|
|
56
|
+
}
|
|
57
|
+
public static parseDate(datetime: string) {
|
|
58
|
+
return new Date(datetime);
|
|
59
|
+
}
|
|
60
|
+
public static formatToTwoNumber(num: number) {
|
|
61
|
+
if (num < 10) {
|
|
62
|
+
return "0" + num;
|
|
63
|
+
}
|
|
64
|
+
return num.toString();
|
|
65
|
+
}
|
|
66
|
+
public static getIsoDate(date: Date): string | null {
|
|
67
|
+
if (date == null) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
if (typeof date == "string") {
|
|
71
|
+
return date;
|
|
72
|
+
}
|
|
73
|
+
return date.getFullYear() + "-" +
|
|
74
|
+
this.formatToTwoNumber(date.getMonth() + 1) + "-" +
|
|
75
|
+
this.formatToTwoNumber(date.getDate()) + "T00:00:00";
|
|
76
|
+
}
|
|
77
|
+
public static roundUp(num: number, r: number) {
|
|
78
|
+
let negative = false;
|
|
79
|
+
if (num < 0) { negative = true } else { negative = false };
|
|
80
|
+
if (negative) { num = num - 10 ** -13; }
|
|
81
|
+
else { num = num + 10 ** -13; }
|
|
82
|
+
num = Math.abs(num);
|
|
83
|
+
let temp1 = Math.round(num * Math.pow(10, r)) / (Math.pow(10, r));
|
|
84
|
+
if (negative) {
|
|
85
|
+
return (-1) * temp1;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return temp1;
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
@@ -0,0 +1,73 @@
|
|
|
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 { OnlyExpressionParse } from "./OnlyExpressionParse";
|
|
7
|
+
|
|
8
|
+
export class CalcDateParse extends BaseParse {
|
|
9
|
+
public value :string="";
|
|
10
|
+
public offset:string="";
|
|
11
|
+
public constructor( valueExpression:string,funname:string)
|
|
12
|
+
{
|
|
13
|
+
super(valueExpression,funname);
|
|
14
|
+
var split = this.Expression.split("," );
|
|
15
|
+
if (split.length == 2)
|
|
16
|
+
{
|
|
17
|
+
this.value = split[0];
|
|
18
|
+
this.offset = split[1];
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
|
|
25
|
+
if(this.value==""||this.offset=="")
|
|
26
|
+
{
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
var valueEval = new OnlyExpressionParse(this.value);
|
|
30
|
+
var valueE = valueEval.Evaluate(obj, critm, record, item);
|
|
31
|
+
|
|
32
|
+
var offsetEval = new OnlyExpressionParse(this.offset);
|
|
33
|
+
var offsetE = offsetEval.Evaluate(obj, critm, record, item);
|
|
34
|
+
var datetimeValue:Date|null = null;
|
|
35
|
+
var offsetInt:number|null = null;
|
|
36
|
+
if (valueE.constructor.name=="Date")
|
|
37
|
+
{
|
|
38
|
+
datetimeValue = valueE;
|
|
39
|
+
}
|
|
40
|
+
else if (typeof valueE =="string")
|
|
41
|
+
{
|
|
42
|
+
datetimeValue=new Date(valueE);
|
|
43
|
+
}
|
|
44
|
+
if (typeof offsetE == "number")
|
|
45
|
+
{
|
|
46
|
+
offsetInt = offsetE;
|
|
47
|
+
}
|
|
48
|
+
else if (typeof offsetE == "string")
|
|
49
|
+
{
|
|
50
|
+
offsetInt=parseInt(offsetE);
|
|
51
|
+
}
|
|
52
|
+
if (offsetInt!=null && datetimeValue!=null)
|
|
53
|
+
{
|
|
54
|
+
datetimeValue.setDate(datetimeValue.getDate() + offsetInt);
|
|
55
|
+
|
|
56
|
+
if (item.TypeDDD == "Date")
|
|
57
|
+
{
|
|
58
|
+
return BaseParse.getIsoDate(datetimeValue);
|
|
59
|
+
}
|
|
60
|
+
else if (item.TypeDDD == "DateTime")
|
|
61
|
+
{
|
|
62
|
+
return BaseParse.getIsoDateTime(datetimeValue);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else
|
|
66
|
+
{
|
|
67
|
+
debugger
|
|
68
|
+
}
|
|
69
|
+
return this.Expression;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
|
|
7
|
+
export class CheckParse extends BaseParse {
|
|
8
|
+
public Detail :string="";
|
|
9
|
+
public Exp:string="";
|
|
10
|
+
public Parameter:string="";
|
|
11
|
+
public constructor( valueExpression:string,funname:string)
|
|
12
|
+
{
|
|
13
|
+
super(valueExpression,funname);
|
|
14
|
+
var split = this.Expression.split("," );
|
|
15
|
+
if (split.length == 2)
|
|
16
|
+
{
|
|
17
|
+
var split = this.Expression.split("," );
|
|
18
|
+
if(split.length!=3 )
|
|
19
|
+
{
|
|
20
|
+
throw "Check have more or less parameters that 3";
|
|
21
|
+
}
|
|
22
|
+
this.Detail = split[0];
|
|
23
|
+
this.Exp = split[1];
|
|
24
|
+
this.Parameter = split[2];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
|
|
29
|
+
var list:RecordSingle[] = [];
|
|
30
|
+
if (InvoiceObj.isMultiple(this.Detail))
|
|
31
|
+
{
|
|
32
|
+
/*var tableLevels = obj.(Detail);
|
|
33
|
+
if (tableLevels == null||tableLevels.Count==0)
|
|
34
|
+
{
|
|
35
|
+
throw new Exception($"Can't find level {Detail}");
|
|
36
|
+
}
|
|
37
|
+
foreach(var tab in tableLevels)
|
|
38
|
+
{
|
|
39
|
+
var array = tab.Records as RecordLevelArray;
|
|
40
|
+
foreach(var rec in array.Records)
|
|
41
|
+
{
|
|
42
|
+
list.Add(rec);
|
|
43
|
+
}
|
|
44
|
+
} */
|
|
45
|
+
}
|
|
46
|
+
else
|
|
47
|
+
{
|
|
48
|
+
var tableLevel = obj.FindTableLevel(this.Detail);
|
|
49
|
+
if (tableLevel == null)
|
|
50
|
+
{
|
|
51
|
+
throw "Can't find level {Detail}";
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (tableLevel.Record!=null)
|
|
55
|
+
{
|
|
56
|
+
throw "Table level isn't detail!";
|
|
57
|
+
}
|
|
58
|
+
if (tableLevel.Records == null)
|
|
59
|
+
{
|
|
60
|
+
throw "Table level doesn't have records!";
|
|
61
|
+
}
|
|
62
|
+
var array = tableLevel.Records.Records ;
|
|
63
|
+
for(var i=0;i<array.length;i++)
|
|
64
|
+
{
|
|
65
|
+
list.push(array[i]);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
var trueCounter = 0;
|
|
69
|
+
|
|
70
|
+
for(var i=0;i<list.length;i++)
|
|
71
|
+
{
|
|
72
|
+
/*var result = ExpressionLogic.ParseExpressionAndReturnValue("IF("+this.Exp+",true,false)", obj, item, rec, 0);
|
|
73
|
+
if(result=="true")
|
|
74
|
+
{
|
|
75
|
+
trueCounter++;
|
|
76
|
+
if(this.Parameter?.toLocaleLowerCase() =="one")
|
|
77
|
+
{
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
}TODO*/
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
if(this.Parameter?.toLocaleLowerCase() =="one")
|
|
85
|
+
{
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
else if(this.Parameter?.toLocaleLowerCase() =="all")
|
|
89
|
+
{
|
|
90
|
+
return trueCounter == list.length;
|
|
91
|
+
}
|
|
92
|
+
else
|
|
93
|
+
{
|
|
94
|
+
throw "Check prameter isn't valid!Valid:One,All.Provided:"+this.Parameter;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
|
|
7
|
+
export class CommaParser extends BaseParse {
|
|
8
|
+
|
|
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
|
+
return this.Expression;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 { CommaParser } from "./CommaParser";
|
|
6
|
+
import { ExpresionLogicService } from "../ExpresionLogicService";
|
|
7
|
+
|
|
8
|
+
export class ConcatParse extends BaseParse {
|
|
9
|
+
public sections:BaseParse[]=[];
|
|
10
|
+
public constructor( valueExpression:string,funname:string)
|
|
11
|
+
{
|
|
12
|
+
super(valueExpression,funname);
|
|
13
|
+
this.sections=ExpresionLogicService.GetExpressions(this.Expression, this)??[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
|
|
17
|
+
var builder = "";
|
|
18
|
+
for(var i=0;i<this.sections.length;i++)
|
|
19
|
+
{
|
|
20
|
+
let section:BaseParse=this.sections[i];
|
|
21
|
+
if(section instanceof CommaParser)
|
|
22
|
+
{
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
var value = section.Evaluate(obj, critm, record, item);
|
|
26
|
+
if(value != null)
|
|
27
|
+
{
|
|
28
|
+
builder+=value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return builder;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 CountParse extends BaseParse {
|
|
7
|
+
public Table:string=";"
|
|
8
|
+
public constructor( valueExpression:string,funname:string)
|
|
9
|
+
{
|
|
10
|
+
super(valueExpression,funname);
|
|
11
|
+
this.Table=this.Expression;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
|
|
15
|
+
if(this.Table=="")
|
|
16
|
+
{
|
|
17
|
+
throw "Function count don't have defined table!";
|
|
18
|
+
}
|
|
19
|
+
var tableLevel = obj.FindTableLevel(this.Table);
|
|
20
|
+
if (tableLevel == null)
|
|
21
|
+
{
|
|
22
|
+
return -1;
|
|
23
|
+
}
|
|
24
|
+
return tableLevel.Records?.Records.length;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { OnlyExpressionParse } from "./OnlyExpressionParse";
|
|
6
|
+
import { ExpresionLogicService } from "../ExpresionLogicService";
|
|
7
|
+
|
|
8
|
+
export class EmptyParse extends BaseParse {
|
|
9
|
+
public valueExp:OnlyExpressionParse|null=null
|
|
10
|
+
public constructor( valueExpression:string,funname:string)
|
|
11
|
+
{
|
|
12
|
+
super(valueExpression,funname);
|
|
13
|
+
var dd = ExpresionLogicService.GetExpressions(this.Expression, this);
|
|
14
|
+
if(dd==null)
|
|
15
|
+
{
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if(dd.length==1&&dd[0] instanceof OnlyExpressionParse)
|
|
19
|
+
{
|
|
20
|
+
this.valueExp = dd[0] as OnlyExpressionParse;
|
|
21
|
+
}
|
|
22
|
+
else
|
|
23
|
+
{
|
|
24
|
+
throw "Expression '"+this.Expression+"' isn't ValueFromObjParse";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
|
|
29
|
+
var value = this.valueExp?.Evaluate(obj, critm, record, item);
|
|
30
|
+
if(value == null)
|
|
31
|
+
{
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
if(typeof value =="string")
|
|
35
|
+
{
|
|
36
|
+
var v=value as string;
|
|
37
|
+
return v == ""||v.trim()=="";
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
|
|
7
|
+
export class ExistParser extends BaseParse {
|
|
8
|
+
public Table:string="";
|
|
9
|
+
public FieldName:string="";
|
|
10
|
+
public Negate:boolean=false;
|
|
11
|
+
|
|
12
|
+
public constructor( valueExpression:string,funname:string)
|
|
13
|
+
{
|
|
14
|
+
super(valueExpression,funname);
|
|
15
|
+
if (funname.toLowerCase()=="notexists(")
|
|
16
|
+
{
|
|
17
|
+
this.Negate = true;
|
|
18
|
+
}
|
|
19
|
+
var split = this.Expression.split("." );
|
|
20
|
+
if (split.length != 2)
|
|
21
|
+
{
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
this.Table = split[0];
|
|
25
|
+
this.FieldName = split[1];
|
|
26
|
+
if (this.Table?.startsWith("!"))
|
|
27
|
+
{
|
|
28
|
+
this.Table = this.Table.substring(1);
|
|
29
|
+
this.Negate = true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
|
|
34
|
+
if(this.Table==null)
|
|
35
|
+
{
|
|
36
|
+
throw "No table"
|
|
37
|
+
}
|
|
38
|
+
var tableLevel = obj.FindTableLevel(this.Table);
|
|
39
|
+
if (tableLevel == null)
|
|
40
|
+
{
|
|
41
|
+
throw "Table level "+this.Table+" don't exist in object!";
|
|
42
|
+
}
|
|
43
|
+
let exist:boolean=false;;
|
|
44
|
+
if(tableLevel==obj.rootLevel)
|
|
45
|
+
{
|
|
46
|
+
var rec = tableLevel.Record;
|
|
47
|
+
exist = rec?.Record.Record[this.FieldName]!=null;
|
|
48
|
+
}
|
|
49
|
+
else
|
|
50
|
+
{
|
|
51
|
+
var records = tableLevel.Records;
|
|
52
|
+
if(records==null)
|
|
53
|
+
{
|
|
54
|
+
throw "Table level "+this.Table+" don't have active records!";
|
|
55
|
+
}
|
|
56
|
+
var index = records.Records.indexOf(critm);
|
|
57
|
+
if(index==-1)
|
|
58
|
+
{
|
|
59
|
+
throw "Table level "+this.Table+" not the same as record!"+critm?.Parent?.Tablename;
|
|
60
|
+
}
|
|
61
|
+
exist = records.Records[index].Record[this.FieldName]!=null;
|
|
62
|
+
}
|
|
63
|
+
if(this.Negate)
|
|
64
|
+
{
|
|
65
|
+
exist = !exist;
|
|
66
|
+
}
|
|
67
|
+
return exist;
|
|
68
|
+
}
|
|
69
|
+
}
|