protected virtual void OnPMDetailInventoryIDFieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { PMDetail row = e.Row as PMDetail; InventoryItem item = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(this, row.InventoryID); if (item != null && row != null) { row.UOM = item.SalesUnit; row.ItemFee = item.BasePrice; row.Description = item.Descr; if (Task.Current != null && Task.Current.CustomerID != null) { Customer customer = PXSelect <Customer, Where <Customer.bAccountID, Equal <Current <PMTask.customerID> > > > .Select(this); if (customer != null && !string.IsNullOrEmpty(customer.LocaleName)) { row.Description = PXDBLocalizableStringAttribute.GetTranslation(Caches[typeof(InventoryItem)], item, nameof(InventoryItem.Descr), customer.LocaleName); } } sender.SetDefaultExt <PMDetail.curyItemFee>(e.Row); } }
protected virtual void OnPMDetailInventoryIDFieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { PMDetail row = (PMDetail)e.Row; if (row == null) { return; } InventoryItem item = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(this, row.InventoryID); if (item != null) { row.UOM = item.SalesUnit; row.ItemFee = item.BasePrice; row.Description = item.Descr; PMProject project = PXSelectorAttribute.Select <PMTran.projectID>(sender, e.Row) as PMProject; if (project != null && project.CustomerID != null) { AR.Customer customer = PXSelectReadonly <AR.Customer, Where <AR.Customer.bAccountID, Equal <Required <AR.Customer.bAccountID> > > > .Select(this, project.CustomerID); if (!string.IsNullOrEmpty(customer?.LocaleName)) { row.Description = PXDBLocalizableStringAttribute.GetTranslation(Caches[typeof(InventoryItem)], item, nameof(InventoryItem.Descr), customer.LocaleName); } } sender.SetDefaultExt <PMDetail.curyItemFee>(e.Row); } }
protected virtual void PMTran_InventoryID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { PMTran row = (PMTran)e.Row; if (row?.InventoryID == null) { return; } InventoryItem inventory = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <PMTran.inventoryID> > > > .Select(this, row.InventoryID); if (inventory != null) { row.Description = inventory.Descr; PMProject project = PXSelect <PMProject, Where <PMProject.contractID, Equal <Required <PMTran.projectID> > > > .Select(this, row.ProjectID); if (project != null && project.CustomerID != null) { Customer customer = PXSelect <Customer, Where <Customer.bAccountID, Equal <Required <Customer.bAccountID> > > > .Select(this, project.CustomerID); if (customer != null && !string.IsNullOrEmpty(customer.LocaleName)) { row.Description = PXDBLocalizableStringAttribute.GetTranslation(Caches[typeof(InventoryItem)], inventory, nameof(InventoryItem.Descr), customer.LocaleName); } } } }
/// <summary>The FieldDefaulting2 event handler for the <see cref="Detail.Descr" /> field.</summary> /// <param name="e">Parameters of the event.</param> protected virtual void _(Events.FieldDefaulting <Detail, Detail.descr> e) { Document doc = Documents.Current; Customer customer = PXSelectReadonly <Customer, Where <Customer.bAccountID, Equal <Required <Customer.bAccountID> > > > .Select(Base, doc.BAccountID); InventoryItem item = (InventoryItem)PXSelectorAttribute.Select <Detail.inventoryID>(Details.Cache, e.Row); e.NewValue = PXDBLocalizableStringAttribute.GetTranslation(Base.Caches[typeof(InventoryItem)], item, nameof(InventoryItem.Descr), customer?.LocaleName); }
public static void X_InventoryID_FieldUpdated <DAC, SubItemID, SiteID, SiteLocationID, UOM, EstimatedDuration, EstimatedQty, BillingRule, ActualDuration, ActualQty>( PXCache cache, PXFieldUpdatedEventArgs e, int?branchLocationID, Customer billCustomerRow, bool useActualFields) where DAC : class, IBqlTable, IFSSODetBase, new() where SubItemID : class, IBqlField where SiteID : class, IBqlField where SiteLocationID : class, IBqlField where UOM : class, IBqlField where EstimatedDuration : class, IBqlField where EstimatedQty : class, IBqlField where BillingRule : class, IBqlField where ActualDuration : class, IBqlField where ActualQty : class, IBqlField { if (e.Row == null) { return; } var row = (DAC)e.Row; // This is required in Inventory FieldUpdated events if (e.ExternalCall) { row.CuryUnitPrice = 0m; } if (IsInventoryLine(row.LineType) == false || (row.InventoryID == null && row.LineType != ID.LineType_All.PICKUP_DELIVERY)) { // Clear fields for non-inventory lines row.IsBillable = false; row.ManualPrice = false; row.TranDesc = null; row.SubItemID = null; row.SiteID = null; row.SiteLocationID = null; cache.SetDefaultExt <FSSODet.uOM>(e.Row); cache.RaiseExceptionHandling <UOM>(e.Row, null, null); row.SetDuration(FieldType.EstimatedField, 0, cache, false); row.SetQty(FieldType.EstimatedField, 0, cache, false); if (useActualFields == true) { row.SetDuration(FieldType.ActualField, 0, cache, false); row.SetQty(FieldType.ActualField, 0, cache, false); } row.BillingRule = ID.BillingRule.NONE; return; } InventoryItem inventoryItemRow = SharedFunctions.GetInventoryItemRow(cache.Graph, row.InventoryID); row.TranDesc = null; if (inventoryItemRow != null) { row.TranDesc = PXDBLocalizableStringAttribute.GetTranslation(cache.Graph.Caches[typeof(InventoryItem)], inventoryItemRow, "Descr", billCustomerRow?.LocaleName); } // UOM is assigned to null here to avoid price calculation while duration and qty fields are defaulted. row.UOM = null; cache.RaiseExceptionHandling <UOM>(e.Row, null, null); cache.SetDefaultExt <SubItemID>(e.Row); cache.SetDefaultExt <SiteID>(e.Row); if (inventoryItemRow != null) { if (row.SiteID == null) { row.SiteID = inventoryItemRow.DfltSiteID; } if (row.SiteID == null) { //TODO: this query may return multiple records INItemSite inItemSiteRow = PXSelect <INItemSite, Where < INItemSite.inventoryID, Equal <Required <INItemSite.inventoryID> > > > .Select(cache.Graph, inventoryItemRow.InventoryID); if (inItemSiteRow != null) { row.SiteID = inItemSiteRow.SiteID; } } } cache.SetDefaultExt <SiteLocationID>(e.Row); if (inventoryItemRow != null) { if (row.SiteLocationID == null && row.LineType == ID.LineType_All.INVENTORY_ITEM) { row.SiteLocationID = inventoryItemRow.DfltShipLocationID; } } int? defaultSubItemID = row.SubItemID; object newValue = null; cache.RaiseFieldDefaulting <UOM>(e.Row, out newValue); string defaultUOM = (string)newValue; int? defaultSiteID = row.SiteID; CompleteItemInfoUsingBranchLocation( cache.Graph, branchLocationID, inventoryItemRow != null ? inventoryItemRow.DefaultSubItemOnEntry : false, ref defaultSubItemID, ref defaultUOM, ref defaultSiteID); row.SubItemID = defaultSubItemID; if (defaultSiteID != null) { cache.SetValueExt <SiteID>(e.Row, defaultSiteID); } cache.SetValueExt <UOM>(e.Row, defaultUOM); row.SetDuration(FieldType.EstimatedField, 0, cache, false); // EstimatedQty MUST be assigned after BillingRule BUT before EstimatedDuration. if (row.LineType == ID.LineType_All.SERVICE && inventoryItemRow != null) { FSxService fsxServiceRow = PXCache <InventoryItem> .GetExtension <FSxService>(inventoryItemRow); cache.SetValueExt <BillingRule>(e.Row, fsxServiceRow.BillingRule); cache.SetDefaultExt <EstimatedQty>(e.Row); cache.SetValueExt <EstimatedDuration>(e.Row, fsxServiceRow.EstimatedDuration ?? 0); } else { cache.SetValueExt <BillingRule>(e.Row, ID.BillingRule.FLAT_RATE); cache.SetDefaultExt <EstimatedQty>(e.Row); } if (useActualFields == true) { cache.SetDefaultExt <ActualQty>(e.Row); cache.SetDefaultExt <ActualDuration>(e.Row); } }