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
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { SchemaStruct } from "../Interfaces/SchemaStruct";
|
|
1
|
+
import type{ SchemaStruct } from "../Interfaces/SchemaStruct";
|
|
4
2
|
import { RecordArray } from "./RecordArray";
|
|
5
3
|
import { RecordSingle } from "./RecordSingle";
|
|
6
4
|
import { TableLevel } from "./TableLevel";
|
|
@@ -8,20 +6,39 @@ import { HelpersTables } from "../Evaluator/HelpersTables";
|
|
|
8
6
|
|
|
9
7
|
export class InvoiceObj {
|
|
10
8
|
rootLevel:TableLevel|null=null;
|
|
9
|
+
Legislation:string;
|
|
11
10
|
ObjectInfo:any;
|
|
12
11
|
LeftObject:any=null;
|
|
13
|
-
|
|
12
|
+
ExternalTables:any={};
|
|
13
|
+
Settings:any=null;
|
|
14
|
+
private _dicValues:any={};
|
|
14
15
|
public EvalType:string="Init";
|
|
15
16
|
public Mappings:any|null=null;
|
|
16
17
|
public CodeListCache:any={};
|
|
18
|
+
public InvoiceStructure:any={};
|
|
17
19
|
public constructor(
|
|
20
|
+
legislation:string,
|
|
18
21
|
obj:any,
|
|
19
22
|
clientinfo:any
|
|
20
23
|
)
|
|
21
24
|
{
|
|
25
|
+
this.Legislation=legislation;
|
|
22
26
|
this.LeftObject=obj;
|
|
23
|
-
this.ObjectInfo=clientinfo?.
|
|
24
|
-
this.CodeListCache=clientinfo?.
|
|
27
|
+
this.ObjectInfo=clientinfo?.OI??{};
|
|
28
|
+
this.CodeListCache=clientinfo?.CodeList??{};
|
|
29
|
+
this.InvoiceStructure=clientinfo?.InvoiceStructure??{};
|
|
30
|
+
this.ExternalTables=clientinfo?.External??{};
|
|
31
|
+
this.Settings=clientinfo?.Settings??{};
|
|
32
|
+
this.prepareValues();
|
|
33
|
+
}
|
|
34
|
+
private prepareValues()
|
|
35
|
+
{
|
|
36
|
+
const now=new Date();
|
|
37
|
+
this._dicValues={
|
|
38
|
+
"NOW":this.formatDateTime(now),
|
|
39
|
+
"DATE" :this.formatDate(now),
|
|
40
|
+
"LEGISLATION":this.Legislation
|
|
41
|
+
};
|
|
25
42
|
}
|
|
26
43
|
public static isMultiple(table:string):boolean{
|
|
27
44
|
return table == "EU_Invoices_Items_Classes" || table == "EU_Invoices_Items_AllowsCharges" || table == "EU_Invoices_CN_IICRefs_Items" || table == "EU_Invoices_AdvanceUsage" || table == "EU_Invoices_AdvanceUsageVatCode";
|
|
@@ -29,6 +46,27 @@ public static isMultiple(table:string):boolean{
|
|
|
29
46
|
public InitAfterConst()
|
|
30
47
|
{
|
|
31
48
|
|
|
49
|
+
}
|
|
50
|
+
public formatDate(date:Date):string
|
|
51
|
+
{
|
|
52
|
+
return date.getFullYear()+"-"+this.formatToTwoNumber(date.getMonth()+ 1)+"-"+ this.formatToTwoNumber(date.getDate());
|
|
53
|
+
}
|
|
54
|
+
public formatDateTime(date:Date):string
|
|
55
|
+
{
|
|
56
|
+
return date.getFullYear()+"-"+this.formatToTwoNumber(date.getMonth()+ 1)+"-"+this.formatToTwoNumber(date.getDate())+"T"+this.formatToTwoNumber(date.getHours())+":"+this.formatToTwoNumber(date.getMinutes())+":"+this.formatToTwoNumber(date.getSeconds());
|
|
57
|
+
}
|
|
58
|
+
formatToTwoNumber(num:number):string
|
|
59
|
+
{
|
|
60
|
+
return num<10?"0"+num:num.toString();
|
|
61
|
+
}
|
|
62
|
+
public GetValues(key:string):any
|
|
63
|
+
{
|
|
64
|
+
var keyUpper=key.toUpperCase();
|
|
65
|
+
if(this._dicValues[keyUpper]!=null)
|
|
66
|
+
{
|
|
67
|
+
return this._dicValues[keyUpper];
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
32
70
|
}
|
|
33
71
|
public FindTableLevel(tableName:string):TableLevel|null
|
|
34
72
|
{
|
|
@@ -44,20 +82,25 @@ public FindTableLevel(tableName:string):TableLevel|null
|
|
|
44
82
|
private RecursiveFindLevel(current:TableLevel|null,tableName:string):TableLevel|null
|
|
45
83
|
{
|
|
46
84
|
if(current==null) {
|
|
85
|
+
current=this.rootLevel;
|
|
86
|
+
}
|
|
87
|
+
if(current==null)
|
|
88
|
+
{
|
|
47
89
|
return null;
|
|
48
90
|
}
|
|
49
|
-
|
|
50
91
|
if(current?.Tablename==tableName)
|
|
51
92
|
{
|
|
52
93
|
return current;
|
|
53
94
|
}
|
|
95
|
+
|
|
54
96
|
if(current.Record!=null)
|
|
55
97
|
{
|
|
56
98
|
if(current.Record.Details!=null)
|
|
57
99
|
{
|
|
58
|
-
|
|
100
|
+
var keys=Object.keys(current.Record.Details);
|
|
101
|
+
for(let i=0;i<keys.length;i++)
|
|
59
102
|
{
|
|
60
|
-
const tableLevel=this.RecursiveFindLevel(current.Record.Details[i],tableName);
|
|
103
|
+
const tableLevel=this.RecursiveFindLevel(current.Record.Details[keys[i]],tableName);
|
|
61
104
|
if(tableLevel!=null)
|
|
62
105
|
{
|
|
63
106
|
return tableLevel;
|
|
@@ -73,11 +116,6 @@ public GetObject():any{
|
|
|
73
116
|
return this.rootLevel?.GetObject();
|
|
74
117
|
}
|
|
75
118
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
119
|
public SumByKey(tAndF:string):number
|
|
82
120
|
{
|
|
83
121
|
// console.log(tAndF)
|
|
@@ -128,11 +166,15 @@ public getFullObject(){
|
|
|
128
166
|
result[this.rootLevel?.Tablename??"EU_Invoices"]=this.rootLevel?.getFullObject(this.ObjectInfo);
|
|
129
167
|
return result;
|
|
130
168
|
}
|
|
131
|
-
|
|
169
|
+
public getAliasObject(){
|
|
170
|
+
const result:any={};
|
|
171
|
+
result[HelpersTables.GetTableForAlias("EU_Invoices")]=this.rootLevel?.GetTableForAlias(this.ObjectInfo);
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
132
174
|
public ValidateBeforeSave()
|
|
133
|
-
{
|
|
134
|
-
var master={};
|
|
135
|
-
|
|
175
|
+
{return;
|
|
176
|
+
//var master={};
|
|
177
|
+
|
|
136
178
|
/*if(master!=null)
|
|
137
179
|
{
|
|
138
180
|
master.Record["InvTotalVatAmountCCInp"]=master.Record["InvTotalVatAmountCC"];
|
|
@@ -140,7 +182,7 @@ public ValidateBeforeSave()
|
|
|
140
182
|
}
|
|
141
183
|
// let errors:string|null=this.rootLevel.Validate();
|
|
142
184
|
let errors:any=this.rootLevel?.Validate();
|
|
143
|
-
//
|
|
185
|
+
// conso-+le.log(errors)
|
|
144
186
|
|
|
145
187
|
let additionalValidations:any = [];
|
|
146
188
|
let combineErrors:null|string = null;
|
|
@@ -201,7 +243,7 @@ public ValidateBeforeSave()
|
|
|
201
243
|
return false;*/
|
|
202
244
|
}
|
|
203
245
|
|
|
204
|
-
private ConcateErrors(combineErrors:string|null,error:string)
|
|
246
|
+
/*private ConcateErrors(combineErrors:string|null,error:string)
|
|
205
247
|
{
|
|
206
248
|
if(combineErrors=='')
|
|
207
249
|
{
|
|
@@ -210,7 +252,7 @@ private ConcateErrors(combineErrors:string|null,error:string)
|
|
|
210
252
|
}
|
|
211
253
|
combineErrors+=" "+error;
|
|
212
254
|
return combineErrors;
|
|
213
|
-
}
|
|
255
|
+
}*/
|
|
214
256
|
public TranslateObj(obj:any)
|
|
215
257
|
{
|
|
216
258
|
this.rootLevel?.TranslateObj(obj);
|
|
@@ -231,12 +273,16 @@ prepareSchemaStruct():SchemaStruct[]{
|
|
|
231
273
|
return result;
|
|
232
274
|
}
|
|
233
275
|
public Evaluate(){
|
|
276
|
+
|
|
277
|
+
this.rootLevel=new TableLevel("EU_Invoices",this.InvoiceStructure["EU_Invoices"],this.ObjectInfo,this);
|
|
234
278
|
var listForEval=this.prepareSchemaStruct();
|
|
235
279
|
var filter=listForEval.filter(x=>x.ValueExpressionInit!=null);
|
|
280
|
+
|
|
236
281
|
this.InicializeEval("Init",filter);
|
|
237
282
|
//left object!
|
|
238
283
|
|
|
239
|
-
|
|
284
|
+
this.FillInvoiceDataIntoObjStuct(this.LeftObject,listForEval,this.ObjectInfo,false);
|
|
285
|
+
console.log(this.getFullObject());
|
|
240
286
|
filter=listForEval.filter(x=>x.EvalStep=="PRE"&&(x.ValueExpression!=null||x.GetValueFrom=="Mappings"||x.GetValueFrom=="Code"));
|
|
241
287
|
this.InicializeEval("Eval",filter);
|
|
242
288
|
|
|
@@ -287,6 +333,7 @@ InicializeEval(mode:string,list:SchemaStruct[])
|
|
|
287
333
|
}
|
|
288
334
|
catch(ex)
|
|
289
335
|
{
|
|
336
|
+
console.error(ex);
|
|
290
337
|
return false;
|
|
291
338
|
}
|
|
292
339
|
return true;
|
|
@@ -300,6 +347,7 @@ InicializeEval(mode:string,list:SchemaStruct[])
|
|
|
300
347
|
{
|
|
301
348
|
const masterTable= NotAliased ? HelpersTables.masterEntity : "Invoice";
|
|
302
349
|
var Doc = obj[masterTable];
|
|
350
|
+
|
|
303
351
|
var details = Doc["_details"];
|
|
304
352
|
|
|
305
353
|
var multipleTables = new Map<string,SchemaStruct[]>();
|
|
@@ -365,12 +413,12 @@ var grouped = this.groupBy(list,"TableName");
|
|
|
365
413
|
}
|
|
366
414
|
}
|
|
367
415
|
|
|
368
|
-
for (var
|
|
416
|
+
for (var j = 0; j < records.length; j++)
|
|
369
417
|
{
|
|
370
418
|
var nRecord = JSON.parse(JSON.stringify(recordBase));
|
|
371
|
-
var record = records[
|
|
419
|
+
var record = records[j];
|
|
372
420
|
var newSingleObj = new RecordSingle(nRecord,OI,tableLevel)
|
|
373
|
-
for(var g=0;group.length;g++)
|
|
421
|
+
for(var g=0;g<group.length;g++)
|
|
374
422
|
{
|
|
375
423
|
var item=group[g];
|
|
376
424
|
this.setValueForObject(record, newSingleObj, item, NotAliased,null);
|
|
@@ -379,7 +427,11 @@ var grouped = this.groupBy(list,"TableName");
|
|
|
379
427
|
newSingleObj.SetLeftInstanceReference(record);
|
|
380
428
|
array.push(newSingleObj);
|
|
381
429
|
}
|
|
382
|
-
tableLevel.Records
|
|
430
|
+
if(tableLevel.Records!=null )
|
|
431
|
+
{
|
|
432
|
+
tableLevel.Records.Records=array;
|
|
433
|
+
}
|
|
434
|
+
|
|
383
435
|
|
|
384
436
|
}
|
|
385
437
|
}
|
|
@@ -436,7 +488,7 @@ var grouped = this.groupBy(list,"TableName");
|
|
|
436
488
|
var nRecord = JSON.parse(JSON.stringify(recordBase));
|
|
437
489
|
var record = records[i];
|
|
438
490
|
var newSingleObj = new RecordSingle(nRecord,OI,tableLevel)
|
|
439
|
-
for(var g=0;group.length;g++)
|
|
491
|
+
for(var g=0;g<group.length;g++)
|
|
440
492
|
{
|
|
441
493
|
var item=group[g];
|
|
442
494
|
this.setValueForObject(record, newSingleObj, item, NotAliased,null);
|
|
@@ -506,7 +558,7 @@ var grouped = this.groupBy(list,"TableName");
|
|
|
506
558
|
var newRecords:RecordSingle[] = [];
|
|
507
559
|
for(var i=0;i< multipleRecords.Count;i++)
|
|
508
560
|
{
|
|
509
|
-
var recordM = multipleRecords[i];
|
|
561
|
+
//var recordM = multipleRecords[i];
|
|
510
562
|
let currentRec:RecordSingle|null = null;
|
|
511
563
|
if (existingRecords && existingRecords.length > i)
|
|
512
564
|
{
|
|
@@ -517,7 +569,7 @@ var grouped = this.groupBy(list,"TableName");
|
|
|
517
569
|
currentRec = new RecordSingle({}, this.ObjectInfo, multipleLevel);
|
|
518
570
|
newRecords.push(currentRec);
|
|
519
571
|
}
|
|
520
|
-
for(var g=0;schemaArray.length;g++)
|
|
572
|
+
for(var g=0;g<schemaArray.length;g++)
|
|
521
573
|
{
|
|
522
574
|
var item=schemaArray[g];
|
|
523
575
|
this.setValueForObject(record, currentRec, item, NotAliased,null);
|
|
@@ -568,9 +620,14 @@ var grouped = this.groupBy(list,"TableName");
|
|
|
568
620
|
{
|
|
569
621
|
return;
|
|
570
622
|
}
|
|
571
|
-
|
|
623
|
+
if(sc==null)
|
|
624
|
+
{
|
|
625
|
+
debugger
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
var field=NotAliased?sc.FieldName:(sc.AliasExport??sc.FieldName);
|
|
572
629
|
|
|
573
|
-
if (obj[field]
|
|
630
|
+
if (obj[field]!=null)
|
|
574
631
|
{
|
|
575
632
|
var inst = record.Record;
|
|
576
633
|
record.SetValueToKey(sc, obj[field], inst);
|
|
@@ -679,14 +736,20 @@ vatsPrepare(list:SchemaStruct[])
|
|
|
679
736
|
var gr=element.Record["VatsUIGroupKey"];
|
|
680
737
|
if(gg[gr]==null)
|
|
681
738
|
{
|
|
682
|
-
gg[gr]=
|
|
739
|
+
gg[gr]=[];
|
|
683
740
|
}
|
|
741
|
+
gg[gr].push(element);
|
|
684
742
|
});
|
|
685
743
|
var itemsForVat:any[]=[];
|
|
686
744
|
Object.keys(gg).forEach((gk)=>{
|
|
687
745
|
var newItem:any={};
|
|
688
746
|
newItem["__VatRate"]=gk;
|
|
689
|
-
|
|
747
|
+
var r=new RecordSingle({},this.ObjectInfo,level);
|
|
748
|
+
r.Record=newItem;
|
|
749
|
+
r.SetReferenceRecords("__VatRate",gg[gk]);
|
|
750
|
+
itemsForVat.push(r);
|
|
751
|
+
|
|
752
|
+
|
|
690
753
|
});
|
|
691
754
|
level.Records.Records=itemsForVat;
|
|
692
755
|
const items = groupTables[key];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
import { SchemaStruct } from "../Interfaces/SchemaStruct";
|
|
3
|
+
import type { SchemaStruct } from "../Interfaces/SchemaStruct";
|
|
4
4
|
import { RecordSingle } from "./RecordSingle";
|
|
5
5
|
import { TableLevel } from "./TableLevel";
|
|
6
6
|
|
|
@@ -10,18 +10,15 @@ export class RecordArray {
|
|
|
10
10
|
public ObjectInfo:any;
|
|
11
11
|
|
|
12
12
|
public constructor(
|
|
13
|
-
|
|
13
|
+
level:any,
|
|
14
14
|
objectInfo:any,
|
|
15
15
|
parent:TableLevel|null,
|
|
16
16
|
)
|
|
17
17
|
{
|
|
18
18
|
this.Parent=parent;
|
|
19
19
|
this.ObjectInfo=objectInfo;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var item=obj[i];
|
|
23
|
-
this.Records.push(new RecordSingle(item,objectInfo,parent))
|
|
24
|
-
}
|
|
20
|
+
this.Records.push(new RecordSingle(level,objectInfo,parent))
|
|
21
|
+
|
|
25
22
|
}
|
|
26
23
|
MapToId(listForEval:SchemaStruct[]) {
|
|
27
24
|
if (this.Records != null) {
|
|
@@ -33,7 +30,15 @@ export class RecordArray {
|
|
|
33
30
|
EvaluateInner(listForEval:SchemaStruct[]) {
|
|
34
31
|
if (this.Records != null) {
|
|
35
32
|
for (let i = 0; i < this.Records.length; i++) {
|
|
36
|
-
|
|
33
|
+
var record=this.Records[i];
|
|
34
|
+
try{
|
|
35
|
+
record.EvaluateInner(listForEval);
|
|
36
|
+
}catch(e)
|
|
37
|
+
{
|
|
38
|
+
debugger
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
37
42
|
}
|
|
38
43
|
}
|
|
39
44
|
}
|
|
@@ -93,7 +98,19 @@ export class RecordArray {
|
|
|
93
98
|
var array=[];
|
|
94
99
|
for(let i=0;i<this.Records.length;i++)
|
|
95
100
|
{
|
|
96
|
-
array.push(this.Records[i].
|
|
101
|
+
array.push(this.Records[i].getFullObject(objectInfo));
|
|
102
|
+
}
|
|
103
|
+
return array;
|
|
104
|
+
}
|
|
105
|
+
public GetTableForAlias(objectInfo:any){
|
|
106
|
+
if(this.Records==null)
|
|
107
|
+
{
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
var array=[];
|
|
111
|
+
for(let i=0;i<this.Records.length;i++)
|
|
112
|
+
{
|
|
113
|
+
array.push(this.Records[i].GetTableForAlias(objectInfo));
|
|
97
114
|
}
|
|
98
115
|
return array;
|
|
99
116
|
}
|
|
@@ -120,7 +137,7 @@ export class RecordArray {
|
|
|
120
137
|
const keys=Object.keys(errors);
|
|
121
138
|
|
|
122
139
|
let errorMessage="";
|
|
123
|
-
let validateDetailsErrors =
|
|
140
|
+
let validateDetailsErrors:any = {};
|
|
124
141
|
|
|
125
142
|
for(let i=0;i<keys.length;i++)
|
|
126
143
|
{
|