public static decimal? AdjustUnitCost(PXCache sender, UnitCostItem ucItem, int? inventoryID, CurrencyInfo currencyinfo, string UOM, decimal? currentUnitCost) { if (ucItem != null) { decimal unitCost = ucItem.Cost; if (currencyinfo != null && ucItem.CuryID != currencyinfo.CuryID) { PXCurrencyAttribute.CuryConvCury(sender, currencyinfo, ucItem.Cost, out unitCost); } if (UOM == null) { return null; } if (ucItem.UOM != UOM) { decimal salesPriceInBase = INUnitAttribute.ConvertFromBase(sender, inventoryID, ucItem.UOM, unitCost, INPrecision.UNITCOST); unitCost = INUnitAttribute.ConvertToBase(sender, inventoryID, UOM, salesPriceInBase, INPrecision.UNITCOST); } if (unitCost == 0m && currentUnitCost != null && currentUnitCost != 0m) return currentUnitCost; else return unitCost; } return null; }
public virtual decimal?CalculateCuryUnitCostInt(PXCache sender, int?vendorID, int?vendorLocationID, int?inventoryID, int?siteID, string curyID, string UOM, decimal?quantity, DateTime date, decimal?currentUnitCost) { InventoryItem item = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(sender.Graph, inventoryID); UnitCostItem ucItem = FindUnitCostInt(sender, vendorID, vendorLocationID, inventoryID, siteID, curyID, curyID, Math.Abs(quantity ?? 0m), UOM, date); return(AdjustUnitCostInt(sender, ucItem, inventoryID, null, UOM, currentUnitCost)); }
public virtual decimal?CalculateUnitCostInt(PXCache sender, int?vendorID, int?vendorLocationID, int?inventoryID, int?siteID, CurrencyInfo currencyinfo, string UOM, decimal?quantity, DateTime date, decimal?currentUnitCost, bool alwaysFromBaseCurrency = false) { InventoryItem item = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(sender.Graph, inventoryID); UnitCostItem ucItem = FindUnitCostInt(sender, vendorID, vendorLocationID, inventoryID, siteID, currencyinfo.BaseCuryID, alwaysFromBaseCurrency ? currencyinfo.BaseCuryID : currencyinfo.CuryID, Math.Abs(quantity ?? 0m), UOM, date); return(AdjustUnitCostInt(sender, ucItem, inventoryID, currencyinfo, UOM, currentUnitCost)); }
/// <summary> /// Calculates Unit Cost. /// </summary> /// <param name="sender">Cache</param> /// <param name="inventoryID">Inventory</param> /// <param name="curyID">Currency</param> /// <param name="UOM">Unit of measure</param> /// <param name="date">Date</param> /// <returns>Unit Cost</returns> public static decimal?CalculateUnitCost(PXCache sender, int?vendorID, int?vendorLocationID, int?inventoryID, CurrencyInfo currencyinfo, string UOM, decimal?quantity, DateTime date, decimal?currentUnitCost, bool alwaysFromBaseCurrency = false) { InventoryItem item = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(sender.Graph, inventoryID); UnitCostItem ucItem = FindUnitCost(sender, vendorID, vendorLocationID, inventoryID, alwaysFromBaseCurrency ? currencyinfo.BaseCuryID : currencyinfo.CuryID, Math.Abs(quantity ?? 0m), UOM, date); if (ucItem != null) { decimal unitCost = ucItem.Cost; if (ucItem.CuryID != currencyinfo.CuryID) { PXCurrencyAttribute.CuryConvCury(sender, currencyinfo, ucItem.Cost, out unitCost); } if (UOM == null) { return(null); } if (ucItem.UOM != UOM) { decimal salesPriceInBase = INUnitAttribute.ConvertFromBase(sender, inventoryID, ucItem.UOM, unitCost, INPrecision.UNITCOST); unitCost = INUnitAttribute.ConvertToBase(sender, inventoryID, UOM, salesPriceInBase, INPrecision.UNITCOST); } if (unitCost == 0m && currentUnitCost != null && currentUnitCost != 0m) { return(currentUnitCost); } else { return(unitCost); } } if (currentUnitCost != null && currentUnitCost != 0m) { return(currentUnitCost); } else { return(null); } }