From c0e18d473c050d143f67ed2c76fa9ec9414daf1a Mon Sep 17 00:00:00 2001 From: Sebastian Rindom Date: Sat, 2 Jul 2022 11:05:20 +0200 Subject: [PATCH] fix(webshipper): only add invoices if invoice generator produces a file (#1749) --- .../src/services/webshipper-fulfillment.js | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/medusa-fulfillment-webshipper/src/services/webshipper-fulfillment.js b/packages/medusa-fulfillment-webshipper/src/services/webshipper-fulfillment.js index 4ea0cd2e00..92a991d9a0 100644 --- a/packages/medusa-fulfillment-webshipper/src/services/webshipper-fulfillment.js +++ b/packages/medusa-fulfillment-webshipper/src/services/webshipper-fulfillment.js @@ -287,19 +287,21 @@ class WebshipperFulfillmentService extends FulfillmentService { fulfillmentItems ) - invoice = await this.client_.documents - .create({ - type: "documents", - attributes: { - document_size: this.options_.document_size || "A4", - document_format: "PDF", - base64: base64Invoice, - document_type: "invoice", - }, - }) - .catch((err) => { - throw err - }) + if (base64Invoice) { + invoice = await this.client_.documents + .create({ + type: "documents", + attributes: { + document_size: this.options_.document_size || "A4", + document_format: "PDF", + base64: base64Invoice, + document_type: "invoice", + }, + }) + .catch((err) => { + throw err + }) + } const cooCountries = this.options_.coo_countries if (