@custom-js/n8n-nodes-pdf-toolkit 1.34.0 → 1.36.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.
@@ -172,7 +172,7 @@ class InvoiceGenerator {
172
172
  displayName: 'Items JSON',
173
173
  name: 'itemsJson',
174
174
  type: 'json',
175
- default: '[]',
175
+ default: '[{"description":"Item 1","quantity":2,"unitPrice":50}]',
176
176
  displayOptions: {
177
177
  show: {
178
178
  itemsMode: ['json'],
@@ -197,20 +197,35 @@ class InvoiceGenerator {
197
197
  let invoiceItems;
198
198
  if (itemsMode === 'json') {
199
199
  const itemsJson = this.getNodeParameter('itemsJson', i);
200
- try {
201
- invoiceItems = JSON.parse(itemsJson);
202
- }
203
- catch (error) {
204
- if (error instanceof Error) {
205
- throw new Error(`Invalid JSON in 'Items JSON' field: ${error.message}`);
200
+ if (typeof itemsJson === 'string') {
201
+ try {
202
+ invoiceItems = JSON.parse(itemsJson);
203
+ }
204
+ catch (error) {
205
+ if (error instanceof Error) {
206
+ throw new Error(`Invalid JSON in 'Items JSON' field: ${error.message}`);
207
+ }
208
+ throw new Error(`Invalid JSON in 'Items JSON' field: ${String(error)}`);
206
209
  }
207
- throw new Error(`Invalid JSON in 'Items JSON' field: ${String(error)}`);
210
+ }
211
+ else if (Array.isArray(itemsJson)) {
212
+ invoiceItems = itemsJson;
213
+ }
214
+ else {
215
+ invoiceItems = [];
208
216
  }
209
217
  }
210
218
  else {
211
219
  const itemsData = this.getNodeParameter('items', i);
212
220
  invoiceItems = itemsData.itemsValues;
213
221
  }
222
+ invoiceItems = invoiceItems.map(item => {
223
+ return {
224
+ description: item.description,
225
+ quantity: Number(item.quantity),
226
+ unitPrice: Number(item.unitPrice),
227
+ };
228
+ });
214
229
  const invoiceData = {
215
230
  issuer,
216
231
  payment,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@custom-js/n8n-nodes-pdf-toolkit",
3
- "version": "1.34.0",
3
+ "version": "1.36.0",
4
4
  "description": "This is official node for interacting with APIs from customjs.space",
5
5
  "keywords": [
6
6
  "customjs",