protected override void FillInventoryMatrixItem(EntryMatrix newRow, int colAttributeIndex, InventoryMapValue inventoryValue) { if (inventoryValue?.InventoryID == null) { return; } var item = InventoryItem.PK.Find(Base, inventoryValue.InventoryID); if (!IsItemStatusDisabled(item)) { newRow.InventoryIDs[colAttributeIndex] = inventoryValue.InventoryID; try { newRow.Quantities[colAttributeIndex] = GetQty(Header.Current.SiteID, inventoryValue.InventoryID); } catch (PXSetPropertyException exception) { newRow.InventoryIDs[colAttributeIndex] = null; newRow.Errors[colAttributeIndex] = exception.Message; } } else { string label = PXStringListAttribute.GetLocalizedLabel <InventoryItem.itemStatus>(Base.Caches <InventoryItem>(), item); newRow.Errors[colAttributeIndex] = PXLocalizer.LocalizeFormat(Messages.InventoryItemIsInStatus, label); } }
public IEnumerable matrix() { bool preliminaryReturned = false; foreach (EntryMatrix row in Matrix.Cache.Cached) { preliminaryReturned |= row.IsPreliminary == true; yield return(row); } if (AddPreliminary && !preliminaryReturned) { EntryMatrix preliminary = GeneratePreliminaryRow(Matrix.Cache.Cached.Cast <EntryMatrix>()); if (preliminary != null) { Matrix.Cache.Hold(preliminary); yield return(preliminary); } } if (AddTotals) { EntryMatrix total = GenerateTotalRow(Matrix.Cache.Cached.Cast <EntryMatrix>()); if (total != null) { yield return(total); } } }
protected virtual void _(Events.FieldSelecting <EntryMatrix, EntryMatrix.matrixAvailability> eventArgs) { eventArgs.ReturnValue = null; EntryMatrix row = eventArgs.Row; if (row != null && row.SelectedColumn != null && Header.Current?.ShowAvailable == true) { int columnIndex = (int)row.SelectedColumn; eventArgs.ReturnValue = GetAvailability(Header.Current.SiteID, GetValueFromArray(row.InventoryIDs, columnIndex), GetValueFromArray(row.Quantities, columnIndex)); } }
protected virtual void RecalcMatrixGrid() { EntryMatrix firstMatrixRow = this.GetFirstMatrixRow(); int? selectedColumn = firstMatrixRow?.SelectedColumn; Matrix.Cache.Clear(); if (Header.Current.ColAttributeID == null || Header.Current.RowAttributeID == null) { return; } IDictionary <InventoryMapKey, InventoryMapValue> inventoryMap = GetInventoryMap(); FillInventoryMatrix(inventoryMap, selectedColumn); }
/// <summary> /// Inserts matrix rows by inventoryMap and result of GetQty method. /// </summary> protected virtual void FillInventoryMatrix(IDictionary <InventoryMapKey, InventoryMapValue> inventoryMap, int?selectedColumn) { MatrixAttributeValues matrixValues = GetMatrixAttributeValues(); for (int rowAttributeIndex = 0; rowAttributeIndex < matrixValues.RowValues.Length; rowAttributeIndex++) { var rowAttribute = matrixValues.RowValues[rowAttributeIndex]; var newRow = new EntryMatrix(); newRow.LineNbr = rowAttributeIndex; newRow.RowAttributeValue = rowAttribute.ValueID; newRow.RowAttributeValueDescr = rowAttribute.Description ?? rowAttribute.ValueID; newRow.ColAttributeValues = new string[matrixValues.ColumnValues.Length]; newRow.ColAttributeValueDescrs = new string[matrixValues.ColumnValues.Length]; newRow.InventoryIDs = new int?[matrixValues.ColumnValues.Length]; newRow.Quantities = new decimal?[matrixValues.ColumnValues.Length]; newRow.Errors = new string[matrixValues.ColumnValues.Length]; newRow.Selected = new bool?[matrixValues.ColumnValues.Length]; newRow.SelectedColumn = selectedColumn; for (int colAttributeIndex = 0; colAttributeIndex < matrixValues.ColumnValues.Length; colAttributeIndex++) { var colAttribute = matrixValues.ColumnValues[colAttributeIndex]; newRow.ColAttributeValues[colAttributeIndex] = colAttribute.ValueID; newRow.ColAttributeValueDescrs[colAttributeIndex] = colAttribute.Description; inventoryMap.TryGetValue(new InventoryMapKey(colAttribute.ValueID, rowAttribute.ValueID), out InventoryMapValue inventoryValue); FillInventoryMatrixItem(newRow, colAttributeIndex, inventoryValue); if (rowAttributeIndex == 0) { AddField(colAttributeIndex); } } Matrix.Cache.SetStatus(newRow, PXEntryStatus.Held); } }
protected override void FillInventoryMatrixItem(EntryMatrix newRow, int colAttributeIndex, InventoryMapValue inventoryValue) { newRow.InventoryIDs[colAttributeIndex] = inventoryValue?.InventoryID; newRow.Selected[colAttributeIndex] = (inventoryValue?.InventoryID != null); }
protected override void FillInventoryMatrixItem(EntryMatrix newRow, int colAttributeIndex, InventoryMapValue inventoryValue) { newRow.InventoryIDs[colAttributeIndex] = inventoryValue?.InventoryID; switch (Header.Current.DisplayPlanType) { case PlanType.Available: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyAvail>(inventoryValue); break; case PlanType.AvailableforShipment: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyHardAvail>(inventoryValue); break; case PlanType.NotAvailable: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyNotAvail>(inventoryValue); break; case PlanType.SOBooked: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtySOBooked>(inventoryValue); break; case PlanType.SOShipped: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtySOShipped>(inventoryValue); break; case PlanType.SOShipping: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtySOShipping>(inventoryValue); break; case PlanType.SOBackOrdered: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtySOBackOrdered>(inventoryValue); break; case PlanType.InAssemblyDemand: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyINAssemblyDemand>(inventoryValue); break; case PlanType.INIssues: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyINIssues>(inventoryValue); break; case PlanType.INReceipts: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyINReceipts>(inventoryValue); break; case PlanType.InTransit: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyInTransit>(inventoryValue); break; case PlanType.PurchasePrepared: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyPOPrepared>(inventoryValue); break; case PlanType.PurchaseOrders: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyPOOrders>(inventoryValue); break; case PlanType.POReceipts: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyPOReceipts>(inventoryValue); break; case PlanType.SOtoPurchase: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtySOFixed>(inventoryValue); break; case PlanType.PurchaseforSO: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyPOFixedOrders>(inventoryValue); break; case PlanType.PurchaseforSOPrepared: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyPOFixedPrepared>(inventoryValue); break; case PlanType.PurchaseReceiptsForSO: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyPOFixedReceipts>(inventoryValue); break; case PlanType.SOtoDropShip: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtySODropShip>(inventoryValue); break; case PlanType.DropShipforSO: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyPODropShipOrders>(inventoryValue); break; case PlanType.DropShipforSOPrepared: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyPODropShipPrepared>(inventoryValue); break; case PlanType.DropShipforSOReceipts: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyPODropShipReceipts>(inventoryValue); break; case PlanType.InAssemblySupply: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyINAssemblySupply>(inventoryValue); break; case PlanType.OnHand: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyOnHand>(inventoryValue); break; case PlanType.Expired: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyExpired>(inventoryValue); break; case PlanType.FSSrvOrdPrepared: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyFSSrvOrdPrepared>(inventoryValue); break; case PlanType.FSSrvOrdBooked: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyFSSrvOrdBooked>(inventoryValue); break; case PlanType.FSSrvOrdAllocated: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyFSSrvOrdAllocated>(inventoryValue); break; case PlanType.FixedFSSrvOrd: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyFixedFSSrvOrd>(inventoryValue); break; case PlanType.POFixedFSSrvOrd: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyPOFixedFSSrvOrd>(inventoryValue); break; case PlanType.POFixedFSSrvOrdPrepared: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyPOFixedFSSrvOrdPrepared>(inventoryValue); break; case PlanType.POFixedFSSrvOrdReceipts: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyPOFixedFSSrvOrdReceipts>(inventoryValue); break; case PlanType.InTransitToProduction: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyInTransitToProduction>(inventoryValue); break; case PlanType.ProductionSupplyPrepared: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyProductionSupplyPrepared>(inventoryValue); break; case PlanType.ProductionSupply: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyProductionSupply>(inventoryValue); break; case PlanType.POFixedProductionPrepared: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyPOFixedProductionPrepared>(inventoryValue); break; case PlanType.POFixedProductionOrders: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyPOFixedProductionOrders>(inventoryValue); break; case PlanType.ProductionDemandPrepared: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyProductionDemandPrepared>(inventoryValue); break; case PlanType.ProductionDemand: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyProductionDemand>(inventoryValue); break; case PlanType.ProductionAllocated: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyProductionAllocated>(inventoryValue); break; case PlanType.SOFixedProduction: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtySOFixedProduction>(inventoryValue); break; case PlanType.ProdFixedPurchase: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyProdFixedPurchase>(inventoryValue); break; case PlanType.ProdFixedProduction: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyProdFixedProduction>(inventoryValue); break; case PlanType.ProdFixedProdOrdersPrepared: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyProdFixedProdOrdersPrepared>(inventoryValue); break; case PlanType.ProdFixedProdOrders: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyProdFixedProdOrders>(inventoryValue); break; case PlanType.ProdFixedSalesOrdersPrepared: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyProdFixedSalesOrdersPrepared>(inventoryValue); break; case PlanType.ProdFixedSalesOrders: newRow.Quantities[colAttributeIndex] = GetQty <INSiteStatus.qtyProdFixedSalesOrders>(inventoryValue); break; default: throw new PXArgumentException(nameof(Header.Current.DisplayPlanType)); } }
protected abstract void FillInventoryMatrixItem(EntryMatrix newRow, int colAttributeIndex, InventoryMapValue inventoryValue);
public virtual MatrixInventoryItem CreateMatrixItemFromTemplate( EntryMatrix row, int attributeNumber, InventoryItem template, List<INMatrixGenerationRule> idGenRules, List<INMatrixGenerationRule> descrGenRules) { int? inventoryId = GetValueFromArray(row?.InventoryIDs, attributeNumber); bool? selected = GetValueFromArray(row?.Selected, attributeNumber); if (inventoryId != null || selected != true) return null; var currentHeader = (EntryHeader)_graph.Caches[typeof(EntryHeader)].Current; var currentAdditionalAttr = (AdditionalAttributes)_graph.Caches[typeof(AdditionalAttributes)].Current; var matrixCache = _graph.Caches[typeof(MatrixInventoryItem)]; var newItem = PropertyTransfer.Transfer(template, new MatrixInventoryItem()); List<string> attributes = new List<string>(currentAdditionalAttr?.AttributeIdentifiers); attributes.Add(currentHeader?.RowAttributeID); attributes.Add(currentHeader?.ColAttributeID); List<string> attrValues = new List<string>(currentAdditionalAttr?.Values); attrValues.Add(row.RowAttributeValue); attrValues.Add(GetValueFromArray(row?.ColAttributeValues, attributeNumber)); List<string> attrValueDescrs = new List<string>(currentAdditionalAttr?.Descriptions); attrValueDescrs.Add(row.RowAttributeValueDescr); attrValueDescrs.Add(GetValueFromArray(row?.ColAttributeValueDescrs, attributeNumber)); newItem.AttributeIDs = attributes.ToArray(); newItem.AttributeValues = attrValues.ToArray(); newItem.AttributeValueDescrs = attrValueDescrs.ToArray(); object newCD = GenerateMatrixItemID(template, idGenRules, newItem); matrixCache.RaiseFieldUpdating<MatrixInventoryItem.inventoryCD>(newItem, ref newCD); newItem.InventoryCD = (string)newCD; object newDescr = GenerateMatrixItemID(template, descrGenRules, newItem); matrixCache.RaiseFieldUpdating<MatrixInventoryItem.descr>(newItem, ref newDescr); newItem.Descr = (string)newDescr; if (PXDBLocalizableStringAttribute.IsEnabled) { PXCache templateCache = _graph.Caches<InventoryItem>(); var oldDescr = template.Descr; DBMatrixLocalizableDescriptionAttribute.CopyTranslations<InventoryItem.descr, MatrixInventoryItem.descr> (templateCache, template, matrixCache, newItem, (translation) => { template.Descr = translation; object newTranslation = GenerateMatrixItemID(template, descrGenRules, newItem); matrixCache.RaiseFieldUpdating<MatrixInventoryItem.descr>(newItem, ref newTranslation); return (string)newTranslation; }); template.Descr = oldDescr; } newItem.Exists = (InventoryItem.UK.Find(_graph, newItem.InventoryCD) != null); newItem.Duplicate = matrixCache.Cached.RowCast<MatrixInventoryItem>().Any(mi => mi.InventoryCD == newItem.InventoryCD); newItem.Selected = (newItem.Exists != true && newItem.Duplicate != true); newItem.IsTemplate = false; return newItem; }