@pokash/n8n-nodes-optima-rest-api 1.7.0 → 1.9.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,133 @@ 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 Pełny',
397
+ name: 'numerPelny',
398
+ type: 'string',
399
+ default: '',
400
+ displayOptions: {
401
+ show: {
402
+ resource: ['document'],
403
+ operation: ['updateKSeF'],
404
+ },
405
+ },
406
+ description: 'Nasz numer dokumentu (np. FS/3/2026/DEV/07) — dla SPRZEDAŻY (unikalny w firmie). Ma pierwszeństwo nad Numer Obcy.',
407
+ },
408
+ {
409
+ displayName: 'Numer Obcy',
410
+ name: 'numerObcy',
411
+ type: 'string',
412
+ default: '',
413
+ displayOptions: {
414
+ show: {
415
+ resource: ['document'],
416
+ operation: ['updateKSeF'],
417
+ },
418
+ },
419
+ description: 'Numer obcy (sprzedawcy) — dla ZAKUPÓW; użyj razem z NIP. Dla sprzedaży użyj Numer Pełny.',
420
+ },
421
+ {
422
+ displayName: 'NIP (Sprzedawcy)',
423
+ name: 'nip',
424
+ type: 'string',
425
+ default: '',
426
+ displayOptions: {
427
+ show: {
428
+ resource: ['document'],
429
+ operation: ['updateKSeF'],
430
+ },
431
+ },
432
+ description: 'NIP sprzedawcy — dopełnia NumerObcy (unikalny tylko w obrębie sprzedawcy). Opcjonalny, ale zalecany.',
433
+ },
434
+ {
435
+ displayName: 'Numer KSeF',
436
+ name: 'nrKsef',
437
+ type: 'string',
438
+ default: '',
439
+ displayOptions: {
440
+ show: {
441
+ resource: ['document'],
442
+ operation: ['updateKSeF'],
443
+ },
444
+ },
445
+ description: 'Numer KSeF dokumentu. Puste = bez zmian.',
446
+ },
447
+ {
448
+ displayName: 'Data Przyjęcia',
449
+ name: 'dataPrzyjecia',
450
+ type: 'string',
451
+ default: '',
452
+ placeholder: '2026-07-01',
453
+ displayOptions: {
454
+ show: {
455
+ resource: ['document'],
456
+ operation: ['updateKSeF'],
457
+ },
458
+ },
459
+ description: 'Data przyjęcia w KSeF (format yyyy-MM-dd). Puste = bez zmian.',
460
+ },
461
+ {
462
+ displayName: 'Forma Płatności',
463
+ name: 'formaPlatnosci',
464
+ type: 'options',
465
+ default: '',
466
+ options: [
467
+ { name: '(bez zmian)', value: '' },
468
+ { name: 'Przelew', value: 'przelew' },
469
+ { name: 'Gotówka', value: 'gotówka' },
470
+ { name: 'Karta', value: 'karta' },
471
+ { name: 'Bon', value: 'bon' },
472
+ { name: 'Czek', value: 'czek' },
473
+ { name: 'Kredyt', value: 'kredyt' },
474
+ { name: 'Mobilna', value: 'mobilna' },
475
+ ],
476
+ displayOptions: {
477
+ show: {
478
+ resource: ['document'],
479
+ operation: ['updateKSeF'],
480
+ },
481
+ },
482
+ description: 'Forma płatności KSeF (mapowana na kod TrN_KSeFFPLId po stronie API)',
483
+ },
484
+ {
485
+ displayName: 'Środowisko',
486
+ name: 'srodowisko',
487
+ type: 'options',
488
+ default: '',
489
+ options: [
490
+ { name: '(bez zmian)', value: '' },
491
+ { name: 'Produkcyjne', value: 'Produkcyjne' },
492
+ { name: 'Demo', value: 'Demo' },
493
+ ],
494
+ displayOptions: {
495
+ show: {
496
+ resource: ['document'],
497
+ operation: ['updateKSeF'],
498
+ },
499
+ },
500
+ description: 'Środowisko KSeF',
501
+ },
502
+ {
503
+ displayName: 'Link Weryfikacyjny',
504
+ name: 'linkWeryfikacyjny',
505
+ type: 'string',
506
+ default: '',
507
+ displayOptions: {
508
+ show: {
509
+ resource: ['document'],
510
+ operation: ['updateKSeF'],
511
+ },
512
+ },
513
+ description: 'Link weryfikacyjny KSeF (QR). Puste = bez zmian.',
514
+ },
385
515
  // Product Operations
