Ejemplo n.º 1
0
        public virtual void CCTransactionsHistoryFilter_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
        {
            CCTransactionsHistoryFilter row    = (CCTransactionsHistoryFilter)e.Row;
            CCTransactionsHistoryFilter oldRow = (CCTransactionsHistoryFilter)e.OldRow;

            if (oldRow.PaymentMethodID != row.PaymentMethodID || oldRow.CardNumber != row.CardNumber || oldRow.PartialCardNumber != row.PartialCardNumber)
            {
                this.RecalcRow(row);
            }
            if (row.MaskedCardNumber != oldRow.MaskedCardNumber || row.DBSearchName != oldRow.DBSearchName)
            {
                PXResult <CustomerPaymentMethod> cnt = PXSelectJoinGroupBy <CustomerPaymentMethod, InnerJoin <Customer,
                                                                                                              On <Customer.bAccountID, Equal <CustomerPaymentMethod.bAccountID> > >,
                                                                            Where <CustomerPaymentMethod.paymentMethodID, Equal <Current <CCTransactionsHistoryFilter.paymentMethodID> >,
                                                                                   And <CustomerPaymentMethod.descr, Like <Optional <CCTransactionsHistoryFilter.maskedCardNumber> >,
                                                                                        And <Customer.acctName, Like <Optional <CCTransactionsHistoryFilter.dBSearchName> >,
                                                                                             And <CustomerPaymentMethod.isActive, Equal <True> > > > >,
                                                                            Aggregate <Count <CustomerPaymentMethod.pMInstanceID> > > .Select(this, row.MaskedCardNumber, row.DBSearchName);

                int count = 0;
                if (cnt != null && cnt.RowCount != null)
                {
                    count             = (int)cnt.RowCount;
                    row.NumberOfCards = cnt.RowCount;
                }
                row.PMInstanceID = count == 1 ? ((CustomerPaymentMethod)cnt).PMInstanceID : null;
            }
        }
Ejemplo n.º 2
0
        public virtual IEnumerable orders()
        {
            foreach (SOOrder order in Orders.Cache.Updated)
            {
                yield return(order);
            }

            foreach (PXResult res in PXSelectJoinGroupBy <SOOrder,
                                                          InnerJoin <SOLine, On <SOLine.orderType, Equal <SOOrder.orderType>, And <SOLine.orderNbr, Equal <SOOrder.orderNbr> > >,
                                                                     InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrder.orderType> >,
                                                                                InnerJoin <SOOrderTypeOperation,
                                                                                           On <SOOrderTypeOperation.orderType, Equal <SOLine.orderType>,
                                                                                               And <SOOrderTypeOperation.operation, Equal <SOLine.operation> > >,
                                                                                           LeftJoin <ARTran, On <ARTran.sOOrderType, Equal <SOLine.orderType>, And <ARTran.sOOrderNbr, Equal <SOLine.orderNbr>, And <ARTran.sOOrderLineNbr, Equal <SOLine.lineNbr> > > >,
                                                                                                     LeftJoin <INTran, On <INTran.sOOrderType, Equal <SOLine.orderType>, And <INTran.sOOrderNbr, Equal <SOLine.orderNbr>, And <INTran.sOOrderLineNbr, Equal <SOLine.lineNbr> > > > > > > > >,
                                                          Where <SOOrder.hold, Equal <boolFalse>,
                                                                 And <SOOrderTypeOperation.iNDocType, NotEqual <INTranType.noUpdate>,
                                                                      And2 <Where <SOOrderType.aRDocType, Equal <ARDocType.noUpdate>, Or <ARTran.refNbr, IsNotNull> >,
                                                                            And <INTran.refNbr, IsNull> > > >,
                                                          Aggregate <GroupBy <SOOrder.orderType, GroupBy <SOOrder.orderNbr> > > > .Select(this))
            {
                SOOrder order;
                if ((order = (SOOrder)Orders.Cache.Locate(res[typeof(SOOrder)])) == null || Orders.Cache.GetStatus(order) == PXEntryStatus.Notchanged)
                {
                    yield return(res[typeof(SOOrder)]);
                }
            }

            Orders.Cache.IsDirty = false;
        }
Ejemplo n.º 3
0
        public virtual IEnumerable languageSearchSettings()
        {
            var cache         = LanguageSearchSettings.Cache;
            var oldDirtyValue = cache.IsDirty;

            foreach (PXResult <SMLanguageSearchSettings, WikiPageLanguage> record in
                     PXSelectJoinGroupBy <SMLanguageSearchSettings,
                                          RightJoin <WikiPageLanguage, On <WikiPageLanguage.language, Equal <SMLanguageSearchSettings.name> > >,
                                          Where <SMLanguageSearchSettings.userID, IsNull,
                                                 Or <SMLanguageSearchSettings.userID, Equal <Current <AccessInfo.userID> > > >,
                                          Aggregate <GroupBy <WikiPageLanguage.language,
                                                              GroupBy <SMLanguageSearchSettings.userID,
                                                                       GroupBy <SMLanguageSearchSettings.active> > > > > .
                     Select(this))
            {
                var langSettings = (SMLanguageSearchSettings)record;
                var pageLanguage = (WikiPageLanguage)record;
                if (langSettings.UserID == null)
                {
                    var fieldValues = new OrderedDictionary
                    {
                        { cache.GetField(typeof(SMLanguageSearchSettings.name)), pageLanguage.Language },
                        { cache.GetField(typeof(SMLanguageSearchSettings.userID)), PXAccess.GetUserID() },
                        { cache.GetField(typeof(SMLanguageSearchSettings.active)), false }
                    };
                    cache.Insert(fieldValues);
                    langSettings = (SMLanguageSearchSettings)cache.Current;
                }
                yield return(langSettings);
            }
            cache.IsDirty = oldDirtyValue;
        }
