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.
- package/dist/js-gei.es.js +36987 -1084
- package/dist/js-gei.umd.js +64 -2
- package/package.json +6 -2
- package/src/Evaluator/CodeLogic/CodeLogicBaseService.ts +33 -0
- package/src/Evaluator/CodeLogic/CodeLogicItemsService.ts +38 -0
- package/src/Evaluator/CodeLogic/CodeLogicVatsUIService.ts +135 -0
- package/src/Evaluator/ExpresionLogicService.ts +81 -50
- package/src/Evaluator/HelpersTables.ts +9 -4
- package/src/Evaluator/Parser/AddLeadZerosParse.ts +1 -1
- package/src/Evaluator/Parser/AppearParse.ts +2 -2
- package/src/Evaluator/Parser/BaseParse.ts +1 -1
- package/src/Evaluator/Parser/CalcDateParse.ts +1 -1
- package/src/Evaluator/Parser/CheckParse.ts +7 -4
- package/src/Evaluator/Parser/CleanParse.ts +1 -1
- package/src/Evaluator/Parser/CodeListCheckParse.ts +50 -0
- package/src/Evaluator/Parser/CommaParser.ts +2 -2
- package/src/Evaluator/Parser/ConcatParse.ts +1 -1
- package/src/Evaluator/Parser/CountParse.ts +2 -2
- package/src/Evaluator/Parser/DateTimeFormatParse.ts +4 -3
- package/src/Evaluator/Parser/EmptyParse.ts +22 -7
- package/src/Evaluator/Parser/ExistParse.ts +2 -2
- package/src/Evaluator/Parser/ExtractParse.ts +89 -0
- package/src/Evaluator/Parser/FromCodeListParse.ts +109 -0
- package/src/Evaluator/Parser/IfParse.ts +3 -2
- package/src/Evaluator/Parser/InDetailParse.ts +7 -9
- package/src/Evaluator/Parser/InListParse.ts +1 -1
- package/src/Evaluator/Parser/LenParse.ts +39 -0
- package/src/Evaluator/Parser/LiteralValueParse.ts +2 -2
- package/src/Evaluator/Parser/LogicalOperatorParse.ts +2 -2
- package/src/Evaluator/Parser/MonthParse.ts +41 -0
- package/src/Evaluator/Parser/NoEvalParse.ts +17 -0
- package/src/Evaluator/Parser/OnlyExpressionParse.ts +1 -1
- package/src/Evaluator/Parser/OperatorParse.ts +2 -2
- package/src/Evaluator/Parser/RegistryCheckParse.ts +51 -0
- package/src/Evaluator/Parser/StartsParse.ts +1 -1
- package/src/Evaluator/Parser/SubstrParse.ts +1 -1
- package/src/Evaluator/Parser/SumParse.ts +2 -2
- package/src/Evaluator/Parser/TimeParse.ts +92 -0
- package/src/Evaluator/Parser/ToNullParse.ts +62 -0
- package/src/Evaluator/Parser/TotalMinutesParse.ts +95 -0
- package/src/Evaluator/Parser/TrimParse.ts +1 -1
- package/src/Evaluator/Parser/UpperLoverParse.ts +1 -1
- package/src/Evaluator/Parser/UseFirstParse.ts +1 -1
- package/src/Evaluator/Parser/ValueFromObjParse.ts +2 -2
- package/src/Evaluator/Parser/ValueParse.ts +3 -3
- package/src/Evaluator/Parser/YearParse.ts +34 -0
- package/src/HelperSessionStorage.ts +5 -1
- package/src/Interfaces/SchemaStruct.ts +4 -2
- package/src/Lib/axios-1.4.0.min.js +2 -0
- package/src/Lib/jsonrpc-2.0.js +874 -0
- package/src/Lib/jsonrpc-2.0.js.bak +874 -0
- package/src/Structure/InvoiceObj.ts +96 -33
- package/src/Structure/RecordArray.ts +27 -10
- package/src/Structure/RecordSingle.ts +216 -87
- package/src/Structure/TableLevel.ts +34 -4
- package/src/main.ts +265 -18
- package/src/Evaluator/Parser/ToNullParser.ts +0 -0
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js-gei",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Lightweight TypeScript library template using Vite",
|
|
5
5
|
"main": "dist/js-gei.umd.js",
|
|
6
6
|
"module": "dist/js-gei.es.js",
|
|
7
7
|
"types": "dist/types/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"dev": "vite",
|
|
9
|
+
"dev": "env-cmd -f .env.dev vite",
|
|
10
10
|
"build": "tsc && vite build",
|
|
11
11
|
"test": "vitest",
|
|
12
12
|
"debug": "node --inspect-brk ./node_modules/vite/bin/vite.js"
|
|
@@ -20,5 +20,9 @@
|
|
|
20
20
|
"typescript": "^5.0.0",
|
|
21
21
|
"vite": "^5.0.0",
|
|
22
22
|
"vitest": "^1.0.0"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"date-fns": "^4.1.0",
|
|
26
|
+
"mathjs": "^15.2.0"
|
|
23
27
|
}
|
|
24
28
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { InvoiceObj } from "../../Structure/InvoiceObj";
|
|
2
|
+
import { RecordSingle } from "../../Structure/RecordSingle";
|
|
3
|
+
|
|
4
|
+
export class CodeLogicBaseService{
|
|
5
|
+
public static GetRecords(obj:InvoiceObj , citm:RecordSingle):RecordSingle[]|null
|
|
6
|
+
{
|
|
7
|
+
return citm.GetReferenceRecords("__VatRate");
|
|
8
|
+
}
|
|
9
|
+
public static SumByFieldNameAndVarCode(fieldName:string, obj:InvoiceObj, citm:RecordSingle)
|
|
10
|
+
{
|
|
11
|
+
var records = this.GetRecords(obj, citm);
|
|
12
|
+
if(records == null)
|
|
13
|
+
{
|
|
14
|
+
return 0;
|
|
15
|
+
}
|
|
16
|
+
var sum:number = 0;
|
|
17
|
+
for (var i=0;i<records.length;i++)
|
|
18
|
+
{
|
|
19
|
+
sum += records[i].Record[fieldName]??0;
|
|
20
|
+
}
|
|
21
|
+
return sum;
|
|
22
|
+
}
|
|
23
|
+
public static GetFirstRecordItem( obj:InvoiceObj, citm:RecordSingle):RecordSingle|null{
|
|
24
|
+
|
|
25
|
+
var records = this.GetRecords(obj, citm);
|
|
26
|
+
if(records == null){
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return records[0];
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SchemaStruct } from "../../Interfaces/SchemaStruct";
|
|
2
|
+
import { InvoiceObj } from "../../Structure/InvoiceObj";
|
|
3
|
+
import { RecordSingle } from "../../Structure/RecordSingle";
|
|
4
|
+
import { CodeLogicBaseService } from "./CodeLogicBaseService";
|
|
5
|
+
export class CodeLogicItemsService{
|
|
6
|
+
|
|
7
|
+
public static Execute( item:SchemaStruct,obj:InvoiceObj|null, citm:RecordSingle, record:any)
|
|
8
|
+
{
|
|
9
|
+
if(obj==null)
|
|
10
|
+
{
|
|
11
|
+
return "Invoice object is null";
|
|
12
|
+
}
|
|
13
|
+
switch (item.FieldName)
|
|
14
|
+
{
|
|
15
|
+
case "LineIdent":
|
|
16
|
+
{
|
|
17
|
+
var records = this.GetRecords(obj);
|
|
18
|
+
var index = records.indexOf(citm) + 1;
|
|
19
|
+
citm.SetValueToKey(item, index, record);
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
private static GetRecords( obj:InvoiceObj):RecordSingle[]
|
|
27
|
+
{
|
|
28
|
+
var tableLevel = obj.FindTableLevel("EU_Invoices_Items");
|
|
29
|
+
if (tableLevel == null)
|
|
30
|
+
{
|
|
31
|
+
throw Error("Can't find level EU_Invoices_Items");
|
|
32
|
+
}
|
|
33
|
+
var records = tableLevel.Records ;
|
|
34
|
+
|
|
35
|
+
return records?.Records ?? [];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { SchemaStruct } from "../../Interfaces/SchemaStruct";
|
|
2
|
+
import { InvoiceObj } from "../../Structure/InvoiceObj";
|
|
3
|
+
import { RecordSingle } from "../../Structure/RecordSingle";
|
|
4
|
+
import { CodeLogicBaseService } from "./CodeLogicBaseService";
|
|
5
|
+
|
|
6
|
+
export class CodeLogicVatsUIService{
|
|
7
|
+
|
|
8
|
+
public static Execute( item:SchemaStruct,obj:InvoiceObj|null, citm:RecordSingle, record:any)
|
|
9
|
+
{
|
|
10
|
+
if(obj == null)
|
|
11
|
+
{
|
|
12
|
+
return "Invoice object is null";
|
|
13
|
+
}
|
|
14
|
+
switch (item.FieldName)
|
|
15
|
+
{
|
|
16
|
+
case "VatInvAllowAmount":
|
|
17
|
+
{
|
|
18
|
+
citm.SetValueToKey(item, CodeLogicBaseService.SumByFieldNameAndVarCode("LineInvAllowAmount", obj, citm), record);
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
case "VatTaxableAmount":
|
|
23
|
+
{
|
|
24
|
+
citm.SetValueToKey(item, CodeLogicBaseService.SumByFieldNameAndVarCode("LineTotalNetAmount", obj, citm), record);
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
case "VatTaxAmount":
|
|
28
|
+
{
|
|
29
|
+
citm.SetValueToKey(item, CodeLogicBaseService.SumByFieldNameAndVarCode("LineTotalVatAmount", obj, citm), record);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
case "VatInvChargeAmount":
|
|
33
|
+
{
|
|
34
|
+
citm.SetValueToKey(item, CodeLogicBaseService.SumByFieldNameAndVarCode("LineTotalVatAmount", obj, citm), record);
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
case "VatInvAllowBaseAmount":
|
|
38
|
+
{
|
|
39
|
+
citm.SetValueToKey(item, CodeLogicBaseService.SumByFieldNameAndVarCode("LineBaseAmountInclAllow", obj, citm), record);
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
case "VatInvChargeBaseAmount":
|
|
43
|
+
{
|
|
44
|
+
citm.SetValueToKey(item, CodeLogicBaseService.SumByFieldNameAndVarCode("LineTotalVatAmount", obj, citm), record);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case "VatCatCode":
|
|
48
|
+
{
|
|
49
|
+
var rec = CodeLogicBaseService.GetFirstRecordItem( obj, citm);
|
|
50
|
+
if (rec != null)
|
|
51
|
+
{
|
|
52
|
+
citm.SetValueToKey(item, rec.RecordAnalitic["ItemVatCodeSC__VCCode_EN16931"], record);
|
|
53
|
+
}
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
case "VatCode":
|
|
57
|
+
{
|
|
58
|
+
var rec = CodeLogicBaseService.GetFirstRecordItem(obj,citm);
|
|
59
|
+
if (rec != null)
|
|
60
|
+
{
|
|
61
|
+
citm.SetValueToKey(item, rec.RecordAnalitic["ItemVatCodeSC__VatCode"], record);
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
case "VatRate":
|
|
66
|
+
{
|
|
67
|
+
var rec = CodeLogicBaseService.GetFirstRecordItem(obj, citm);
|
|
68
|
+
if (rec != null)
|
|
69
|
+
{
|
|
70
|
+
citm.SetValueToKey(item, rec.RecordAnalitic["ItemVatCodeSC__Rate"], record);
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
case "VatCodeUI":
|
|
75
|
+
{
|
|
76
|
+
var rec = CodeLogicBaseService.GetFirstRecordItem(obj, citm);
|
|
77
|
+
if (rec != null)
|
|
78
|
+
{
|
|
79
|
+
citm.SetValueToKey(item, rec.RecordAnalitic["ItemVatCodeSC__GroupUIVatCode"], record);
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
case "VatExemptReasonDesc":
|
|
85
|
+
{
|
|
86
|
+
var recs = CodeLogicBaseService.GetRecords(obj, citm);
|
|
87
|
+
if (recs != null && recs.length > 0)
|
|
88
|
+
{
|
|
89
|
+
var hash = new Set<string>();
|
|
90
|
+
for (var i = 0; i < recs.length; i++)
|
|
91
|
+
{
|
|
92
|
+
var r = recs[i];
|
|
93
|
+
if (r.Record["ItemVatCodeSC__VatCode"] == "E_999")
|
|
94
|
+
{
|
|
95
|
+
hash.add(r.Record["VatExemReasonDescE_999"] ?? "");
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
hash.add(r.RecordAnalitic["ItemVatCodeSC__VERDesc"] ?? "");
|
|
99
|
+
}
|
|
100
|
+
const filteredSet = new Set(
|
|
101
|
+
[...hash].filter(x => x !="")
|
|
102
|
+
);
|
|
103
|
+
if (filteredSet.size > 0)
|
|
104
|
+
{
|
|
105
|
+
citm.SetValueToKey(item, [...filteredSet].join(', '), record);
|
|
106
|
+
}
|
|
107
|
+
else
|
|
108
|
+
{
|
|
109
|
+
citm.SetValueToKey(item, null, record);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
case "VatExemptReasonCode":
|
|
116
|
+
{
|
|
117
|
+
var rec = CodeLogicBaseService.GetFirstRecordItem(obj, citm);
|
|
118
|
+
if (rec != null)
|
|
119
|
+
{
|
|
120
|
+
citm.SetValueToKey(item, null, record);
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
case "NumOfItems":
|
|
125
|
+
{
|
|
126
|
+
var recs = CodeLogicBaseService.GetRecords(obj, citm);
|
|
127
|
+
if (recs != null)
|
|
128
|
+
{
|
|
129
|
+
citm.SetValueToKey(item, recs.length, record);
|
|
130
|
+
}
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -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 './Parser/BaseParse';
|
|
@@ -28,39 +28,69 @@ import { CheckParse } from "./Parser/CheckParse";
|
|
|
28
28
|
import { TrimParse } from "./Parser/TrimParse";
|
|
29
29
|
import { ValueParse } from './Parser/ValueParse';
|
|
30
30
|
import { UseFirstParse } from './Parser/UseFirstParse';
|
|
31
|
-
|
|
31
|
+
import { RegistryCheckParse } from './Parser/RegistryCheckParse';
|
|
32
|
+
import { YearParse } from './Parser/YearParse';
|
|
33
|
+
import { MonthParse } from './Parser/MonthParse';
|
|
34
|
+
import { CleanParse } from './Parser/CleanParse';
|
|
35
|
+
import { ExtractParse } from './Parser/ExtractParse';
|
|
36
|
+
import { DateTimeFormat } from './Parser/DateTimeFormatParse';
|
|
37
|
+
import { ToNullParse } from './Parser/ToNullParse';
|
|
38
|
+
import { NoEvalParse } from './Parser/NoEvalParse';
|
|
39
|
+
import { TotalMinutesParse } from './Parser/TotalMinutesParse';
|
|
40
|
+
import { TimeParse } from './Parser/TimeParse';
|
|
41
|
+
import { LenParse } from './Parser/LenParse';
|
|
42
|
+
import { FromCodeListParse } from './Parser/FromCodeListParse';
|
|
43
|
+
import { CodeListCheckParse } from './Parser/CodeListCheckParse';
|
|
44
|
+
import { evaluate } from 'mathjs';
|
|
32
45
|
export class ExpresionLogicService {
|
|
33
46
|
|
|
34
47
|
constructor() { }
|
|
35
48
|
public static _suportedFunctions:any =
|
|
36
|
-
{
|
|
49
|
+
{ "tonull(":ToNullParse,
|
|
37
50
|
"sum(":SumParse,
|
|
38
51
|
"if(":IfParse,
|
|
39
|
-
"addleadzeros(":AddLeadZerosParse,
|
|
40
|
-
"appear(":AppearParse,
|
|
41
52
|
"calcdate(":CalcDateParse,
|
|
42
|
-
"
|
|
43
|
-
"lower(":UpperLowerParse,
|
|
44
|
-
"inlist(":INListParser,
|
|
45
|
-
"notinlist(":INListParser,
|
|
46
|
-
"indetail(":InDetailParse,
|
|
47
|
-
"notindetail(":InDetailParse,
|
|
53
|
+
"addleadzeros(":AddLeadZerosParse,
|
|
48
54
|
"starts(":StartsParse,
|
|
49
55
|
"substr(":SubstrParse,
|
|
50
56
|
"count(":CountParse,
|
|
51
57
|
"check(":CheckParse,
|
|
52
58
|
"concat(":ConcatParse,
|
|
53
59
|
"empty(":EmptyParse,
|
|
60
|
+
"nonempty(":EmptyParse,
|
|
54
61
|
"exists(":ExistParser,
|
|
55
62
|
"notexists(":ExistParser,
|
|
56
|
-
"
|
|
63
|
+
"noeval(":NoEvalParse,
|
|
64
|
+
"appear(":AppearParse,
|
|
57
65
|
"value(":ValueParse,
|
|
58
|
-
"
|
|
66
|
+
"year(":YearParse,
|
|
67
|
+
"month(":MonthParse,
|
|
68
|
+
"screxists(":CodeListCheckParse,
|
|
69
|
+
"inlist(":INListParser,
|
|
70
|
+
"notinlist(":INListParser,
|
|
71
|
+
"indetail(":InDetailParse,
|
|
72
|
+
"notindetail(":InDetailParse,
|
|
73
|
+
"upper(":UpperLowerParse,
|
|
74
|
+
"lower(":UpperLowerParse,
|
|
75
|
+
"trim(":TrimParse,
|
|
76
|
+
"totalminutes(":TotalMinutesParse,
|
|
77
|
+
"datetimeformat(":DateTimeFormat,
|
|
78
|
+
"time(":TimeParse,
|
|
79
|
+
"clean(":CleanParse,
|
|
80
|
+
"fromcodelist(":FromCodeListParse,
|
|
81
|
+
"len(":LenParse,
|
|
82
|
+
"registrycheck(":RegistryCheckParse,
|
|
83
|
+
"extract(":ExtractParse,
|
|
84
|
+
"usefirst(":UseFirstParse,
|
|
59
85
|
};
|
|
60
86
|
public static GetExpressions(
|
|
61
|
-
valueExpression:string,
|
|
87
|
+
valueExpression:string, parent:BaseParse|null):BaseParse[]|null
|
|
62
88
|
{
|
|
89
|
+
if(parent!=null)
|
|
90
|
+
{
|
|
63
91
|
|
|
92
|
+
}
|
|
93
|
+
|
|
64
94
|
let _exprtessions:any = [];
|
|
65
95
|
var cursor = 0;
|
|
66
96
|
var currentLit = "";
|
|
@@ -285,8 +315,12 @@ export class ExpresionLogicService {
|
|
|
285
315
|
}
|
|
286
316
|
return -1;
|
|
287
317
|
}
|
|
288
|
-
public static ConcatValues( t:BaseParse[], obj:InvoiceObj, critm:RecordSingle, record:any, item:SchemaStruct)
|
|
318
|
+
public static ConcatValues( t:BaseParse[]|null, obj:InvoiceObj, critm:RecordSingle, record:any, item:SchemaStruct)
|
|
289
319
|
{
|
|
320
|
+
if(t==null)
|
|
321
|
+
{
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
290
324
|
if (t.length == 1)
|
|
291
325
|
{
|
|
292
326
|
return t[0].Evaluate(obj, critm, record, item);
|
|
@@ -333,7 +367,6 @@ export class ExpresionLogicService {
|
|
|
333
367
|
|
|
334
368
|
outptValue=parseInt(value);
|
|
335
369
|
break;
|
|
336
|
-
break;
|
|
337
370
|
}
|
|
338
371
|
case "bool":
|
|
339
372
|
{
|
|
@@ -359,17 +392,17 @@ export class ExpresionLogicService {
|
|
|
359
392
|
}
|
|
360
393
|
return outptValue;
|
|
361
394
|
}
|
|
362
|
-
static ParseAndFillExpression( valueExp:string,item:SchemaStruct, obj:InvoiceObj|null, citm:RecordSingle,
|
|
395
|
+
static ParseAndFillExpression( valueExp:string,item:SchemaStruct, obj:InvoiceObj|null, citm:RecordSingle, _record:any, tryEvaluate:boolean , init:boolean):any
|
|
363
396
|
{
|
|
364
397
|
if(obj==null)
|
|
365
398
|
{
|
|
366
399
|
return null;
|
|
367
400
|
}
|
|
368
401
|
var value = ExpresionLogicService.ParseExpressionAndReturnValue(valueExp, obj, item, citm, 0);
|
|
369
|
-
console.log(item.FieldName+" "+
|
|
402
|
+
console.log(item.FieldName+" "+valueExp+" "+value);
|
|
370
403
|
if (value != null)
|
|
371
404
|
{
|
|
372
|
-
if ((
|
|
405
|
+
if ((item.Type == "decimal" || item.Type == "int"))
|
|
373
406
|
{
|
|
374
407
|
try
|
|
375
408
|
{
|
|
@@ -384,24 +417,26 @@ export class ExpresionLogicService {
|
|
|
384
417
|
}
|
|
385
418
|
|
|
386
419
|
|
|
387
|
-
var ret = eval(value);
|
|
388
|
-
|
|
420
|
+
//var ret = eval(value);
|
|
421
|
+
const ret = evaluate(value);
|
|
422
|
+
console.log(item.FieldName+" "+valueExp+" RET: "+value+" EVAL:"+ret);
|
|
389
423
|
|
|
390
424
|
return ret;
|
|
391
425
|
|
|
392
426
|
}
|
|
393
427
|
catch (ex)
|
|
394
428
|
{
|
|
429
|
+
|
|
395
430
|
if (init)
|
|
396
431
|
{
|
|
397
|
-
console.log(item.FieldName+" "+
|
|
432
|
+
console.log(item.FieldName+" "+valueExp+" Err: "+0);
|
|
398
433
|
return 0;
|
|
399
434
|
}
|
|
400
435
|
else
|
|
401
436
|
{
|
|
402
437
|
|
|
403
438
|
var val= ExpresionLogicService.CastToTypeNet(item,value);
|
|
404
|
-
console.log(item.FieldName+" "+
|
|
439
|
+
console.log(item.FieldName+" "+valueExp+" Err: "+val);
|
|
405
440
|
return val;
|
|
406
441
|
}
|
|
407
442
|
}
|
|
@@ -410,20 +445,20 @@ export class ExpresionLogicService {
|
|
|
410
445
|
{
|
|
411
446
|
var val= ExpresionLogicService.CastToTypeNet(item,value);
|
|
412
447
|
|
|
413
|
-
console.log(item.FieldName+" "+
|
|
448
|
+
console.log(item.FieldName+" "+valueExp+" Ret: "+val);
|
|
414
449
|
return val;
|
|
415
450
|
|
|
416
451
|
}
|
|
417
452
|
}
|
|
418
453
|
else
|
|
419
454
|
{
|
|
420
|
-
console.log(item.FieldName+" "+
|
|
455
|
+
console.log(item.FieldName+" "+valueExp+" Value: "+value);
|
|
421
456
|
return value;
|
|
422
457
|
|
|
423
458
|
}
|
|
424
459
|
}
|
|
425
460
|
|
|
426
|
-
public static ParseExpressionAndReturnValue( valueExp:string|null,obj:InvoiceObj|null,item:SchemaStruct,citm:RecordSingle,
|
|
461
|
+
public static ParseExpressionAndReturnValue( valueExp:string|null,obj:InvoiceObj|null,item:SchemaStruct,citm:RecordSingle,_level:number):string|null
|
|
427
462
|
{
|
|
428
463
|
if(valueExp==null||obj==null)
|
|
429
464
|
{
|
|
@@ -448,7 +483,7 @@ export class ExpresionLogicService {
|
|
|
448
483
|
|
|
449
484
|
}
|
|
450
485
|
var record = citm.Record;
|
|
451
|
-
|
|
486
|
+
// let sb:string = "";
|
|
452
487
|
if (returned.length == 1)
|
|
453
488
|
{
|
|
454
489
|
var value = returned[0].Evaluate(obj, citm, record, item);
|
|
@@ -510,57 +545,53 @@ export class ExpresionLogicService {
|
|
|
510
545
|
var prefix = split[0];
|
|
511
546
|
switch (prefix)
|
|
512
547
|
{
|
|
513
|
-
|
|
548
|
+
case "V":
|
|
514
549
|
{
|
|
515
550
|
return obj.GetValues(split[1]);
|
|
516
551
|
}
|
|
517
|
-
|
|
552
|
+
|
|
518
553
|
case "E":
|
|
519
554
|
{
|
|
520
|
-
|
|
555
|
+
const tableName = split[1];
|
|
521
556
|
const field = split[2];
|
|
522
|
-
|
|
557
|
+
if (tableName.toLowerCase()=="eu_scr")
|
|
523
558
|
{
|
|
524
|
-
return obj.
|
|
525
|
-
}
|
|
526
|
-
else if (tableName.toLowerCase()=="eu_scr")
|
|
527
|
-
{
|
|
528
|
-
return obj.service.aboutOrganisation["_countryRecord"][field];
|
|
559
|
+
return obj.ExternalTables["EU_SCR"][field];
|
|
529
560
|
}
|
|
530
561
|
else if (tableName.toLowerCase()=="session")
|
|
531
562
|
{
|
|
532
|
-
var
|
|
563
|
+
var session= obj.ExternalTables["Session"];
|
|
533
564
|
|
|
534
565
|
for (var i = 2; i < split.length; i++)
|
|
535
566
|
{
|
|
536
|
-
if(
|
|
567
|
+
if(session[split[i]]!=null)
|
|
537
568
|
{
|
|
538
|
-
|
|
569
|
+
session=session[split[i]];
|
|
539
570
|
}
|
|
540
571
|
else
|
|
541
572
|
{
|
|
542
573
|
return null;
|
|
543
574
|
}
|
|
544
575
|
}
|
|
545
|
-
return
|
|
576
|
+
return session;
|
|
546
577
|
}
|
|
547
578
|
|
|
548
579
|
else
|
|
549
580
|
{
|
|
550
581
|
return "";
|
|
551
|
-
}
|
|
552
|
-
|
|
582
|
+
}
|
|
583
|
+
break;
|
|
553
584
|
}
|
|
554
585
|
case "S":
|
|
555
586
|
{
|
|
556
|
-
|
|
587
|
+
if(obj.Settings==null||obj.Settings[split[1]]==null)
|
|
557
588
|
{
|
|
558
589
|
throw "Can't find setting for "+split[1];
|
|
559
590
|
}
|
|
560
|
-
var settingRecord=obj.
|
|
591
|
+
var settingRecord=obj.Settings[split[1]];
|
|
561
592
|
return settingRecord["Value"];
|
|
562
|
-
*/
|
|
563
593
|
|
|
594
|
+
|
|
564
595
|
}
|
|
565
596
|
|
|
566
597
|
default:
|
|
@@ -606,10 +637,7 @@ export class ExpresionLogicService {
|
|
|
606
637
|
return value2["return"];
|
|
607
638
|
}
|
|
608
639
|
}
|
|
609
|
-
|
|
610
|
-
{
|
|
611
|
-
throw "Can't evaluate "+valueExpression+" key:"+item.FieldName+"";
|
|
612
|
-
}
|
|
640
|
+
|
|
613
641
|
|
|
614
642
|
return null;
|
|
615
643
|
}
|
|
@@ -637,7 +665,10 @@ export class ExpresionLogicService {
|
|
|
637
665
|
return value2["return"];
|
|
638
666
|
}
|
|
639
667
|
}
|
|
640
|
-
|
|
668
|
+
if(key=="ItemRetailPriceInp"||key=="ItemVatCodeSC__VCCode_EN16931")
|
|
669
|
+
{
|
|
670
|
+
return null;
|
|
671
|
+
}
|
|
641
672
|
throw "Can't evaluate "+valueExpression+" key:"+item.FieldName;
|
|
642
673
|
|
|
643
674
|
}
|
|
@@ -34,7 +34,12 @@ public static _dicAliasMap:any =
|
|
|
34
34
|
"EU_Invoices_CN_IICRefs":"CreditNoteRefs" ,
|
|
35
35
|
"EU_Invoices_Items":"Items" ,
|
|
36
36
|
"EU_Invoices_PaymentInstrs":"Payments" ,
|
|
37
|
-
"EU_Invoices_AddRefDocs":"Attachments"
|
|
37
|
+
"EU_Invoices_AddRefDocs":"Attachments",
|
|
38
|
+
"EU_Invoices_Items_Classes":"ItemsClasses" ,
|
|
39
|
+
"EU_Invoices_Items_Attributes":"ItemsAttributes" ,
|
|
40
|
+
"EU_Invoices_Items_Incomes":"ItemsIncomes" ,
|
|
41
|
+
"EU_Invoices_Items_Expenses":"ItemsExpenses" ,
|
|
42
|
+
"EU_Invoices_Items_AllowsCharges":"ItemsAllowsCharges"
|
|
38
43
|
|
|
39
44
|
};
|
|
40
45
|
public static __multipleParent:any =
|
|
@@ -42,9 +47,9 @@ public static __multipleParent:any =
|
|
|
42
47
|
"EU_Invoices_Items_Classes":"EU_Invoices_Items" ,
|
|
43
48
|
"EU_Invoices_Items_AllowsCharges":"EU_Invoices_Items" ,
|
|
44
49
|
"EU_Invoices_CN_IICRefs_Items":"EU_Invoices_Items" ,
|
|
45
|
-
"EU_Invoices_Items_Attributes":"EU_Invoices_Items"
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
"EU_Invoices_Items_Attributes":"EU_Invoices_Items",
|
|
51
|
+
"EU_Invoices_Items_Incomes":"EU_Invoices_Items",
|
|
52
|
+
"EU_Invoices_Items_Expenses":"EU_Invoices_Items"
|
|
48
53
|
};
|
|
49
54
|
public static isMultiple(table:string):boolean
|
|
50
55
|
{
|
|
@@ -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";
|
|
@@ -19,7 +19,7 @@ export class AppearParse extends BaseParse {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
public Evaluate(obj: InvoiceObj,
|
|
22
|
+
public Evaluate(obj: InvoiceObj, _critm: RecordSingle, _record: any, _item: SchemaStruct):any {
|
|
23
23
|
var tablelevel = obj.FindTableLevel(this.Table);
|
|
24
24
|
if(tablelevel == null)
|
|
25
25
|
{
|
|
@@ -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,6 +1,7 @@
|
|
|
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
|
+
import { ExpresionLogicService } from "../ExpresionLogicService";
|
|
4
5
|
import { BaseParse } from "./BaseParse";
|
|
5
6
|
|
|
6
7
|
|
|
@@ -25,10 +26,11 @@ export class CheckParse extends BaseParse {
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
public Evaluate(obj: InvoiceObj,
|
|
29
|
+
public Evaluate(obj: InvoiceObj, _critm: RecordSingle, _record: any, item: SchemaStruct):any {
|
|
29
30
|
var list:RecordSingle[] = [];
|
|
30
31
|
if (InvoiceObj.isMultiple(this.Detail))
|
|
31
32
|
{
|
|
33
|
+
//todo
|
|
32
34
|
/*var tableLevels = obj.(Detail);
|
|
33
35
|
if (tableLevels == null||tableLevels.Count==0)
|
|
34
36
|
{
|
|
@@ -69,7 +71,8 @@ export class CheckParse extends BaseParse {
|
|
|
69
71
|
|
|
70
72
|
for(var i=0;i<list.length;i++)
|
|
71
73
|
{
|
|
72
|
-
|
|
74
|
+
var rec= list[i];
|
|
75
|
+
var result = ExpresionLogicService.ParseExpressionAndReturnValue("IF("+this.Exp+",true,false)", obj, item, rec, 0);
|
|
73
76
|
if(result=="true")
|
|
74
77
|
{
|
|
75
78
|
trueCounter++;
|
|
@@ -77,7 +80,7 @@ export class CheckParse extends BaseParse {
|
|
|
77
80
|
{
|
|
78
81
|
return true;
|
|
79
82
|
}
|
|
80
|
-
}
|
|
83
|
+
}
|
|
81
84
|
}
|
|
82
85
|
|
|
83
86
|
|
|
@@ -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";
|