protected virtual void _(Events.RowSelected <CROpportunityProducts> e) { if (e.Row == null) { return; } CROpportunityProducts crOpportunityProductsRow = (CROpportunityProducts)e.Row; PXCache cache = e.Cache; FSxCROpportunityProducts fsxCROpportunityProductsRow = cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow); if (fsxCROpportunityProductsRow != null) { InventoryItem inventoryItemRow = SharedFunctions.GetInventoryItemRow(Base, crOpportunityProductsRow.InventoryID); if (inventoryItemRow != null) { PXUIFieldAttribute.SetEnabled <FSxCROpportunityProducts.billingRule>(cache, crOpportunityProductsRow, inventoryItemRow.ItemType == INItemTypes.ServiceItem); PXUIFieldAttribute.SetEnabled <FSxCROpportunityProducts.estimatedDuration>(cache, crOpportunityProductsRow, inventoryItemRow.ItemType == INItemTypes.ServiceItem || inventoryItemRow.ItemType == INItemTypes.NonStockItem); PXUIFieldAttribute.SetEnabled <CROpportunityProducts.curyUnitCost>(cache, crOpportunityProductsRow, crOpportunityProductsRow.POCreate == true); PXUIFieldAttribute.SetEnabled <FSxCROpportunityProducts.vendorLocationID>(cache, crOpportunityProductsRow, crOpportunityProductsRow.POCreate == true); PXUIFieldAttribute.SetEnabled <CROpportunityProducts.quantity>(cache, crOpportunityProductsRow, fsxCROpportunityProductsRow.BillingRule != ID.BillingRule.TIME); } } }
public static void InsertFSSODetFromOpportunity(ServiceOrderEntry graphServiceOrder, PXCache cacheOpportunityProducts, CRSetup crSetupRow, CROpportunityProducts crOpportunityProductRow, FSxCROpportunityProducts fsxCROpportunityProductsRow, InventoryItem inventoryItemRow) { if (graphServiceOrder == null || crOpportunityProductRow == null || fsxCROpportunityProductsRow == null || inventoryItemRow == null) { return; } //Insert a new SODet line FSSODet fsSODetRow = new FSSODet(); UpdateFSSODetFromOpportunity(graphServiceOrder.ServiceOrderDetails.Cache, fsSODetRow, crOpportunityProductRow, fsxCROpportunityProductsRow, SharedFunctions.GetLineTypeFromInventoryItem(inventoryItemRow)); SharedFunctions.CopyNotesAndFiles(cacheOpportunityProducts, graphServiceOrder.ServiceOrderDetails.Cache, crOpportunityProductRow, graphServiceOrder.ServiceOrderDetails.Current, crSetupRow.CopyNotes, crSetupRow.CopyFiles); }
protected virtual void _(Events.FieldDefaulting <CROpportunityProducts, FSxCROpportunityProducts.estimatedDuration> e) { if (e.Row == null) { return; } CROpportunityProducts crOpportunityProductsRow = (CROpportunityProducts)e.Row; FSxCROpportunityProducts fsxCROpportunityProductsRow = e.Cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow); if (fsxCROpportunityProductsRow != null) { InventoryItem inventoryItemRow = SharedFunctions.GetInventoryItemRow(Base, crOpportunityProductsRow.InventoryID); if (inventoryItemRow != null) { FSxService fsxServiceRow = PXCache <InventoryItem> .GetExtension <FSxService>(inventoryItemRow); if (inventoryItemRow.ItemType == INItemTypes.ServiceItem || inventoryItemRow.ItemType == INItemTypes.NonStockItem) { e.NewValue = fsxServiceRow?.EstimatedDuration; e.Cancel = true; } } } }
protected virtual void _(Events.FieldDefaulting <CROpportunityProducts, FSxCROpportunityProducts.billingRule> e) { if (e.Row == null) { return; } CROpportunityProducts crOpportunityProductsRow = (CROpportunityProducts)e.Row; FSxCROpportunityProducts fsxCROpportunityProductsRow = e.Cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow); if (crOpportunityProductsRow.InventoryID != null) { InventoryItem inventoryItemRow = SharedFunctions.GetInventoryItemRow(Base, crOpportunityProductsRow.InventoryID); if (inventoryItemRow.ItemType == INItemTypes.ServiceItem) { FSxService fsxServiceRow = PXCache <InventoryItem> .GetExtension <FSxService>(inventoryItemRow); e.NewValue = fsxServiceRow?.BillingRule; e.Cancel = true; } else { e.NewValue = ID.BillingRule.FLAT_RATE; e.Cancel = true; } } }
protected virtual void CROpportunityProducts_CuryUnitCost_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e) { if (e.Row == null) { return; } CROpportunityProducts crOpportunityProductsRow = (CROpportunityProducts)e.Row; FSxCROpportunityProducts fsxCROpportunityProductsRow = cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow); if (string.IsNullOrEmpty(crOpportunityProductsRow.UOM) == false && crOpportunityProductsRow.InventoryID != null && crOpportunityProductsRow.POCreate == true) { object unitcost; cache.RaiseFieldDefaulting <CROpportunityProducts.unitCost>(e.Row, out unitcost); if (unitcost != null && (decimal)unitcost != 0m) { decimal newval = INUnitAttribute.ConvertToBase <CROpportunityProducts.inventoryID, CROpportunityProducts.uOM>(cache, crOpportunityProductsRow, (decimal)unitcost, INPrecision.NOROUND); IPXCurrencyHelper currencyHelper = Base.FindImplementation <IPXCurrencyHelper>(); if (currencyHelper != null) { currencyHelper.CuryConvCury((decimal)unitcost, out newval); } else { CM.PXDBCurrencyAttribute.CuryConvCury(cache, crOpportunityProductsRow, newval, out newval, true); } e.NewValue = Math.Round(newval, CommonSetupDecPl.PrcCst, MidpointRounding.AwayFromZero); e.Cancel = true; } } }
public GetAttributeRecords(PXGraph graph, ref int?bAccountID, ref int?inventoryID) { CROpportunity current1 = graph.Caches <CROpportunity>().Current as CROpportunity; PXFieldState valueExt = graph.Caches <CROpportunity>().GetValueExt((object)current1, "AttributeENDCUSTOME") as PXFieldState; bAccountID = PXSelectBase <BAccountR, PXSelect <BAccountR, Where <BAccountR.acctCD, Equal <Required <BAccountR.acctCD> > > > .Config> .Select(graph, valueExt.Value).TopFirst.BAccountID; CROpportunityProducts current2 = graph.Caches <CROpportunityProducts>().Current as CROpportunityProducts; inventoryID = current2.InventoryID; }
public static void UpdateFSSODetFromOpportunity(PXCache soDetCache, FSSODet fsSODetRow, CROpportunityProducts crOpportunityProductRow, FSxCROpportunityProducts fsxCROpportunityProductsRow, string lineType) { if (crOpportunityProductRow == null || fsxCROpportunityProductsRow == null) { return; } fsSODetRow.SourceNoteID = crOpportunityProductRow.NoteID; soDetCache.Current = fsSODetRow = (FSSODet)soDetCache.Insert(fsSODetRow); fsSODetRow.LineType = lineType; fsSODetRow.InventoryID = crOpportunityProductRow.InventoryID; fsSODetRow.IsBillable = crOpportunityProductRow.IsFree == false; soDetCache.Current = fsSODetRow = (FSSODet)soDetCache.Update(fsSODetRow); fsSODetRow = (FSSODet)soDetCache.CreateCopy(fsSODetRow); fsSODetRow.BillingRule = fsxCROpportunityProductsRow.BillingRule; fsSODetRow.TranDesc = crOpportunityProductRow.Descr; if (crOpportunityProductRow.SiteID != null) { fsSODetRow.SiteID = crOpportunityProductRow.SiteID; } fsSODetRow.EstimatedDuration = fsxCROpportunityProductsRow.EstimatedDuration; fsSODetRow.EstimatedQty = crOpportunityProductRow.Qty; fsSODetRow.CuryUnitPrice = crOpportunityProductRow.CuryUnitPrice; fsSODetRow.ManualPrice = crOpportunityProductRow.ManualPrice; fsSODetRow.ProjectID = crOpportunityProductRow.ProjectID; fsSODetRow.ProjectTaskID = crOpportunityProductRow.TaskID; fsSODetRow.CostCodeID = crOpportunityProductRow.CostCodeID; fsSODetRow.CuryUnitCost = crOpportunityProductRow.CuryUnitCost; fsSODetRow.ManualCost = crOpportunityProductRow.POCreate; fsSODetRow.EnablePO = crOpportunityProductRow.POCreate; fsSODetRow.POVendorID = crOpportunityProductRow.VendorID; fsSODetRow.POVendorLocationID = fsxCROpportunityProductsRow.VendorLocationID; fsSODetRow.TaxCategoryID = crOpportunityProductRow.TaxCategoryID; fsSODetRow.DiscPct = crOpportunityProductRow.DiscPct; fsSODetRow.CuryDiscAmt = crOpportunityProductRow.CuryDiscAmt; fsSODetRow.CuryBillableExtPrice = crOpportunityProductRow.CuryExtPrice; soDetCache.Current = soDetCache.Update(fsSODetRow); }
protected virtual void _(Events.FieldUpdated <CROpportunityProducts, FSxCROpportunityProducts.estimatedDuration> e) { if (e.Row == null) { return; } CROpportunityProducts crOpportunityProductsRow = (CROpportunityProducts)e.Row; FSxCROpportunityProducts fsxCROpportunityProductsRow = e.Cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow); if (fsxCROpportunityProductsRow.EstimatedDuration != null && fsxCROpportunityProductsRow.BillingRule == ID.BillingRule.TIME) { e.Cache.SetDefaultExt <CROpportunityProducts.quantity>(crOpportunityProductsRow); } }
protected virtual void _(Events.FieldDefaulting <CROpportunityProducts, FSxCROpportunityProducts.vendorLocationID> e) { if (e.Row == null) { return; } CROpportunityProducts crOpportunityProductsRow = (CROpportunityProducts)e.Row; FSxCROpportunityProducts fsxCROpportunityProductsRow = e.Cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow); if (crOpportunityProductsRow.POCreate == false || crOpportunityProductsRow.InventoryID == null) { e.Cancel = true; } }
protected virtual void CROpportunityProducts_EstimatedDuration_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e) { if (e.Row == null) { return; } CROpportunityProducts crOpportunityProductsRow = (CROpportunityProducts)e.Row; FSxCROpportunityProducts fsxCROpportunityProductsRow = cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow); if (fsxCROpportunityProductsRow.EstimatedDuration != null && fsxCROpportunityProductsRow.BillingRule == ID.BillingRule.TIME) { cache.SetDefaultExt <CROpportunityProducts.quantity>(crOpportunityProductsRow); } }
protected virtual void CROpportunityProducts_VendorLocationID_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e) { if (e.Row == null) { return; } CROpportunityProducts crOpportunityProductsRow = (CROpportunityProducts)e.Row; FSxCROpportunityProducts fsxCROpportunityProductsRow = cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow); if (crOpportunityProductsRow.POCreate == false || crOpportunityProductsRow.InventoryID == null) { e.Cancel = true; } }
protected virtual void CROpportunityProducts_SiteID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e) { if (e.Row == null) { return; } CROpportunityProducts crOpportunityProductsRow = (CROpportunityProducts)e.Row; FSxCROpportunityProducts fsxCROpportunityProductsRow = cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow); if (fsxCROpportunityProductsRow != null) { cache.SetDefaultExt <CROpportunityProducts.curyUnitCost>(e.Row); } }
protected virtual void _(Events.FieldUpdated <CROpportunityProducts, CROpportunityProducts.siteID> e) { if (e.Row == null) { return; } CROpportunityProducts crOpportunityProductsRow = (CROpportunityProducts)e.Row; PXCache cache = e.Cache; FSxCROpportunityProducts fsxCROpportunityProductsRow = cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow); if (fsxCROpportunityProductsRow != null && Base.IsImportFromExcel == false) { cache.SetDefaultExt <CROpportunityProducts.curyUnitCost>(e.Row); } }
public virtual void FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e) { if (e.Cancel || e.Row == null) { return; } object obj = sender.GetValue(e.Row, this._inventoryType.Name); if (obj == null) { return; } InventoryItem inventoryItem = InventoryItem.PK.Find(sender.Graph, new int?((int)obj)); if (!inventoryItem.DfltSiteID.HasValue) { object branchId = sender.GetValue(e.Row, this._branchType.Name); if (branchId == null) { CROpportunityProducts current = (CROpportunityProducts)sender.Current; if (current != null) { branchId = (object)SelectFrom <CROpportunity> .Where <CROpportunity.quoteNoteID.IsEqual <P.AsGuid> > .View.SelectSingleBound(sender.Graph, null, (object)current.QuoteID).TopFirst.BranchID; } } PX.Objects.CR.Location location = (PX.Objects.CR.Location)SelectFrom <PX.Objects.CR.Location> .InnerJoin <PX.Objects.GL.Branch> .On <PX.Objects.GL.Branch.bAccountID.IsEqual <PX.Objects.CR.Location.bAccountID> > .Where <PX.Objects.GL.Branch.branchID.IsEqual <P.AsInt> > .View.ReadOnly.Select(sender.Graph, branchId); if (location == null) { return; } e.NewValue = (object)location.CSiteID; } else { INSite inSite = (INSite)PXSelectBase <INSite, PXSelectReadonly <INSite, Where <INSite.siteID, Equal <Required <INSite.siteID> >, And <Match <INSite, Current <AccessInfo.userName> > > > > .Config> .Select(sender.Graph, (object)inventoryItem.DfltSiteID); if (inSite == null) { return; } e.NewValue = (object)inSite.SiteID; } }
protected virtual void _(Events.FieldDefaulting <CROpportunityProducts, CROpportunityProducts.quantity> e) { if (e.Row == null) { return; } CROpportunityProducts crOpportunityProductsRow = (CROpportunityProducts)e.Row; FSxCROpportunityProducts fsxCROpportunityProductsRow = e.Cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow); if (fsxCROpportunityProductsRow != null && fsxCROpportunityProductsRow.BillingRule == ID.BillingRule.TIME && fsxCROpportunityProductsRow.EstimatedDuration != null && fsxCROpportunityProductsRow.EstimatedDuration > 0) { e.NewValue = fsxCROpportunityProductsRow.EstimatedDuration / 60m; } else { e.NewValue = 0m; } }
protected virtual void CROpportunityProducts_Quantity_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e) { if (e.Row == null) { return; } CROpportunityProducts crOpportunityProductsRow = (CROpportunityProducts)e.Row; FSxCROpportunityProducts fsxCROpportunityProductsRow = cache.GetExtension <FSxCROpportunityProducts>(crOpportunityProductsRow); if (fsxCROpportunityProductsRow != null && fsxCROpportunityProductsRow.BillingRule == ID.BillingRule.TIME && fsxCROpportunityProductsRow.EstimatedDuration != null && fsxCROpportunityProductsRow.EstimatedDuration > 0) { e.NewValue = fsxCROpportunityProductsRow.EstimatedDuration / 60m; } else { e.NewValue = 0m; } }
protected GetTaxRequest BuildGetTaxRequest(PMQuote quote) { if (quote == null) { throw new PXArgumentException(ErrorMessages.ArgumentNullException); } BAccount cust = (BAccount)PXSelect <BAccount, Where <BAccount.bAccountID, Equal <Required <BAccount.bAccountID> > > > . Select(Base, quote.BAccountID); CR.Location loc = (CR.Location) PXSelect <CR.Location, Where <CR.Location.bAccountID, Equal <Required <CR.Location.bAccountID> >, And <CR.Location.locationID, Equal <Required <CR.Location.locationID> > > > > . Select(Base, quote.BAccountID, quote.LocationID); IAddressBase addressFrom = GetFromAddress(quote); IAddressBase addressTo = GetToAddress(quote); if (addressFrom == null) { throw new PXException(CR.Messages.FailedGetFromAddressCR); } if (addressTo == null) { throw new PXException(CR.Messages.FailedGetToAddressCR); } GetTaxRequest request = new GetTaxRequest(); request.CompanyCode = CompanyCodeFromBranch(quote.TaxZoneID, Base.Accessinfo.BranchID); request.CurrencyCode = quote.CuryID; request.CustomerCode = cust.AcctCD; request.OriginAddress = AddressConverter.ConvertTaxAddress(addressFrom); request.DestinationAddress = AddressConverter.ConvertTaxAddress(addressTo); request.DocCode = string.Format("CR.{0}", quote.OpportunityID); request.DocDate = quote.DocumentDate.GetValueOrDefault(); request.Discount = quote.CuryLineDocDiscountTotal.GetValueOrDefault(); int mult = 1; if (!string.IsNullOrEmpty(loc.CAvalaraCustomerUsageType)) { request.CustomerUsageType = loc.CAvalaraCustomerUsageType; } if (!string.IsNullOrEmpty(loc.CAvalaraExemptionNumber)) { request.ExemptionNo = loc.CAvalaraExemptionNumber; } request.DocType = TaxDocumentType.SalesOrder; var select = PXSelectJoin <CROpportunityProducts, LeftJoin <InventoryItem, On <InventoryItem.inventoryID, Equal <CROpportunityProducts.inventoryID> >, LeftJoin <Account, On <Account.accountID, Equal <InventoryItem.salesAcctID> > > >, Where <CROpportunityProducts.quoteID, Equal <Required <PMQuote.quoteID> > >, OrderBy <Asc <CROpportunityProducts.lineNbr> > > .Select(Base, quote.QuoteID); foreach (PXResult <CROpportunityProducts, InventoryItem, Account> res in select) { CROpportunityProducts tran = (CROpportunityProducts)res; InventoryItem item = (InventoryItem)res; Account salesAccount = (Account)res; var line = new TaxCartItem(); line.Index = tran.LineNbr ?? 0; line.Amount = mult * tran.CuryAmount.GetValueOrDefault(); line.Description = tran.Descr; line.DestinationAddress = request.DestinationAddress; line.OriginAddress = request.OriginAddress; line.ItemCode = item.InventoryCD; line.Quantity = tran.Qty.GetValueOrDefault(); line.Discounted = request.Discount > 0; line.RevAcct = salesAccount.AccountCD; line.TaxCode = tran.TaxCategoryID; request.CartItems.Add(line); } return(request); }