Esempio n. 1
0
        public static PXGraph FindSourceDocumentGraph(CCProcTran tran)
        {
            PXGraph target = null;

            if (tran != null)
            {
                if (tran.DocType == ARDocType.CashSale || tran.DocType == ARDocType.Payment)
                {
                    if (tran.DocType == ARDocType.Payment)
                    {
                        ARPaymentEntry graph = PXGraph.CreateInstance <ARPaymentEntry>();
                        graph.Document.Current = graph.Document.Search <ARPayment.refNbr>(tran.RefNbr, tran.DocType);
                        if (graph.Document.Current != null)
                        {
                            target = graph;
                        }
                    }
                    if (tran.DocType == ARDocType.Payment)
                    {
                        ARCashSaleEntry graph = PXGraph.CreateInstance <ARCashSaleEntry>();
                        graph.Document.Current = graph.Document.Search <PX.Objects.AR.Standalone.ARCashSale.refNbr>(tran.RefNbr, tran.DocType);
                        if (graph.Document.Current != null)
                        {
                            target = graph;
                        }
                    }
                }
                if (tran.DocType == ARDocType.Invoice)
                {
                    SO.SOInvoiceEntry graph = PXGraph.CreateInstance <SO.SOInvoiceEntry>();
                    graph.Document.Current = graph.Document.Search <ARInvoice.refNbr>(tran.RefNbr, tran.DocType);
                    if (graph.Document.Current != null)
                    {
                        target = graph;
                    }
                }
                if (target == null && !String.IsNullOrEmpty(tran.OrigRefNbr))
                {
                    SO.SOOrderEntry graph = PXGraph.CreateInstance <SO.SOOrderEntry>();
                    graph.Document.Current = graph.Document.Search <SO.SOOrder.orderNbr>(tran.OrigRefNbr, tran.OrigDocType);
                    if (graph.Document.Current != null)
                    {
                        target = graph;
                    }
                }
            }
            return(target);
        }
Esempio n. 2
0
        public static PXGraph FindSourceDocumentGraph(string docType, string refNbr, string origDocType, string origRefNbr)
        {
            PXGraph target = null;

            if (docType == ARDocType.Payment || docType == ARDocType.VoidPayment)
            {
                ARPaymentEntry graph = PXGraph.CreateInstance <ARPaymentEntry>();
                graph.Document.Current = graph.Document.Search <ARPayment.refNbr>(refNbr, docType);
                if (graph.Document.Current != null)
                {
                    target = graph;
                }
            }
            if (docType == ARDocType.CashSale)
            {
                ARCashSaleEntry graph = PXGraph.CreateInstance <ARCashSaleEntry>();
                graph.Document.Current = graph.Document.Search <Standalone.ARCashSale.refNbr>(refNbr, docType);
                if (graph.Document.Current != null)
                {
                    target = graph;
                }
            }
            if (docType == ARDocType.Invoice)
            {
                SO.SOInvoiceEntry graph = PXGraph.CreateInstance <SO.SOInvoiceEntry>();
                graph.Document.Current = graph.Document.Search <ARInvoice.refNbr>(refNbr, docType);
                if (graph.Document.Current != null)
                {
                    target = graph;
                }
            }
            if (target == null && !string.IsNullOrEmpty(origRefNbr))
            {
                SO.SOOrderEntry graph = PXGraph.CreateInstance <SO.SOOrderEntry>();
                graph.Document.Current = graph.Document.Search <SO.SOOrder.orderNbr>(origRefNbr, origDocType);
                if (graph.Document.Current != null)
                {
                    target = graph;
                }
            }
            return(target);
        }
