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,610 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvoiceObj = void 0;
|
|
4
|
+
const RecordSingle_1 = require("./RecordSingle");
|
|
5
|
+
const TableLevel_1 = require("./TableLevel");
|
|
6
|
+
class InvoiceObj {
|
|
7
|
+
constructor(obj, def, oi, oiOut, map) {
|
|
8
|
+
this.masterRecord = null;
|
|
9
|
+
this.itemsRecord = null;
|
|
10
|
+
this.taxRecord = null;
|
|
11
|
+
this.taxRecordUI = null;
|
|
12
|
+
this.paymentRecord = null;
|
|
13
|
+
this.cnRefsRecord = null;
|
|
14
|
+
this.CNRefs = null;
|
|
15
|
+
this.defObj = null;
|
|
16
|
+
this.OIObj = null;
|
|
17
|
+
this.OIOutObj = null;
|
|
18
|
+
this.defObj = JSON.parse(JSON.stringify(def));
|
|
19
|
+
this.OIObj = JSON.parse(JSON.stringify(oi));
|
|
20
|
+
this.OIOutObj = JSON.parse(JSON.stringify(oiOut));
|
|
21
|
+
this.objectInfo = oi;
|
|
22
|
+
this.objectInfoUIEdit = oiOut;
|
|
23
|
+
this.mappings = map;
|
|
24
|
+
const table = "EU_Invoices";
|
|
25
|
+
this.rootLevel = new TableLevel_1.TableLevel(table, obj[table], def[table], this.objectInfo, this);
|
|
26
|
+
// console.log('obj12: ' + JSON.stringify(obj));
|
|
27
|
+
this.GetMasterRecord();
|
|
28
|
+
/*this.GetItemsRecord();
|
|
29
|
+
this.GetTaxesRecord();
|
|
30
|
+
this.GetTaxesUIRecord();
|
|
31
|
+
this.GetPaymentRecord();
|
|
32
|
+
this.GetCnRefsRecord();
|
|
33
|
+
this.HasCNRecords();*/
|
|
34
|
+
this.rewriteInvoiceClouse();
|
|
35
|
+
}
|
|
36
|
+
static isMultiple(table) {
|
|
37
|
+
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";
|
|
38
|
+
}
|
|
39
|
+
InitAfterConst() {
|
|
40
|
+
}
|
|
41
|
+
FindTableLevel(tableName) {
|
|
42
|
+
var tableModel = this.RecursiveFindLevel(this.rootLevel, tableName);
|
|
43
|
+
if (tableModel == null) {
|
|
44
|
+
// console.log("Can't find level "+tableName);
|
|
45
|
+
}
|
|
46
|
+
return tableModel;
|
|
47
|
+
}
|
|
48
|
+
RecursiveFindLevel(current, tableName) {
|
|
49
|
+
if (current == null) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
if ((current === null || current === void 0 ? void 0 : current.Tablename) == tableName) {
|
|
53
|
+
return current;
|
|
54
|
+
}
|
|
55
|
+
if (current.Record != null) {
|
|
56
|
+
if (current.Record.Details != null) {
|
|
57
|
+
for (let i = 0; i < current.Record.Details.length; i++) {
|
|
58
|
+
const tableLevel = this.RecursiveFindLevel(current.Record.Details[i], tableName);
|
|
59
|
+
if (tableLevel != null) {
|
|
60
|
+
return tableLevel;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
GetObject() {
|
|
68
|
+
return this.rootLevel.GetObject();
|
|
69
|
+
}
|
|
70
|
+
GetMasterRecord() {
|
|
71
|
+
const tableName = "EU_Invoices";
|
|
72
|
+
if (this.masterRecord == null) {
|
|
73
|
+
var tableLevel = this.RecursiveFindLevel(this.rootLevel, tableName);
|
|
74
|
+
if (tableLevel != null && tableLevel.Record != null) {
|
|
75
|
+
this.masterRecord = tableLevel.Record;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return this.masterRecord;
|
|
81
|
+
}
|
|
82
|
+
/*public GetItemsRecord():RecordArray|null{
|
|
83
|
+
const tableName="EU_Invoices_Items";
|
|
84
|
+
if(this.itemsRecord==null)
|
|
85
|
+
{
|
|
86
|
+
var tableLevel=this.RecursiveFindLevel(this.rootLevel,tableName);
|
|
87
|
+
if(tableLevel!=null && tableLevel.Records!=null)
|
|
88
|
+
{
|
|
89
|
+
this.itemsRecord=tableLevel.Records;
|
|
90
|
+
}
|
|
91
|
+
else{
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
return this.itemsRecord;
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
public AddItem() {
|
|
99
|
+
this.itemsRecord?.Records?.push(new RecordSingle(JSON.parse(JSON.stringify(this.itemsRecord?.Parent?.DefaultRecord??{})),this.itemsRecord?.Parent?.DefaultRecord??{},this.itemsRecord.ObjectInfo,this.itemsRecord.Parent,this.service));
|
|
100
|
+
}
|
|
101
|
+
public RemoveItem(item:RecordSingle)
|
|
102
|
+
{
|
|
103
|
+
let index=this.itemsRecord?.Records?.indexOf(item);
|
|
104
|
+
if(index!=undefined&&index!=-1)
|
|
105
|
+
{
|
|
106
|
+
if(this.itemsRecord?.Records!=null)
|
|
107
|
+
{
|
|
108
|
+
|
|
109
|
+
this.itemsRecord?.Records?.splice(index,1);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
public AddPaymentItem()
|
|
114
|
+
{
|
|
115
|
+
this.paymentRecord?.Records?.push(
|
|
116
|
+
// new RecordSingle(JSON.parse(JSON.stringify(this.paymentRecord?.Parent?.DefaultRecord??{})),this.paymentRecord?.Parent?.DefaultRecord??{},this.paymentRecord.ObjectInfo,this.paymentRecord.Parent));
|
|
117
|
+
new RecordSingle({},{},this.paymentRecord.ObjectInfo,this.paymentRecord.Parent,this.service));
|
|
118
|
+
}
|
|
119
|
+
public RemovePaymentItem(item:RecordSingle)
|
|
120
|
+
{
|
|
121
|
+
let index=this.paymentRecord?.Records?.indexOf(item);
|
|
122
|
+
if(index!=undefined&&index!=-1)
|
|
123
|
+
{
|
|
124
|
+
if(this.paymentRecord?.Records!=null)
|
|
125
|
+
{
|
|
126
|
+
this.paymentRecord?.Records?.splice(index,1);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
public GetCnRefsRecord():RecordArray|null{
|
|
133
|
+
const tableName="EU_Invoices_CN_IICRefs";
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
let tableLevel=this.RecursiveFindLevel(this.rootLevel,tableName);
|
|
137
|
+
if(tableLevel!=null&&tableLevel.Records!=null)
|
|
138
|
+
{
|
|
139
|
+
this.cnRefsRecord=tableLevel.Records;
|
|
140
|
+
this.service._cnRefsRecord.next(tableLevel.Records);
|
|
141
|
+
}
|
|
142
|
+
else{
|
|
143
|
+
this.cnRefsRecord=null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
// console.log(this.cnRefsRecord?.Records);
|
|
148
|
+
return this.cnRefsRecord;
|
|
149
|
+
|
|
150
|
+
}
|
|
151
|
+
public HasCNRecords():boolean
|
|
152
|
+
{
|
|
153
|
+
const cn=this.GetCnRefsRecord();
|
|
154
|
+
if(cn==null)
|
|
155
|
+
{
|
|
156
|
+
this.service.HasCNRecords.next(false);
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
if(cn.Records==null||cn.Records.length==0)
|
|
160
|
+
{
|
|
161
|
+
this.service.HasCNRecords.next(false);
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
if(cn.Records.length==1)
|
|
165
|
+
{
|
|
166
|
+
let empty=false;
|
|
167
|
+
for(var key in cn.Records[0].Record)
|
|
168
|
+
{
|
|
169
|
+
if(cn.Records[0].Record[key]!=null&&cn.Records[0].Record[key]!==false&&cn.Records[0].Record[key]!==0)
|
|
170
|
+
{
|
|
171
|
+
empty=true;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
this.service.HasCNRecords.next(empty);
|
|
176
|
+
return empty;
|
|
177
|
+
}
|
|
178
|
+
this.service.HasCNRecords.next(true);
|
|
179
|
+
return true;
|
|
180
|
+
}*/
|
|
181
|
+
CreateRecordSingle(obj, table) {
|
|
182
|
+
var _a, _b;
|
|
183
|
+
let CnRefRecord = this.RecursiveFindLevel(this.rootLevel, table);
|
|
184
|
+
if (!CnRefRecord) {
|
|
185
|
+
CnRefRecord = new TableLevel_1.TableLevel(table, [], [], this.objectInfo, this);
|
|
186
|
+
(_b = (_a = this.rootLevel.Record) === null || _a === void 0 ? void 0 : _a.Details) === null || _b === void 0 ? void 0 : _b.push(CnRefRecord);
|
|
187
|
+
}
|
|
188
|
+
return new RecordSingle_1.RecordSingle(obj, {}, this.objectInfo[table], CnRefRecord);
|
|
189
|
+
}
|
|
190
|
+
/*public ReplaceRecords(Records:RecordSingle[],table:string)
|
|
191
|
+
{
|
|
192
|
+
let CnRefRecord = this.RecursiveFindLevel(this.rootLevel,table);
|
|
193
|
+
|
|
194
|
+
if(!CnRefRecord) {
|
|
195
|
+
CnRefRecord = new TableLevel(table,[],[],this.objectInfo,this);
|
|
196
|
+
this.rootLevel.Record?.Details?.push(CnRefRecord);
|
|
197
|
+
}
|
|
198
|
+
if(CnRefRecord!=null&&CnRefRecord.Records!=null)
|
|
199
|
+
CnRefRecord.Records.Records=Records;
|
|
200
|
+
|
|
201
|
+
switch(table)
|
|
202
|
+
{
|
|
203
|
+
case "EU_Invoices_CN_IICRefs":
|
|
204
|
+
{
|
|
205
|
+
|
|
206
|
+
if(CnRefRecord.Records!=null)
|
|
207
|
+
this.service._cnRefsRecord.next(CnRefRecord.Records);
|
|
208
|
+
|
|
209
|
+
this.HasCNRecords();
|
|
210
|
+
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}*/
|
|
215
|
+
/*public AddCnRef(item:any) {
|
|
216
|
+
const tableNameCNRefs="EU_Invoices_CN_IICRefs";
|
|
217
|
+
|
|
218
|
+
let CnRefRecord = this.RecursiveFindLevel(this.rootLevel,tableNameCNRefs);
|
|
219
|
+
|
|
220
|
+
if(!CnRefRecord) {
|
|
221
|
+
CnRefRecord = new TableLevel(tableNameCNRefs,[],[],this.objectInfo,this,this.service);
|
|
222
|
+
this.rootLevel.Record?.Details?.push(CnRefRecord);
|
|
223
|
+
if(CnRefRecord.Records) {
|
|
224
|
+
this.service._cnRefsRecord.next(CnRefRecord.Records);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
CnRefRecord.Records?.Records.push(
|
|
229
|
+
new RecordSingle(item,{},this.objectInfo[tableNameCNRefs],CnRefRecord,this.service)
|
|
230
|
+
);
|
|
231
|
+
}*/
|
|
232
|
+
/*public RemoveCnRef(item:RecordSingle)
|
|
233
|
+
{
|
|
234
|
+
|
|
235
|
+
if(this.cnRefsRecord?.Records==null){
|
|
236
|
+
this.GetCnRefsRecord();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
let index = this.cnRefsRecord?.Records.findIndex((rec:RecordSingle) => rec=== item);
|
|
240
|
+
|
|
241
|
+
if(index!=undefined&&index!=-1)
|
|
242
|
+
{
|
|
243
|
+
if(this.cnRefsRecord?.Records!=null)
|
|
244
|
+
{
|
|
245
|
+
this.cnRefsRecord?.Records?.splice(index,1);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}*/
|
|
249
|
+
/*public RemoveCnRefAll()
|
|
250
|
+
{
|
|
251
|
+
const tableName="EU_Invoices_CN_IICRefs";
|
|
252
|
+
let tableLevel=this.RecursiveFindLevel(this.rootLevel,tableName);
|
|
253
|
+
if(tableLevel==null)
|
|
254
|
+
{
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const index=this.rootLevel.Record?.Details?.indexOf(tableLevel);
|
|
258
|
+
if(index!=null&&index!=-1)
|
|
259
|
+
{
|
|
260
|
+
this.rootLevel.Record?.Details?.splice(index,1);
|
|
261
|
+
}
|
|
262
|
+
this.service._cnRefsRecord.next(new RecordArray({}, {}, {}, null,this.service));
|
|
263
|
+
this.HasCNRecords();
|
|
264
|
+
}
|
|
265
|
+
*/
|
|
266
|
+
/*public GetTaxesRecord():RecordArray|null{
|
|
267
|
+
const tableName="EU_Invoices_Vats";
|
|
268
|
+
if(this.taxRecord==null)
|
|
269
|
+
{
|
|
270
|
+
let tableLevel=this.RecursiveFindLevel(this.rootLevel,tableName);
|
|
271
|
+
if(tableLevel!=null&&tableLevel.Records!=null)
|
|
272
|
+
{
|
|
273
|
+
this.taxRecord=tableLevel.Records;
|
|
274
|
+
}
|
|
275
|
+
else{
|
|
276
|
+
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
}
|
|
280
|
+
return this.taxRecord;
|
|
281
|
+
|
|
282
|
+
}
|
|
283
|
+
public GetTaxesUIRecord():RecordArray|null{
|
|
284
|
+
const tableName="EU_Invoices_VatsUI";
|
|
285
|
+
if(this.taxRecordUI==null)
|
|
286
|
+
{
|
|
287
|
+
let tableLevel=this.RecursiveFindLevel(this.rootLevel,tableName);
|
|
288
|
+
if(tableLevel!=null&&tableLevel.Records!=null)
|
|
289
|
+
{
|
|
290
|
+
this.taxRecordUI=tableLevel.Records;
|
|
291
|
+
}
|
|
292
|
+
else{
|
|
293
|
+
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
}
|
|
297
|
+
return this.taxRecordUI;
|
|
298
|
+
|
|
299
|
+
}
|
|
300
|
+
public GetPaymentRecord():RecordArray|null{
|
|
301
|
+
const tableName="EU_Invoices_PaymentInstrs";
|
|
302
|
+
|
|
303
|
+
if(this.paymentRecord==null)
|
|
304
|
+
{
|
|
305
|
+
let tableLevel=this.RecursiveFindLevel(this.rootLevel,tableName);
|
|
306
|
+
if(tableLevel!=null && tableLevel.Records!=null)
|
|
307
|
+
{
|
|
308
|
+
this.paymentRecord=tableLevel.Records;
|
|
309
|
+
}
|
|
310
|
+
else{
|
|
311
|
+
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
}
|
|
315
|
+
return this.paymentRecord;
|
|
316
|
+
}
|
|
317
|
+
*/
|
|
318
|
+
Inicalize() {
|
|
319
|
+
var _a, _b;
|
|
320
|
+
console.log("Inicalize");
|
|
321
|
+
// console.log('Inicalize - GetObject: ' + JSON.stringify(this.GetObject()));
|
|
322
|
+
const skippedlevels = ["EU_Invoices_Vats", "EU_Invoices_VatsUI"];
|
|
323
|
+
this.rootLevel.Inicialize(skippedlevels);
|
|
324
|
+
for (let i = 0; i < skippedlevels.length; i++) {
|
|
325
|
+
let tablelevel = this.RecursiveFindLevel(this.rootLevel, skippedlevels[i]);
|
|
326
|
+
if (tablelevel == null) {
|
|
327
|
+
tablelevel = new TableLevel_1.TableLevel(skippedlevels[i], [], {}, this.objectInfo[skippedlevels[i]], this);
|
|
328
|
+
(_b = (_a = this.rootLevel.Record) === null || _a === void 0 ? void 0 : _a.Details) === null || _b === void 0 ? void 0 : _b.push(tablelevel);
|
|
329
|
+
}
|
|
330
|
+
/*switch(skippedlevels[i])
|
|
331
|
+
{
|
|
332
|
+
case "EU_Invoices_Vats":
|
|
333
|
+
{
|
|
334
|
+
this.InitEU_Invoices_Vats(tablelevel);
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
case "EU_Invoices_VatsUI":
|
|
338
|
+
{
|
|
339
|
+
this.InitEU_Invoices_VatsUI(tablelevel);
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
}*/
|
|
343
|
+
}
|
|
344
|
+
this.taxRecordUI = null;
|
|
345
|
+
/*this.GetTaxesUIRecord();
|
|
346
|
+
if(this.taxRecordUI!=null)
|
|
347
|
+
{
|
|
348
|
+
this.service._taxRecordsUI.next(this.taxRecordUI);
|
|
349
|
+
}*/
|
|
350
|
+
this.rewriteInvoiceClouse();
|
|
351
|
+
}
|
|
352
|
+
rewriteInvoiceClouse() {
|
|
353
|
+
/*const vatDescMap=new Map<string,string>();
|
|
354
|
+
for(let i=0;i<(this.GetItemsRecord()?.Records??[])?.length;i++)
|
|
355
|
+
{
|
|
356
|
+
const item=this.GetItemsRecord()?.Records[i].Record;
|
|
357
|
+
if(item==null)
|
|
358
|
+
{
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
const vatid=item.ItemVatCodeSC;
|
|
362
|
+
if(!vatDescMap.has(vatid))
|
|
363
|
+
{
|
|
364
|
+
vatDescMap.set(vatid,"");
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
let note="";
|
|
368
|
+
const vatDescMapDest=new Map<string,string>();
|
|
369
|
+
for(let i=0;i<this.service.VATArray.length;i++)
|
|
370
|
+
{
|
|
371
|
+
const vat=this.service.VATArray[i];
|
|
372
|
+
if(vat.VERDesc==null||vat.VERDesc==""||vatDescMapDest.has(vat.VERDesc))
|
|
373
|
+
{
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
if(vatDescMap.has(vat.Id))
|
|
377
|
+
{
|
|
378
|
+
if(note!="")
|
|
379
|
+
{
|
|
380
|
+
note += " ";
|
|
381
|
+
}
|
|
382
|
+
vatDescMapDest.set(vat.VERDesc,"");
|
|
383
|
+
note+=vat.VERDesc;
|
|
384
|
+
}
|
|
385
|
+
if(this.masterRecord!=null&&this.masterRecord.Record!=null)
|
|
386
|
+
{
|
|
387
|
+
this.masterRecord.Record["InvNoteClause"]=note;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
}*/
|
|
391
|
+
}
|
|
392
|
+
InitEU_Invoices_Vats(tablelevel) {
|
|
393
|
+
/*var items=this.GetItemsRecord();
|
|
394
|
+
if(items==null)
|
|
395
|
+
{
|
|
396
|
+
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
let myMap = new Map<string, RecordSingle[]>();
|
|
400
|
+
for(let i=0;i<items.Records?.length;i++)
|
|
401
|
+
{
|
|
402
|
+
let item=items.Records[i];
|
|
403
|
+
let key=item.Record["ItemVatCodeSC__VCCode_EN16931"]+"||"+item.Record["ItemVatCodeSC__Rate"]+"||"+item.Record["ItemVatCodeSC__VERCode"];
|
|
404
|
+
if(key=="||")
|
|
405
|
+
{
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
if(!myMap.has(key))
|
|
409
|
+
{
|
|
410
|
+
|
|
411
|
+
myMap.set(key,[]);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
myMap.get(key)?.push(item);
|
|
415
|
+
}
|
|
416
|
+
const vats=[];
|
|
417
|
+
for(let array of myMap.values())
|
|
418
|
+
{
|
|
419
|
+
|
|
420
|
+
if(array==null)
|
|
421
|
+
{
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
let obj={
|
|
425
|
+
"VatInvAllowBaseAmount":this.sumBykey("LineBaseAmountInclAllow",array),
|
|
426
|
+
"VatInvAllowAmount":this.sumBykey("LineInvAllowAmount",array),
|
|
427
|
+
"VatTaxableAmount":this.sumBykey("LineTotalNetAmount",array),
|
|
428
|
+
"VatTaxAmount":this.sumBykey("LineTotalVatAmount",array),
|
|
429
|
+
"VatCatCode":array[0].Record["ItemVatCodeSC__VCCode_EN16931"],
|
|
430
|
+
"VatCatCode__Name":array[0].Record["ItemVatCodeSC__VCCode_EN16931__Name"],
|
|
431
|
+
"VatRate":array[0].Record["ItemVatCodeSC__Rate"],
|
|
432
|
+
"VatExemptReasonCode":""
|
|
433
|
+
};
|
|
434
|
+
vats.push(obj);
|
|
435
|
+
}
|
|
436
|
+
tablelevel.Records=new RecordArray(vats,{},this.objectInfo[tablelevel?.Tablename],tablelevel,this.service);
|
|
437
|
+
// console.log(vats)
|
|
438
|
+
}
|
|
439
|
+
private InitEU_Invoices_VatsUI(tablelevel:TableLevel){
|
|
440
|
+
var items=this.GetItemsRecord();
|
|
441
|
+
if(items==null)
|
|
442
|
+
{
|
|
443
|
+
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
let myMap = new Map<string, RecordSingle[]>();
|
|
447
|
+
for(let i=0;i<items.Records?.length;i++)
|
|
448
|
+
{
|
|
449
|
+
let item=items.Records[i];
|
|
450
|
+
// let key=item.Record["ItemVatCodeSC__GroupUIVatCode"]+"||"+item.Record["ItemVatCodeSC__Rate"];
|
|
451
|
+
let key=item.Record["ItemVatCodeSC__GroupUIVatCode"];
|
|
452
|
+
if(key=="||")
|
|
453
|
+
{
|
|
454
|
+
continue;
|
|
455
|
+
}
|
|
456
|
+
if(!myMap.has(key))
|
|
457
|
+
{
|
|
458
|
+
|
|
459
|
+
myMap.set(key,[]);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
myMap.get(key)?.push(item);
|
|
463
|
+
}
|
|
464
|
+
const vats=[];
|
|
465
|
+
for(let array of myMap.values())
|
|
466
|
+
{
|
|
467
|
+
|
|
468
|
+
if(array==null)
|
|
469
|
+
{
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
let obj={
|
|
473
|
+
"VatInvAllowAmount":this.sumBykey("LineInvAllowAmount",array),
|
|
474
|
+
"VatTaxableAmount":this.sumBykey("LineTotalNetAmount",array),
|
|
475
|
+
"VatTaxAmount":this.sumBykey("LineTotalVatAmount",array),
|
|
476
|
+
"VatInvChargeAmount":this.sumBykey("LineTotalVatAmount",array),
|
|
477
|
+
"VatInvAllowBaseAmount":this.sumBykey("LineBaseAmountInclAllow",array),
|
|
478
|
+
"VatInvChargeBaseAmount":this.sumBykey("LineTotalVatAmount",array),
|
|
479
|
+
"VatCatCode":array[0].Record["ItemVatCodeSC__VCCode_EN16931"],
|
|
480
|
+
"VatCatCode__Name":array[0].Record["ItemVatCodeSC__VCCode_EN16931__Name"],
|
|
481
|
+
"VatCodeUI":array[0].Record["ItemVatCodeSC__GroupUIVatCode"],
|
|
482
|
+
"VatCode":array[0].Record["ItemVatCodeSC__VatCode"],
|
|
483
|
+
"VatRate":array[0].Record["ItemVatCodeSC__Rate"],
|
|
484
|
+
"NumOfItems":array.length,
|
|
485
|
+
"VatExemptReasonCode":""
|
|
486
|
+
};
|
|
487
|
+
vats.push(obj);
|
|
488
|
+
}
|
|
489
|
+
tablelevel.Records=new RecordArray(vats,{},this.objectInfo[tablelevel?.Tablename],tablelevel,this.service);
|
|
490
|
+
// console.log(vats)
|
|
491
|
+
*/
|
|
492
|
+
}
|
|
493
|
+
/*private sumBykey(key:string,array:RecordSingle[]):number{
|
|
494
|
+
let num=0;
|
|
495
|
+
for(let i=0;i<array.length;i++)
|
|
496
|
+
{
|
|
497
|
+
let item=array[i].Record;
|
|
498
|
+
if(item[key]==null){
|
|
499
|
+
continue;
|
|
500
|
+
}
|
|
501
|
+
num+=item[key];
|
|
502
|
+
}
|
|
503
|
+
return num;
|
|
504
|
+
}*/
|
|
505
|
+
SumByKey(tAndF) {
|
|
506
|
+
// console.log(tAndF)
|
|
507
|
+
var splitifStat = tAndF.split(",");
|
|
508
|
+
var split = splitifStat[0].split(".");
|
|
509
|
+
if (split.length != 2) {
|
|
510
|
+
throw "Key isn't well formmed! " + tAndF;
|
|
511
|
+
}
|
|
512
|
+
var tableLevel = this.RecursiveFindLevel(this.rootLevel, split[0]);
|
|
513
|
+
if (tableLevel == null) {
|
|
514
|
+
throw "Can't find table level " + split[0];
|
|
515
|
+
}
|
|
516
|
+
let booleanField = null;
|
|
517
|
+
if (splitifStat.length == 2) {
|
|
518
|
+
var split2 = splitifStat[1].split(".");
|
|
519
|
+
booleanField = split2[1];
|
|
520
|
+
}
|
|
521
|
+
let sum = 0;
|
|
522
|
+
if (tableLevel.Records != null) {
|
|
523
|
+
var rec = tableLevel.Records;
|
|
524
|
+
for (var i = 0; i < rec.Records.length; i++) {
|
|
525
|
+
const r = rec.Records[i];
|
|
526
|
+
if (r.Record[split[1]] != null) {
|
|
527
|
+
if (booleanField != null && !r.Record[booleanField] == true) {
|
|
528
|
+
continue;
|
|
529
|
+
}
|
|
530
|
+
sum += r.Record[split[1]];
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
return sum;
|
|
535
|
+
}
|
|
536
|
+
getSaveObject() {
|
|
537
|
+
var _a;
|
|
538
|
+
const result = {};
|
|
539
|
+
result[(_a = this.rootLevel) === null || _a === void 0 ? void 0 : _a.Tablename] = this.rootLevel.getSaveObject(this.objectInfoUIEdit);
|
|
540
|
+
return result;
|
|
541
|
+
}
|
|
542
|
+
getFullObject() {
|
|
543
|
+
var _a;
|
|
544
|
+
const result = {};
|
|
545
|
+
result[(_a = this.rootLevel) === null || _a === void 0 ? void 0 : _a.Tablename] = this.rootLevel.getFullObject(this.objectInfo);
|
|
546
|
+
return result;
|
|
547
|
+
}
|
|
548
|
+
ValidateBeforeSave() {
|
|
549
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
550
|
+
var master = this.GetMasterRecord();
|
|
551
|
+
if (master != null) {
|
|
552
|
+
master.Record["InvTotalVatAmountCCInp"] = master.Record["InvTotalVatAmountCC"];
|
|
553
|
+
master.Record["InvAmountInclVatInp"] = master.Record["InvAmountInclVat"];
|
|
554
|
+
}
|
|
555
|
+
// let errors:string|null=this.rootLevel.Validate();
|
|
556
|
+
let errors = this.rootLevel.Validate();
|
|
557
|
+
// console.log(errors)
|
|
558
|
+
let additionalValidations = [];
|
|
559
|
+
let combineErrors = null;
|
|
560
|
+
let invErrors = [];
|
|
561
|
+
let invDetailErrors = [];
|
|
562
|
+
if (errors) {
|
|
563
|
+
combineErrors = errors['combineErrors'];
|
|
564
|
+
invErrors = errors['validateErrors'];
|
|
565
|
+
invDetailErrors = errors['validateDeatailErrors'];
|
|
566
|
+
}
|
|
567
|
+
if (((_a = master === null || master === void 0 ? void 0 : master.Record) === null || _a === void 0 ? void 0 : _a.BuyerIsVat) == true && (((_b = master === null || master === void 0 ? void 0 : master.Record) === null || _b === void 0 ? void 0 : _b.BuyerVatNum) == null || ((_c = master === null || master === void 0 ? void 0 : master.Record) === null || _c === void 0 ? void 0 : _c.BuyerVatNum.length) == 0)) {
|
|
568
|
+
// errors=this.ConcateErrors(errors,"Buyer vat flag is true, but Buyer Vat number isn't defined!");
|
|
569
|
+
combineErrors = this.ConcateErrors(combineErrors, "Buyer vat flag is true, but Buyer Vat number isn't defined!");
|
|
570
|
+
additionalValidations.push('BuyerIsVat');
|
|
571
|
+
}
|
|
572
|
+
if (((_d = master === null || master === void 0 ? void 0 : master.Record) === null || _d === void 0 ? void 0 : _d.BuyerIsBudget) == true && (((_e = master === null || master === void 0 ? void 0 : master.Record) === null || _e === void 0 ? void 0 : _e.BuyerBudgetNum) == null || ((_f = master === null || master === void 0 ? void 0 : master.Record) === null || _f === void 0 ? void 0 : _f.BuyerBudgetNum.length) == 0)) {
|
|
573
|
+
// errors=this.ConcateErrors(errors,"Buyer budget flag is true, but Buyer Budget number isn't defined!");
|
|
574
|
+
combineErrors = this.ConcateErrors(combineErrors, "Buyer budget flag is true, but Buyer Budget number isn't defined!");
|
|
575
|
+
additionalValidations.push('BuyerIsBudget');
|
|
576
|
+
}
|
|
577
|
+
if (((_g = master === null || master === void 0 ? void 0 : master.Record) === null || _g === void 0 ? void 0 : _g.InvStartDate) > ((_h = master === null || master === void 0 ? void 0 : master.Record) === null || _h === void 0 ? void 0 : _h.InvEndDate)) {
|
|
578
|
+
combineErrors = this.ConcateErrors(combineErrors, "Invoice end date can't be smaller that Invoice start date!");
|
|
579
|
+
additionalValidations.push('InvEndDate1');
|
|
580
|
+
}
|
|
581
|
+
if (invErrors.length > 0 || invDetailErrors.length > 0 || additionalValidations.length > 0) {
|
|
582
|
+
// končal tu ker mi ne vrača array - uredi da vrne array in jih lokaliziraj!
|
|
583
|
+
let invErrorsParam = [];
|
|
584
|
+
if (invErrors.length > 0) {
|
|
585
|
+
invErrorsParam = (_j = invErrors[0]) === null || _j === void 0 ? void 0 : _j.split(', ');
|
|
586
|
+
}
|
|
587
|
+
if (additionalValidations.length > 0) {
|
|
588
|
+
invErrorsParam.unshift(additionalValidations);
|
|
589
|
+
}
|
|
590
|
+
let invDeatailErrorsParam = invDetailErrors;
|
|
591
|
+
// this.service.AlertMessageFromValidation("Error", invErrorsParam, invDeatailErrorsParam);
|
|
592
|
+
}
|
|
593
|
+
else {
|
|
594
|
+
return true;
|
|
595
|
+
}
|
|
596
|
+
return false;
|
|
597
|
+
}
|
|
598
|
+
ConcateErrors(combineErrors, error) {
|
|
599
|
+
if (combineErrors == '') {
|
|
600
|
+
combineErrors = error;
|
|
601
|
+
return combineErrors;
|
|
602
|
+
}
|
|
603
|
+
combineErrors += " " + error;
|
|
604
|
+
return combineErrors;
|
|
605
|
+
}
|
|
606
|
+
TranslateObj(obj) {
|
|
607
|
+
this.rootLevel.TranslateObj(obj);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
exports.InvoiceObj = InvoiceObj;
|