public void WillGetItemIsPersonalValue() { string netsuiteSalesOrderId = "72290158"; List <string> itemFulfillmentIdsImported = new List <string>(); var itemFulfillmentGroupsToImport = NetSuiteController.GetItemFulfillmentsNotImported(netsuiteSalesOrderId, itemFulfillmentIdsImported); foreach (var itemGroup in itemFulfillmentGroupsToImport) { foreach (var line in itemGroup) { Assert.NotNull(line.IsPersonal); } } }
public void WillGetItemFulfillmentsNotImportedToNetSuite() { List <string> itemFulfillmentIdsImported = new List <string>(); var itemFulfillmentGroupsToImport = NetSuiteController.GetItemFulfillmentsNotImported(netsuiteSalesOrderId, itemFulfillmentIdsImported); foreach (var itemFulfillmentGroup in itemFulfillmentGroupsToImport) { foreach (var itemFulfillment in itemFulfillmentGroup) { //Assert.Equal(itemFulfillmentIdOne, itemFulfillment.ItemFulfillmentId); if (itemFulfillment.ItemFulfillmentId == itemFulfillmentIdOne) { Assert.Equal("R&L Carriers", itemFulfillment.Carrier); Assert.Equal(trackingNumberOne, itemFulfillment.TrackingNumber); if (itemFulfillment.SKU == "559LF-BLMPU") { Assert.Equal(1, itemFulfillment.Quantity); } else if (itemFulfillment.SKU == "SS114#01" || itemFulfillment.SKU == "C244EF#01" || itemFulfillment.SKU == "ST243E#01") { Assert.Equal(3, itemFulfillment.Quantity); } } else if (itemFulfillment.ItemFulfillmentId == itemFulfillmentIdTwo) { Assert.Equal("UPS COLLECT", itemFulfillment.Carrier); Assert.Equal(trackingNumberTwo, itemFulfillment.TrackingNumber); if (itemFulfillment.SKU == "T14459-BL") { Assert.Equal(1, itemFulfillment.Quantity); } } } } }
public static void ImportShipmentsToBigCommerce(JArray allOrdersAwaitingShipments) { try { foreach (var order in allOrdersAwaitingShipments) { Order parsedOrder = JsonConvert.DeserializeObject <Order>(order.ToString()); BigCommerceController.bigCommerceOrderId = parsedOrder.id; Log.Information($"Big Commerce Order Id: {BigCommerceController.bigCommerceOrderId}"); // Query NetSuite to get any matching item fulfillments string netsuiteSalesOrderId = parsedOrder.staff_notes; /* Get a list of NetSuite item fulfillment ids (partially shipped orders only) that already exist * in Big Commerce to exclude so we do not create duplicate shipments. */ List <string> importedItemFulfillmentIds = new List <string>(); if (parsedOrder.status.ToLower() == "partially shipped") { importedItemFulfillmentIds = BigCommerceController.GetImportedItemFulfillments(); } var itemFulfillmentGroupsToImport = NetSuiteController.GetItemFulfillmentsNotImported(netsuiteSalesOrderId, importedItemFulfillmentIds); // Skip line if no item fulfillments are found if (itemFulfillmentGroupsToImport.Count() == 0) { Log.Information($"No item fulfillments to import."); continue; } // Send each item fulfillment group to Big Commerce as a Shipment foreach (var itemFulfillmentGroupToImport in itemFulfillmentGroupsToImport) { Log.Information($"Itfil ID: {itemFulfillmentGroupToImport.Key}"); BigCommerceController.currentItemFulfillment = itemFulfillmentGroupToImport; Shipment shipmentToCreate = BigCommerceController.CreateShipmentRequest(itemFulfillmentGroupToImport); // Big Commerce will throw exception if shipment does not have a tracking number if (shipmentToCreate.TrackingNumber == "") { Log.Warning($"No tracking numbers found. Shipment not created."); continue; } // Create the Shipment in Big Commerce try { Shipment shipmentCreated = BigCommerceController.PostShipmentToBigCommerce(shipmentToCreate); Log.Information($"shipment id {shipmentCreated.ShipmentId} created."); } catch (Exception ex) { string errorMessage = $"Error Posting Shipment To Big Commerce. Error: {ex}"; Log.Error(errorMessage); string title = "Error in NestProShipments PostShipmentToBigCommerce"; string text = errorMessage; string color = "yellow"; TeamsHelper teamsMessage = new TeamsHelper(title, text, color, Program.teamsUrl); teamsMessage.LogToMicrosoftTeams(teamsMessage); } } } } catch (Exception ex) { string errorMessage = $"Error in ImportShipmentsToBigCommerce. Error: {ex}"; Log.Error(errorMessage); string title = "Error in NestProShipments ImportShipmentsToBigCommerce"; string text = errorMessage; string color = "red"; TeamsHelper teamsMessage = new TeamsHelper(title, text, color, Program.teamsUrl); teamsMessage.LogToMicrosoftTeams(teamsMessage); } }