protected void HandleCrossReferences(InventoryItem product, ref List <KCAPIAttribute> attributes) { IEnumerable <INItemXRef> crossReferences = Graph.CrossReferences.Select(product.InventoryID).RowCast <INItemXRef>(); List <string> fieldReferencesAttributesToExport = new List <string>(); foreach (INItemXRef crossRef in crossReferences) { KCINItemXRefExt crossRefKCExt = crossRef.GetExtension <KCINItemXRefExt>(); foreach (KCCrossReferenceMapping mapping in Graph.CrossReferenceMapping.Select()) { KCAttribute cAAttribute = Graph.KCAttributes.Select().RowCast <KCAttribute>().FirstOrDefault(x => x.AttributeID == mapping.CAAttributeID); if (!fieldReferencesAttributesToExport.Contains(cAAttribute.AttributeName)) { if (cAAttribute.AttributeType.Equals(KCAttributeType.Custom)) { if (KCGeneralDataHelper.CrossReferenceMatchTheRule(mapping, crossRef)) { attributes.Add(new KCAPIAttribute { Name = cAAttribute.AttributeName, Value = crossRef.AlternateID }); fieldReferencesAttributesToExport.Add(cAAttribute.AttributeName); } } } } } }
public static void GetSOLine(KCAPIOrderItem orderItem, InventoryItem item, SOLine soLine, int?branchID, int?defaultWarehouse) { soLine.BranchID = branchID; soLine.Qty = orderItem.Quantity; soLine.OpenQty = orderItem.Quantity; soLine.CuryUnitPrice = orderItem.UnitPrice; soLine.UOM = item.SalesUnit; soLine.SalesAcctID = item.SalesAcctID; soLine.SalesSubID = item.SalesSubID ?? KCGeneralDataHelper.GetDefaultSalesSubID(); soLine.InventoryID = item.InventoryID; soLine.SiteID = defaultWarehouse; soLine.TaxCategoryID = "TAXABLE"; soLine.CuryLineAmt = soLine.CuryUnitPrice * soLine.Qty; soLine.ShipComplete = "B"; KCSOLineExt soLineExt = soLine.GetExtension <KCSOLineExt>(); soLineExt.UsrKCOrderItemID = orderItem.ID; soLineExt.UsrKCCAOrderID = orderItem.OrderID; SOLinePCExt soLinePCExt = soLine.GetExtension <SOLinePCExt>(); InventoryItemPCExt itemPCExt = item.GetExtension <InventoryItemPCExt>(); if (itemPCExt.UsrKNCompositeType != null) { soLinePCExt.UsrKNIsMasterLine = true; } }
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 KCAPIInventoryItem GetAPIInventoryItem(InventoryItem product) { DAC.KNSIKCInventoryItem kcProduct = BulkGraph.KCInventoryItem.SelectSingle(product.InventoryID); InventoryItemPCExt productPcExt = product.GetExtension <InventoryItemPCExt>(); string classificationName = KCGeneralDataHelper.GetClassificationByInventoryId(ClassificationsGraph, product); KCAPIInventoryItem apiProduct = new KCAPIInventoryItem() { Classification = classificationName }; if (IsConfigurableParentOrChild(product, productPcExt)) { PropagateConfigurable(product, apiProduct, productPcExt.UsrKNCompositeType == null); } if (productPcExt.UsrKNCompositeType == KCConstants.GroupedProduct) { PropagateBundle(product, apiProduct); } if (product.KitItem.GetValueOrDefault()) { PropagateKit(product, apiProduct); } KCDynamicProductMapper mapper = new KCDynamicProductMapper(KCMappingEntitiesConstants.Product); mapper.Mapping.MappingValues = ConversionGraph.GetEntity(product.InventoryCD); apiProduct = mapper.MapApiInventoryItem(apiProduct, product, kcProduct); apiProduct = KCGeneralDataHelper.FillReservedAttributes(product, apiProduct); return(apiProduct); }
public static APIQuantityValue GetAPIQuantity(int?inventoryID, List <INLocationStatus> statuses = null, decimal?vendorQty = null) { KCBulkProductMaint graph = PXGraph.CreateInstance <KCBulkProductMaint>(); KCInventoryManagementMaint inventoryManagementGraph = PXGraph.CreateInstance <KCInventoryManagementMaint>(); if (statuses == null) { var settingsGraph = PXGraph.CreateInstance <KCInventoryManagementMaint>(); statuses = KCGeneralDataHelper.GetINLocationStatuses(graph, inventoryID).Where(x => settingsGraph.IsSiteMapped(x.SiteID)).ToList(); } if (vendorQty == null) { vendorQty = KCGeneralDataHelper.GetVendorQty(inventoryID); } List <KCAPIQuantity> qtys = KCGeneralDataHelper.GetProductQtys(inventoryManagementGraph, inventoryID, statuses, vendorQty); return(new APIQuantityValue { Value = new APIUpdates() { UpdateType = "InStock", Updates = qtys } }); }
private void UpdatePrice(KCDataExchangeMaint masterGraph, KCMSMQInventoryPrice priceProduct, KCInventoryItemAPIHelper helper) { InventoryItem inventoryItem = masterGraph.ProductByInvCd.Select(priceProduct.InventoryID.Trim()); if (inventoryItem != null) { KNSIKCInventoryItem kcProduct = masterGraph.KCInventoryItem.SelectSingle(inventoryItem.InventoryID); InventoryItemPCExt inventoryItemPCExt = inventoryItem.GetExtension <InventoryItemPCExt>(); InventoryItem parent = KCGeneralDataHelper.GetInventoryItemByInventoryId(PXGraph.CreateInstance <KCDataExchangeMaint>(), inventoryItemPCExt.UsrKNCompositeID); logger.SetParentAndEntityIds(parent?.InventoryCD, inventoryItem.InventoryCD); try { if (kcProduct.UsrKCCAID != null) { helper.EditProduct(KCMapInventoryItem.GetAPIMSMQInventoryPrice(priceProduct), kcProduct.UsrKCCAID); } logger.Information(KCMessages.MSMQSyncAPI); } catch (Exception e) { logger.Information(e.Message); } } }
public void PropagateConfigurable(InventoryItem product, KCAPIInventoryItem apiProduct, bool isChild) { apiProduct.VariationParentSku = isChild ? BulkGraph.ItemById.SelectSingle(product.GetExtension <InventoryItemPCExt>().UsrKNCompositeID).InventoryCD : KCConstants.Parent; string relationshipName = KCGeneralDataHelper.GetRelationshipName(RelationshipGraph, product.ItemClassID); apiProduct.RelationshipName = relationshipName; }
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 static KCAPIBundleComponent GetAPIGroupedBundleComponent(KCInventoryItemAPIHelper helper, int?productId, KNSIGroupedItems component) { KCDataExchangeMaint graph = PXGraph.CreateInstance <KCDataExchangeMaint>(); return(new KCAPIBundleComponent() { ProductID = productId.GetValueOrDefault(), ComponentID = KCGeneralDataHelper.GetCAIDByInventoryId(graph, helper, component.MappedInventoryID).GetValueOrDefault(), Quantity = Convert.ToInt32(component.Quantity) }); }
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 virtual void updateAttributes() { KCClassificationsMappingMaint classificationsGraph = PXGraph.CreateInstance <KCClassificationsMappingMaint>(); PXResultset <KCAttribute> existingAttributes = Attributes.Select(); List <string> existingNames = new List <string>(); existingAttributes.RowCast <KCAttribute>().ForEach(x => existingNames.Add(x.AttributeName.Trim().ToUpper())); KCSiteMaster connection = Connection.SelectSingle(); KCARestClient client = new KCARestClient(connection); KCInventoryItemAPIHelper helper = new KCInventoryItemAPIHelper(client); List <string> classificationAttributes = classificationsGraph.GetClassificationAttributes(helper); SaveAttributes(existingNames, classificationAttributes); List <string> skuAttributes = new List <string>(); List <KNSIKCClassificationsMapping> SKUs = GetSKUs(); List <int?> CAIDs = new List <int?>(); foreach (KNSIKCClassificationsMapping classificationsMapping in SKUs) { CAIDs.Add(KCGeneralDataHelper.GetExistingCAProductByInventoryItemCd(helper, classificationsMapping.ChannelAdvisorSKU)?.ID); } foreach (int?CAID in CAIDs) { KCODataWrapper <KCAPIAttribute> CAAttributes = helper.GetAttributes(CAID); if (CAAttributes != null && CAAttributes.Value != null && CAAttributes.Value.Count > 0) { List <string> attributeNames = new List <string>(); CAAttributes.Value.ForEach(x => attributeNames.Add(x.Name)); SaveAttributes(existingNames, attributeNames); CAAttributes.Value.ForEach(x => skuAttributes.Add(x.Name)); } } DeleteExtraAttributes(existingAttributes, classificationAttributes, skuAttributes); Actions.PressSave(); }