@pokash/n8n-nodes-optima-rest-api 1.3.1 → 1.5.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.
@@ -319,9 +319,45 @@ class OptimaRestApi {
319
319
  name: 'Purchase Invoice',
320
320
  value: 'Purchase',
321
321
  },
322
+ {
323
+ name: 'Margin Invoice (VAT marża)',
324
+ value: 'Margin',
325
+ },
322
326
  ],
323
327
  default: 'Sale',
324
328
  },
329
+ // Procedura marży - only for Margin Invoice
330
+ {
331
+ displayName: 'Margin Procedure',
332
+ name: 'proceduraMarzy',
333
+ type: 'options',
334
+ displayOptions: {
335
+ show: {
336
+ resource: ['document'],
337
+ operation: ['createInvoice'],
338
+ documentType: ['Margin'],
339
+ },
340
+ },
341
+ options: [
342
+ {
343
+ name: 'Towary używane',
344
+ value: 'towary używane',
345
+ },
346
+ {
347
+ name: 'Biura podróży',
348
+ value: 'biura podróży',
349
+ },
350
+ {
351
+ name: 'Dzieła sztuki',
352
+ value: 'dzieła sztuki',
353
+ },
354
+ {
355
+ name: 'Przedmioty kolekcjonerskie i antyki',
356
+ value: 'przedmioty kolekcjonerskie i antyki',
357
+ },
358
+ ],
359
+ default: 'towary używane',
360
+ },
325
361
  // Record Type for Additional Record
326
362
  {
327
363
  displayName: 'Record Type',
@@ -700,7 +736,22 @@ class OptimaRestApi {
700
736
  }
701
737
  else {
702
738
  // Split mode - return each customer as separate item
703
- if (items[i].binary) {
739
+ if (customers.length === 0) {
740
+ // No customers found - return metadata so flow can continue
741
+ const result = {
742
+ json: {
743
+ Success: responseData.Success,
744
+ TotalCount: responseData.TotalCount,
745
+ Customers: [],
746
+ _empty: true,
747
+ }
748
+ };
749
+ if (items[i].binary) {
750
+ result.binary = items[i].binary;
751
+ }
752
+ returnData.push(result);
753
+ }
754
+ else if (items[i].binary) {
704
755
  // First item gets binary
705
756
  returnData.push({
706
757
  json: customers[0] || {},
@@ -799,6 +850,11 @@ class OptimaRestApi {
799
850
  if (operation === 'createInvoice') {
800
851
  const documentType = this.getNodeParameter('documentType', i);
801
852
  const documentData = JSON.parse(this.getNodeParameter('documentData', i));
853
+ // Add ProceduraMarzy for Margin invoices
854
+ if (documentType === 'Margin') {
855
+ const proceduraMarzy = this.getNodeParameter('proceduraMarzy', i);
856
+ documentData.ProceduraMarzy = proceduraMarzy;
857
+ }
802
858
  const response = await makeAuthenticatedRequest({
803
859
  method: 'POST',
804
860
  url: `${gatewayUrl}/api/Documents/Invoice/${documentType}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pokash/n8n-nodes-optima-rest-api",
3
- "version": "1.3.1",
3
+ "version": "1.5.0",
4
4
  "description": "n8n node for Comarch Optima REST API integration",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",