Ejemplo n.º 4
0
        public virtual IEnumerable orders()
        {
            foreach (PXResult <POReceipt> res in PXSelectJoinGroupBy <POReceipt,
                                                                      LeftJoinSingleTable <Vendor, On <Vendor.bAccountID, Equal <POReceipt.vendorID> >,
                                                                                           InnerJoin <POReceiptLine, On <POReceiptLine.receiptNbr, Equal <POReceipt.receiptNbr> >,
                                                                                                      LeftJoin <APTran, On <APTran.receiptNbr, Equal <POReceiptLine.receiptNbr>,
                                                                                                                            And <APTran.receiptLineNbr, Equal <POReceiptLine.lineNbr> > > > > >,
                                                                      Where2 <Where <Vendor.bAccountID, IsNull, Or <Match <Vendor, Current <AccessInfo.userName> > > >,
                                                                              And <POReceipt.hold, Equal <boolFalse>,
                                                                                   And <POReceipt.released, Equal <boolFalse>,
                                                                                        And <APTran.refNbr, IsNull> > > >,
                                                                      Aggregate <GroupBy <POReceipt.receiptNbr,
                                                                                          GroupBy <POReceipt.receiptType,
                                                                                                   GroupBy <POReceipt.released,
                                                                                                            GroupBy <POReceipt.hold,
                                                                                                                     GroupBy <POReceipt.autoCreateInvoice> > > > > > >
                     .Select(this))
            {
                POReceipt sel = res;
                POReceipt order;
                if ((order = (POReceipt)Orders.Cache.Locate(sel)) != null)
                {
                    sel.Selected = order.Selected;
                }

                yield return(sel);
            }
            Orders.Cache.IsDirty = false;
        }
        private bool PaymentCycleWorkflowIsStartedAndItIsOtherPayment(string paymentDocType, string paymentRefNbr, string origDocType, string origRefNbr)
        {
            PXResult <APInvoice, APAdjust>[] records = PXSelectJoinGroupBy <APInvoice,
                                                                            InnerJoin <APAdjust,
                                                                                       On <APAdjust.adjdDocType, Equal <APInvoice.docType>,
                                                                                           And <APAdjust.adjdRefNbr, Equal <APInvoice.refNbr>,
                                                                                                And <APAdjust.voided, Equal <False> > > > >,
                                                                            Where2 <Where <APAdjust.adjgDocType, Equal <Required <APAdjust.adjgDocType> >,
                                                                                           And <APAdjust.adjgRefNbr, Equal <Required <APAdjust.adjgRefNbr> >,
                                                                                                Or <APInvoiceJCExt.isPaymentCycleWorkflow, Equal <True> > > >,
                                                                                    And <Where <APInvoice.origDocType, Equal <Required <APInvoice.origDocType> >,
                                                                                                And <APInvoice.origRefNbr, Equal <Required <APInvoice.origRefNbr> >,
                                                                                                     And <APInvoice.isRetainageDocument, Equal <True>,
                                                                                                          Or <APInvoice.docType, Equal <Required <APInvoice.docType> >,
                                                                                                              And <APInvoice.refNbr, Equal <Required <APInvoice.refNbr> > > > > > > > >,
                                                                            Aggregate <GroupBy <APInvoiceJCExt.isPaymentCycleWorkflow,
                                                                                                GroupBy <APAdjust.adjgRefNbr,
                                                                                                         GroupBy <APAdjust.adjgDocType> > > > >
                                                       .Select(Graph, paymentDocType, paymentRefNbr, origDocType, origRefNbr, origDocType, origRefNbr)
                                                       .AsEnumerable()
                                                       .Cast <PXResult <APInvoice, APAdjust> >()
                                                       .ToArray();

            return(records.Any(record => ((APInvoice)record).GetExtension <APInvoiceJCExt>().IsPaymentCycleWorkflow == true) &&
                   !records.Any(record =>
            {
                APAdjust adjust = record;
                return adjust.AdjgDocType == paymentDocType && adjust.AdjgRefNbr == paymentRefNbr;
            }));
        }
Ejemplo n.º 6
0
        protected virtual IEnumerable customers()
        {
            BillingFilter filter = Filter.Current;

            if (filter == null)
            {
                yield break;
            }
            bool found = false;

            foreach (CustomersList item in Customers.Cache.Inserted)
            {
                found = true;
                yield return(item);
            }
            if (found)
            {
                yield break;
            }

            PXSelectBase <EPExpenseClaimDetails> sel = new PXSelectJoinGroupBy <EPExpenseClaimDetails, InnerJoin <Customer, On <EPExpenseClaimDetails.customerID, Equal <Customer.bAccountID> >,
                                                                                                                  LeftJoin <Contract, On <EPExpenseClaimDetails.contractID, Equal <Contract.contractID> > > >,
                                                                                Where <EPExpenseClaimDetails.released, Equal <boolTrue>,
                                                                                       And <EPExpenseClaimDetails.billable, Equal <boolTrue>,
                                                                                            And <EPExpenseClaimDetails.billed, Equal <boolFalse>,
                                                                                                 And <EPExpenseClaimDetails.expenseDate, LessEqual <Current <BillingFilter.endDate> > > > > >,
                                                                                Aggregate <GroupBy <EPExpenseClaimDetails.customerID,
                                                                                                    GroupBy <EPExpenseClaimDetails.customerLocationID> > > >(this);

            if (filter.CustomerClassID != null)
            {
                sel.WhereAnd <Where <Customer.customerClassID, Equal <Current <BillingFilter.customerClassID> > > >();
            }
            if (filter.CustomerID != null)
            {
                sel.WhereAnd <Where <Customer.bAccountID, Equal <Current <BillingFilter.customerID> > > >();
            }

            foreach (PXResult <EPExpenseClaimDetails, Customer, Contract> res in sel.Select())
            {
                CustomersList         retitem      = new CustomersList();
                Customer              customer     = res;
                EPExpenseClaimDetails claimdetaisl = res;
                Contract              contract     = (Contract)res;

                if (contract.BaseType == PMProject.ProjectBaseType.Project)
                {
                    continue;
                }


                retitem.CustomerID      = customer.BAccountID;
                retitem.LocationID      = claimdetaisl.CustomerLocationID;
                retitem.CustomerClassID = customer.CustomerClassID;

                retitem.Selected = false;

                yield return(Customers.Insert(retitem));
            }
        }
        protected virtual void PMProject_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            PMProject      pmProjectRow      = (PMProject)e.Row;
            PMProjectSSExt pmProjectSSExtRow = PXCache <PMProject> .GetExtension <PMProjectSSExt>(pmProjectRow);

            pmProjectSSExtRow.SyncedInSmartsheet = pmProjectSSExtRow.UsrSmartsheetContractID != null;

            Dictionary <string, string> fields = new Dictionary <string, string>();

            foreach (PMTemplateListSS pmTemplateListSSRow in PXSelectJoinGroupBy <
                         PMTemplateListSS,
                         InnerJoin <PMSSMapping,
                                    On <PMSSMapping.templateSS, Equal <PMTemplateListSS.templateSS>,
                                        And <PMSSMapping.nameAcu, IsNotNull,
                                             And <PMSSMapping.nameAcu, NotEqual <Required <PMSSMapping.nameAcu> > > > > >,
                         Aggregate <
                             GroupBy <PMTemplateListSS.templateSS> > >
                     .Select(this.Base, ""))
            {
                fields.Add(pmTemplateListSSRow.TemplateSS, pmTemplateListSSRow.TemplateName);
            }
            PXStringListAttribute.SetList <PMProjectSSExt.usrTemplateSS>(sender, pmProjectRow, fields.Keys.ToArray(), fields.Values.ToArray());
            PXUIFieldAttribute.SetEnabled <PMProjectSSExt.usrTemplateSS>(sender, pmProjectRow, !(bool)pmProjectSSExtRow.SyncedInSmartsheet);
        }
