@pokash/n8n-nodes-optima-rest-api 1.7.0 → 1.8.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.
|
@@ -302,6 +302,12 @@ class OptimaRestApi {
|
|
|
302
302
|
description: 'Create additional purchase/sale record (expense/income)',
|
|
303
303
|
action: 'Create an additional record',
|
|
304
304
|
},
|
|
305
|
+
{
|
|
306
|
+
name: 'Update KSeF Data',
|
|
307
|
+
value: 'updateKSeF',
|
|
308
|
+
description: 'Update KSeF header data (numer, data przyjęcia, forma płatności, środowisko, link) by NumerObcy',
|
|
309
|
+
action: 'Update KSeF data of a document',
|
|
310
|
+
},
|
|
305
311
|
],
|
|
306
312
|
default: 'createInvoice',
|
|
307
313
|
},
|
|
@@ -314,6 +320,7 @@ class OptimaRestApi {
|
|
|
314
320
|
displayOptions: {
|
|
315
321
|
show: {
|
|
316
322
|
resource: ['document'],
|
|
323
|
+
operation: ['createInvoice', 'createInvoiceCorrection', 'createAdditionalRecord'],
|
|
317
324
|
},
|
|
318
325
|
},
|
|
319
326
|
options: [
|
|
@@ -341,6 +348,7 @@ class OptimaRestApi {
|
|
|
341
348
|
displayOptions: {
|
|
342
349
|
show: {
|
|
343
350
|
resource: ['document'],
|
|
351
|
+
operation: ['createInvoice', 'createInvoiceCorrection', 'createAdditionalRecord'],
|
|
344
352
|
},
|
|
345
353
|
},
|
|
346
354
|
options: [
|
|
@@ -377,11 +385,121 @@ class OptimaRestApi {
|
|
|
377
385
|
displayOptions: {
|
|
378
386
|
show: {
|
|
379
387
|
resource: ['document'],
|
|
388
|
+
operation: ['createInvoice', 'createInvoiceCorrection', 'createAdditionalRecord'],
|
|
380
389
|
},
|
|
381
390
|
},
|
|
382
391
|
default: '{\n "platnik": {\n "akronim": "KLIENT01"\n },\n "pozycje": [\n {\n "kod": "PROD01",\n "ilosc": 1,\n "cena": 100\n }\n ]\n}',
|
|
383
392
|
description: 'Document data in JSON format. For corrections: include OryginalDocumentId and PrzyczynaKorekty.',
|
|
384
393
|
},
|
|
394
|
+
// ---- KSeF Update fields (operation: updateKSeF) ----
|
|
395
|
+
{
|
|
396
|
+
displayName: 'Numer Obcy',
|
|
397
|
+
name: 'numerObcy',
|
|
398
|
+
type: 'string',
|
|
399
|
+
required: true,
|
|
400
|
+
default: '',
|
|
401
|
+
displayOptions: {
|
|
402
|
+
show: {
|
|
403
|
+
resource: ['document'],
|
|
404
|
+
operation: ['updateKSeF'],
|
|
405
|
+
},
|
|
406
|
+
},
|
|
407
|
+
description: 'Numer obcy dokumentu (klucz wyszukiwania). Wraz z NIP wskazuje dokładnie 1 dokument.',
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
displayName: 'NIP (Sprzedawcy)',
|
|
411
|
+
name: 'nip',
|
|
412
|
+
type: 'string',
|
|
413
|
+
default: '',
|
|
414
|
+
displayOptions: {
|
|
415
|
+
show: {
|
|
416
|
+
resource: ['document'],
|
|
417
|
+
operation: ['updateKSeF'],
|
|
418
|
+
},
|
|
419
|
+
},
|
|
420
|
+
description: 'NIP sprzedawcy — dopełnia NumerObcy (unikalny tylko w obrębie sprzedawcy). Opcjonalny, ale zalecany.',
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
displayName: 'Numer KSeF',
|
|
424
|
+
name: 'nrKsef',
|
|
425
|
+
type: 'string',
|
|
426
|
+
default: '',
|
|
427
|
+
displayOptions: {
|
|
428
|
+
show: {
|
|
429
|
+
resource: ['document'],
|
|
430
|
+
operation: ['updateKSeF'],
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
description: 'Numer KSeF dokumentu. Puste = bez zmian.',
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
displayName: 'Data Przyjęcia',
|
|
437
|
+
name: 'dataPrzyjecia',
|
|
438
|
+
type: 'string',
|
|
439
|
+
default: '',
|
|
440
|
+
placeholder: '2026-07-01',
|
|
441
|
+
displayOptions: {
|
|
442
|
+
show: {
|
|
443
|
+
resource: ['document'],
|
|
444
|
+
operation: ['updateKSeF'],
|
|
445
|
+
},
|
|
446
|
+
},
|
|
447
|
+
description: 'Data przyjęcia w KSeF (format yyyy-MM-dd). Puste = bez zmian.',
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
displayName: 'Forma Płatności',
|
|
451
|
+
name: 'formaPlatnosci',
|
|
452
|
+
type: 'options',
|
|
453
|
+
default: '',
|
|
454
|
+
options: [
|
|
455
|
+
{ name: '(bez zmian)', value: '' },
|
|
456
|
+
{ name: 'Przelew', value: 'przelew' },
|
|
457
|
+
{ name: 'Gotówka', value: 'gotówka' },
|
|
458
|
+
{ name: 'Karta', value: 'karta' },
|
|
459
|
+
{ name: 'Bon', value: 'bon' },
|
|
460
|
+
{ name: 'Czek', value: 'czek' },
|
|
461
|
+
{ name: 'Kredyt', value: 'kredyt' },
|
|
462
|
+
{ name: 'Mobilna', value: 'mobilna' },
|
|
463
|
+
],
|
|
464
|
+
displayOptions: {
|
|
465
|
+
show: {
|
|
466
|
+
resource: ['document'],
|
|
467
|
+
operation: ['updateKSeF'],
|
|
468
|
+
},
|
|
469
|
+
},
|
|
470
|
+
description: 'Forma płatności KSeF (mapowana na kod TrN_KSeFFPLId po stronie API)',
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
displayName: 'Środowisko',
|
|
474
|
+
name: 'srodowisko',
|
|
475
|
+
type: 'options',
|
|
476
|
+
default: '',
|
|
477
|
+
options: [
|
|
478
|
+
{ name: '(bez zmian)', value: '' },
|
|
479
|
+
{ name: 'Produkcyjne', value: 'Produkcyjne' },
|
|
480
|
+
{ name: 'Demo', value: 'Demo' },
|
|
481
|
+
],
|
|
482
|
+
displayOptions: {
|
|
483
|
+
show: {
|
|
484
|
+
resource: ['document'],
|
|
485
|
+
operation: ['updateKSeF'],
|
|
486
|
+
},
|
|
487
|
+
},
|
|
488
|
+
description: 'Środowisko KSeF',
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
displayName: 'Link Weryfikacyjny',
|
|
492
|
+
name: 'linkWeryfikacyjny',
|
|
493
|
+
type: 'string',
|
|
494
|
+
default: '',
|
|
495
|
+
displayOptions: {
|
|
496
|
+
show: {
|
|
497
|
+
resource: ['document'],
|
|
498
|
+
operation: ['updateKSeF'],
|
|
499
|
+
},
|
|
500
|
+
},
|
|
501
|
+
description: 'Link weryfikacyjny KSeF (QR). Puste = bez zmian.',
|
|
502
|
+
},
|
|
385
503
|
// Product Operations
|
|
386
504
|
{
|
|
387
505
|
displayName: 'Operation',
|
|
@@ -818,40 +936,79 @@ class OptimaRestApi {
|
|
|
818
936
|
}
|
|
819
937
|
}
|
|
820
938
|
else if (resource === 'document') {
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
939
|
+
if (operation === 'updateKSeF') {
|
|
940
|
+
// Aktualizacja danych KSeF nagłówka po NumerObcy (+ opcjonalnie NIP sprzedawcy).
|
|
941
|
+
// Partial update: dołączamy tylko niepuste pola (pusty string = "bez zmian").
|
|
942
|
+
const numerObcy = this.getNodeParameter('numerObcy', i);
|
|
943
|
+
const nip = this.getNodeParameter('nip', i, '');
|
|
944
|
+
const nrKsef = this.getNodeParameter('nrKsef', i, '');
|
|
945
|
+
const dataPrzyjecia = this.getNodeParameter('dataPrzyjecia', i, '');
|
|
946
|
+
const formaPlatnosci = this.getNodeParameter('formaPlatnosci', i, '');
|
|
947
|
+
const srodowisko = this.getNodeParameter('srodowisko', i, '');
|
|
948
|
+
const linkWeryfikacyjny = this.getNodeParameter('linkWeryfikacyjny', i, '');
|
|
949
|
+
const body = { NumerObcy: numerObcy };
|
|
950
|
+
if (nip)
|
|
951
|
+
body.Nip = nip;
|
|
952
|
+
if (nrKsef)
|
|
953
|
+
body.NrKsef = nrKsef;
|
|
954
|
+
if (dataPrzyjecia)
|
|
955
|
+
body.DataPrzyjecia = dataPrzyjecia;
|
|
956
|
+
if (formaPlatnosci)
|
|
957
|
+
body.FormaPlatnosci = formaPlatnosci;
|
|
958
|
+
if (srodowisko)
|
|
959
|
+
body.Srodowisko = srodowisko;
|
|
960
|
+
if (linkWeryfikacyjny)
|
|
961
|
+
body.LinkWeryfikacyjny = linkWeryfikacyjny;
|
|
962
|
+
const response = await makeAuthenticatedRequest({
|
|
963
|
+
method: 'PUT',
|
|
964
|
+
url: `${gatewayUrl}/api/Documents/KSeF`,
|
|
965
|
+
body,
|
|
966
|
+
json: true,
|
|
967
|
+
});
|
|
968
|
+
const result = {
|
|
969
|
+
json: response
|
|
970
|
+
};
|
|
971
|
+
if (items[i].binary) {
|
|
972
|
+
result.binary = items[i].binary;
|
|
973
|
+
}
|
|
974
|
+
returnData.push(result);
|
|
838
975
|
}
|
|
839
976
|
else {
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
977
|
+
const documentType = this.getNodeParameter('documentType', i);
|
|
978
|
+
const documentData = JSON.parse(this.getNodeParameter('documentData', i));
|
|
979
|
+
// Add ProceduraMarzy for Margin documents (if provided)
|
|
980
|
+
const proceduraMarzy = this.getNodeParameter('proceduraMarzy', i, '');
|
|
981
|
+
if (proceduraMarzy) {
|
|
982
|
+
documentData.ProceduraMarzy = proceduraMarzy;
|
|
983
|
+
}
|
|
984
|
+
// Build endpoint URL based on operation
|
|
985
|
+
let endpoint;
|
|
986
|
+
if (operation === 'createInvoice') {
|
|
987
|
+
endpoint = `Documents/Invoice/${documentType}`;
|
|
988
|
+
}
|
|
989
|
+
else if (operation === 'createInvoiceCorrection') {
|
|
990
|
+
endpoint = `Documents/Invoice-Correction/${documentType}`;
|
|
991
|
+
}
|
|
992
|
+
else if (operation === 'createAdditionalRecord') {
|
|
993
|
+
endpoint = `Documents/AdditionalRecords/${documentType}`;
|
|
994
|
+
}
|
|
995
|
+
else {
|
|
996
|
+
throw new Error(`Unsupported document operation: ${operation}`);
|
|
997
|
+
}
|
|
998
|
+
const response = await makeAuthenticatedRequest({
|
|
999
|
+
method: 'POST',
|
|
1000
|
+
url: `${gatewayUrl}/api/${endpoint}`,
|
|
1001
|
+
body: documentData,
|
|
1002
|
+
json: true,
|
|
1003
|
+
});
|
|
1004
|
+
const result = {
|
|
1005
|
+
json: response
|
|
1006
|
+
};
|
|
1007
|
+
if (items[i].binary) {
|
|
1008
|
+
result.binary = items[i].binary;
|
|
1009
|
+
}
|
|
1010
|
+
returnData.push(result);
|
|
853
1011
|
}
|
|
854
|
-
returnData.push(result);
|
|
855
1012
|
}
|
|
856
1013
|
else if (resource === 'dictionary') {
|
|
857
1014
|
const options = this.getNodeParameter('options', i, {});
|
package/package.json
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@pokash/n8n-nodes-optima-rest-api",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "n8n node for Comarch Optima REST API integration",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"n8n-community-node-package",
|
|
7
|
-
"n8n",
|
|
8
|
-
"optima",
|
|
9
|
-
"comarch",
|
|
10
|
-
"erp"
|
|
11
|
-
],
|
|
12
|
-
"license": "MIT",
|
|
13
|
-
"homepage": "https://github.com/pokash-pl/n8n-nodes-optima-rest-api",
|
|
14
|
-
"author": {
|
|
15
|
-
"name": "POKASH.PL Sp. z o. o.",
|
|
16
|
-
"email": "hello@pokash.cloud"
|
|
17
|
-
},
|
|
18
|
-
"repository": {
|
|
19
|
-
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/pokash-pl/n8n-nodes-optima-rest-api.git"
|
|
21
|
-
},
|
|
22
|
-
"main": "index.js",
|
|
23
|
-
"scripts": {
|
|
24
|
-
"build": "tsc && gulp build:icons",
|
|
25
|
-
"dev": "tsc --watch",
|
|
26
|
-
"format": "prettier nodes --write",
|
|
27
|
-
"lint": "eslint nodes/**/*.ts package.json",
|
|
28
|
-
"lintfix": "eslint nodes/**/*.ts package.json --fix",
|
|
29
|
-
"prepublishOnly": "npm run build"
|
|
30
|
-
},
|
|
31
|
-
"files": [
|
|
32
|
-
"dist"
|
|
33
|
-
],
|
|
34
|
-
"n8n": {
|
|
35
|
-
"n8nNodesApiVersion": 1,
|
|
36
|
-
"credentials": [
|
|
37
|
-
"dist/credentials/OptimaRestApiCredentials.credentials.js"
|
|
38
|
-
],
|
|
39
|
-
"nodes": [
|
|
40
|
-
"dist/nodes/OptimaRestApi/OptimaRestApi.node.js"
|
|
41
|
-
]
|
|
42
|
-
},
|
|
43
|
-
"devDependencies": {
|
|
44
|
-
"@types/node": "^20.0.0",
|
|
45
|
-
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
46
|
-
"@typescript-eslint/parser": "^6.21.0",
|
|
47
|
-
"eslint": "^8.57.0",
|
|
48
|
-
"eslint-plugin-n8n-nodes-base": "^1.16.0",
|
|
49
|
-
"gulp": "^5.0.0",
|
|
50
|
-
"n8n-workflow": "^2.2.2",
|
|
51
|
-
"prettier": "^3.3.0",
|
|
52
|
-
"typescript": "~5.6.0"
|
|
53
|
-
},
|
|
54
|
-
"peerDependencies": {
|
|
55
|
-
"n8n-workflow": "^2.0.0"
|
|
56
|
-
},
|
|
57
|
-
"overrides": {
|
|
58
|
-
"form-data": "^4.0.4"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@pokash/n8n-nodes-optima-rest-api",
|
|
3
|
+
"version": "1.8.0",
|
|
4
|
+
"description": "n8n node for Comarch Optima REST API integration",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"n8n-community-node-package",
|
|
7
|
+
"n8n",
|
|
8
|
+
"optima",
|
|
9
|
+
"comarch",
|
|
10
|
+
"erp"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"homepage": "https://github.com/pokash-pl/n8n-nodes-optima-rest-api",
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "POKASH.PL Sp. z o. o.",
|
|
16
|
+
"email": "hello@pokash.cloud"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/pokash-pl/n8n-nodes-optima-rest-api.git"
|
|
21
|
+
},
|
|
22
|
+
"main": "index.js",
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc && gulp build:icons",
|
|
25
|
+
"dev": "tsc --watch",
|
|
26
|
+
"format": "prettier nodes --write",
|
|
27
|
+
"lint": "eslint nodes/**/*.ts package.json",
|
|
28
|
+
"lintfix": "eslint nodes/**/*.ts package.json --fix",
|
|
29
|
+
"prepublishOnly": "npm run build"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
34
|
+
"n8n": {
|
|
35
|
+
"n8nNodesApiVersion": 1,
|
|
36
|
+
"credentials": [
|
|
37
|
+
"dist/credentials/OptimaRestApiCredentials.credentials.js"
|
|
38
|
+
],
|
|
39
|
+
"nodes": [
|
|
40
|
+
"dist/nodes/OptimaRestApi/OptimaRestApi.node.js"
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^20.0.0",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
46
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
47
|
+
"eslint": "^8.57.0",
|
|
48
|
+
"eslint-plugin-n8n-nodes-base": "^1.16.0",
|
|
49
|
+
"gulp": "^5.0.0",
|
|
50
|
+
"n8n-workflow": "^2.2.2",
|
|
51
|
+
"prettier": "^3.3.0",
|
|
52
|
+
"typescript": "~5.6.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"n8n-workflow": "^2.0.0"
|
|
56
|
+
},
|
|
57
|
+
"overrides": {
|
|
58
|
+
"form-data": "^4.0.4"
|
|
59
|
+
}
|
|
60
|
+
}
|