protected virtual void RedirectToDoc(string aDocType, string aRefNbr)
        {
            Dictionary <string, string> alltypes = new ARDocType.ListAttribute().ValueLabelDic;

            if (new ARInvoiceType.ListAttribute().ValueLabelDic.ContainsKey(aDocType))
            {
                ARInvoice doc = ARDocumentEnq.FindDoc <ARInvoice>(this, aDocType, aRefNbr);
                if (doc != null)
                {
                    ARInvoiceEntry graph = PXGraph.CreateInstance <ARInvoiceEntry>();
                    graph.Document.Current = doc;
                    throw new PXRedirectRequiredException(graph, true, "Document")
                          {
                              Mode = PXBaseRedirectException.WindowMode.NewWindow
                          };
                }
                throw new PXException(Messages.DocumentNotFound, alltypes[aDocType], aRefNbr);
            }
            if (new ARPaymentType.ListAttribute().ValueLabelDic.ContainsKey(aDocType))
            {
                ARPayment doc = ARDocumentEnq.FindDoc <ARPayment>(this, aDocType, aRefNbr);
                if (doc != null)
                {
                    ARPaymentEntry graph = PXGraph.CreateInstance <ARPaymentEntry>();
                    graph.Document.Current = doc;
                    throw new PXRedirectRequiredException(graph, true, "Document")
                          {
                              Mode = PXBaseRedirectException.WindowMode.NewWindow
                          };
                }
                throw new PXException(Messages.DocumentNotFound, alltypes[aDocType], aRefNbr);
            }
            if (new ARCashSaleType.ListAttribute().ValueLabelDic.ContainsKey(aDocType))
            {
                ARCashSale doc = ARDocumentEnq.FindDoc <ARCashSale>(this, aDocType, aRefNbr);
                if (doc != null)
                {
                    ARCashSaleEntry graph = PXGraph.CreateInstance <ARCashSaleEntry>();
                    graph.Document.Current = doc;
                    throw new PXRedirectRequiredException(graph, true, "Document")
                          {
                              Mode = PXBaseRedirectException.WindowMode.NewWindow
                          };
                }
                throw new PXException(Messages.DocumentNotFound, alltypes[aDocType], aRefNbr);
            }
            throw new PXException(Messages.UnknownDocumentType);
        }
Ejemplo n.º 2
0
        protected override List <ARGLDiscrepancyByDocumentEnqResult> SelectDetails()
        {
            var list = new List <ARGLDiscrepancyByDocumentEnqResult>();
            ARGLDiscrepancyByCustomerEnqFilter header = Filter.Current;

            if (header == null ||
                header.BranchID == null ||
                header.PeriodFrom == null ||
                header.CustomerID == null)
            {
                return(list);
            }

            #region AR balances

            ARDocumentEnq graphAR = PXGraph.CreateInstance <ARDocumentEnq>();
            ARDocumentEnq.ARDocumentFilter filterAR = PXCache <ARDocumentEnq.ARDocumentFilter> .CreateCopy(graphAR.Filter.Current);

            filterAR.BranchID             = header.BranchID;
            filterAR.CustomerID           = header.CustomerID;
            filterAR.Period               = header.PeriodFrom;
            filterAR.ARAcctID             = header.AccountID;
            filterAR.SubCD                = header.SubCD;
            filterAR.IncludeChildAccounts = false;
            filterAR.IncludeGLTurnover    = true;
            filterAR = graphAR.Filter.Update(filterAR);

            Dictionary <ARDocKey, ARGLDiscrepancyByDocumentEnqResult> dict = new Dictionary <ARDocKey, ARGLDiscrepancyByDocumentEnqResult>();
            foreach (ARDocumentResult document in graphAR.Documents.Select())
            {
                var result = new ARGLDiscrepancyByDocumentEnqResult {
                    XXTurnover = (document.ARTurnover ?? 0m)
                };
                PXCache <ARDocumentResult> .RestoreCopy(result, document);

                if (header.ShowOnlyWithDiscrepancy != true || result.Discrepancy != 0m)
                {
                    list.Add(result);
                }
            }

            return(list);

            #endregion
        }