Ejemplo n.º 8
0
        public virtual IEnumerable orders()
        {
            foreach (POReceipt order in Orders.Cache.Updated)
            {
                yield return(order);
            }

            foreach (PXResult res in PXSelectJoinGroupBy <POReceipt,
                                                          InnerJoin <Vendor, On <Vendor.bAccountID, Equal <POReceipt.vendorID> >,
                                                                     InnerJoin <POReceiptLine, On <POReceiptLine.receiptNbr, Equal <POReceipt.receiptNbr> >,
                                                                                LeftJoin <APTran, On <APTran.receiptNbr, Equal <POReceiptLine.receiptNbr>,
                                                                                                      And <APTran.receiptLineNbr, Equal <POReceiptLine.lineNbr> > > > > >,
                                                          Where2 <Match <Vendor, Current <AccessInfo.userName> >,
                                                                  And <POReceipt.hold, Equal <boolFalse>,
                                                                       And <POReceipt.released, Equal <boolFalse>,
                                                                            And <APTran.refNbr, IsNull> > > >,
                                                          Aggregate <GroupBy <POReceipt.receiptNbr,
                                                                              GroupBy <POReceipt.receiptType,
                                                                                       GroupBy <POReceipt.released,
                                                                                                GroupBy <POReceipt.hold,
                                                                                                         GroupBy <POReceipt.autoCreateInvoice> > > > > > >
                     .Select(this))
            {
                POReceipt order;
                if ((order = (POReceipt)Orders.Cache.Locate(res[typeof(POReceipt)])) == null ||
                    Orders.Cache.GetStatus(order) == PXEntryStatus.Notchanged)
                {
                    yield return(res[typeof(POReceipt)]);
                }
            }
            Orders.Cache.IsDirty = false;
        }
Ejemplo n.º 9
0
        public virtual IEnumerable transactions()
        {
            PXSelectBase <PMTran> select = new PXSelectJoinGroupBy <PMTran,
                                                                    LeftJoin <Account, On <Account.accountID, Equal <PMTran.offsetAccountID> >,
                                                                              LeftJoin <PMRegister, On <PMTran.tranType, Equal <PMRegister.module>, And <PMTran.refNbr, Equal <PMRegister.refNbr> > >,
                                                                                        LeftJoin <ARTran, On <ARTran.pMTranID, Equal <PMTran.tranID> >,
                                                                                                  LeftJoin <PMAllocationAuditTran, On <PMAllocationAuditTran.sourceTranID, Equal <PMTran.tranID> >,
                                                                                                            LeftJoin <PMTranEx, On <PMTranEx.tranID, Equal <PMAllocationAuditTran.tranID> > > > > > >,
                                                                    Where <PMTran.projectID, Equal <Current <TranFilter.projectID> > >,
                                                                    Aggregate <GroupBy <PMTran.tranID, GroupBy <PMTran.billable, GroupBy <PMTran.useBillableQty, GroupBy <PMTran.allocated,
                                                                                                                                                                          GroupBy <PMTran.released, GroupBy <PMTran.billed, GroupBy <PMTran.reversed, GroupBy <PMTran.isNonGL, GroupBy <PMTran.isQtyOnly> > > > > > > > > > >(this);

            TranFilter filter = this.Filter.Current;

            if (filter != null)
            {
                if (filter.AccountGroupID != null)
                {
                    select.WhereAnd <Where <PMTran.accountGroupID, Equal <Current <TranFilter.accountGroupID> >, Or <Account.accountGroupID, Equal <Current <TranFilter.accountGroupID> > > > >();
                }
                if (filter.ProjectTaskID != null)
                {
                    select.WhereAnd <Where <PMTran.taskID, Equal <Current <TranFilter.projectTaskID> > > >();
                }
                if (filter.InventoryID != null)
                {
                    select.WhereAnd <Where <PMTran.inventoryID, Equal <Current <TranFilter.inventoryID> > > >();
                }
                if (filter.ResourceID != null)
                {
                    select.WhereAnd <Where <PMTran.resourceID, Equal <Current <TranFilter.resourceID> > > >();
                }
                if (filter.OnlyAllocation == true)
                {
                    select.WhereAnd <Where <PMRegister.isAllocation, Equal <True> > >();
                }
                if (filter.DateFrom != null && filter.DateTo != null)
                {
                    if (filter.DateFrom == filter.DateTo)
                    {
                        select.WhereAnd <Where <PMTran.date, Equal <Current <TranFilter.dateFrom> > > >();
                    }
                    else
                    {
                        select.WhereAnd <Where <PMTran.date, Between <Current <TranFilter.dateFrom>, Current <TranFilter.dateTo> > > >();
                    }
                }
                else if (filter.DateFrom != null)
                {
                    select.WhereAnd <Where <PMTran.date, GreaterEqual <Current <TranFilter.dateFrom> > > >();
                }
                else if (filter.DateTo != null)
                {
                    select.WhereAnd <Where <PMTran.date, LessEqual <Current <TranFilter.dateTo> > > >();
                }
            }

            return(select.Select());
        }
