public MainWindow() { InitializeComponent(); AllocationItem allocation1 = LoadChartView.Items[0].GanttChartItems[0]; allocation1.Start = DateTime.Today.Add(TimeSpan.Parse("08:00:00")); allocation1.Finish = DateTime.Today.Add(TimeSpan.Parse("16:00:00")); AllocationItem allocation12 = LoadChartView.Items[0].GanttChartItems[1]; allocation12.Start = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("08:00:00")); allocation12.Finish = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("12:00:00")); allocation12.Units = 1.5; AllocationItem allocation2 = LoadChartView.Items[0].GanttChartItems[2]; allocation2.Start = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("12:00:00")); allocation2.Finish = DateTime.Today.AddDays(2).Add(TimeSpan.Parse("16:00:00")); allocation2.Units = 0.5; AllocationItem allocation3 = LoadChartView.Items[0].GanttChartItems[3]; allocation3.Start = DateTime.Today.AddDays(4).Add(TimeSpan.Parse("08:00:00")); allocation3.Finish = DateTime.Today.AddDays(4).Add(TimeSpan.Parse("16:00:00")); }
public virtual Decimal CalcAllocationValue(PXGraph graph, AllocationItem allocationItem, POReceiptLineSplit aSplit, Decimal aBaseTotal, Decimal aAllocationTotal) { var result = CalcAllocationValue(graph, allocationItem, aBaseTotal, aAllocationTotal); result *= ((aSplit.BaseQty / (allocationItem.BaseQty == 0 ? (decimal?)null : allocationItem.BaseQty)) ?? 1); return(result); }
public MainWindow() { InitializeComponent(); LoadChartDataGrid.TimelinePageStart = DateTime.Today; LoadChartDataGrid.TimelinePageFinish = DateTime.Today.AddMonths(2); LoadChartDataGrid.VisibleDayStart = TimeOfDay.Parse("09:00:00"); LoadChartDataGrid.VisibleDayFinish = TimeOfDay.Parse("15:00:00"); AllocationItem allocation11 = LoadChartDataGrid.Items[0].GanttChartItems[0]; allocation11.Start = DateTime.Today.Add(TimeSpan.Parse("08:00:00")); allocation11.Finish = DateTime.Today.Add(TimeSpan.Parse("16:00:00")); AllocationItem allocation112 = LoadChartDataGrid.Items[0].GanttChartItems[1]; allocation112.Start = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("08:00:00")); allocation112.Finish = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("12:00:00")); allocation112.Units = 1.5; AllocationItem allocation12 = LoadChartDataGrid.Items[0].GanttChartItems[2]; allocation12.Start = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("12:00:00")); allocation12.Finish = DateTime.Today.AddDays(2).Add(TimeSpan.Parse("16:00:00")); allocation12.Units = 0.5; AllocationItem allocation13 = LoadChartDataGrid.Items[0].GanttChartItems[3]; allocation13.Start = DateTime.Today.AddDays(4).Add(TimeSpan.Parse("08:00:00")); allocation13.Finish = DateTime.Today.AddDays(4).Add(TimeSpan.Parse("16:00:00")); AllocationItem allocation22 = LoadChartDataGrid.Items[1].GanttChartItems[0]; allocation22.Start = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("08:00:00")); allocation22.Finish = DateTime.Today.AddDays(2).Add(TimeSpan.Parse("16:00:00")); for (int i = 3; i <= 16; i++) { LoadChartItem item = new LoadChartItem { Content = "Resource " + i }; for (int j = 1; j <= (i - 1) % 4 + 1; j++) { item.GanttChartItems.Add( new AllocationItem { Content = "Task " + i + "." + j + (((i + j) % 2 == 1 ? " [200%]" : string.Empty)), Start = DateTime.Today.AddDays(i + (i - 1) * (j - 1)), Finish = DateTime.Today.AddDays(i * 1.2 + (i - 1) * (j - 1) + 1), Units = 1 + (i + j) % 2 }); } LoadChartDataGrid.Items.Add(item); } }
public override Decimal CalcAllocationValue(PXGraph graph, AllocationItem allocationItem, Decimal aBaseTotal, Decimal aAllocationTotal) { Decimal value = Decimal.Zero; if (IsApplicable(graph, allocationItem.LandedCostCode, allocationItem.ReceiptLine)) { Decimal baseShare = GetBaseValue(allocationItem); value = aBaseTotal == 0 ? 0 : (baseShare * aAllocationTotal) / aBaseTotal; } return(value); }
public virtual decimal AllocateOverRCTLine(PXGraph graph, List <POReceiptLineAdjustment> result, POReceiptLine aLine, decimal toDistribute, Int32?branchID) { var allocationItem = new AllocationItem { LandedCostCode = new LandedCostCode(), ReceiptLine = aLine }; allocationItem.LandedCostCode.AllocationMethod = LandedCostAllocationMethod.ByQuantity; var rest = AllocateOverRCTLine(graph, result, allocationItem, toDistribute, branchID); return(rest); }
public virtual POReceiptLineAdjustment CreateReceiptLineAdjustment(AllocationItem allocationItem, POReceiptLine receiptLine, decimal qtyToAssign, int?branchID) { if ((allocationItem == null || allocationItem.ReceiptLine == null) && receiptLine == null) { var emptyReceiptLine = new POReceiptLine(); return(new POReceiptLineAdjustment(emptyReceiptLine, qtyToAssign, branchID)); } var result = new POReceiptLineAdjustment(receiptLine ?? allocationItem.ReceiptLine, qtyToAssign, branchID); return(result); }
private void LoadChartDataGrid_PreviewMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { Point controlPosition = e.GetPosition(LoadChartDataGrid); Point contentPosition = e.GetPosition(LoadChartDataGrid.ChartContentElement); DateTime dateTime = LoadChartDataGrid.GetDateTime(contentPosition.X); LoadChartItem itemRow = LoadChartDataGrid.GetItemAt(contentPosition.Y) as LoadChartItem; AllocationItem item = null; FrameworkElement frameworkElement = e.OriginalSource as FrameworkElement; if (frameworkElement != null) { item = frameworkElement.DataContext as AllocationItem; } if (controlPosition.X < LoadChartDataGrid.ActualWidth - LoadChartDataGrid.GanttChartView.ActualWidth) { return; } string message = String.Empty; if (controlPosition.Y < LoadChartDataGrid.HeaderHeight) { message = string.Format("You have clicked the chart scale header at date and time {0:g}.", dateTime); } else if (item != null) { message = string.Format("You have clicked the allocation item '{0}' of resource item '#{1}' at date and time {2:g}.", item, itemRow.ActualDisplayRowIndex + 1, dateTime > item.Finish ? item.Finish : dateTime); } else if (itemRow != null) { message = string.Format("You have clicked at date and time {0:g} within the row of item '#{1}'.", dateTime, itemRow.ActualDisplayRowIndex + 1); } else { message = string.Format("You have clicked at date and time {0:g} within an empty area of the chart.", dateTime); } NotificationsTextBox.AppendText(string.Format("{0}{1}", NotificationsTextBox.Text.Length > 0 ? "\n" : string.Empty, message)); NotificationsTextBox.ScrollToEnd(); }
public override POReceiptLineAdjustment CreateReceiptLineAdjustment(AllocationItem allocationItem, POReceiptLine receiptLine, decimal qtyToAssign, int?branchID) { if ((allocationItem == null || allocationItem.ReceiptLine == null) && receiptLine == null) { var emptyReceiptLine = new POReceiptLine(); return(new POLandedCostReceiptLineAdjustment(emptyReceiptLine, null, null, qtyToAssign, branchID)); } if (!(allocationItem is LandedCostAllocationItem)) { return(base.CreateReceiptLineAdjustment(allocationItem, receiptLine, qtyToAssign, branchID)); } var lcAllocationItemitem = (LandedCostAllocationItem)allocationItem; var result = new POLandedCostReceiptLineAdjustment(receiptLine ?? allocationItem.ReceiptLine, lcAllocationItemitem.LandedCostReceiptLine, lcAllocationItemitem.LandedCostDetail, qtyToAssign, branchID); return(result); }
public virtual Decimal GetBaseValue(AllocationItem allocationItem) { Decimal value = Decimal.Zero; switch (allocationItem.LandedCostCode.AllocationMethod) { case LandedCostAllocationMethod.ByCost: value = allocationItem.TranCostFinal ?? Decimal.Zero; break; case LandedCostAllocationMethod.ByQuantity: value = allocationItem.BaseQty ?? Decimal.Zero; break; case LandedCostAllocationMethod.ByWeight: value = allocationItem.Weight ?? Decimal.Zero; break; case LandedCostAllocationMethod.ByVolume: value = allocationItem.Volume ?? Decimal.Zero; break; case LandedCostAllocationMethod.None: value = Decimal.One; break; //Line Count default: throw new PXException(Messages.UnknownLCAllocationMethod, allocationItem.LandedCostCode.LandedCostCodeID); } return(value); }
public MainWindow() { InitializeComponent(); AllocationItem allocation11 = LoadChartView.Items[0].GanttChartItems[0]; allocation11.Start = DateTime.Today.Add(TimeSpan.Parse("08:00:00")); allocation11.Finish = DateTime.Today.Add(TimeSpan.Parse("16:00:00")); AllocationItem allocation112 = LoadChartView.Items[0].GanttChartItems[1]; allocation112.Start = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("08:00:00")); allocation112.Finish = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("12:00:00")); allocation112.Units = 1.5; AllocationItem allocation12 = LoadChartView.Items[0].GanttChartItems[2]; allocation12.Start = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("12:00:00")); allocation12.Finish = DateTime.Today.AddDays(2).Add(TimeSpan.Parse("16:00:00")); allocation12.Units = 0.5; AllocationItem allocation13 = LoadChartView.Items[0].GanttChartItems[3]; allocation13.Start = DateTime.Today.AddDays(4).Add(TimeSpan.Parse("08:00:00")); allocation13.Finish = DateTime.Today.AddDays(4).Add(TimeSpan.Parse("16:00:00")); AllocationItem allocation22 = LoadChartView.Items[1].GanttChartItems[0]; allocation22.Start = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("08:00:00")); allocation22.Finish = DateTime.Today.AddDays(2).Add(TimeSpan.Parse("16:00:00")); for (int i = 3; i <= 16; i++) { LoadChartItem item = new LoadChartItem(); for (int j = 1; j <= (i - 1) % 4 + 1; j++) { item.GanttChartItems.Add( new AllocationItem { Content = "Task " + i + "." + j + (((i + j) % 2 == 1 ? " [200%]" : string.Empty) + " (Resource " + i + ")"), Start = DateTime.Today.AddDays(i + (i - 1) * (j - 1)), Finish = DateTime.Today.AddDays(i * 1.2 + (i - 1) * (j - 1) + 1), Units = 1 + (i + j) % 2 }); } LoadChartView.Items.Add(item); } // You may uncomment the next lines of code to test the component performance: // for (int i = 17; i <= 1024; i++) // { // LoadChartItem item = new LoadChartItem(); // for (int j = 1; j <= (i - 1) % 4 + 1; j++) // { // item.GanttChartItems.Add( // new AllocationItem // { // Content = "Task " + i + "." + j + (((i + j) % 2 == 1 ? " [200%]" : string.Empty) + " (Resource " + i + ")"), // Start = DateTime.Today.AddDays(i + (i - 1) * (j - 1)), // Finish = DateTime.Today.AddDays(i * 1.2 + (i - 1) * (j - 1) + 1), // Units = 1 + (i + j) % 2 // }); // } // LoadChartView.Items.Add(item); // } // Initialize the control area. ScalesComboBox.SelectedIndex = 0; ShowWeekendsCheckBox.IsChecked = true; }
public virtual Decimal CalcAllocationValue(PXGraph graph, AllocationItem allocationItem, Decimal aBaseTotal, Decimal aAllocationTotal) { return(aAllocationTotal); }
public virtual decimal AllocateOverRCTLine( PXGraph graph, List <POReceiptLineAdjustment> result, AllocationItem allocationItem, decimal toDistribute, Int32?branchID) { // the artificial object is used for allocating the landed cost amount between splits (by quantity) var nAllocationItem = new AllocationItem() { LandedCostCode = new LandedCostCode() { AllocationMethod = LandedCostAllocationMethod.ByQuantity }, ReceiptLine = allocationItem.ReceiptLine, }; InventoryItem ii = InventoryItem.PK.Find(graph, allocationItem.ReceiptLine.InventoryID.Value); bool requireLotSerial = (ii.ValMethod == INValMethod.Specific); List <Type> bql = new List <Type>(16) { typeof(Select4 <, ,>), typeof(POReceiptLineSplit), typeof(Where <POReceiptLineSplit.receiptType, Equal <Required <POReceiptLine.receiptType> >, And <POReceiptLineSplit.receiptNbr, Equal <Required <POReceiptLine.receiptNbr> >, And <POReceiptLineSplit.lineNbr, Equal <Required <POReceiptLine.lineNbr> > > > >), typeof(Aggregate <>), typeof(GroupBy <,>), typeof(POReceiptLineSplit.locationID), typeof(GroupBy <,>), typeof(POReceiptLineSplit.subItemID), typeof(Sum <>), typeof(POReceiptLineSplit.baseQty), }; if (requireLotSerial) { bql.Insert(bql.Count - 2, typeof(GroupBy <,>)); bql.Insert(bql.Count - 2, typeof(POReceiptLineSplit.lotSerialNbr)); } PXView splitsView = new PXView(graph, false, BqlCommand.CreateInstance(bql.ToArray())); var splits = splitsView.SelectMulti(allocationItem.ReceiptLine.ReceiptType, allocationItem.ReceiptLine.ReceiptNbr, allocationItem.ReceiptLine.LineNbr); bool hasSplits = false; decimal baseTotal = GetBaseValue(nAllocationItem); decimal allocatedBase = 0m; decimal allocatingBase = 0m; decimal allocatedAmt = 0m; POReceiptLineSplit maxSplit = null; foreach (POReceiptLineSplit split in splits) { hasSplits = true; allocatingBase += split.BaseQty ?? 0m; decimal handledSplitsAmt = (baseTotal == 0m) ? 0m : (allocatedBase + allocatingBase) * toDistribute / baseTotal; handledSplitsAmt = PXDBCurrencyAttribute.BaseRound(graph, handledSplitsAmt); decimal shareAmt = handledSplitsAmt - allocatedAmt; if (maxSplit == null || maxSplit.BaseQty < split.BaseQty) { maxSplit = split; } if (shareAmt != 0m) { POReceiptLine newPOReceiptLine = PXCache <POReceiptLine> .CreateCopy(allocationItem.ReceiptLine); newPOReceiptLine.LocationID = maxSplit.LocationID; newPOReceiptLine.SiteID = maxSplit.SiteID; newPOReceiptLine.SubItemID = maxSplit.SubItemID; newPOReceiptLine.LotSerialNbr = requireLotSerial ? maxSplit.LotSerialNbr : null; var adj = CreateReceiptLineAdjustment(allocationItem, newPOReceiptLine, shareAmt, branchID); result.Add(adj); allocatedAmt += shareAmt; allocatedBase += allocatingBase; allocatingBase = 0m; maxSplit = null; } } if (!hasSplits) { decimal shareAmt = toDistribute; shareAmt = PXDBCurrencyAttribute.BaseRound(graph, shareAmt); if (shareAmt != 0m) { var adj = CreateReceiptLineAdjustment(allocationItem, null, shareAmt, branchID); result.Add(adj); } allocatedAmt = shareAmt; } return(allocatedAmt); }