Exemplo n.º 1
0
 protected override IEnumerable SelectDelegate()
 {
     if (_Graph.Caches[typeof(TParentEntity)].Current != null)
     {
         if (!String.IsNullOrEmpty(Convert.ToString(_Graph.Caches[typeof(TParentEntity)].GetValue(_Graph.Caches[typeof(TParentEntity)].Current,
                                                                                                  typeof(TParentField).Name))))
         {
             _Graph.Caches[typeof(TEntity)].Current = _Graph.Views["InventoryLotSerialContainer"].SelectSingle();
             if (_Graph.Caches[typeof(TEntity)].Current != null)
             {
                 PXParentAttribute.SetParent(_Graph.Caches[typeof(TEntity)], _Graph.Caches[typeof(TEntity)].Current,
                                             typeof(TParentEntity), _Graph.Caches[typeof(TParentEntity)].Current);
             }
         }
         else
         {
             _Graph.Caches[typeof(TEntity)].Current = null;
         }
     }
     else
     {
         _Graph.Caches[typeof(TEntity)].Current = null;
     }
     return(base.SelectDelegate());
 }
        public static bool TryAggregateToFirstSuitableTran(PXCache sender, GLTran tran, IEnumerable <GLTran> summaryTrans)
        {
            foreach (GLTran summ_tran in summaryTrans)
            {
                PXParentAttribute.SetParent(sender, summ_tran, typeof(Batch), sender.Graph.Caches[typeof(Batch)].Current);

                GLTran copy_tran = PXCache <GLTran> .CreateCopy(summ_tran);

                copy_tran.CuryCreditAmt += tran.CuryCreditAmt;
                copy_tran.CreditAmt     += tran.CreditAmt;
                copy_tran.CuryDebitAmt  += tran.CuryDebitAmt;
                copy_tran.DebitAmt      += tran.DebitAmt;

                if (tran.ZeroPost == false)
                {
                    copy_tran.ZeroPost = false;
                }

                if ((copy_tran.CuryDebitAmt - copy_tran.CuryCreditAmt) > 0m && (copy_tran.DebitAmt - copy_tran.CreditAmt) < 0m ||
                    (copy_tran.CuryDebitAmt - copy_tran.CuryCreditAmt) < 0m && (copy_tran.DebitAmt - copy_tran.CreditAmt) > 0m)
                {
                    continue;
                }

                PostGraph.NormalizeAmounts(copy_tran);

                if (copy_tran.CuryDebitAmt == 0m &&
                    copy_tran.CuryCreditAmt == 0m &&
                    copy_tran.DebitAmt == 0m &&
                    copy_tran.CreditAmt == 0m &&
                    copy_tran.ZeroPost != true)
                {
                    sender.Delete(copy_tran);
                }
                else
                {
                    if (!object.Equals(copy_tran.TranDesc, tran.TranDesc))
                    {
                        copy_tran.TranDesc = Messages.SummaryTranDesc;
                    }

                    copy_tran.Qty         = 0m;
                    copy_tran.UOM         = null;
                    copy_tran.InventoryID = null;
                    copy_tran.TranLineNbr = null;

                    sender.Update(copy_tran);
                }
                return(true);
            }
            return(false);
        }
        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);
                }
            }
        }