Ejemplo n.º 10
0
        public virtual void PMEnsureInitialized()
        {
            if (_historyLoaded == null)
            {
                _reportPeriods = new RMReportPeriods <PMHistory>(this.Base);

                var accountGroupSelect = new PXSelect <PMAccountGroup>(this.Base);
                accountGroupSelect.View.Clear();
                accountGroupSelect.Cache.Clear();

                var projectSelect = new PXSelect <PMProject, Where <PMProject.isTemplate, Equal <False>, And <PMProject.nonProject, Equal <False>, And <PMProject.baseType, Equal <PMProject.ProjectBaseType> > > > >(this.Base);
                projectSelect.View.Clear();
                projectSelect.Cache.Clear();

                var taskSelect = new PXSelectJoin <PMTask, InnerJoin <PMProject, On <PMTask.projectID, Equal <PMProject.contractID> > >, Where <PMProject.isTemplate, Equal <False>, And <PMProject.nonProject, Equal <False> > > >(this.Base);
                taskSelect.View.Clear();
                taskSelect.Cache.Clear();

                var itemSelect = new PXSelectJoinGroupBy <InventoryItem, InnerJoin <PMHistory, On <InventoryItem.inventoryID, Equal <PMHistory.inventoryID> > >, Aggregate <GroupBy <InventoryItem.inventoryID> > >(this.Base);
                itemSelect.View.Clear();
                itemSelect.Cache.Clear();

                if (Base.Report.Current.ApplyRestrictionGroups == true)
                {
                    projectSelect.WhereAnd <Where <Match <Current <AccessInfo.userName> > > >();
                    taskSelect.WhereAnd <Where <Match <Current <AccessInfo.userName> > > >();
                    itemSelect.WhereAnd <Where <Match <Current <AccessInfo.userName> > > >();
                }

                accountGroupSelect.Select();
                projectSelect.Select();
                taskSelect.Select();

                foreach (InventoryItem item in itemSelect.Select())
                {
                    //The PXSelectJoinGroupBy is read-only, and Inventory items won't be added to the cache. Add them manually.
                    itemSelect.Cache.SetStatus(item, PXEntryStatus.Notchanged);
                }

                _historySegments       = new HashSet <PMHistoryKeyTuple>();
                _pmhistoryPeriodsByKey = new Dictionary <PMHistoryKeyTuple, Dictionary <string, PMHistory> >();
                _historyLoaded         = new HashSet <int>();

                _accountGroupsRangeCache = new RMReportRange <PMAccountGroup>(Base, PM.AccountGroupAttribute.DimensionName, RMReportConstants.WildcardMode.Fixed, RMReportConstants.BetweenMode.Fixed);
                _projectsRangeCache      = new RMReportRange <PMProject>(Base, PM.ProjectAttribute.DimensionName, RMReportConstants.WildcardMode.Fixed, RMReportConstants.BetweenMode.Fixed);
                _tasksRangeCache         = new RMReportRange <PMTask>(Base, PM.ProjectTaskAttribute.DimensionName, RMReportConstants.WildcardMode.Normal, RMReportConstants.BetweenMode.Fixed);
                _itemRangeCache          = new RMReportRange <InventoryItem>(Base, IN.InventoryAttribute.DimensionName, RMReportConstants.WildcardMode.Fixed, RMReportConstants.BetweenMode.Fixed);

                //Add Inventory <OTHER> with InventoryID=0
                InventoryItem other = new InventoryItem
                {
                    InventoryCD = RMReportWildcard.EnsureWildcardForFixed(Messages.OtherItem, _itemRangeCache.Wildcard),
                    InventoryID = PMInventorySelectorAttribute.EmptyInventoryID,
                    Descr       = Messages.OtherItemDescription
                };
                itemSelect.Cache.SetStatus(other, PXEntryStatus.Notchanged);
            }
        }
