public static T GetSOPackageDetail <T>(KCAPIFulfillment fulfillment, T acumaticaPackage, SOShipment shipment, string boxID) { KCSiteMasterMaint graph = PXGraph.CreateInstance <KCSiteMasterMaint>(); decimal? boxWeight = KCGeneralDataHelper.GetBoxWeight(graph, boxID); foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(acumaticaPackage)) { switch (property.DisplayName) { case "Confirmed": property.SetValue(acumaticaPackage, true); break; case "Weight": property.SetValue(acumaticaPackage, boxWeight + shipment.ShipmentWeight); break; case "TrackNumber": property.SetValue(acumaticaPackage, fulfillment.TrackingNumber); break; case "ShipmentNbr": property.SetValue(acumaticaPackage, shipment.ShipmentNbr); break; } } return(acumaticaPackage); }
public bool CheckBranches(KCSiteMasterMaint sitemaster, List <KCAPIOrderItem> orderItems, KCAPIOrder order) { BAccount customer = KCGeneralDataHelper.GetCustomerByCAOrder(sitemaster, order); if (customer == null) { logger.SetNonChildEntityId(order.ID.ToString()); logger.Information(KCMessages.CustomerNotFound(order.ID, order.BuyerEmailAddress)); return(false); } bool workflowPublished = new KCNamespaceReview().Test(KCConstants.NamespaceTesterPackage); if (workflowPublished) { bool validItem; foreach (KCAPIOrderItem item in orderItems) { DAC.KNSIKCInventoryItem stockItem = sitemaster.ExistingProducts.SelectSingle(item.ProductID); InventoryItem product = sitemaster.ProductByInvId.SelectSingle(stockItem.InventoryID); KCInventoryItemExt productKCExt = product.GetExtension <KCInventoryItemExt>(); validItem = false; if (product.GetExtension <InventoryItemPCExt>().UsrKNCompositeType == null) { if (productKCExt.UsrKNCPBranch != null && customer.GetExtension <KCCustomerExt>()?.UsrKNCPBranchID != null) { List <string> productBranches = productKCExt.UsrKNCPBranch.Split(',').ToList(); foreach (string branch in productBranches) { if (customer.GetExtension <KCCustomerExt>()?.UsrKNCPBranchID?.Split(',').Select(x => x.Trim()).ToList().Contains(branch) == true) { validItem = true; } } } else { validItem = true; } } else { validItem = true; } if (!validItem) { logger.SetNonChildEntityId(order.ID.ToString()); logger.Information(KCMessages.WebsitesAreNotAssociated(order.ID, product.InventoryCD, customer.AcctName)); return(false); } } } return(true); }
public KCImportOrderRequest(KCStore store, KCSiteMasterMaint siteMasterMaint) { Store = store; SiteMasterMaint = siteMasterMaint; KCSiteMaster connection = SiteMasterMaint.SiteMaster.Select().RowCast <KCSiteMaster>().Where(x => x.SiteMasterCD.Equals(Store.SiteMasterCD)).First(); KCARestClient client = new KCARestClient(connection); Helper = new KCOrderAPIHelper(client); CustomerClassID = connection.CustomerClassID; BranchID = connection.BranchID; }
public static SOOrder GetSOOrder(SOOrderEntry orderGraph, KCAPIOrder order, SOOrder acumaticaOrder, int?branchID, bool FBA) { KCSiteMasterMaint graph = PXGraph.CreateInstance <KCSiteMasterMaint>(); var customer = KCGeneralDataHelper.GetCustomerByCAOrder(graph, order); var paymentmethod = KCGeneralDataHelper.GetPaymenthMethodId(graph, order); var mapper = new KCDynamicOrderMapper(KCMappingEntitiesConstants.Order); var conversionGraph = PXGraph.CreateInstance <KCOrderConversionDataMaint>(); mapper.Mapping.MappingValues = conversionGraph.GetEntity(); mapper.MapOrder(acumaticaOrder, order); if (paymentmethod == null) { KCPaymentMethodsMappingMaint paymentMethodMappingGraph = PXGraph.CreateInstance <KCPaymentMethodsMappingMaint>(); CustomerPaymentMethodMaint paymentMethodGraph = PXGraph.CreateInstance <CustomerPaymentMethodMaint>(); try { KCGeneralDataHelper.CreatePaymentMethod(paymentMethodGraph, paymentMethodMappingGraph, customer.BAccountID, order); paymentmethod = KCGeneralDataHelper.GetPaymenthMethodId(graph, order); } catch { } } acumaticaOrder.CustomerID = customer.BAccountID; acumaticaOrder.PMInstanceID = paymentmethod?.PMInstanceID; acumaticaOrder.Status = SOOrderStatus.Open; acumaticaOrder.CreatePMInstance = true; KCSOOrderEntryExt orderext = orderGraph.GetExtension <KCSOOrderEntryExt>(); string orderType = new KCMarketplaceHelper().GetOrderType(order, orderGraph); acumaticaOrder.OrderType = orderType ?? acumaticaOrder.OrderType; if (order.EstimatedShipDateUtc == null) { acumaticaOrder.RequestDate = acumaticaOrder.OrderDate; } orderGraph.CurrentDocument.Current = acumaticaOrder; PXNoteAttribute.SetNote(orderGraph.CurrentDocument.Cache, orderGraph.CurrentDocument.Current, order.PrivateNotes); string firstName = orderext.AccountCD.SelectSingle(acumaticaOrder.CustomerID).AcctName; bool isFBAFirstName = firstName.Contains("FBA"); KCSOOrderExt orderExt = acumaticaOrder.GetExtension <KCSOOrderExt>(); orderExt = mapper.MapOrderCaExt(orderExt, order); orderExt.UsrKCSyncDate = DateTime.Now; orderExt.UsrKCSiteName += FBA ? "/FBA" : "/Non-FBA"; if ((FBA && orderExt.UsrKCSiteName.Contains("Amazon")) || isFBAFirstName) { acumaticaOrder.Status = KCCheckoutStatus.CCompleted; } return(acumaticaOrder); }
public static SOShipment GetSOShipment(SOOrder acumaticaOrder, KCAPIFulfillment fulfillment, SOShipment acumaticaShipment) { SOOrderEntry orderGraph = PXGraph.CreateInstance <SOOrderEntry>(); KCSiteMasterMaint masterGraph = PXGraph.CreateInstance <KCSiteMasterMaint>(); acumaticaShipment.Operation = INDocType.Issue; acumaticaShipment.CustomerID = acumaticaOrder.CustomerID; acumaticaShipment.CustomerLocationID = acumaticaOrder.CustomerLocationID; acumaticaShipment.SiteID = masterGraph.SiteMaster.SelectSingle().SiteID; acumaticaShipment.ShipDate = fulfillment.UpdatedDateUtc.DateTime; acumaticaShipment.GetExtension <KCSOShipmentExt>().UsrKCCAFulfillmentID = fulfillment.ID; return(acumaticaShipment); }
protected virtual IEnumerable GetRecords() { KCSiteMasterMaint graph = (KCSiteMasterMaint)_Graph; var taxMappingIds = graph.TaxManag.Select().RowCast <KCTaxManagement>().Where(x => x.StateId != null) .Select(x => x.StateId).ToList(); int count = taxMappingIds.Count; for (int i = 0; i < count; i++) { if (Regex.Matches(taxMappingIds[0], "[;]", RegexOptions.Singleline).Count != 0) { taxMappingIds[0].Replace(" ", "").Split(';'); foreach (var splited in taxMappingIds[0].Replace(" ", "").Split(';')) { taxMappingIds.Add(splited.ToUpper()); } taxMappingIds.Remove(taxMappingIds[0]); } } var taxMappingIdsArr = taxMappingIds.ToArray(); var country = graph.TaxManag.Current.CountryId; // Select().RowCast<KCTaxManagement>() //.Select(x => x.CountryId).ToArray(); var allStates = new List <State>(); if (taxMappingIds.Count() != 0) { allStates = graph.AllStates.Select().RowCast <State>().Where(x => x.CountryID == country).ToList();// graph.RequiredState.Select().RowCast<State>().ToList(); foreach (var item in taxMappingIdsArr) { allStates.Remove(allStates.Find(x => x.StateID == item)); } } else { allStates = graph.AllStates.Select().RowCast <State>().Where(x => x.CountryID == country).ToList(); } foreach (State market in allStates) { yield return(market); } }
public bool CheckOrderItems(List <KCAPIOrderItem> orderItems, KCSiteMasterMaint exchangeMaint) { bool result = false; if (orderItems != null) { foreach (KCAPIOrderItem orderItem in orderItems) { DAC.KNSIKCInventoryItem stockItem = exchangeMaint.ExistingProducts.SelectSingle(orderItem.ProductID); if (stockItem == null) { logger.SetNonChildEntityId(orderItem.OrderID.ToString()); logger.Information(KCMessages.ProductDoesntExist(orderItem.OrderID, orderItem.ProductID)); return(false); } result = true; } } return(result); }
public bool CheckSalesAccountID(KCSiteMasterMaint sitemaster, InventoryItem product, int orderID, int CAProductId) { if (product != null && !product.StkItem.GetValueOrDefault() && (product.SalesAcctID == null || product.SalesSubID == null)) { DAC.KNSIKCInventoryItem KCChild = sitemaster.KCInventoryItem.SelectSingle(product.InventoryID); if (KCChild != null) { logger.SetNonChildEntityId(orderID.ToString()); logger.Information(KCMessages.SalesAcctIDCannotBeEmpty(orderID, KCChild.UsrKCCAID.GetValueOrDefault())); } else { logger.SetNonChildEntityId(orderID.ToString()); logger.Information(KCMessages.SalesAcctIDCannotBeEmpty(orderID, CAProductId)); } return(false); } return(true); }
public bool CheckProductStatus(KCSiteMasterMaint sitemaster, InventoryItem product, int orderID, int CAProductId) { if (product != null && product.ItemStatus != KCConstants.Active) { DAC.KNSIKCInventoryItem KCChild = sitemaster.KCInventoryItem.SelectSingle(product.InventoryID); if (KCChild != null) { logger.SetNonChildEntityId(orderID.ToString()); logger.Information(KCMessages.ProductDoesntActive(orderID, KCChild.UsrKCCAID.GetValueOrDefault())); } else { logger.SetNonChildEntityId(orderID.ToString()); logger.Information(KCMessages.ProductDoesntActive(orderID, CAProductId)); } return(false); } return(true); }
protected virtual IEnumerable GetRecords() { KCSiteMasterMaint graph = (KCSiteMasterMaint)_Graph; var marketplaceMappingIds = graph.KCMarketplaceManagement.Select().RowCast <KCMarketplaceManagement>() .Select(x => x.MarketplaceId).ToArray(); var allMarketplaces = new List <KCMarketplace>(); if (marketplaceMappingIds.Length != 0) { allMarketplaces = graph.RequiredMarketplaces.Select(marketplaceMappingIds).RowCast <KCMarketplace>().ToList(); } else { allMarketplaces = graph.KCMarketplace.Select().RowCast <KCMarketplace>().ToList(); } foreach (KCMarketplace market in allMarketplaces) { yield return(market); } }
public bool ValidateItems <T>(List <T> items, Validation method, KCSiteMasterMaint sitemaster) { bool result = false; List <KCAPIOrderItem> orderItems; List <KCAPIFulfillmentItem> filfillmentItems; if (items as List <KCAPIOrderItem> != null) { orderItems = items as List <KCAPIOrderItem>; } if (items as List <KCAPIFulfillmentItem> != null) { filfillmentItems = items as List <KCAPIFulfillmentItem>; } if (items != null) { foreach (T item in items) { KCAPIOrderItem orderItem = null; KCAPIFulfillmentItem fulfillmetItem = null; if (item as KCAPIOrderItem != null) { orderItem = item as KCAPIOrderItem; } if (item as KCAPIFulfillmentItem != null) { fulfillmetItem = item as KCAPIFulfillmentItem; } int productID = 0; int orderID = 0; if (orderItem == null) { productID = fulfillmetItem.ProductID; orderID = fulfillmetItem.OrderID; } else { productID = orderItem.ProductID; orderID = orderItem.OrderID; } DAC.KNSIKCInventoryItem stockItem = sitemaster.ExistingProducts.SelectSingle(productID); InventoryItem inventoryItem = sitemaster.ProductByInvId.SelectSingle(stockItem.InventoryID); if (inventoryItem != null) { if (!method(sitemaster, inventoryItem, orderID, productID)) { return(false); } else if (inventoryItem.GetExtension <InventoryItemPCExt>().UsrKNCompositeType == KCConstants.ConfigurableProduct) { PXResultset <InventoryItem> childItems = sitemaster.ConfigChildItems.Select(inventoryItem.InventoryID); foreach (InventoryItem child in childItems) { if (!method(sitemaster, child, orderID, productID)) { return(false); } } } else if (inventoryItem.GetExtension <InventoryItemPCExt>().UsrKNCompositeType == KCConstants.GroupedProduct) { PXResultset <KNSIGroupedItems> childItems = sitemaster.GroupedChildItems.Select(inventoryItem.InventoryID); foreach (KNSIGroupedItems child in childItems) { InventoryItem product = sitemaster.ProductByInvId.SelectSingle(child.MappedInventoryID); if (!method(sitemaster, product, orderID, productID)) { return(false); } } } else if (inventoryItem.KitItem.GetValueOrDefault()) { string revisionId = sitemaster.KitProduct.SelectSingle(inventoryItem.InventoryID)?.RevisionID; IEnumerable <INKitSpecNonStkDet> nonStockKitComponents = sitemaster.NonStockKitComponents.Select(inventoryItem.InventoryID, revisionId)?.RowCast <INKitSpecNonStkDet>(); foreach (INKitSpecNonStkDet child in nonStockKitComponents) { InventoryItem product = sitemaster.ProductByInvId.SelectSingle(child.CompInventoryID); if (!method(sitemaster, product, orderID, productID)) { return(false); } } } } result = true; } } return(result); }
public bool CheckAddress(KCSiteMasterMaint graph, KCAPIOrder order) { Country billingCountry = graph.Countries.Select().RowCast <Country>().Where(x => x.CountryID.Equals(order.BillingCountry)).FirstOrDefault(); Country shippingCountry = graph.Countries.Select().RowCast <Country>().Where(x => x.CountryID.Equals(order.ShippingCountry)).FirstOrDefault(); if (billingCountry == null) { logger.SetNonChildEntityId(order.ID.ToString()); logger.Information(KCMessages.InvalidCountryInBillingAddress(order.ID, order.BillingCountry)); return(false); } if (shippingCountry == null) { logger.SetNonChildEntityId(order.ID.ToString()); logger.Information(KCMessages.InvalidCountryInShippingAddress(order.ID, order.ShippingCountry)); return(false); } State billingState = graph.State.SelectSingle(billingCountry.CountryID, order.BillingStateOrProvince); State shippingState = graph.State.SelectSingle(shippingCountry.CountryID, order.ShippingStateOrProvince); if (billingState == null) { logger.SetNonChildEntityId(order.ID.ToString()); logger.Information(KCMessages.InvalidStateInBillingAddress(order.ID, order.BillingStateOrProvinceName)); return(false); } if (shippingState == null) { logger.SetNonChildEntityId(order.ID.ToString()); logger.Information(KCMessages.InvalidStateInShippingAddress(order.ID, order.ShippingStateOrProvinceName)); return(false); } bool billingZip = false; if (order.BillingPostalCode != null) { billingZip = billingCountry.ZipCodeRegexp == null || Regex.IsMatch(order.BillingPostalCode, billingCountry.ZipCodeRegexp); } bool shippingZip = false; if (order.ShippingPostalCode != null) { shippingZip = shippingCountry.ZipCodeRegexp == null || Regex.IsMatch(order.ShippingPostalCode, shippingCountry.ZipCodeRegexp); } if (!shippingZip) { logger.SetNonChildEntityId(order.ID.ToString()); logger.Information(KCMessages.InvalidZipInShippingAddress(order.ID, order.ShippingPostalCode)); return(false); } if (!billingZip) { logger.SetNonChildEntityId(order.ID.ToString()); logger.Information(KCMessages.InvalidZipInBillingAddress(order.ID, order.BillingPostalCode)); return(false); } return(true); }
public bool CheckItemsStatuses <T>(List <T> items, KCSiteMasterMaint sitemaster) { Validation validationMethod = CheckProductStatus; return(ValidateItems(items, validationMethod, sitemaster)); }
public bool CheckItemsStatuses <T>(List <T> items) { KCSiteMasterMaint sitemaster = PXGraph.CreateInstance <KCSiteMasterMaint>(); return(CheckItemsStatuses(items, sitemaster)); }
//24.09.2019 KA: Validation added to avoid issue with "SalesAcctID can not be empty" error message when we create orders with non-stock items public bool CheckSalesAccount(List <KCAPIOrderItem> orderItems, KCSiteMasterMaint sitemaster) { Validation validationMethod = CheckSalesAccountID; return(ValidateItems(orderItems, validationMethod, sitemaster)); }