Exemple #1
0
        public static void ReleaseDoc(List <POReceipt> list, bool aIsMassProcess)
        {
            POReceiptEntry            docgraph        = PXGraph.CreateInstance <POReceiptEntry>();
            DocumentList <INRegister> created         = new DocumentList <INRegister>(docgraph);
            DocumentList <APInvoice>  invoicesCreated = new DocumentList <APInvoice>(docgraph);
            INReceiptEntry            iRe             = null;
            INIssueEntry iIe = null;

            AP.APInvoiceEntry apInvoiceGraph = PXGraph.CreateInstance <APInvoiceEntry>();
            int  iRow   = 0;
            bool failed = false;

            foreach (POReceipt order in list)
            {
                try
                {
                    switch (order.ReceiptType)
                    {
                    case POReceiptType.POReceipt:
                    case POReceiptType.TransferReceipt:
                        if (iRe == null)
                        {
                            iRe = docgraph.CreateReceiptEntry();
                        }
                        docgraph.ReleaseReceipt(iRe, apInvoiceGraph, order, created, invoicesCreated, aIsMassProcess);
                        break;

                    case POReceiptType.POReturn:
                        if (iIe == null)
                        {
                            iIe = docgraph.CreateIssueEntry();
                        }
                        docgraph.ReleaseReturn(iIe, apInvoiceGraph, order, created, invoicesCreated, aIsMassProcess);
                        break;
                    }
                    PXProcessing <POReceipt> .SetInfo(iRow, ActionsMessages.RecordProcessed);
                }
                catch (Exception e)
                {
                    if (aIsMassProcess)
                    {
                        PXProcessing <POReceipt> .SetError(iRow, e);

                        failed = true;
                    }
                    else
                    {
                        throw;
                    }
                }
                iRow++;
            }
            if (failed)
            {
                throw new PXException(Messages.ReleaseOfOneOrMoreReceiptsHasFailed);
            }
        }
        public static void Redirect(PXGraph graph, CABankTranMatch match)
        {
            if (match.DocModule == GL.BatchModule.AP && match.DocType == CATranType.CABatch && match.DocRefNbr != null)
            {
                CABatchEntry docGraph = PXGraph.CreateInstance <CABatchEntry>();
                docGraph.Clear();
                docGraph.Document.Current = PXSelect <CABatch, Where <CABatch.batchNbr, Equal <Required <CATran.origRefNbr> > > > .Select(docGraph, match.DocRefNbr);

                throw new PXRedirectRequiredException(docGraph, true, "Document")
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };
            }
            else if (match.CATranID != null)
            {
                CATran catran = PXSelect <CATran, Where <CATran.tranID, Equal <Required <CABankTranMatch.cATranID> > > > .Select(graph, match.CATranID);

                CATran.Redirect(null, catran);
            }
            else if (match.DocModule != null && match.DocType != null && match.DocRefNbr != null)
            {
                if (match.DocModule == GL.BatchModule.AP)
                {
                    AP.APInvoiceEntry docGraph = PXGraph.CreateInstance <AP.APInvoiceEntry>();
                    docGraph.Clear();
                    AP.APInvoice invoice = PXSelect <AP.APInvoice, Where <AP.APInvoice.refNbr, Equal <Required <CABankTranMatch.docRefNbr> >, And <AP.APInvoice.docType, Equal <Required <CABankTranMatch.docType> > > > > .Select(docGraph, match.DocRefNbr, match.DocType);

                    docGraph.Document.Current = invoice;
                    throw new PXRedirectRequiredException(docGraph, true, "Document")
                          {
                              Mode = PXBaseRedirectException.WindowMode.NewWindow
                          };
                }
                else if (match.DocModule == GL.BatchModule.AR)
                {
                    AR.ARInvoiceEntry docGraph = PXGraph.CreateInstance <AR.ARInvoiceEntry>();
                    docGraph.Clear();
                    AR.ARInvoice invoice = PXSelect <AR.ARInvoice, Where <AR.ARInvoice.refNbr, Equal <Required <CABankTranMatch.docRefNbr> >, And <AR.ARInvoice.docType, Equal <Required <CABankTranMatch.docType> > > > > .Select(docGraph, match.DocRefNbr, match.DocType);

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