private string GetProductType(InventoryItem product) { InventoryItemPCExt productPCExt = product.GetExtension <InventoryItemPCExt>(); if (productPCExt.UsrKNCompositeType == KCConstants.GroupedProduct) { return(KCProductType.Grouped); } else if (productPCExt.UsrKNCompositeType == KCConstants.ConfigurableProduct) { return(KCProductType.Configurable); } else { bool stock = product.StkItem == true; bool isKit = product.KitItem == true; if (stock && isKit) { return(KCProductType.StockKit); } else if (stock && !isKit) { return(KCProductType.Stock); } else if (!stock && isKit) { return(KCProductType.NonStockKit); } else { return(KCProductType.NonStock); } } }
/// <summary> /// Check whether all Grouped/Configurable products'/Kits' children are valid. /// </summary> /// <param name="inventoryItem">Grouped/Configurable Product/Kit that should be checked</param> /// <returns>Validation result</returns> private bool ValidateChildren(InventoryItem inventoryItem) { List <int> validIds = InputList.Select(validItem => validItem.InventoryID.GetValueOrDefault()).ToList(); List <int> childIds = new List <int>(); bool result = false; InventoryItemPCExt itemPCExt = inventoryItem.GetExtension <InventoryItemPCExt>(); if (itemPCExt != null) { if (itemPCExt.UsrKNCompositeType == KCConstants.GroupedProduct) { IEnumerable <KNSIGroupedItems> childItems = Graph.GroupedItemChilds.Select(inventoryItem.InventoryID).RowCast <KNSIGroupedItems>(); childIds.AddRange(childItems.Select(child => child.MappedInventoryID.GetValueOrDefault())); } else if (itemPCExt.UsrKNCompositeType == KCConstants.ConfigurableProduct) { IEnumerable <InventoryItem> childItems = Graph.ChildrenByCompositeId.Select(inventoryItem.InventoryID).RowCast <InventoryItem>(); childIds.AddRange(childItems.Select(child => child.InventoryID.GetValueOrDefault())); } } if (inventoryItem.KitItem.GetValueOrDefault()) { string revisionId = Graph.KitProduct.SelectSingle(inventoryItem.InventoryID)?.RevisionID; IEnumerable <INKitSpecStkDet> stockKitComponents = Graph.StockKitComponents.Select(inventoryItem.InventoryID, revisionId)?.RowCast <INKitSpecStkDet>(); IEnumerable <INKitSpecNonStkDet> nonStockKitComponents = Graph.NonStockKitComponents.Select(inventoryItem.InventoryID, revisionId)?.RowCast <INKitSpecNonStkDet>(); childIds.AddRange(stockKitComponents.Select(x => x.CompInventoryID.GetValueOrDefault())); childIds.AddRange(nonStockKitComponents.Select(x => x.CompInventoryID.GetValueOrDefault())); } result = childIds.Count == 0 || childIds.All(child => validIds.Contains(child)); return(result); }
public ODataShipment GetAPIShipment(SOShipment shipment, SOPackageDetail package, PXResultset <SOLine> lines) { var wrapper = new ODataShipment(); var apiShipment = new KCAPIShipment() { ShippedDateUtc = shipment.ShipDate, TrackingNumber = package?.TrackNumber, ShippingCarrier = shipment.ShipVia, ShippingClass = shipment.ShipVia, DeliveryStatus = "Complete" }; var apiItems = new List <KCAPIShipmentItem>(); foreach (PXResult <SOLine> line in lines) { SOLine soLine = line.GetItem <SOLine>(); SOShipLine shipLine = line.GetItem <SOShipLine>(); DAC.KNSIKCInventoryItem kcInventoryItem = line.GetItem <DAC.KNSIKCInventoryItem>(); InventoryItem inventoryItem = line.GetItem <InventoryItem>(); InventoryItemPCExt inventoryItemPcExt = inventoryItem.GetExtension <InventoryItemPCExt>(); SOLinePCExt soLinePcExt = soLine.GetExtension <SOLinePCExt>(); int quantity = Convert.ToInt32(shipLine.ShippedQty.GetValueOrDefault()); if ((soLine.LineNbr != soLinePcExt?.UsrKNMasterLineNbr && ParentIsGrouped(lines, soLinePcExt)) || (inventoryItemPcExt?.UsrKNCompositeType == KCConstants.ConfigurableProduct && soLine.LineNbr == soLinePcExt?.UsrKNMasterLineNbr)) { continue; } if (inventoryItemPcExt?.UsrKNCompositeType == KCConstants.GroupedProduct && quantity == 0) { SOShipLine childItem = lines.Where(x => x.GetItem <SOLine>().GetExtension <SOLinePCExt>().UsrKNMasterLineNbr == soLine.LineNbr && x.GetItem <SOLine>().LineNbr != soLine.LineNbr).RowCast <SOShipLine>().FirstOrDefault(); if (childItem != null) { KCDataExchangeMaint graph = PXGraph.CreateInstance <KCDataExchangeMaint>(); List <KNSIGroupedItems> origChildItems = graph.GroupedChildItems.Select(inventoryItem.InventoryID).RowCast <KNSIGroupedItems>().ToList(); quantity = Convert.ToInt32(childItem.ShippedQty / origChildItems.Where(x => x.MappedInventoryID == childItem.InventoryID).FirstOrDefault().Quantity); } else { throw new KCCorruptedShipmentException(); } } apiItems.Add(new KCAPIShipmentItem { ProductID = kcInventoryItem?.UsrKCCAID.ToString(), OrderItemID = soLine?.GetExtension <KCSOLineExt>()?.UsrKCOrderItemID.ToString(), Quantity = shipLine == null ? 0 : Convert.ToInt32(quantity) }); } apiShipment.Items = apiItems; wrapper.Value = apiShipment; return(wrapper); }
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 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); }
private bool IsConfigurableParentOrChild(InventoryItem product, InventoryItemPCExt productPcExt) { return((productPcExt.UsrKNCompositeType == null && productPcExt.UsrKNCompositeID != null && BulkGraph.ItemById.SelectSingle(productPcExt.UsrKNCompositeID).GetExtension <InventoryItemPCExt>().UsrKNCompositeType == KCConstants.ConfigurableProduct) || productPcExt.UsrKNCompositeType == KCConstants.ConfigurableProduct); }
protected virtual void ARTaxTran_RowInserting(PXCache sender, PXRowInsertingEventArgs e, PXRowInserting baseHandler) { if (!(e.Row is ARTaxTran row)) { return; } baseHandler?.Invoke(sender, e); row.CuryTaxableAmt = 0; foreach (ARTran tran in Base.Transactions.Select()) { SOLine line = PXSelect < SOLine, Where <SOLine.orderNbr, Equal <Required <SOLine.orderNbr> > > > .Select(Base, tran.SOOrderNbr); SOLinePCExt linePCExt = line.GetExtension <SOLinePCExt>(); InventoryItem product = KCInventoryItem.SelectSingle(tran.InventoryID); if (product != null) { InventoryItemPCExt productPCExt = product.GetExtension <InventoryItemPCExt>(); if (productPCExt != null) { if (productPCExt.UsrKNCompositeType == null) { row.CuryTaxableAmt += tran.CuryTranAmt; } } } } baseHandler.Invoke(sender, e); }
private void UpdateInvoiceTotal(ARInvoice invoice) { if (invoice == null) { return; } invoice.CuryLineTotal = 0; foreach (ARTran tran in Base.Transactions.Select()) { InventoryItem product = KCInventoryItem.SelectSingle(tran.InventoryID); if (product != null) { InventoryItemPCExt productPCExt = product.GetExtension <InventoryItemPCExt>(); if (productPCExt != null) { if (productPCExt.UsrKNCompositeType == null) { invoice.CuryLineTotal += tran.CuryTranAmt; } } } } // invoice.CuryLineTotal = order?.OrderTotal ?? 0 - order?.TaxTotal ?? 0; invoice.CuryLineTotal += invoice.PremiumFreightAmt; invoice.CuryDocBal = invoice.CuryLineTotal + invoice.TaxTotal; invoice.CuryOrigDocAmt = invoice.CuryDocBal; invoice.CuryGoodsTotal = invoice.CuryLineTotal; invoice.GoodsTotal = invoice.CuryLineTotal; }
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; } }
/// <summary> /// Check whether InventoryItem is not a Bundle Product /// </summary> /// <param name="inventoryItem">InventoryItem that should be checked</param> /// <returns>Validation result</returns> private bool IsActive(InventoryItem inventoryItem) { InventoryItemPCExt itemPcExt = inventoryItem.GetExtension <InventoryItemPCExt>(); bool isNotBundleProduct = itemPcExt == null || itemPcExt.UsrKNCompositeType == null || itemPcExt.UsrKNCompositeType != KCConstants.BundleProduct; return(isNotBundleProduct); }
/// <summary> /// Check whether parent of composite child item is valid. /// </summary> /// <param name="inventoryItem">Grouped/Configurable Product/Kit that should be checked</param> /// <returns>Validation result</returns> private bool Validate(InventoryItem inventoryItem) { List <int> validIds = InputList.Select(validItem => validItem.InventoryID.GetValueOrDefault()).ToList(); //List<int> childIds = new List<int>(); bool result = true; InventoryItemPCExt itemPCExt = inventoryItem.GetExtension <InventoryItemPCExt>(); if (itemPCExt != null && itemPCExt.UsrKNCompositeType == null) { if (itemPCExt.UsrKNCompositeID != null) { result = validIds.Contains(itemPCExt.UsrKNCompositeID.Value); if (!result) { return(result); } } if (inventoryItem.StkItem.GetValueOrDefault()) { PXResultset <INKitSpecStkDet> stockComponents = Graph.StockKitComponentsExisted.Select(inventoryItem.InventoryID); foreach (INKitSpecStkDet comp in stockComponents) { string revisionId = Graph.KitProduct.SelectSingle(comp.KitInventoryID)?.RevisionID; if (comp.RevisionID == revisionId) { result = validIds.Contains(comp.KitInventoryID.Value); } if (result) { return(result); } } } else { PXResultset <INKitSpecNonStkDet> nonStockComponents = Graph.NonStockKitComponentsExisted.Select(inventoryItem.InventoryID); foreach (INKitSpecNonStkDet comp in nonStockComponents) { string revisionId = Graph.KitProduct.SelectSingle(comp.KitInventoryID)?.RevisionID; if (comp.RevisionID == revisionId) { result = validIds.Contains(comp.KitInventoryID.Value); } if (result) { return(result); } } } } return(result); }
private bool IsVariationRelationshipUpdated(InventoryItem product, KNSIKCInventoryItem kcProduct) { InventoryItemPCExt productPcExt = product.GetExtension <InventoryItemPCExt>(); if (productPcExt?.UsrKNCompositeType != KCConstants.ConfigurableProduct) { return(false); } return(RequiredRelation.SelectSingle(product.ItemClassID, kcProduct.UsrKCCASyncDate) != null); }
private bool RemoveInvalidChildren(InventoryItem item) { InventoryItemPCExt itemPCExt = item.GetExtension <InventoryItemPCExt>(); string parentCD = null; bool result = true; if (itemPCExt != null && itemPCExt.UsrKNCompositeID != null) { parentCD = Graph.ItemById.SelectSingle(itemPCExt.UsrKNCompositeID).InventoryCD; } if (parentCD != null) { result = InputList.Any(x => x.InventoryCD == parentCD); if (!result) { return(result); } } if (item.StkItem.GetValueOrDefault()) { PXResultset <INKitSpecStkDet> stockComponents = Graph.StockKitComponentsExisted.Select(item.InventoryID); foreach (INKitSpecStkDet comp in stockComponents) { string revisionId = Graph.KitProduct.SelectSingle(comp.KitInventoryID)?.RevisionID; if (comp.RevisionID == revisionId) { result = InputList.Any(x => x.InventoryID == comp.KitInventoryID.Value); } if (result) { return(result); } } } else { PXResultset <INKitSpecNonStkDet> nonStockComponents = Graph.NonStockKitComponentsExisted.Select(item.InventoryID); foreach (INKitSpecNonStkDet comp in nonStockComponents) { string revisionId = Graph.KitProduct.SelectSingle(comp.KitInventoryID)?.RevisionID; if (comp.RevisionID == revisionId) { result = InputList.Any(x => x.InventoryID == comp.KitInventoryID.Value); } if (result) { return(result); } } } return(result); }
public bool ParentIsGrouped(PXResultset <SOLine> lines, SOLinePCExt soLinePcExt) { if (soLinePcExt == null) { return(false); } PXResult <SOLine> parent = lines.FirstOrDefault(line => line.GetItem <SOLine>() != null && line.GetItem <SOLine>().LineNbr == soLinePcExt.UsrKNMasterLineNbr); InventoryItem parentItem = parent?.GetItem <InventoryItem>(); InventoryItemPCExt parentItemPcExt = parentItem?.GetExtension <InventoryItemPCExt>(); return(parentItemPcExt?.UsrKNCompositeType == KCConstants.GroupedProduct); }
protected virtual void SOLineSplit_RowPersisting(PXCache sender, PXRowPersistingEventArgs e, PXRowPersisting baseHandler) { if (!(e.Row is SOLineSplit row)) { return; } InventoryItem item = KCProductByID.Select(row.InventoryID); InventoryItemPCExt itemPcExt = item.GetExtension <InventoryItemPCExt>(); if (itemPcExt != null && itemPcExt.UsrKNCompositeType != null) { e.Cancel = true; } baseHandler.Invoke(sender, e); }
/// <summary> /// Check whether sum of Quantities of the Grouped Items' and Kits' children is bigger than 1. /// </summary> /// <param name="inventoryItem">InventoryItem that should be checked</param> /// <returns>Validation result</returns> private bool HasMoreThanOneQuantity(InventoryItem inventoryItem) { decimal sum = 2; InventoryItemPCExt itemPcExt = inventoryItem.GetExtension <InventoryItemPCExt>(); if (itemPcExt?.UsrKNCompositeType == KCConstants.GroupedProduct) { IEnumerable <KNSIGroupedItems> children = Graph.GroupedItemChilds.Select(inventoryItem.InventoryID)?.RowCast <KNSIGroupedItems>(); // 06/05/19 AT: InputList contains only those items, that are valid for ChannelAdvisor(excluding this rule). // We need to take into account only those children, which are valid for Export. // The intersection of children and InputList will give us the desired list. children = children.Where(child => InputList.Any(validatedItems => validatedItems.InventoryID == child.MappedInventoryID)); sum = children != null?children.Sum(x => x.Quantity.GetValueOrDefault()) : 0; } else if (inventoryItem.KitItem.GetValueOrDefault()) { string revisionId = Graph.KitProduct.SelectSingle(inventoryItem.InventoryID)?.RevisionID; sum = (decimal)Graph.StockKitComponents.Select(inventoryItem.InventoryID, revisionId)?.RowCast <INKitSpecStkDet>()?.Sum(x => x.DfltCompQty.GetValueOrDefault()); sum += (decimal)Graph.NonStockKitComponents.Select(inventoryItem.InventoryID, revisionId)?.RowCast <INKitSpecNonStkDet>()?.Sum(x => x.DfltCompQty.GetValueOrDefault()); } return(sum > 1); }
protected virtual void GLTran_RowInserting(PXCache sender, PXRowInsertingEventArgs e, PXRowInserting baseHandler) { if (!(e.Row is GLTran row)) { return; } InventoryItem product = KCGetProductById.SelectSingle(row.InventoryID); if (product == null) { return; } InventoryItemPCExt productPCExt = product.GetExtension <InventoryItemPCExt>(); if (productPCExt == null) { return; } if (productPCExt.UsrKNCompositeType != null) { SetToDef(row); } baseHandler.Invoke(sender, e); }
public decimal?GetOrderTotals(SOOrder order) { if (order == null) { return(null); } order.OrderQty = 0; decimal CuryOrderTotal = 0; foreach (SOLine line in Base.Transactions.Select()) { SOLinePCExt linePCExt = line.GetExtension <SOLinePCExt>(); InventoryItem product = KCProductByID.SelectSingle(line.InventoryID); InventoryItemPCExt productPCExt = product.GetExtension <InventoryItemPCExt>(); if (linePCExt.UsrKNMasterLineNbr == null) { CuryOrderTotal += (decimal)line.CuryLineAmt; order.OrderQty += line.OrderQty; } else if (linePCExt.UsrKNMasterLineNbr == line.LineNbr && productPCExt.UsrKNCompositeType == "G") { CuryOrderTotal += (decimal)line.CuryLineAmt; } else if (linePCExt.UsrKNMasterLineNbr != line.LineNbr) { SOLine parentLine = Base.Transactions.Select().RowCast <SOLine>() .Where(x => x.LineNbr == linePCExt.UsrKNMasterLineNbr).FirstOrDefault(); InventoryItem parentProduct = KCProductByID.SelectSingle(parentLine.InventoryID); InventoryItemPCExt parentProductPCExt = parentProduct.GetExtension <InventoryItemPCExt>(); if (parentProductPCExt.UsrKNCompositeType == "C") { CuryOrderTotal += (decimal)line.CuryLineAmt; order.OrderQty += line.OrderQty; } else { order.OrderQty += line.OrderQty; } } if (order.Status != SOOrderStatus.Shipping) { line.OpenQty = line.Qty - line.ShippedQty; } } if (order.CuryTaxTotal <= 0) { order.CuryTaxTotal = 0; foreach (SOTaxTran tax in Base.Taxes.Cache.Cached) { order.CuryTaxTotal += tax.CuryTaxAmt; } } CuryOrderTotal += (decimal)order.CuryPremiumFreightAmt.GetValueOrDefault(); CuryOrderTotal += (decimal)order.CuryTaxTotal.GetValueOrDefault(); return(CuryOrderTotal); }
private void UpdateOrderBalances(SOOrder order) { ARPayment payment = KCOrderPayment.Select(order.CustomerOrderNbr); if (payment != null) { order.PaymentTotal = order.CuryPaymentTotal = payment.CuryOrigDocAmt; } order.UnpaidBalance = order.CuryUnpaidBalance; order.CuryUnbilledOrderTotal = 0; order.CuryUnbilledLineTotal = 0; order.UnbilledOrderQty = 0; foreach (SOLine line in Base.Transactions.Select()) { SOLinePCExt linePCExt = line.GetExtension <SOLinePCExt>(); InventoryItem product = KCProductByID.SelectSingle(line.InventoryID); InventoryItemPCExt productPCExt = product.GetExtension <InventoryItemPCExt>(); if (linePCExt.UsrKNMasterLineNbr == null) { order.CuryUnbilledOrderTotal += line.UnbilledAmt; order.CuryUnbilledLineTotal += line.UnbilledAmt; order.UnbilledOrderQty += line.UnbilledQty; } else if (linePCExt.UsrKNMasterLineNbr == line.LineNbr && productPCExt.UsrKNCompositeType == "G") { order.CuryUnbilledOrderTotal += line.UnbilledAmt; order.CuryUnbilledLineTotal += line.UnbilledAmt; } else if (linePCExt.UsrKNMasterLineNbr != line.LineNbr) { SOLine parentLine = Base.Transactions.Select().RowCast <SOLine>() .Where(x => x.LineNbr == linePCExt.UsrKNMasterLineNbr).FirstOrDefault(); InventoryItem parentProduct = KCProductByID.SelectSingle(parentLine.InventoryID); InventoryItemPCExt parentProductPCExt = parentProduct.GetExtension <InventoryItemPCExt>(); if (parentProductPCExt.UsrKNCompositeType == "C") { order.CuryUnbilledOrderTotal += line.UnbilledAmt; order.CuryUnbilledLineTotal += line.UnbilledAmt; order.UnbilledOrderQty += line.UnbilledQty; } else { order.UnbilledOrderQty += line.UnbilledQty; } } } order.CuryUnbilledOrderTotal += order.CuryUnbilledTaxTotal; order.CuryUnbilledOrderTotal += order.CuryUnbilledMiscTot; order.UnbilledOrderTotal = order.CuryUnbilledOrderTotal; if (order.CuryTaxTotal < 0) { order.CuryTaxTotal = 0; foreach (SOTaxTran tax in Base.Taxes.Cache.Cached) { order.CuryTaxTotal += tax.CuryTaxAmt; } } }
public void UpdateOrderTotals(SOOrder order) { if (order == null) { return; } bool isOpenLines = false; order.OrderQty = 0; order.CuryOrderTotal = 0; foreach (SOLine line in Base.Transactions.Select()) { SOLinePCExt linePCExt = line.GetExtension <SOLinePCExt>(); InventoryItem product = KCProductByID.SelectSingle(line.InventoryID); InventoryItemPCExt productPCExt = product.GetExtension <InventoryItemPCExt>(); if (linePCExt.UsrKNMasterLineNbr == null) { order.CuryOrderTotal += line.CuryLineAmt; order.OrderQty += line.OrderQty; } else if (linePCExt.UsrKNMasterLineNbr == line.LineNbr && productPCExt.UsrKNCompositeType == "G") { order.CuryOrderTotal += line.CuryLineAmt; } else if (linePCExt.UsrKNMasterLineNbr != line.LineNbr) { SOLine parentLine = Base.Transactions.Select().RowCast <SOLine>() .Where(x => x.LineNbr == linePCExt.UsrKNMasterLineNbr).FirstOrDefault(); InventoryItem parentProduct = KCProductByID.SelectSingle(parentLine.InventoryID); InventoryItemPCExt parentProductPCExt = parentProduct.GetExtension <InventoryItemPCExt>(); if (parentProductPCExt.UsrKNCompositeType == "C") { order.CuryOrderTotal += line.CuryLineAmt; order.OrderQty += line.OrderQty; } else { order.OrderQty += line.OrderQty; } } if (order.Status != SOOrderStatus.Shipping) { line.OpenQty = line.Qty - line.ShippedQty; } if (line.OpenQty > 0) { isOpenLines = true; } } if (order.CuryTaxTotal <= 0) { order.CuryTaxTotal = 0; foreach (SOTaxTran tax in Base.Taxes.Cache.Cached) { order.CuryTaxTotal += tax.CuryTaxAmt; } } order.CuryOrderTotal += order.CuryPremiumFreightAmt; order.CuryOrderTotal += order.CuryTaxTotal; order.UnbilledOrderTotal = order.CuryUnbilledOrderTotal = order.CuryOrderTotal; if (order.CuryDocBal != 0 && order.CuryDocBal != order.CuryOrderTotal) { order.CuryDocBal = order.CuryOrderTotal; order.DocBal = order.CuryDocBal; } if (Base.Transactions.Select().Count > 0 && !isOpenLines) { order.Status = SOOrderStatus.Completed; } }
protected override TaxDetail CalculateTaxSum(PXCache sender, object taxrow, object row) { TaxRev taxrev = PXResult.Unwrap <TaxRev>(taxrow); Tax tax = PXResult.Unwrap <Tax>(taxrow); bool propagateCustomRate = false; decimal? origTaxRate = taxrev.TaxRate; SOTaxTran soTax = PXResult <SOTaxTran> .Current; if (taxrev != null && taxrev.TaxID != null && tax != null) { KCTaxExt taxExt = tax.GetExtension <KCTaxExt>(); if (taxExt.UsrKCPropagateTaxAmt == true) { if (soTax != null && taxrev.TaxID == soTax.TaxID && soTax.CuryTaxableAmt.GetValueOrDefault() > 0) { decimal?taxRate = soTax.CuryTaxAmt / soTax.CuryTaxableAmt * 100; if (taxRate != origTaxRate && taxRate > 0) { taxrev.TaxRate = taxRate; propagateCustomRate = true; } } } } bool compositeExists = false; foreach (var line in sender.Inserted) { ARTran tran = (ARTran)line; KCSOInvoiceEntryExt graphKCExt = sender.Graph.GetExtension <KCSOInvoiceEntryExt>(); InventoryItem product = graphKCExt.KCInventoryItem.SelectSingle(tran.InventoryID); if (product == null) { continue; } InventoryItemPCExt productPCExt = product.GetExtension <InventoryItemPCExt>(); if (productPCExt == null) { continue; } if (productPCExt.UsrKNCompositeType != null) { compositeExists = true; tran.CuryTranAmt = 0; tran.TranAmt = 0; } } TaxDetail result = base.CalculateTaxSum(sender, taxrow, row); if ((compositeExists || result == null) && PXResult <SOOrder> .Current != null && soTax != null) { if (result != null) { result = null; } bool?isFromCA = ((SOOrder)PXResult <SOOrder> .Current).GetExtension <KCSOOrderExt>().UsrKCSiteName?.EndsWith("FBA"); if (isFromCA.GetValueOrDefault()) { decimal?taxableAmount = 0; foreach (ARTran tran in sender.Inserted) { if (tran.LineType == KCConstants.LineTypeGI || tran.LineType == KCConstants.LineTypeGN) { taxableAmount += tran.TranAmt; } } if (soTax.CuryTaxableAmt != soTax.TaxableAmt && soTax.CuryTaxableAmt == 0) { soTax.CuryTaxableAmt = soTax.TaxableAmt; } decimal?taxAmount = soTax.TaxAmt * taxableAmount / soTax.CuryTaxableAmt; result = (TaxDetail)((PXResult)taxrow)[0]; PXCache pxcache2 = sender.Graph.Caches[this._TaxSumType]; pxcache2.SetValue(result, this._CuryOrigTaxableAmt, soTax.CuryTaxableAmt); pxcache2.SetValue(result, this._CuryTaxableAmt, taxableAmount); pxcache2.SetValue(result, this._CuryTaxAmt, taxAmount); } } if (propagateCustomRate && result != null) { result.TaxRate = origTaxRate; } return(result); }
public void ProcessMessageFTP(List <KCPriceAndInventoryMessage> messages, CancellationToken cancellationToken) { KCDataExchangeMaint masterGraph = PXGraph.CreateInstance <KCDataExchangeMaint>(); KCPriceAndInventoryMaint graph = PXGraph.CreateInstance <KCPriceAndInventoryMaint>(); var MSMQQuantityUpdates = new Dictionary <string, List <KCAPIQuantity> >(); var MSMQPrices = new Dictionary <string, KCAPIInventoryItem>(); var productsForExportPrice = new List <KeyValuePair <string, InventoryItem> >(); var productsForExportQuantity = new Dictionary <string, KeyValuePair <string, InventoryItem> >(); PushNotificationsHook pricePN = graph.PushNotification.SelectSingle(KCMSMQQueueHelper.GetSyncName(SyncType.InventoryPrice)); PushNotificationsHook quantityPN = graph.PushNotification.SelectSingle(KCMSMQQueueHelper.GetSyncName(SyncType.InventoryQuantity)); PushNotificationsHook vendorPN = graph.PushNotification.SelectSingle(KCMSMQQueueHelper.GetSyncName(SyncType.VendorQuantity)); KCMSMQueueReader price = null; KCMSMQueueReader quantity = null; KCMSMQueueReader vendor = null; try { price = new KCMSMQueueReader(pricePN.Address); quantity = new KCMSMQueueReader(quantityPN.Address); vendor = new KCMSMQueueReader(vendorPN.Address); foreach (KCPriceAndInventoryMessage msg in messages) { var syncType = KCMSMQQueueHelper.ParseSyncQueueName(msg.Address); if (syncType == SyncType.InventoryQuantity || syncType == SyncType.VendorQuantity) { List <object> insertedMessages = null; if (syncType == SyncType.InventoryQuantity && quantity.TryReceiveMessage(msg.MessageID, out var invMessage)) { insertedMessages = invMessage.Inserted; } if (syncType == SyncType.VendorQuantity && vendor.TryReceiveMessage(msg.MessageID, out var vendorMessage)) { insertedMessages = vendorMessage.Inserted; } if (insertedMessages != null) { foreach (object item in insertedMessages) { KCMSMQInventoryQuantity quantityProduct = JsonConvert.DeserializeObject <KCMSMQInventoryQuantity>(item.ToString()); InventoryItem inventoryItem = masterGraph.ProductByInvCd.Select(quantityProduct.InventoryID.Trim()); KNSIKCInventoryItem kcProduct = masterGraph.KCInventoryItem.SelectSingle(inventoryItem.InventoryID); if (kcProduct.UsrKCCAID != null) { var key = inventoryItem.InventoryCD; if (!MSMQQuantityUpdates.ContainsKey(key)) { MSMQQuantityUpdates.Add(key, quantityProduct.Updates); } if (!productsForExportQuantity.ContainsKey(key)) { InventoryItemPCExt inventoryItemPCExt = inventoryItem.GetExtension <InventoryItemPCExt>(); productsForExportQuantity.Add(inventoryItem.InventoryCD, new KeyValuePair <string, InventoryItem>(inventoryItemPCExt.UsrKNCompositeType, inventoryItem)); } } } } } else if (syncType == SyncType.InventoryPrice) { if (price.TryReceiveMessage(msg.MessageID, out var message)) { foreach (object item in message.Inserted) { KCMSMQInventoryPrice priceProduct = JsonConvert.DeserializeObject <KCMSMQInventoryPrice>(item.ToString()); InventoryItem inventoryItem = masterGraph.ProductByInvCd.Select(priceProduct.InventoryID.Trim()); InventoryItemPCExt inventoryItemPCExt = inventoryItem.GetExtension <InventoryItemPCExt>(); productsForExportPrice.Add(new KeyValuePair <string, InventoryItem>(inventoryItemPCExt.UsrKNCompositeType, inventoryItem)); MSMQPrices.Add(inventoryItem.InventoryCD, KCMapInventoryItem.GetAPIMSMQInventoryPrice(priceProduct)); } } } } } finally { price?.Dispose(); quantity?.Dispose(); vendor?.Dispose(); } Export(masterGraph, productsForExportPrice, cancellationToken, MSMQPrices); Export(masterGraph, productsForExportQuantity.Values.ToList(), cancellationToken, null, MSMQQuantityUpdates); }