From f492c031b51a492294d47dcd2fbdc6c8462cdf06 Mon Sep 17 00:00:00 2001 From: Jannik Zinkl Date: Wed, 21 Jun 2023 15:50:06 +0200 Subject: [PATCH] fix: improve error handling for empty salesorder shipment date --- pkg/integration-zoho-entities/src/salesorders/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/integration-zoho-entities/src/salesorders/index.ts b/pkg/integration-zoho-entities/src/salesorders/index.ts index 404c2c459..b1150830a 100644 --- a/pkg/integration-zoho-entities/src/salesorders/index.ts +++ b/pkg/integration-zoho-entities/src/salesorders/index.ts @@ -279,6 +279,10 @@ export class ZohoSalesOrdersSyncService { }, }; + const expectedShippingDate = salesorder.shipment_date + ? new Date(salesorder.shipment_date) + : undefined; + // Create or connect the internal order using the salesorder number as identifier const orderCreateOrConnect: Prisma.OrderUpdateOneRequiredWithoutZohoSalesOrdersNestedInput = { @@ -293,7 +297,7 @@ export class ZohoSalesOrdersSyncService { id: id.id("order"), orderNumber: salesorder.salesorder_number, date: new Date(salesorder.date), - expectedShippingDate: new Date(salesorder.shipment_date), + expectedShippingDate, carrier, totalPriceGross: salesorder.total, invoiceStatus, @@ -360,7 +364,7 @@ export class ZohoSalesOrdersSyncService { order: { update: { date: new Date(salesorder.date), - expectedShippingDate: new Date(salesorder.shipment_date), + expectedShippingDate, customerNote, carrier, shipmentStatus: this.parseShipmentStatus(