Ejemplo n.º 11
0
        protected virtual IEnumerable period_Details()
        {
            VATPeriodFilter filter = Period_Header.Current;

            using (new PXReadBranchRestrictedScope(filter.OrganizationID.SingleToArray(), filter.BranchID.SingleToArrayOrNull()))
            {
                return(Period_Details_Expanded.Select());
            }
        }
        public static IEnumerable DriverRecordsDelegate(PXGraph graph, SharedClasses.RouteSelected_view routeSelected, PXFilter <DriverSelectionFilter> filter)
        {
            if (routeSelected.Current == null)
            {
                yield break;
            }

            List <object>             args          = new List <object>();
            PXSelectBase <EPEmployee> commandFilter = new PXSelectJoinGroupBy <EPEmployee,
                                                                               InnerJoin <FSRouteEmployee,
                                                                                          On <
                                                                                              FSRouteEmployee.employeeID, Equal <EPEmployee.bAccountID> >,
                                                                                          LeftJoin <FSRouteDocument,
                                                                                                    On <
                                                                                                        FSRouteDocument.driverID, Equal <FSRouteEmployee.employeeID>,
                                                                                                        And <
                                                                                                            FSRouteDocument.date, Equal <Required <FSRouteDocument.date> > > > > >,
                                                                               Where <
                                                                                   FSRouteEmployee.routeID, Equal <Required <FSRouteEmployee.routeID> >,
                                                                                   And <
                                                                                       FSxEPEmployee.sDEnabled, Equal <True>,
                                                                                       And <
                                                                                           FSxEPEmployee.isDriver, Equal <True> > > >,
                                                                               Aggregate <
                                                                                   GroupBy <
                                                                                       EPEmployee.bAccountID> >,
                                                                               OrderBy <
                                                                                   Asc <FSRouteEmployee.priorityPreference> > >(graph);

            args.Add(routeSelected.Current.Date);
            args.Add(routeSelected.Current.RouteID);

            if (filter.Current.ShowUnassignedDrivers == true)
            {
                commandFilter.WhereAnd <Where <FSRouteDocument.routeID, IsNull> >();
            }

            var bqlResultSet = commandFilter.Select(args.ToArray());

            foreach (PXResult <EPEmployee, FSRouteEmployee, FSRouteDocument> bqlResult in bqlResultSet)
            {
                EPEmployee      epEmployeeRow      = (EPEmployee)bqlResult;
                FSRouteEmployee fsRouteEmployeeRow = (FSRouteEmployee)bqlResult;
                FSRouteDocument fsRouteDocumentRow = (FSRouteDocument)bqlResult;

                FSxEPEmployee fsxEPEmployeeRow = PXCache <EPEmployee> .GetExtension <FSxEPEmployee>(epEmployeeRow);

                if (fsRouteDocumentRow != null && fsRouteDocumentRow.RouteID != null)
                {
                    fsxEPEmployeeRow.Mem_UnassignedDriver = true;
                }

                yield return(bqlResult);
            }
        }
        protected virtual void Report()
        {
            PXReportResultset reportData = new PXReportResultset(typeof(AppointmentData));

            foreach (AppointmentData row in RouteAppointmentGPSLocationRecords.Select())
            {
                reportData.Add(row);
            }

            throw new PXReportRequiredException(reportData, ID.ReportID.ROUTE_APP_GPS_LOCATION, PXBaseRedirectException.WindowMode.NewWindow, "Report");
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Keep synchronized the Customer's Billing Cycle settings when Multiple Billing Cycle option is turn on from Setup screen.
        /// </summary>
        public virtual void KeepCustomerMultBillCyleSettings(PXGraph setupGraph)
        {
            PXResultset <FSServiceOrder> customersAffectedRows = PXSelectJoinGroupBy <FSServiceOrder,
                                                                                      InnerJoin <Customer,
                                                                                                 On <
                                                                                                     Customer.bAccountID, Equal <FSServiceOrder.customerID> >,
                                                                                                 InnerJoin <FSSrvOrdType,
                                                                                                            On <
                                                                                                                FSSrvOrdType.srvOrdType, Equal <FSServiceOrder.srvOrdType> >,
                                                                                                            LeftJoin <FSCustomerBillingSetup,
                                                                                                                      On <
                                                                                                                          FSCustomerBillingSetup.customerID, Equal <Customer.bAccountID>,
                                                                                                                          And <FSCustomerBillingSetup.srvOrdType, Equal <FSServiceOrder.srvOrdType>,
                                                                                                                               And <FSCustomerBillingSetup.billingCycleID, Equal <FSxCustomer.billingCycleID> > > > > > >,
                                                                                      Where <
                                                                                          FSCustomerBillingSetup.billingCycleID, IsNull,
                                                                                          And <FSxCustomer.billingCycleID, IsNotNull,
                                                                                               And <FSSrvOrdType.active, Equal <True>,
                                                                                                    And <FSSrvOrdType.behavior, NotEqual <FSSrvOrdType.behavior.Quote> > > > >,
                                                                                      Aggregate <
                                                                                          GroupBy <FSServiceOrder.customerID,
                                                                                                   GroupBy <FSServiceOrder.srvOrdType> > >,
                                                                                      OrderBy <
                                                                                          Asc <FSServiceOrder.customerID> > >
                                                                 .Select(this);

            var graphCustomer  = PXGraph.CreateInstance <CustomerMaint>();
            int?lastCustomerID = null;

            foreach (FSServiceOrder currentCustomer in customersAffectedRows)
            {
                if (currentCustomer.CustomerID != lastCustomerID)
                {
                    graphCustomer.BAccount.Current = graphCustomer.BAccount.Search <Customer.bAccountID>(currentCustomer.CustomerID);
                    lastCustomerID = currentCustomer.CustomerID;
                }

                FSxCustomer fsxCustomerRow = graphCustomer.BAccount.Cache.GetExtension <FSxCustomer>(graphCustomer.BAccount.Current);

                if (fsxCustomerRow != null)
                {
                    SM_CustomerMaint sm_CustomerMaintGraph = graphCustomer.GetExtension <SM_CustomerMaint>();

                    FSCustomerBillingSetup fsCustomerBillingSetupRow = new FSCustomerBillingSetup();
                    fsCustomerBillingSetupRow.SrvOrdType         = currentCustomer.SrvOrdType;
                    fsCustomerBillingSetupRow.BillingCycleID     = fsxCustomerRow.BillingCycleID;
                    fsCustomerBillingSetupRow.SendInvoicesTo     = fsxCustomerRow.SendInvoicesTo;
                    fsCustomerBillingSetupRow.BillShipmentSource = fsxCustomerRow.BillShipmentSource;

                    sm_CustomerMaintGraph.CustomerBillingCycles.Insert(fsCustomerBillingSetupRow);
                    graphCustomer.Save.Press();
                }
            }
        }
        private bool IsCBIDRelatedToPostedDocuments(int?cBID)
        {
            int?rowCount = PXSelectJoinGroupBy <FSServiceOrder,
                                                InnerJoin <FSPostDoc,
                                                           On <FSPostDoc.sOID, Equal <FSServiceOrder.sOID> > >,
                                                Where <
                                                    FSServiceOrder.cBID, Equal <Required <FSServiceOrder.cBID> > >,
                                                Aggregate <Count> >
                           .Select(Base, cBID).RowCount;

            return(rowCount.HasValue && rowCount > 0);
        }
		public IEnumerable customerPaymentMethodList()
		{
			var query = new PXSelectJoinGroupBy<CustomerPaymentMethod,
				LeftJoin<CustomerPaymentMethodDetail, On<CustomerPaymentMethodDetail.pMInstanceID, Equal<CustomerPaymentMethod.pMInstanceID>>>, 
				Where<CustomerPaymentMethod.paymentMethodID, Equal<Current<Filter.oldPaymentMethodID>>,
					And<CustomerPaymentMethod.cCProcessingCenterID, Equal<Current<Filter.oldCCProcessingCenterID>>,
					And<CustomerPaymentMethodDetail.value, IsNotNull>>>,
				Aggregate<GroupBy<CustomerPaymentMethod.pMInstanceID>>>(this);
			foreach (PXResult<CustomerPaymentMethod,CustomerPaymentMethodDetail> items in query.Select())
			{
				CustomerPaymentMethod cpm = (CustomerPaymentMethod)items;
				yield return cpm;
			}
		}
Ejemplo n.º 17
0
        protected virtual void EPActivityFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            EPActivityApprove totals = Totals.Select();
            EPActivityFilter  row    = (EPActivityFilter)e.Row;

            if (totals != null && row != null)
            {
                row.BillableTime     = totals.TimeBillable - totals.OvertimeBillable;
                row.BillableOvertime = totals.OvertimeBillable;
                row.BillableTotal    = totals.TimeBillable;
                row.RegularTime      = totals.TimeSpent - totals.OvertimeSpent;
                row.RegularOvertime  = totals.OvertimeSpent;
                row.RegularTotal     = totals.TimeSpent;
            }
        }
Ejemplo n.º 18
0
 private string GetDirectSaleIndicator(PXGraph graph, int VendorID, string FinYear)
 {
     using (new PXReadBranchRestrictedScope(MarkedBranches))
     {
         foreach (PXResult <AP1099History, AP1099Box> dataRec in PXSelectJoinGroupBy <AP1099History,
                                                                                      InnerJoin <AP1099Box, On <AP1099Box.boxNbr, Equal <AP1099History.boxNbr> > >,
                                                                                      Where <AP1099History.vendorID, Equal <Required <AP1099History.vendorID> >,
                                                                                             And <AP1099History.boxNbr, Equal <Required <AP1099History.boxNbr> >,
                                                                                                  And <AP1099History.finYear, Equal <Required <AP1099History.finYear> > > > >,
                                                                                      Aggregate <GroupBy <AP1099History.boxNbr, Sum <AP1099History.histAmt> > > > .Select(graph, VendorID, 9, FinYear))
         {
             return((((AP1099History)dataRec).HistAmt >= ((AP1099Box)dataRec).MinReportAmt) ? "1" : string.Empty);
         }
     }
     return(string.Empty);
 }