386
516
  {
387
517
  displayName: 'Operation',
@@ -818,40 +948,84 @@ class OptimaRestApi {
818
948
  }
819
949
  }
820
950
  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;
830
- if (operation === 'createInvoice') {
831
- endpoint = `Documents/Invoice/${documentType}`;
832
- }
833
- else if (operation === 'createInvoiceCorrection') {
834
- endpoint = `Documents/Invoice-Correction/${documentType}`;
835
- }
836
- else if (operation === 'createAdditionalRecord') {
837
- endpoint = `Documents/AdditionalRecords/${documentType}`;
951
+ if (operation === 'updateKSeF') {
952
+ // Aktualizacja danych KSeF nagłówka po NumerObcy (+ opcjonalnie NIP sprzedawcy).
953
+ // Partial update: dołączamy tylko niepuste pola (pusty string = "bez zmian").
954
+ const numerPelny = this.getNodeParameter('numerPelny', i, '');
955
+ const numerObcy = this.getNodeParameter('numerObcy', i, '');
956
+ const nip = this.getNodeParameter('nip', i, '');
957
+ const nrKsef = this.getNodeParameter('nrKsef', i, '');
958
+ const dataPrzyjecia = this.getNodeParameter('dataPrzyjecia', i, '');
959
+ const formaPlatnosci = this.getNodeParameter('formaPlatnosci', i, '');
960
+ const srodowisko = this.getNodeParameter('srodowisko', i, '');
961
+ const linkWeryfikacyjny = this.getNodeParameter('linkWeryfikacyjny', i, '');
962
+ const body = {};
963
+ if (numerPelny)
964
+ body.NumerPelny = numerPelny;
965
+ if (numerObcy)
966
+ body.NumerObcy = numerObcy;
967
+ if (nip)
968
+ body.Nip = nip;
969
+ if (nrKsef)
970
+ body.NrKsef = nrKsef;
971
+ if (dataPrzyjecia)
972
+ body.DataPrzyjecia = dataPrzyjecia;
973
+ if (formaPlatnosci)
974
+ body.FormaPlatnosci = formaPlatnosci;
975
+ if (srodowisko)
976
+ body.Srodowisko = srodowisko;
977
+ if (linkWeryfikacyjny)
978
+ body.LinkWeryfikacyjny = linkWeryfikacyjny;
979
+ const response = await makeAuthenticatedRequest({
980
+ method: 'PUT',
981
+ url: `${gatewayUrl}/api/Documents/KSeF`,
982
+ body,
983
+ json: true,
984
+ });
985
+ const result = {
986
+ json: response
987
+ };
988
+ if (items[i].binary) {
989
+ result.binary = items[i].binary;
990
+ }
991
+ returnData.push(result);
838
992
  }
839
993
  else {
840
- throw new Error(`Unsupported document operation: ${operation}`);
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;
994
+ const documentType = this.getNodeParameter('documentType', i);
995
+ const documentData = JSON.parse(this.getNodeParameter('documentData', i));
996
+ // Add ProceduraMarzy for Margin documents (if provided)
997
+ const proceduraMarzy = this.getNodeParameter('proceduraMarzy', i, '');
998
+ if (proceduraMarzy) {
999
+ documentData.ProceduraMarzy = proceduraMarzy;
1000
+ }
1001
+ // Build endpoint URL based on operation
1002
+ let endpoint;
1003
+ if (operation === 'createInvoice') {
1004
+ endpoint = `Documents/Invoice/${documentType}`;
1005
+ }
1006
+ else if (operation === 'createInvoiceCorrection') {
1007
+ endpoint = `Documents/Invoice-Correction/${documentType}`;
1008
+ }
1009
+ else if (operation === 'createAdditionalRecord') {
1010
+ endpoint = `Documents/AdditionalRecords/${documentType}`;
1011
+ }
1012
+ else {
1013
+ throw new Error(`Unsupported document operation: ${operation}`);
1014
+ }
1015
+ const response = await makeAuthenticatedRequest({
1016
+ method: 'POST',
1017
+ url: `${gatewayUrl}/api/${endpoint}`,
1018
+ body: documentData,
1019
+ json: true,
1020
+ });
1021
+ const result = {
1022
+ json: response
1023
+ };
1024
+ if (items[i].binary) {
1025
+ result.binary = items[i].binary;
1026
+ }
1027
+ returnData.push(result);
853
1028
  }
854
- returnData.push(result);
855
1029
  }
856
1030
  else if (resource === 'dictionary') {
857
1031
  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.7.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
- }
1
+ {
2
+ "name": "@pokash/n8n-nodes-optima-rest-api",
3
+ "version": "1.9.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
+ }