/// <summary> /// Verifies whether or not the system can convert the InventoryItem's <c>UOM</c> to the one defined in the Sales Price screen. /// If <c>arSalesPriceRow != null</c> means that the price from Sale Price applies. /// If <c>arSalesPriceRow.UOM != uom</c> means that the <c>UOM</c> conversion applies. /// </summary> /// <param name="cache">PXCache instance.</param> /// <param name="arSalesPriceRow"><c>ARSalesPrice</c> instance.</param> /// <param name="inventoryID">Inventory Item ID.</param> /// <param name="uom">Unit of measure required.</param> /// <returns>Returns an errorCode status.</returns> private static string CheckInventoryItemUOM(PXCache cache, ARSalesPrice arSalesPriceRow, int?inventoryID, string uom) { string errorCode = ID.PriceErrorCode.OK; if (arSalesPriceRow != null && arSalesPriceRow.UOM != uom) { try { decimal value = 0m; decimal salesprice = INUnitAttribute.ConvertFromBase(cache, inventoryID, arSalesPriceRow.UOM, value, INPrecision.NOROUND); } catch (PXException e) { //The error code that can be thrown by ConvertFromBase routine is PX.Objects.IN.Messages.MissingUnitConversion, though, //the error message is captured in case it does not match it for unknown reasons. errorCode = e.Message; //At this point it's ensured that e.Message corresponds to MissingUnitConversion, //changing the errorCode value to a more explanatory message. if (e.Message.IndexOf(PX.Objects.IN.Messages.MissingUnitConversion) != -1) { errorCode = ID.PriceErrorCode.UOM_INCONSISTENCY; } } } return(errorCode); }
private static bool ValidatePrice(PXGraph graph, int InventoryID, ContractItem item) { PXSelectBase <ARSalesPrice> s = new PXSelectJoin <ARSalesPrice, InnerJoin <InventoryItem, On <InventoryItem.inventoryID, Equal <ARSalesPrice.inventoryID> > >, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> >, And <ARSalesPrice.curyID, Equal <Required <ARSalesPrice.curyID> >, And <ARSalesPrice.custPriceClassID, Equal <AR.ARPriceClass.emptyPriceClass> > > > >(graph); ARSalesPrice aRPrice = s.SelectSingle(InventoryID, item.CuryID); if (aRPrice == null) { return(false); } return(true); }
private void SetDefTokenPrice(JToken insertedToken, string key) { DateTime now = DateTime.Now; var graph = PXGraph.CreateInstance <KCInventoryManagementMaint>(); var sku = ((JValue)insertedToken.First().Values().First()).Value.ToString(); var id = graph.ItemByCD.SelectSingle(sku).InventoryID; ARSalesPrice rec = graph.KCSalesPrice.SelectSingle("B", id); if (rec != null) { if (Between(rec.EffectiveDate, rec.ExpirationDate)) { insertedToken[key] = rec.SalesPrice; } } else { insertedToken[key] = insertedToken[DEFAULT_PRICE]; } }
public void ExportProducts(KCStore store, List <KeyValuePair <string, InventoryItem> > productsForExport = null) { DateTime today = DateTime.Now; _store = store; KCSiteMaster connection = Graph.StoreConfig.Select().RowCast <KCSiteMaster>().First(x => x.SiteMasterCD.Equals(store.SiteMasterCD)); KCARestClient client = new KCARestClient(connection); ApiHelper = new KCInventoryItemAPIHelper(client); if (productsForExport == null) { productsForExport = GetProductsForExport(); } List <KCBulkProduct> dtos = HandleItems(productsForExport); foreach (var item in dtos) { var id = Graph.ItemByCD.SelectSingle(item.Product.Sku).InventoryID; ARSalesPrice rec = Graph.KCSalesPrice.SelectSingle("B", id); if (rec != null) { item.Product.RetailPrice = rec.SalesPrice; } } bool anyProductToExport = dtos.Count > 0; if (anyProductToExport) { string bulkFile = PrepareItemBulkFile(dtos); string productFilePath = GenerateProductUploadPath(connection); UploadFileToFTP(connection, bulkFile, productFilePath); } logger.ClearLoggingIds(); logger.Information(anyProductToExport ? KCMessages.BulkUploadSuccess(store.SiteMasterCD) : KCMessages.NoProductsToExport); }