Ejemplo n.º 19
0
 public virtual IEnumerable enqResults()
 {
     foreach (var result in PXSelectJoinGroupBy <ARDunningLetter,
                                                 LeftJoin <Customer, On <Customer.bAccountID, Equal <ARDunningLetter.bAccountID> >,
                                                           LeftJoin <ARDunningLetterDetail, On <ARDunningLetterDetail.dunningLetterID, Equal <ARDunningLetter.dunningLetterID> > > >,
                                                 Where2 <Where <ARDunningLetter.bAccountID, Equal <Current <DLByCustomerFilter.bAccountID> >, Or <Current <DLByCustomerFilter.bAccountID>, IsNull> >,
                                                         And <ARDunningLetter.dunningLetterDate, GreaterEqual <Current <DLByCustomerFilter.beginDate> >,
                                                              And <ARDunningLetter.dunningLetterDate, LessEqual <Current <DLByCustomerFilter.endDate> > > > >,
                                                 Aggregate <GroupBy <ARDunningLetter.dunningLetterID, GroupBy <ARDunningLetter.released, GroupBy <ARDunningLetter.voided, Sum <ARDunningLetterDetail.overdueBal, Count <ARDunningLetterDetail.refNbr> > > > > >,
                                                 OrderBy <Asc <ARDunningLetter.dunningLetterDate> > > .Select(this))
     {
         ARDunningLetter letter = (ARDunningLetter)result;
         letter.DetailsCount = result.RowCount;
         yield return(result);
     }
 }
Ejemplo n.º 20
0
        protected virtual Dictionary <int, decimal> GetTranYTDCostTableByPeriod(string periodID)
        {
            if (string.IsNullOrEmpty(periodID))
            {
                throw new ArgumentNullException();
            }

            if (tranYTDCostTable != null)
            {
                return(tranYTDCostTable);
            }

            tranYTDCostTable = new Dictionary <int, decimal>();

            var select = new PXSelectJoinGroupBy <INItemCostHist,
                                                  InnerJoin <INItemCostHistByPeriod,
                                                             On <INItemCostHist.inventoryID, Equal <INItemCostHistByPeriod.inventoryID>,
                                                                 And <INItemCostHist.costSiteID, Equal <INItemCostHistByPeriod.costSiteID>,
                                                                      And <INItemCostHist.costSubItemID, Equal <INItemCostHistByPeriod.costSubItemID>,
                                                                           And <INItemCostHist.accountID, Equal <INItemCostHistByPeriod.accountID>,
                                                                                And <INItemCostHist.subID, Equal <INItemCostHistByPeriod.subID>,
                                                                                     And <INItemCostHist.finPeriodID, Equal <INItemCostHistByPeriod.lastActivityPeriod> > > > > > > >,
                                                  Where <INItemCostHistByPeriod.finPeriodID, Equal <Required <INItemCostHistByPeriod.finPeriodID> >,
                                                         And <INItemCostHistByPeriod.siteID, Equal <Required <INItemCostHistByPeriod.siteID> > > >,
                                                  Aggregate <
                                                      GroupBy <INItemCostHist.costSiteID,
                                                               GroupBy <INItemCostHist.inventoryID,
                                                                        GroupBy <INItemCostHist.finPeriodID,
                                                                                 Sum <INItemCostHist.tranYtdCost> > > > >
                                                  >(context);

            foreach (PXResult <INItemCostHist, INItemCostHistByPeriod> res in select.Select(periodID, siteID))
            {
                INItemCostHist cost = (INItemCostHist)res;

                if (!tranYTDCostTable.ContainsKey(cost.InventoryID.Value))
                {
                    tranYTDCostTable.Add(cost.InventoryID.Value, cost.FinYtdCost.GetValueOrDefault());
                }
                else
                {
                    tranYTDCostTable[cost.InventoryID.Value] += cost.FinYtdCost.GetValueOrDefault();
                }
            }

            return(tranYTDCostTable);
        }