Esempio n. 3
0
        public static void Redirect(PXCache sender, CATran catran)
        {
            if (catran == null)
            {
                return;
            }
            if (catran.OrigTranType == CAAPARTranType.GLEntry)
            {
                JournalEntry graph = PXGraph.CreateInstance <JournalEntry>();
                graph.Clear();
                if (sender != null)
                {
                    sender.IsDirty = false;
                }
                graph.BatchModule.Current = PXSelect <Batch, Where <Batch.module, Equal <Required <Batch.module> >, And <Batch.batchNbr, Equal <Required <Batch.batchNbr> > > > > .Select(graph, catran.OrigModule, catran.OrigRefNbr);

                throw new PXRedirectRequiredException(graph, true, "Document")
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };
            }
            else if (catran.OrigModule == GL.BatchModule.AP && (catran.OrigTranType == AP.APDocType.QuickCheck || catran.OrigTranType == AP.APDocType.VoidQuickCheck))
            {
                APQuickCheckEntry graph = PXGraph.CreateInstance <APQuickCheckEntry>();
                graph.Clear();
                if (sender != null)
                {
                    sender.IsDirty = false;
                }
                graph.Document.Current = PXSelect <APQuickCheck, Where <APQuickCheck.refNbr, Equal <Required <APQuickCheck.refNbr> >,
                                                                        And <APQuickCheck.docType, Equal <Required <APQuickCheck.docType> > > > > .Select(graph, catran.OrigRefNbr, catran.OrigTranType);

                throw new PXRedirectRequiredException(graph, true, "Document")
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };
            }
            else if (catran.OrigModule == GL.BatchModule.AP && catran.OrigTranType == CATranType.CABatch)
            {
                CABatchEntry graph = PXGraph.CreateInstance <CABatchEntry>();
                graph.Clear();
                if (sender != null)
                {
                    sender.IsDirty = false;
                }
                graph.Document.Current = PXSelect <CABatch, Where <CABatch.batchNbr, Equal <Required <CATran.origRefNbr> > > > .Select(graph, catran.OrigRefNbr);

                throw new PXRedirectRequiredException(graph, true, "Document")
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };
            }
            else if (catran.OrigModule == GL.BatchModule.AP)
            {
                APPaymentEntry graph = PXGraph.CreateInstance <APPaymentEntry>();
                graph.Clear();
                if (sender != null)
                {
                    sender.IsDirty = false;
                }
                graph.Document.Current = (APPayment)PXSelect <APPayment, Where <APPayment.refNbr, Equal <Required <APPayment.refNbr> >,
                                                                                And <APPayment.docType, Equal <Required <APPayment.docType> > > > > .Select(graph, catran.OrigRefNbr, catran.OrigTranType);

                throw new PXRedirectRequiredException(graph, true, "Document")
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };
            }
            else if (catran.OrigModule == GL.BatchModule.AR && (catran.OrigTranType == ARDocType.CashSale || catran.OrigTranType == ARDocType.CashReturn))
            {
                ARCashSale document = (ARCashSale)PXSelect <ARCashSale, Where <ARCashSale.refNbr, Equal <Required <ARCashSale.refNbr> >,
                                                                               And <ARCashSale.docType, Equal <Required <ARCashSale.docType> > > > > .Select(sender.Graph, catran.OrigRefNbr, catran.OrigTranType);

                if (document.OrigModule == BatchModule.SO && document.Released == false)
                {
                    SO.SOInvoiceEntry graph = PXGraph.CreateInstance <SO.SOInvoiceEntry>();
                    graph.Clear();
                    sender.IsDirty = false;

                    graph.Document.Current = (ARInvoice)PXSelect <ARInvoice, Where <ARInvoice.refNbr, Equal <Required <ARInvoice.refNbr> >,
                                                                                    And <ARInvoice.docType, Equal <Required <ARInvoice.docType> > > > > .Select(sender.Graph, catran.OrigRefNbr, catran.OrigTranType);

                    throw new PXRedirectRequiredException(graph, true, "Document")
                          {
                              Mode = PXBaseRedirectException.WindowMode.NewWindow
                          };
                }
                else
                {
                    ARCashSaleEntry graph = PXGraph.CreateInstance <ARCashSaleEntry>();
                    graph.Clear();
                    if (sender != null)
                    {
                        sender.IsDirty = false;
                    }

                    graph.Document.Current = document;
                    throw new PXRedirectRequiredException(graph, true, "Document")
                          {
                              Mode = PXBaseRedirectException.WindowMode.NewWindow
                          };
                }
            }
            else if (catran.OrigModule == GL.BatchModule.AR)
            {
                ARPaymentEntry graph = PXGraph.CreateInstance <ARPaymentEntry>();
                graph.Clear();
                if (sender != null)
                {
                    sender.IsDirty = false;
                }
                graph.Document.Current = (ARPayment)PXSelect <ARPayment, Where <ARPayment.refNbr, Equal <Required <ARPayment.refNbr> >,
                                                                                And <ARPayment.docType, Equal <Required <ARPayment.docType> > > > > .Select(graph, catran.OrigRefNbr, catran.OrigTranType);

                throw new PXRedirectRequiredException(graph, true, "Document")
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };
            }
            else if (catran.OrigModule == GL.BatchModule.CA && catran.OrigTranType == CATranType.CAAdjustment)
            {
                CATranEntry graph = PXGraph.CreateInstance <CATranEntry>();
                graph.Clear();
                if (sender != null)
                {
                    sender.IsDirty = false;
                }
                graph.CAAdjRecords.Current = PXSelect <CAAdj, Where <CAAdj.tranID, Equal <Required <CAAdj.tranID> > > > .Select(graph, catran.TranID);

                throw new PXRedirectRequiredException(graph, true, "Document")
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };
            }
            else if (catran.OrigModule == GL.BatchModule.CA && catran.OrigTranType == CATranType.CATransferExp)
            {
                CATranEntry graph = PXGraph.CreateInstance <CATranEntry>();
                graph.Clear();
                if (sender != null)
                {
                    sender.IsDirty = false;
                }
                graph.CAAdjRecords.Current = PXSelect <CAAdj, Where <CAAdj.adjTranType, Equal <CAAPARTranType.cATransferExp>, And <CAAdj.transferNbr, Equal <Required <CATran.origRefNbr> > > > > .Select(graph, catran.OrigRefNbr);

                throw new PXRedirectRequiredException(graph, true, "Document")
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };
            }
            else if (catran.OrigModule == GL.BatchModule.CA)
            {
                if (catran.OrigTranType == CATranType.CADeposit || catran.OrigTranType == CATranType.CAVoidDeposit)
                {
                    CADepositEntry graph = PXGraph.CreateInstance <CADepositEntry>();
                    graph.Clear();
                    if (sender != null)
                    {
                        sender.IsDirty = false;
                    }
                    graph.Document.Current = PXSelect <CADeposit, Where <CADeposit.tranType, Equal <Required <CADeposit.tranType> >,
                                                                         And <CADeposit.refNbr, Equal <Required <CADeposit.refNbr> > > > >
                                             .Select(graph, catran.OrigTranType, catran.OrigRefNbr);

                    throw new PXRedirectRequiredException(graph, true, "Document")
                          {
                              Mode = PXBaseRedirectException.WindowMode.NewWindow
                          };
                }
                else
                {
                    CashTransferEntry graph = PXGraph.CreateInstance <CashTransferEntry>();
                    graph.Clear();
                    if (sender != null)
                    {
                        sender.IsDirty = false;
                    }
                    graph.Transfer.Current = PXSelect <CATransfer, Where <CATransfer.tranIDOut, Equal <Required <CATransfer.tranIDOut> >, Or <CATransfer.tranIDIn, Equal <Required <CATransfer.tranIDIn> > > > >
                                             .Select(graph, catran.TranID, catran.TranID);

                    throw new PXRedirectRequiredException(graph, true, "Document")
                          {
                              Mode = PXBaseRedirectException.WindowMode.NewWindow
                          };
                }
            }
        }