protected override PMCommitment FromRecord(PXCache sender, object row) { POLineUOpen poline = (POLineUOpen)row; POOrder order = (POOrder)PXParentAttribute.SelectParent(sender.Graph.Caches[detailEntity], row, typeof(POOrder)); PMCommitment commitment = new PMCommitment(); commitment.Type = PMCommitmentType.Internal; commitment.CommitmentID = poline.CommitmentID ?? Guid.NewGuid(); commitment.AccountGroupID = GetAccountGroup(sender, row); commitment.ProjectID = poline.ProjectID; commitment.ProjectTaskID = poline.TaskID; commitment.UOM = poline.UOM; commitment.Qty = poline.OrderQty; commitment.Amount = poline.ExtCost; commitment.OpenQty = poline.OpenQty; commitment.OpenAmount = poline.OpenAmt; commitment.ReceivedQty = poline.ReceivedQty; commitment.InvoicedQty = 0; commitment.InvoicedAmount = 0; commitment.InvoicedIsReadonly = true; commitment.RefNoteID = order.NoteID; commitment.InventoryID = poline.InventoryID ?? PMInventorySelectorAttribute.EmptyInventoryID; commitment.CostCodeID = poline.CostCodeID ?? CostCodeAttribute.GetDefaultCostCode(); return(commitment); }
protected override PMCommitment FromRecord(PXCache sender, object row) { SOMiscLine2 line = (SOMiscLine2)row; SOOrder order = (SOOrder)PXParentAttribute.SelectParent(sender.Graph.Caches[detailEntity], row, typeof(SOOrder)); int sign = line.Operation == SOOperation.Issue ? 1 : -1; PMCommitment commitment = new PMCommitment(); commitment.Type = PMCommitmentType.Internal; commitment.CommitmentID = line.CommitmentID ?? Guid.NewGuid(); commitment.AccountGroupID = GetAccountGroup(sender, row); commitment.ProjectID = line.ProjectID; commitment.ProjectTaskID = line.TaskID; commitment.UOM = line.UOM; commitment.Qty = sign * line.OrderQty; commitment.Amount = sign * line.LineAmt; commitment.OpenQty = sign * line.UnbilledQty; commitment.OpenAmount = sign * line.UnbilledAmt; commitment.ReceivedQty = 0; commitment.InvoicedQty = 0; commitment.InvoicedAmount = 0; commitment.InvoicedIsReadonly = true; commitment.RefNoteID = order.NoteID; commitment.InventoryID = line.InventoryID ?? PMInventorySelectorAttribute.EmptyInventoryID; commitment.CostCodeID = line.CostCodeID ?? CostCodeAttribute.GetDefaultCostCode(); return(commitment); }
protected virtual void DeleteCommitment(PXCache sender, Guid?commitmentID) { if (commitmentID != null) { PMCommitment commitment = PXSelect <PMCommitment, Where <PMCommitment.commitmentID, Equal <Required <PMCommitment.commitmentID> > > > .Select(sender.Graph, commitmentID); if (commitment != null) { sender.Graph.Caches[typeof(PMCommitment)].Delete(commitment); } } }
protected virtual void ProjectBalanceFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { ProjectBalanceFilter row = e.Row as ProjectBalanceFilter; if (row != null) { PMCommitment summary = Totals.Select(); if (summary != null) { row.Qty = summary.Qty.GetValueOrDefault(); row.Amount = summary.Amount.GetValueOrDefault(); row.OpenQty = summary.OpenQty.GetValueOrDefault(); row.OpenAmount = summary.OpenAmount.GetValueOrDefault(); row.ReceivedQty = summary.ReceivedQty.GetValueOrDefault(); row.InvoicedQty = summary.InvoicedQty.GetValueOrDefault(); row.InvoicedAmount = summary.InvoicedAmount.GetValueOrDefault(); } } }
private static void AddInvoicedBase(PXCache sender, PMCommitment container) { PMCommitment commitment = (PMCommitment)sender.Graph.Caches[typeof(PMCommitment)].Locate(container); if (commitment == null) { commitment = PXSelect <PMCommitment, Where <PMCommitment.commitmentID, Equal <Required <PMCommitment.commitmentID> > > > .Select(sender.Graph, container.CommitmentID); } if (commitment != null) { decimal quantity = container.InvoicedQty.GetValueOrDefault(); if (commitment.UOM != container.UOM) { if (PXAccess.FeatureInstalled <FeaturesSet.multipleUnitMeasure>()) { decimal inBase = IN.INUnitAttribute.ConvertToBase(sender.Graph.Caches[typeof(PMCommitment)], commitment.InventoryID, container.UOM, quantity, IN.INPrecision.QUANTITY); try { quantity = IN.INUnitAttribute.ConvertFromBase(sender.Graph.Caches[typeof(PMCommitment)], commitment.InventoryID, commitment.UOM, inBase, IN.INPrecision.QUANTITY); } catch (PX.Objects.IN.PXUnitConversionException ex) { IN.InventoryItem item = PXSelectorAttribute.Select(sender.Graph.Caches[typeof(PMCommitment)], commitment, "inventoryID") as IN.InventoryItem; string msg = PXMessages.LocalizeFormatNoPrefixNLA(Messages.UnitConversionNotDefinedForItemOnBudgetUpdate, item?.BaseUnit, commitment.UOM, item?.InventoryCD); throw new PXException(msg, ex); } } else { quantity = IN.INUnitAttribute.ConvertGlobalUnits(sender.Graph, container.UOM, commitment.UOM, quantity, IN.INPrecision.QUANTITY); } } commitment.InvoicedAmount += container.InvoicedAmount.GetValueOrDefault(); commitment.InvoicedQty += quantity; sender.Graph.Caches[typeof(PMCommitment)].Update(commitment); } }
public static void AddToInvoiced(PXCache sender, PMCommitment container) { PMCommitmentAttribute commitmentAttribute = null; foreach (PXEventSubscriberAttribute attr in sender.GetAttributesReadonly("commitmentID")) { if (attr is PMCommitmentAttribute) { commitmentAttribute = (PMCommitmentAttribute)attr; break; } } if (commitmentAttribute != null) { commitmentAttribute.AddInvoiced(sender, container); } else { AddInvoicedBase(sender, container); } }
protected override PMCommitment FromRecord(PXCache sender, object row) { SOLine4 line = (SOLine4)row; SOOrder order = (SOOrder)PXParentAttribute.SelectParent(sender.Graph.Caches[detailEntity], row, typeof(SOOrder)); int sign = line.Operation == SOOperation.Issue ? 1 : -1; PMCommitment commitment = new PMCommitment(); commitment.Type = PMCommitmentType.Internal; commitment.CommitmentID = (Guid?)sender.GetValue(row, "CommitmentID") ?? Guid.NewGuid(); commitment.AccountGroupID = GetAccountGroup(sender, row); commitment.ProjectID = (int?)sender.GetValue(row, "ProjectID"); commitment.ProjectTaskID = (int?)sender.GetValue(row, "TaskID"); commitment.UOM = line.UOM; commitment.OrigQty = sign * line.OrderQty; commitment.OrigAmount = sign * (decimal?)sender.GetValue(row, "LineAmt"); commitment.Qty = sign * line.OrderQty; commitment.Amount = sign * (decimal?)sender.GetValue(row, "LineAmt"); if (order.Hold == true || order.Cancelled == true) { //Back Order put on Hold. commitment.OpenQty = 0; commitment.OpenAmount = 0; } else { commitment.OpenQty = sign * line.OpenQty; commitment.OpenAmount = sign * line.OpenAmt; } commitment.ReceivedQty = sign * line.ShippedQty; commitment.InvoicedQty = 0; commitment.InvoicedAmount = 0; commitment.InvoicedIsReadonly = true; commitment.RefNoteID = order.NoteID; commitment.InventoryID = line.InventoryID ?? PMInventorySelectorAttribute.EmptyInventoryID; return(commitment); }
protected override PMCommitment FromRecord(PXCache sender, object row) { POLine poline = (POLine)row; POOrder order = (POOrder)PXParentAttribute.SelectParent(sender.Graph.Caches[detailEntity], row, typeof(POOrder)); PMCommitment commitment = new PMCommitment(); commitment.Type = PMCommitmentType.Internal; commitment.CommitmentID = poline.CommitmentID ?? Guid.NewGuid(); commitment.AccountGroupID = GetAccountGroup(sender, row); commitment.ProjectID = poline.ProjectID; commitment.ProjectTaskID = poline.TaskID; commitment.UOM = poline.UOM; if (poline.OrigExtCost == null) { commitment.OrigQty = poline.OrderQty; commitment.OrigAmount = poline.ExtCost + poline.RetainageAmt.GetValueOrDefault(); } else { commitment.OrigQty = poline.OrigOrderQty; commitment.OrigAmount = poline.OrigExtCost; } commitment.Qty = poline.OrderQty; commitment.Amount = poline.ExtCost + poline.RetainageAmt.GetValueOrDefault(); commitment.OpenQty = CalculateOpenQty(poline.OpenQty, poline.UnbilledQty); commitment.OpenAmount = CalculateOpenAmount(commitment.OpenQty, poline.OrderQty, poline.ExtCost, poline.UnbilledAmt); commitment.ReceivedQty = CalculateReceivedQty(poline.CompletedQty, poline.BilledQty); commitment.InvoicedQty = 0; commitment.InvoicedAmount = 0; commitment.InvoicedIsReadonly = true; commitment.RefNoteID = order.NoteID; commitment.InventoryID = poline.InventoryID ?? PMInventorySelectorAttribute.EmptyInventoryID; commitment.CostCodeID = poline.CostCodeID ?? CostCodeAttribute.GetDefaultCostCode(); return(commitment); }
public virtual void ProcessSOCommitments(PMProject project) { foreach (PXResult <SOLine, SOOrder> res in solines.Select(project.ContractID)) { SOLine soline = (SOLine)res; SOOrder order = (SOOrder)res; PXParentAttribute.SetParent(solines.Cache, soline, typeof(SOOrder), order); PMCommitmentAttribute.Sync(solines.Cache, soline); } foreach (ARTran tran in artran.Select(project.ContractID)) { SOLine soline = new SOLine(); soline.OrderType = tran.SOOrderType; soline.OrderNbr = tran.SOOrderNbr; soline.LineNbr = tran.SOOrderLineNbr; soline = solines.Locate(soline); if (soline != null && soline.CommitmentID != null) { decimal sign = (tran.DrCr == DrCr.Credit) ? Decimal.One : Decimal.MinusOne; PMCommitment container = new PMCommitment(); container.CommitmentID = soline.CommitmentID; container.UOM = tran.UOM; container.InventoryID = tran.InventoryID; container.CostCodeID = tran.CostCodeID.GetValueOrDefault(CostCodeAttribute.GetDefaultCostCode()); container.InvoicedAmount = sign * tran.TranAmt.GetValueOrDefault(); container.InvoicedQty = sign * tran.Qty.GetValueOrDefault(); PMCommitmentAttribute.AddToInvoiced(solines.Cache, container); } } }
public virtual void ProcessPOCommitments(PMProject project) { foreach (PXResult <POLine, POOrder> res in polines.Select(project.ContractID)) { POLine poline = (POLine)res; POOrder order = (POOrder)res; PXParentAttribute.SetParent(polines.Cache, poline, typeof(POOrder), order); PMCommitmentAttribute.Sync(polines.Cache, poline); } foreach (APTran tran in aptran.Select(project.ContractID)) { POLine poline = new POLine(); poline.OrderType = tran.POOrderType; poline.OrderNbr = tran.PONbr; poline.LineNbr = tran.POLineNbr; poline = polines.Locate(poline); if (poline != null && poline.CommitmentID != null) { decimal sign = (tran.DrCr == DrCr.Debit) ? Decimal.One : Decimal.MinusOne; PMCommitment container = new PMCommitment(); container.CommitmentID = poline.CommitmentID; container.UOM = tran.UOM; container.InventoryID = tran.InventoryID; container.CostCodeID = tran.CostCodeID.GetValueOrDefault(CostCodeAttribute.GetDefaultCostCode()); container.InvoicedAmount = sign * tran.LineAmt.GetValueOrDefault(); container.InvoicedQty = sign * tran.Qty.GetValueOrDefault(); PMCommitmentAttribute.AddToInvoiced(polines.Cache, container); } } }
protected virtual void AddInvoiced(PXCache sender, PMCommitment container) { AddInvoicedBase(sender, container); }
protected virtual void SyncCommitment(PXCache sender, object row, bool skipCommitmentSelect) { if (!IsCommitmentTrackingEnabled(sender)) { return; } PXCache detailCache = sender.Graph.Caches[detailEntity]; Guid? commitmentID = (Guid?)detailCache.GetValue(row, FieldOrdinal); if (EraseCommitment(sender, row)) { DeleteCommitment(sender, commitmentID); detailCache.SetValue(row, FieldOrdinal, null); detailCache.SmartSetStatus(row, PXEntryStatus.Updated); } else { int?accountGroup = GetAccountGroup(sender, row); PMCommitment commitment = null; if (!skipCommitmentSelect && commitmentID != null) { commitment = PXSelect <PMCommitment, Where <PMCommitment.commitmentID, Equal <Required <PMCommitment.commitmentID> > > > .Select(sender.Graph, commitmentID); } if (commitment == null) { commitment = FromRecord(sender, row); sender.Graph.Caches[typeof(PMCommitment)].Insert(commitment); if (commitment.CommitmentID != commitmentID) { detailCache.SetValue(row, FieldOrdinal, commitment.CommitmentID); detailCache.SmartSetStatus(row, PXEntryStatus.Updated); } } else { PMCommitment container = FromRecord(sender, row); commitment.AccountGroupID = accountGroup; commitment.ProjectID = container.ProjectID; commitment.ProjectTaskID = container.TaskID; commitment.UOM = container.UOM; commitment.Qty = container.Qty; commitment.Amount = container.Amount; commitment.ReceivedQty = container.ReceivedQty; commitment.OpenQty = container.OpenQty; commitment.OpenAmount = container.OpenAmount; if (container.InvoicedIsReadonly != true) { commitment.InvoicedQty = container.InvoicedQty; commitment.InvoicedAmount = container.InvoicedAmount; } commitment.InvoicedIsReadonly = container.InvoicedIsReadonly; commitment.RefNoteID = container.RefNoteID; commitment.InventoryID = container.InventoryID; commitment.CostCodeID = container.CostCodeID; sender.Graph.Caches[typeof(PMCommitment)].Update(commitment); } } }