@pokash/n8n-nodes-optima-rest-api 1.4.0 → 1.6.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.
@@ -290,6 +290,12 @@ class OptimaRestApi {
290
290
  description: 'Create a sales or purchase invoice',
291
291
  action: 'Create an invoice',
292
292
  },
293
+ {
294
+ name: 'Create Invoice Correction',
295
+ value: 'createInvoiceCorrection',
296
+ description: 'Create a sales, purchase, or margin invoice correction (korekta)',
297
+ action: 'Create an invoice correction',
298
+ },
293
299
  {
294
300
  name: 'Create Additional Record',
295
301
  value: 'createAdditionalRecord',
@@ -358,6 +364,33 @@ class OptimaRestApi {
358
364
  ],
359
365
  default: 'towary używane',
360
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
+ },
361
394
  // Record Type for Additional Record
362
395
  {
363
396
  displayName: 'Record Type',
@@ -381,7 +414,7 @@ class OptimaRestApi {
381
414
  ],
382
415
  default: 'Purchase',
383
416
  },
384
- // Document Data for Invoice
417
+ // Document Data for Invoice and Invoice Correction
385
418
  {
386
419
  displayName: 'Document Data',
387
420
  name: 'documentData',
@@ -390,7 +423,7 @@ class OptimaRestApi {
390
423
  displayOptions: {
391
424
  show: {
392
425
  resource: ['document'],
393
- operation: ['createInvoice'],
426
+ operation: ['createInvoice', 'createInvoiceCorrection'],
394
427
  },
395
428
  },
396
429
  default: '{\n "platnik": {\n "akronim": "KLIENT01"\n },\n "pozycje": [\n {\n "kod": "PROD01",\n "ilosc": 1,\n "cena": 100\n }\n ]\n}',
@@ -736,7 +769,22 @@ class OptimaRestApi {
736
769
  }
737
770
  else {
738
771
  // Split mode - return each customer as separate item
739
- if (items[i].binary) {
772
+ if (customers.length === 0) {
773
+ // No customers found - return metadata so flow can continue
774
+ const result = {
775
+ json: {
776
+ Success: responseData.Success,
777
+ TotalCount: responseData.TotalCount,
778
+ Customers: [],
779
+ _empty: true,
780
+ }
781
+ };
782
+ if (items[i].binary) {
783
+ result.binary = items[i].binary;
784
+ }
785
+ returnData.push(result);
786
+ }
787
+ else if (items[i].binary) {
740
788
  // First item gets binary
741
789
  returnData.push({
742
790
  json: customers[0] || {},
@@ -854,6 +902,23 @@ class OptimaRestApi {
854
902
  }
855
903
  returnData.push(result);
856
904
  }
905
+ else if (operation === 'createInvoiceCorrection') {
906
+ const correctionType = this.getNodeParameter('correctionType', i);
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);
921
+ }
857
922
  else if (operation === 'createAdditionalRecord') {
858
923
  const recordType = this.getNodeParameter('recordType', i);
859
924
  const recordData = JSON.parse(this.getNodeParameter('recordData', i));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pokash/n8n-nodes-optima-rest-api",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "n8n node for Comarch Optima REST API integration",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",