@pokash/n8n-nodes-optima-rest-api 1.6.2 → 1.7.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.
|
@@ -277,7 +277,7 @@ class OptimaRestApi {
|
|
|
277
277
|
displayName: 'Operation',
|
|
278
278
|
name: 'operation',
|
|
279
279
|
type: 'options',
|
|
280
|
-
noDataExpression:
|
|
280
|
+
noDataExpression: false,
|
|
281
281
|
displayOptions: {
|
|
282
282
|
show: {
|
|
283
283
|
resource: ['document'],
|
|
@@ -305,34 +305,35 @@ class OptimaRestApi {
|
|
|
305
305
|
],
|
|
306
306
|
default: 'createInvoice',
|
|
307
307
|
},
|
|
308
|
-
// Document Type
|
|
308
|
+
// Document Type (Invoice: Sale/Purchase/Margin, Correction: Sale/Purchase/Margin, Additional Record: Purchase/Sale)
|
|
309
309
|
{
|
|
310
310
|
displayName: 'Document Type',
|
|
311
311
|
name: 'documentType',
|
|
312
312
|
type: 'options',
|
|
313
|
+
noDataExpression: false,
|
|
313
314
|
displayOptions: {
|
|
314
315
|
show: {
|
|
315
316
|
resource: ['document'],
|
|
316
|
-
operation: ['createInvoice'],
|
|
317
317
|
},
|
|
318
318
|
},
|
|
319
319
|
options: [
|
|
320
320
|
{
|
|
321
|
-
name: 'Sales Invoice',
|
|
321
|
+
name: 'Sales Invoice / Sale Correction',
|
|
322
322
|
value: 'Sale',
|
|
323
323
|
},
|
|
324
324
|
{
|
|
325
|
-
name: 'Purchase Invoice',
|
|
325
|
+
name: 'Purchase Invoice / Purchase Correction',
|
|
326
326
|
value: 'Purchase',
|
|
327
327
|
},
|
|
328
328
|
{
|
|
329
|
-
name: 'Margin Invoice
|
|
329
|
+
name: 'Margin Invoice / Margin Correction',
|
|
330
330
|
value: 'Margin',
|
|
331
331
|
},
|
|
332
332
|
],
|
|
333
333
|
default: 'Sale',
|
|
334
|
+
description: 'Type of document. For invoices: Sale/Purchase/Margin. For corrections: determines which original document type. For additional records: Purchase (expense) or Sale (income).',
|
|
334
335
|
},
|
|
335
|
-
// Procedura marży -
|
|
336
|
+
// Procedura marży - optional, used when Document Type = Margin
|
|
336
337
|
{
|
|
337
338
|
displayName: 'Margin Procedure',
|
|
338
339
|
name: 'proceduraMarzy',
|
|
@@ -340,11 +341,13 @@ class OptimaRestApi {
|
|
|
340
341
|
displayOptions: {
|
|
341
342
|
show: {
|
|
342
343
|
resource: ['document'],
|
|
343
|
-
operation: ['createInvoice'],
|
|
344
|
-
documentType: ['Margin'],
|
|
345
344
|
},
|
|
346
345
|
},
|
|
347
346
|
options: [
|
|
347
|
+
{
|
|
348
|
+
name: '(not applicable)',
|
|
349
|
+
value: '',
|
|
350
|
+
},
|
|
348
351
|
{
|
|
349
352
|
name: 'Towary używane',
|
|
350
353
|
value: 'towary używane',
|
|
@@ -362,59 +365,10 @@ class OptimaRestApi {
|
|
|
362
365
|
value: 'przedmioty kolekcjonerskie i antyki',
|
|
363
366
|
},
|
|
364
367
|
],
|
|
365
|
-
default: '
|
|
366
|
-
|
|
367
|
-
// Correction Type for Invoice Correction
|
|
368
|
-
{
|
|
369
|
-
displayName: 'Correction Type',
|
|
370
|
-
name: 'correctionType',
|
|
371
|
-
type: 'options',
|
|
372
|
-
displayOptions: {
|
|
373
|
-
show: {
|
|
374
|
-
resource: ['document'],
|
|
375
|
-
operation: ['createInvoiceCorrection'],
|
|
376
|
-
},
|
|
377
|
-
},
|
|
378
|
-
options: [
|
|
379
|
-
{
|
|
380
|
-
name: 'Sales Invoice Correction',
|
|
381
|
-
value: 'Sale',
|
|
382
|
-
},
|
|
383
|
-
{
|
|
384
|
-
name: 'Purchase Invoice Correction',
|
|
385
|
-
value: 'Purchase',
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
name: 'Margin Invoice Correction (VAT marża)',
|
|
389
|
-
value: 'Margin',
|
|
390
|
-
},
|
|
391
|
-
],
|
|
392
|
-
default: 'Sale',
|
|
393
|
-
},
|
|
394
|
-
// Record Type for Additional Record
|
|
395
|
-
{
|
|
396
|
-
displayName: 'Record Type',
|
|
397
|
-
name: 'recordType',
|
|
398
|
-
type: 'options',
|
|
399
|
-
displayOptions: {
|
|
400
|
-
show: {
|
|
401
|
-
resource: ['document'],
|
|
402
|
-
operation: ['createAdditionalRecord'],
|
|
403
|
-
},
|
|
404
|
-
},
|
|
405
|
-
options: [
|
|
406
|
-
{
|
|
407
|
-
name: 'Purchase (Expense)',
|
|
408
|
-
value: 'Purchase',
|
|
409
|
-
},
|
|
410
|
-
{
|
|
411
|
-
name: 'Sale (Income)',
|
|
412
|
-
value: 'Sale',
|
|
413
|
-
},
|
|
414
|
-
],
|
|
415
|
-
default: 'Purchase',
|
|
368
|
+
default: '',
|
|
369
|
+
description: 'Only used when Document Type is Margin. Leave empty for non-margin documents.',
|
|
416
370
|
},
|
|
417
|
-
// Document Data for Invoice and
|
|
371
|
+
// Document Data (for Invoice, Correction, and Additional Record)
|
|
418
372
|
{
|
|
419
373
|
displayName: 'Document Data',
|
|
420
374
|
name: 'documentData',
|
|
@@ -423,26 +377,10 @@ class OptimaRestApi {
|
|
|
423
377
|
displayOptions: {
|
|
424
378
|
show: {
|
|
425
379
|
resource: ['document'],
|
|
426
|
-
operation: ['createInvoice', 'createInvoiceCorrection'],
|
|
427
380
|
},
|
|
428
381
|
},
|
|
429
382
|
default: '{\n "platnik": {\n "akronim": "KLIENT01"\n },\n "pozycje": [\n {\n "kod": "PROD01",\n "ilosc": 1,\n "cena": 100\n }\n ]\n}',
|
|
430
|
-
description: 'Document data in JSON format',
|
|
431
|
-
},
|
|
432
|
-
// Record Data for Additional Record
|
|
433
|
-
{
|
|
434
|
-
displayName: 'Record Data',
|
|
435
|
-
name: 'recordData',
|
|
436
|
-
type: 'json',
|
|
437
|
-
required: true,
|
|
438
|
-
displayOptions: {
|
|
439
|
-
show: {
|
|
440
|
-
resource: ['document'],
|
|
441
|
-
operation: ['createAdditionalRecord'],
|
|
442
|
-
},
|
|
443
|
-
},
|
|
444
|
-
default: '{\n "platnik": {\n "akronim": "KLIENT01"\n },\n "pozycje": [\n {\n "kod": "PROD01",\n "ilosc": 1,\n "cena": 100\n }\n ]\n}',
|
|
445
|
-
description: 'Additional record data in JSON format',
|
|
383
|
+
description: 'Document data in JSON format. For corrections: include OryginalDocumentId and PrzyczynaKorekty.',
|
|
446
384
|
},
|
|
447
385
|
// Product Operations
|
|
448
386
|
{
|
|
@@ -880,62 +818,40 @@ class OptimaRestApi {
|
|
|
880
818
|
}
|
|
881
819
|
}
|
|
882
820
|
else if (resource === 'document') {
|
|
821
|
+
const documentType = this.getNodeParameter('documentType', i);
|
|
822
|
+
const documentData = JSON.parse(this.getNodeParameter('documentData', i));
|
|
823
|
+
// Add ProceduraMarzy for Margin documents (if provided)
|
|
824
|
+
const proceduraMarzy = this.getNodeParameter('proceduraMarzy', i, '');
|
|
825
|
+
if (proceduraMarzy) {
|
|
826
|
+
documentData.ProceduraMarzy = proceduraMarzy;
|
|
827
|
+
}
|
|
828
|
+
// Build endpoint URL based on operation
|
|
829
|
+
let endpoint;
|
|
883
830
|
if (operation === 'createInvoice') {
|
|
884
|
-
|
|
885
|
-
const documentData = JSON.parse(this.getNodeParameter('documentData', i));
|
|
886
|
-
// Add ProceduraMarzy for Margin invoices
|
|
887
|
-
if (documentType === 'Margin') {
|
|
888
|
-
const proceduraMarzy = this.getNodeParameter('proceduraMarzy', i);
|
|
889
|
-
documentData.ProceduraMarzy = proceduraMarzy;
|
|
890
|
-
}
|
|
891
|
-
const response = await makeAuthenticatedRequest({
|
|
892
|
-
method: 'POST',
|
|
893
|
-
url: `${gatewayUrl}/api/Documents/Invoice/${documentType}`,
|
|
894
|
-
body: documentData,
|
|
895
|
-
json: true,
|
|
896
|
-
});
|
|
897
|
-
const result = {
|
|
898
|
-
json: response
|
|
899
|
-
};
|
|
900
|
-
if (items[i].binary) {
|
|
901
|
-
result.binary = items[i].binary;
|
|
902
|
-
}
|
|
903
|
-
returnData.push(result);
|
|
831
|
+
endpoint = `Documents/Invoice/${documentType}`;
|
|
904
832
|
}
|
|
905
833
|
else if (operation === 'createInvoiceCorrection') {
|
|
906
|
-
|
|
907
|
-
const documentData = JSON.parse(this.getNodeParameter('documentData', i));
|
|
908
|
-
const response = await makeAuthenticatedRequest({
|
|
909
|
-
method: 'POST',
|
|
910
|
-
url: `${gatewayUrl}/api/Documents/Invoice-Correction/${correctionType}`,
|
|
911
|
-
body: documentData,
|
|
912
|
-
json: true,
|
|
913
|
-
});
|
|
914
|
-
const result = {
|
|
915
|
-
json: response
|
|
916
|
-
};
|
|
917
|
-
if (items[i].binary) {
|
|
918
|
-
result.binary = items[i].binary;
|
|
919
|
-
}
|
|
920
|
-
returnData.push(result);
|
|
834
|
+
endpoint = `Documents/Invoice-Correction/${documentType}`;
|
|
921
835
|
}
|
|
922
836
|
else if (operation === 'createAdditionalRecord') {
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
url: `${gatewayUrl}/api/Documents/AdditionalRecords/${recordType}`,
|
|
928
|
-
body: recordData,
|
|
929
|
-
json: true,
|
|
930
|
-
});
|
|
931
|
-
const result = {
|
|
932
|
-
json: response
|
|
933
|
-
};
|
|
934
|
-
if (items[i].binary) {
|
|
935
|
-
result.binary = items[i].binary;
|
|
936
|
-
}
|
|
937
|
-
returnData.push(result);
|
|
837
|
+
endpoint = `Documents/AdditionalRecords/${documentType}`;
|
|
838
|
+
}
|
|
839
|
+
else {
|
|
840
|
+
throw new Error(`Unsupported document operation: ${operation}`);
|
|
938
841
|
}
|
|
842
|
+
const response = await makeAuthenticatedRequest({
|
|
843
|
+
method: 'POST',
|
|
844
|
+
url: `${gatewayUrl}/api/${endpoint}`,
|
|
845
|
+
body: documentData,
|
|
846
|
+
json: true,
|
|
847
|
+
});
|
|
848
|
+
const result = {
|
|
849
|
+
json: response
|
|
850
|
+
};
|
|
851
|
+
if (items[i].binary) {
|
|
852
|
+
result.binary = items[i].binary;
|
|
853
|
+
}
|
|
854
|
+
returnData.push(result);
|
|
939
855
|
}
|
|
940
856
|
else if (resource === 'dictionary') {
|
|
941
857
|
const options = this.getNodeParameter('options', i, {});
|