public static CurrencyInfo GetEX(CM.CurrencyInfo info) { return(new CurrencyInfo { BaseCalc = info.BaseCalc, BaseCuryID = info.BaseCuryID, BasePrecision = info.BasePrecision, CuryEffDate = info.CuryEffDate, CuryID = info.CuryID, CuryInfoID = info.CuryInfoID, CuryMultDiv = info.CuryMultDiv, CuryPrecision = info.CuryPrecision, CuryRate = info.CuryRate, CuryRateTypeID = info.CuryRateTypeID, DisplayCuryID = info.DisplayCuryID, IsReadOnly = info.IsReadOnly, ModuleCode = info.ModuleCode, RecipRate = info.RecipRate, SampleCuryRate = info.SampleCuryRate, SampleRecipRate = info.SampleRecipRate, tstamp = info.tstamp }); }
protected virtual void _(Events.FieldDefaulting <PMBudget, PMBudget.rate> e) { PMAccountGroup ag = PXSelect <PMAccountGroup, Where <PMAccountGroup.groupID, Equal <Required <PMAccountGroup.groupID> > > > .Select(this, e.Row.AccountGroupID); if (ag != null) { if (ag.IsExpense == true) { if (e.Row.InventoryID != null && e.Row.InventoryID != PMInventorySelectorAttribute.EmptyInventoryID) { InventoryItem item = (InventoryItem)PXSelectorAttribute.Select <PMCostBudget.inventoryID>(e.Cache, e.Row); e.NewValue = item?.StdCost; } } else { if (e.Row.InventoryID != null && e.Row.InventoryID != PMInventorySelectorAttribute.EmptyInventoryID) { string customerPriceClass = ARPriceClass.EmptyPriceClass; PMTask projectTask = (PMTask)PXSelectorAttribute.Select <PMRevenueBudget.projectTaskID>(e.Cache, e.Row); CR.Location c = (CR.Location)PXSelectorAttribute.Select <PMTask.locationID>(e.Cache, projectTask); if (c != null && !string.IsNullOrEmpty(c.CPriceClassID)) { customerPriceClass = c.CPriceClassID; } CM.CurrencyInfo dummy = new CM.CurrencyInfo(); dummy.CuryID = Accessinfo.BaseCuryID; dummy.BaseCuryID = Accessinfo.BaseCuryID; dummy.CuryRate = 1; e.NewValue = ARSalesPriceMaint.CalculateSalesPrice(Caches[typeof(PMTran)], customerPriceClass, projectTask.CustomerID, e.Row.InventoryID, dummy, e.Row.Qty, e.Row.UOM, Accessinfo.BusinessDate.Value, true); } } } }
public virtual decimal GetItemPrice(PXCache sender, string curyID, int?customerID, int?locationID, string contractStatus, int?contractItemID, int?itemID, string itemType, string priceOption, decimal?fixedPrice, decimal?setupPrice, decimal?qty, DateTime?date) { decimal itemPrice = 0m; ContractItem item = PXSelect <ContractItem, Where <ContractItem.contractItemID, Equal <Required <ContractItem.contractItemID> > > > .Select(sender.Graph, contractItemID); if (item != null) { IN.InventoryItem nonstock = PXSelect <IN.InventoryItem, Where <IN.InventoryItem.inventoryID, Equal <Required <IN.InventoryItem.inventoryID> > > > .Select(sender.Graph, itemID); CR.Location customerLocation = PXSelect < CR.Location, Where < CR.Location.bAccountID, Equal <Required <Contract.customerID> >, And <CR.Location.locationID, Equal <Required <Contract.locationID> > > > > .Select(sender.Graph, customerID, locationID); string customerPriceClass = string.IsNullOrEmpty(customerLocation?.CPriceClassID) ? ARPriceClass.EmptyPriceClass : customerLocation.CPriceClassID; if (priceOption == null) { switch (itemType) { case ContractDetailType.Setup: priceOption = item.BasePriceOption; break; case ContractDetailType.Renewal: priceOption = item.RenewalPriceOption; break; case ContractDetailType.Billing: priceOption = item.FixedRecurringPriceOption; break; case ContractDetailType.UsagePrice: priceOption = item.UsagePriceOption; break; } } CM.CurrencyInfo currencyInfo = new CM.CurrencyInfo(); currencyInfo.BaseCuryID = new PXSetup <Company>(sender.Graph).Current.BaseCuryID; currencyInfo.CuryID = curyID; Customer customer = PXSelect <Customer, Where <Customer.bAccountID, Equal <Required <Customer.bAccountID> > > > .Select(sender.Graph, customerID); if (customer != null && customer.CuryRateTypeID != null) { currencyInfo.CuryRateTypeID = customer.CuryRateTypeID; } currencyInfo.SetCuryEffDate(sender.Graph.Caches[typeof(CM.CurrencyInfo)], date); if (nonstock != null && currencyInfo != null) { switch (priceOption) { case PriceOption.ItemPrice: itemPrice = ARSalesPriceMaint.CalculateSalesPrice(sender, customerPriceClass, customerID, itemID, currencyInfo, qty, nonstock.BaseUnit, date ?? DateTime.Now, false) ?? 0m; break; case PriceOption.ItemPercent: itemPrice = ((ARSalesPriceMaint.CalculateSalesPrice(sender, customerPriceClass, customerID, itemID, currencyInfo, qty, nonstock.BaseUnit, date ?? DateTime.Now, false) ?? 0m) / 100m * (fixedPrice ?? 0m)); break; case PriceOption.BasePercent: itemPrice = (setupPrice ?? 0m) / 100m * (fixedPrice ?? 0m); break; case PriceOption.Manually: itemPrice = fixedPrice ?? 0m; break; } } } return(itemPrice); }