Ejemplo n.º 21
0
        public IEnumerable <PXResult <GLTran, CurrencyInfo> > GetTaxableGLTransWithCuryInfoGroupedByDocumentAttrAndTaxCategory(int?branchID, string[] batchNbrs)
        {
            var childBranchIds = PXAccess.GetChildBranchIDs(GetBranchByID(branchID).BranchCD);

            return(PXSelectJoinGroupBy <GLTran,
                                        InnerJoin <CurrencyInfo,
                                                   On <GLTran.curyInfoID, Equal <CurrencyInfo.curyInfoID> > >,
                                        Where <GLTran.branchID, In <Required <GLTran.branchID> >,
                                               And <GLTran.batchNbr, In <Required <GLTran.batchNbr> >,
                                                    And <GLTran.taxCategoryID, IsNotNull,
                                                         And <GLTran.module, Equal <BatchModule.moduleGL> > > > >,
                                        Aggregate <GroupBy <GLTran.branchID,
                                                            GroupBy <GLTran.batchNbr,
                                                                     GroupBy <GLTran.refNbr,
                                                                              GroupBy <GLTran.taxCategoryID> > > > > >
                   .Select(_graph, childBranchIds, batchNbrs)
                   .Cast <PXResult <GLTran, CurrencyInfo> >());
        }
        public IEnumerable yearVendorSummary()
        {
            PXResultset <AP1099Box> list;

            using (new PXReadBranchRestrictedScope(YearVendorHeader.Current.MasterBranchID))
            {
                list = PXSelectJoinGroupBy <AP1099Box,
                                            LeftJoin <AP1099History, On <AP1099History.vendorID, Equal <Current <AP1099YearMaster.vendorID> >,
                                                                         And <AP1099History.boxNbr, Equal <AP1099Box.boxNbr>,
                                                                              And <AP1099History.finYear, Equal <Current <AP1099YearMaster.finYear> > > > > >,
                                            Where <Current <AP1099YearMaster.masterBranchID>, IsNotNull>,
                                            Aggregate <GroupBy <AP1099Box.boxNbr, Sum <AP1099History.histAmt> > > > .Select(this);

                //There is "masterBranch is not null" because select parameters must be changed after changing masterBranch.
                //If select parametrs is unchanged since last use this select will not be executed and return previous result.
            }
            return(list);
        }
        public static IEnumerable VehicleRecordsDelegate(PXGraph graph, SharedClasses.RouteSelected_view routeSelected, PXFilter <VehicleSelectionFilter> filter)
        {
            if (routeSelected.Current == null)
            {
                yield break;
            }

            List <object> args = new List <object>();

            PXSelectBase <FSVehicle> commandFilter = new PXSelectJoinGroupBy <FSVehicle,
                                                                              LeftJoin <FSRouteDocument,
                                                                                        On <
                                                                                            FSRouteDocument.vehicleID, Equal <FSVehicle.SMequipmentID>,
                                                                                            And <FSRouteDocument.date, Equal <Required <FSRouteDocument.date> > > > >,
                                                                              Where <
                                                                                  FSVehicle.isVehicle, Equal <True> >,
                                                                              Aggregate <
                                                                                  GroupBy <
                                                                                      FSVehicle.SMequipmentID> >,
                                                                              OrderBy <
                                                                                  Asc <FSServiceVehicleType.priorityPreference> > >(graph);

            args.Add(routeSelected.Current.Date);

            if (filter.Current.ShowUnassignedVehicles == true)
            {
                commandFilter.WhereAnd <Where <FSRouteDocument.routeID, IsNull> >();
            }

            var list = commandFilter.Select(args.ToArray());

            foreach (PXResult <FSVehicle, FSRouteDocument> bqlResult in list)
            {
                FSVehicle       fsEquipmentRow     = (FSVehicle)bqlResult;
                FSRouteDocument fsRouteDocumentRow = (FSRouteDocument)bqlResult;

                if (fsRouteDocumentRow != null && fsRouteDocumentRow.RouteID != null)
                {
                    fsEquipmentRow.Mem_UnassignedVehicle = true;
                }

                yield return(bqlResult);
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Query to get data for calculation of the begin balances of accounts.
        /// </summary>
        /// <returns>Account;
        /// GLHistory: total of ptdDebit and ptdCredit of specified period;
        /// AH: total of finYtdBalance for last period activity period.</returns>
        public IEnumerable <PXResult <Account, GLHistory, AH> > GetAccountsWithDataToCalcBeginBalancesExcludingYTDNetIncAcc(int?branchID, int?ledgerID, string finPeriodID)
        {
            var glSetup        = GetGLSetup();
            var childBranchIds = PXAccess.GetChildBranchIDs(GetBranchByID(branchID).BranchCD);

            return(PXSelectJoinGroupBy <Account,
                                        LeftJoin <GLHistoryByPeriod,
                                                  On <GLHistoryByPeriod.branchID, In <Required <GLHistoryByPeriod.branchID> >,
                                                      And <GLHistoryByPeriod.ledgerID, Equal <Required <GLHistoryByPeriod.ledgerID> >,
                                                           And <Account.accountID, Equal <GLHistoryByPeriod.accountID>,
                                                                And <GLHistoryByPeriod.finPeriodID, Equal <Required <GLHistoryByPeriod.finPeriodID> >,
                                                                     And <Where2 <Where <Account.type, Equal <AccountType.asset>,
                                                                                         Or <Account.type, Equal <AccountType.liability> > >,
                                                                                  Or <Where <GLHistoryByPeriod.lastActivityPeriod, GreaterEqual <Required <GLHistoryByPeriod.lastActivityPeriod> >,                 // greater than the first period of a year
                                                                                             And <Where <Account.type, Equal <AccountType.expense>,
                                                                                                         Or <Account.type, Equal <AccountType.income> > > > > > > > > > > >,
                                                  //to get saldo in selected period
                                                  LeftJoin <GLHistory,
                                                            On <GLHistoryByPeriod.branchID, Equal <GLHistory.branchID>,
                                                                And <GLHistoryByPeriod.ledgerID, Equal <GLHistory.ledgerID>,
                                                                     And <GLHistoryByPeriod.accountID, Equal <GLHistory.accountID>,
                                                                          And <GLHistoryByPeriod.subID, Equal <GLHistory.subID>,
                                                                               And <GLHistoryByPeriod.finPeriodID, Equal <GLHistory.finPeriodID> > > > > >,
                                                            //to get ending balance for last activity period
                                                            LeftJoin <AH,
                                                                      On <GLHistoryByPeriod.ledgerID, Equal <AH.ledgerID>,
                                                                          And <GLHistoryByPeriod.branchID, Equal <AH.branchID>,
                                                                               And <GLHistoryByPeriod.accountID, Equal <AH.accountID>,
                                                                                    And <GLHistoryByPeriod.subID, Equal <AH.subID>,
                                                                                         And <GLHistoryByPeriod.lastActivityPeriod, Equal <AH.finPeriodID> > > > > > > > >,
                                        Where <Account.accountID, NotEqual <Required <Account.accountID> > >,                   // not YTD Net Income Account>,
                                        Aggregate <
                                            Sum <AH.finYtdBalance,
                                                 Sum <GLHistory.finPtdCredit,
                                                      Sum <GLHistory.finPtdDebit,
                                                           GroupBy <Account.accountID> > > > > >
                   .Select(_graph, childBranchIds,
                           ledgerID,
                           finPeriodID,
                           FinPeriodIDAttribute.GetFirstFinPeriodIDOfYear(finPeriodID),
                           glSetup.YtdNetIncAccountID)
                   .Cast <PXResult <Account, GLHistoryByPeriod, GLHistory, AH> >()
                   .Select(row => new PXResult <Account, GLHistory, AH>((Account)row, (GLHistory)row, (AH)row)));
        }
Ejemplo n.º 25
0
        private void CheckUnshiftedOrganizationCalendars()
        {
            List <string> organizations = PXSelectJoinGroupBy <
                OrganizationFinPeriod,
                InnerJoin <Organization,
                           On <OrganizationFinPeriod.organizationID, Equal <Organization.organizationID> > >,
                Where <OrganizationFinPeriod.finPeriodID, NotEqual <OrganizationFinPeriod.masterFinPeriodID> >,
                Aggregate <
                    GroupBy <Organization.organizationCD> > >
                                          .Select(this)
                                          .RowCast <Organization>()
                                          .Select(org => org.OrganizationCD.Trim())
                                          .ToList();

            if (organizations.Any())
            {
                throw new PXSetPropertyException(GL.Messages.ShiftedOrganizationCalendarsDetected, string.Join(", ", organizations));
            }
        }
Ejemplo n.º 26
0
 public virtual int GetListCount()
 {
     return((int)(PXSelectJoinGroupBy <CRActivity,
                                       LeftJoin <EPAttendee,
                                                 On <EPAttendee.userID, Equal <Current <AccessInfo.userID> >,
                                                     And <EPAttendee.eventNoteID, Equal <CRActivity.noteID> > >,
                                                 LeftJoin <CRReminder,
                                                           On <CRReminder.refNoteID, Equal <CRActivity.noteID>,
                                                               And <CRReminder.owner, Equal <Current <AccessInfo.userID> > > > > >,
                                       Where2 <Where <CRActivity.classID, Equal <CRActivityClass.task>,
                                                      Or <CRActivity.classID, Equal <CRActivityClass.events> > >,
                                               And2 <Where <CRActivity.uistatus, NotEqual <ActivityStatusAttribute.canceled>,
                                                            And <CRActivity.uistatus, NotEqual <ActivityStatusAttribute.completed>,
                                                                 And <CRActivity.uistatus, NotEqual <ActivityStatusAttribute.released> > > >,
                                                     And <CRReminder.reminderDate, IsNotNull,
                                                          And2 <Where <CRReminder.reminderDate, Less <Now>, And <CRReminder.dismiss, NotEqual <True> > >,
                                                                And <Where <CRReminder.owner, Equal <Current <AccessInfo.userID> >,
                                                                            Or <EPAttendee.userID, IsNotNull> > > > > > >,
                                       Aggregate <Count> > .Select(this).RowCount));
 }
Ejemplo n.º 27
0
        private static PXResultset <TaxHistory> GetTaxHistoryLines(PXGraph graph, int?curVendorBaccountID, string taxPeriodId, int?revisionId)
        {
            PXResultset <TaxHistory> lines =
                PXSelectJoinGroupBy <TaxHistory,
                                     InnerJoin <
                                         TaxReportLine,
                                         On <TaxReportLine.vendorID, Equal <TaxHistory.vendorID>,
                                             And <TaxReportLine.lineNbr, Equal <TaxHistory.lineNbr> > > >,
                                     Where <
                                         TaxHistory.vendorID, Equal <Required <TaxHistory.vendorID> >,
                                         And <TaxHistory.taxPeriodID, Equal <Required <TaxHistory.taxPeriodID> >,
                                              And <TaxHistory.revisionID, Equal <Required <TaxHistory.revisionID> > > > >,
                                     Aggregate <
                                         GroupBy <TaxHistory.branchID,
                                                  GroupBy <TaxReportLine.lineNbr,
                                                           GroupBy <TaxReportLine.netTax,
                                                                    Sum <TaxHistory.reportFiledAmt> > > > > >
                .Select(graph, curVendorBaccountID, taxPeriodId, revisionId);

            return(lines);
        }
Ejemplo n.º 28
0
        public Dictionary <string, CustomerData> GetUnsynchronizedCustomerProfiles()
        {
            Dictionary <string, CustomerData>    customerProfiles = GetCustomerProfilesFromService();
            PXSelectBase <CustomerPaymentMethod> query            = new PXSelectJoinGroupBy <CustomerPaymentMethod,
                                                                                             InnerJoin <CCProcessingCenterPmntMethod, On <CustomerPaymentMethod.paymentMethodID, Equal <CCProcessingCenterPmntMethod.paymentMethodID> > >,
                                                                                             Where <CCProcessingCenterPmntMethod.processingCenterID, Equal <Required <CCProcessingCenterPmntMethod.processingCenterID> >,
                                                                                                    And <CustomerPaymentMethod.customerCCPID, IsNotNull> >,
                                                                                             Aggregate <
                                                                                                 GroupBy <CustomerPaymentMethod.customerCCPID> > >(graph);
            PXResultset <CustomerPaymentMethod> lines = query.Select(processingCenterId);

            foreach (CustomerPaymentMethod line in lines)
            {
                string checkCustomerProfile = line.CustomerCCPID;
                if (customerProfiles.ContainsKey(checkCustomerProfile))
                {
                    customerProfiles.Remove(checkCustomerProfile);
                }
            }
            return(customerProfiles);
        }
Ejemplo n.º 29
0
        private void CheckFullLengthOrganizationCalendars()
        {
            List <string> organizations = PXSelectJoinGroupBy <
                MasterFinPeriod,
                CrossJoin <Organization,
                           LeftJoin <OrganizationFinPeriod,
                                     On <MasterFinPeriod.finPeriodID, Equal <OrganizationFinPeriod.masterFinPeriodID>,
                                         And <Organization.organizationID, Equal <OrganizationFinPeriod.organizationID> > > > >,
                Where <OrganizationFinPeriod.finPeriodID, IsNull>,
                Aggregate <
                    GroupBy <Organization.organizationCD> > >
                                          .Select(this)
                                          .RowCast <Organization>()
                                          .Select(org => org.OrganizationCD.Trim())
                                          .ToList();

            if (organizations.Any())
            {
                throw new PXSetPropertyException(GL.Messages.ShortOrganizationCalendarsDetected, string.Join(", ", organizations));
            }
        }
Ejemplo n.º 30
0
        public virtual IEnumerable envelopes()
        {
            PXSelectBase <ESignEnvelopeInfo> query = new PXSelectJoinGroupBy <ESignEnvelopeInfo,
                                                                              InnerJoin <UploadFileRevision,
                                                                                         On <UploadFileRevision.fileID, Equal <ESignEnvelopeInfo.fileID>,
                                                                                             And <UploadFileRevision.fileRevisionID, Equal <ESignEnvelopeInfo.fileRevisionID> > >,
                                                                                         InnerJoin <ESignAccount, On <ESignEnvelopeInfo.eSignAccountID, Equal <ESignAccount.accountID> >,
                                                                                                    InnerJoin <UploadFileWithIDSelector, On <UploadFileWithIDSelector.fileID, Equal <UploadFileRevision.fileID> >,
                                                                                                               InnerJoin <SiteMap, On <SiteMap.screenID, Equal <UploadFileWithIDSelector.primaryScreenID> > > > > >,
                                                                              Where <ESignEnvelopeInfo.lastStatus, NotEqual <Empty>,
                                                                                     And <ESignEnvelopeInfo.isFinalVersion, NotEqual <True> > >,
                                                                              Aggregate <GroupBy <ESignEnvelopeInfo.envelopeInfoID> > >(this);

            EnvelopeFilter filter = Filter.Current;

            if (filter.OwnerID != null)
            {
                query.WhereAnd <Where <ESignEnvelopeInfo.createdByID, Equal <Current <EnvelopeFilter.ownerID> > > >();
            }

            return(query.Select());
        }