public IEnumerable records()
        {
            SalesPriceFilter filter = this.Filter.Current;

            if (filter != null)
            {
                PXSelectBase <SOSalesPrice> select = new PXSelectJoin <SOSalesPrice,
                                                                       InnerJoin <InventoryItem, On <SOSalesPrice.inventoryID, Equal <InventoryItem.inventoryID> > >,
                                                                       Where <SOSalesPrice.curyID, Equal <Current <SalesPriceFilter.curyID> > > >(this);

                if (!string.IsNullOrEmpty(filter.InventoryPriceClassID))
                {
                    select.WhereAnd <Where <InventoryItem.priceClassID, Equal <Current <SalesPriceFilter.inventoryPriceClassID> > > >();
                }

                if (filter.InventoryID != null)
                {
                    select.WhereAnd <Where <SOSalesPrice.inventoryID, Equal <Current <SalesPriceFilter.inventoryID> > > >();
                }

                return(select.Select());
            }
            else
            {
                return(null);
            }
        }
        //Where<CustomerPaymentMethod.expirationDate, GreaterEqual<Current<ARExpiringCardFilter.beginDate>>,
        //And<CustomerPaymentMethod.expirationDate, LessEqual<Current<ARExpiringCardFilter.endDate>>,
        //And<CustomerPaymentMethod.isActive, Equal<BQLConstants.BitOn>,
        ////Or<Current<ARExpiringCardFilter.activeOnly>,Equal<BQLConstants.BitOff>>>,
        //And<Where<Customer.customerClassID,Equal<Current<ARExpiringCardFilter.customerClassID>>,
        //Or<Current<ARExpiringCardFilter.customerClassID>, IsNull>>>>>>> Cards;

        public virtual IEnumerable cards()
        {
            ARExpiringCardFilter filter = this.Filter.Current;

            if (filter != null)
            {
                PXSelectBase <CustomerPaymentMethod> select = new PXSelectJoin <CustomerPaymentMethod,
                                                                                InnerJoin <Customer, On <Customer.bAccountID, Equal <CustomerPaymentMethod.bAccountID> >,
                                                                                           LeftJoin <CR.Contact, On <CR.Contact.bAccountID, Equal <Customer.bAccountID>,
                                                                                                                     And <CR.Contact.contactID, Equal <Customer.defBillContactID> > > > >,
                                                                                Where <CustomerPaymentMethod.expirationDate, GreaterEqual <Required <CustomerPaymentMethod.expirationDate> >,
                                                                                       And <CustomerPaymentMethod.expirationDate, LessEqual <Required <CustomerPaymentMethod.expirationDate> > > > >(this);

                if (!string.IsNullOrEmpty(filter.CustomerClassID))
                {
                    select.WhereAnd <Where <Customer.customerClassID, Equal <Required <Customer.customerClassID> > > >();
                }

                if ((bool)filter.ActiveOnly)
                {
                    select.WhereAnd <Where <CustomerPaymentMethod.isActive, Equal <BQLConstants.BitOn> > >();
                }

                return(select.Select(filter.BeginDate, filter.EndDate, filter.CustomerClassID));
            }
            return(null);
        }
Esempio n. 3
0
        protected virtual IEnumerable billed()
        {
            UsageFilter filter = Filter.Current;

            if (filter == null)
            {
                return(new List <PMTran>());
            }

            PXSelectBase <PMTran> select = new  PXSelectJoin <
                PMTran
                , LeftJoin <EPActivity, On <EPActivity.noteID, Equal <PMTran.origRefID> >, LeftJoin <CRCase, On <CRCase.noteID, Equal <PMTran.origRefID>, Or <CRCase.noteID, Equal <EPActivity.refNoteID> > > > >
                , Where <PMTran.billed, Equal <True>, And <PMTran.projectID, Equal <Current <UsageFilter.contractID> > > >
                >(this);

            if (filter.CustomerID != null)
            {
                select.WhereAnd <Where <PMTran.bAccountID, Equal <Current <UsageFilter.customerID> > > >();
            }
            if (filter.LocationID != null)
            {
                select.WhereAnd <Where <PMTran.locationID, Equal <Current <UsageFilter.locationID> > > >();
            }
            if (!string.IsNullOrEmpty(filter.InvFinPeriodID))
            {
                FinPeriod finPeriod = PXSelect <FinPeriod, Where <FinPeriod.finPeriodID, Equal <Current <UsageFilter.invFinPeriodID> > > > .Select(this);

                if (finPeriod != null)
                {
                    select.WhereAnd <Where <PMTran.billedDate, Between <Required <FinPeriod.startDate>, Required <FinPeriod.endDate> > > >();
                }
            }

            return(select.Select());
        }
Esempio n. 4
0
        protected virtual IEnumerable spdocs()
        {
            List <ARSPCommnDocResult> res = new List <ARSPCommnDocResult>();
            SPDocFilter filter            = (SPDocFilter)this.Filter.Current;

            if (filter != null && filter.SalesPersonID != null && filter.CommnPeriod != null)
            {
                PXSelectBase <ARSalesPerTran> sel = new PXSelectJoin <ARSalesPerTran,
                                                                      InnerJoin <ARRegister, On <ARSalesPerTran.docType, Equal <ARRegister.docType>,
                                                                                                 And <ARSalesPerTran.refNbr, Equal <ARRegister.refNbr> > >,
                                                                                 InnerJoinSingleTable <Customer, On <Customer.bAccountID, Equal <ARRegister.customerID>,
                                                                                                                     And <Match <Customer, Current <AccessInfo.userName> > > > > >,
                                                                      Where <ARSalesPerTran.salespersonID, Equal <Current <SPDocFilter.salesPersonID> >,
                                                                             And <ARSalesPerTran.commnPaymntPeriod, Equal <Current <SPDocFilter.commnPeriod> >,
                                                                                  And <ARSalesPerTran.actuallyUsed, Equal <BQLConstants.BitOn> > > > >(this);
                if (filter.CustomerID != null)
                {
                    sel.WhereAnd <Where <ARRegister.customerID, Equal <Current <SPDocFilter.customerID> > > >();
                }
                if (filter.LocationID != null)
                {
                    sel.WhereAnd <Where <ARRegister.customerLocationID, Equal <Current <SPDocFilter.locationID> > > >();
                }

                foreach (PXResult <ARSalesPerTran, ARRegister, Customer> it in sel.Select())
                {
                    ARSPCommnDocResult m = new ARSPCommnDocResult();
                    Copy(m, ((ARSalesPerTran)it));
                    Copy(m, ((ARRegister)it));
                    res.Add(m);
                }
            }
            return(res);
        }
        public virtual IEnumerable GetRecords()
        {
            SOAmazonSetup currentItem = (SOAmazonSetup)this._Graph.Views["setupview"].Cache.Current;

            if (currentItem == null)
            {
                return(null);
            }
            PXSelectBase <SOOrderType> ordertype = new PXSelectJoin <SOOrderType, InnerJoin <SOOrderTypeOperation, On <SOOrderTypeOperation.orderType,
                                                                                                                       Equal <SOOrderType.orderType>, And <SOOrderTypeOperation.operation, Equal <SOOrderType.defaultOperation> > > > >(this._Graph);

            switch (currentItem.IntegrationType.Trim())
            {
            case SOConstants.AMIntegrationType.FBA:
            case SOConstants.AMIntegrationType.CAFBA:
            case SOConstants.AMIntegrationType.UKFBA:
            case SOConstants.AMIntegrationType.JPFBA:
            case SOConstants.AMIntegrationType.DEFBA:
            case SOConstants.AMIntegrationType.INFBA:
                ordertype.WhereAnd <Where <SOOrderType.template, Equal <SOConstants.InvoiceType>,
                                           And <SOOrderType.aRDocType, Equal <ARDocType.invoice> > > >();
                return(ordertype.Select());

            case SOConstants.AMIntegrationType.FBM:
                ordertype.WhereAnd <Where <SOOrderType.template, Equal <SOConstants.SalesOrderType> > >();
                return(ordertype.Select());
            }
            return(null);
        }
        public virtual IEnumerable cards()
        {
            ARExpiredCardFilter filter = this.Filter.Current;

            if (filter != null)
            {
                PXSelectBase <CustomerPaymentMethod> select = new PXSelectJoin <CustomerPaymentMethod,
                                                                                InnerJoin <Customer, On <Customer.bAccountID, Equal <CustomerPaymentMethod.bAccountID>,
                                                                                                         And <Customer.status, NotEqual <Customer.status.inactive> > >,
                                                                                           LeftJoin <CR.Contact, On <CR.Contact.bAccountID, Equal <Customer.bAccountID>,
                                                                                                                     And <CR.Contact.contactID, Equal <Customer.defBillContactID> > > > >,
                                                                                Where <CustomerPaymentMethod.isActive, Equal <boolTrue>,
                                                                                       And <CustomerPaymentMethod.expirationDate, LessEqual <Required <CustomerPaymentMethod.expirationDate> >,
                                                                                            And <CustomerPaymentMethod.expirationDate, GreaterEqual <Required <CustomerPaymentMethod.expirationDate> > > > > >(this);

                if (!string.IsNullOrEmpty(filter.CustomerClassID))
                {
                    select.WhereAnd <Where <Customer.customerClassID, Equal <Required <Customer.customerClassID> > > >();
                }
                if (filter.DefaultOnly == true)
                {
                    select.WhereAnd <Where <CustomerPaymentMethod.pMInstanceID, Equal <Customer.defPMInstanceID> > >();
                }
                //Dates are inverted - end is less then begin
                foreach (PXResult <CustomerPaymentMethod, Customer, Contact> it in select.Select(filter.BeginDate, filter.EndDate, filter.CustomerClassID))
                {
                    CustomerPaymentMethod cpm = (CustomerPaymentMethod)it;
                    if (filter.NotificationSendOnly == true)
                    {
                        if (cpm.LastNotificationDate.HasValue)
                        {
                            if (cpm.ExpirationDate.HasValue)
                            {
                                TimeSpan diff = cpm.ExpirationDate.Value - cpm.LastNotificationDate.Value;
                                if (diff.TotalDays > 0)
                                {
                                    if (diff.TotalDays > 60)
                                    {
                                        continue;
                                    }
                                }
                                else
                                {
                                    if (Math.Abs(diff.TotalDays) > 180)
                                    {
                                        continue;
                                    }
                                }
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    yield return(it);
                }
            }
            yield break;
        }
Esempio n. 7
0
        private void CheckUnpostedBatchesNotExist(GLConsolSetup glConsolSetup)
        {
            var getUnpostedBatchesQuery = new PXSelectJoin <Batch,
                                                            InnerJoin <GLConsolBatch,
                                                                       On <Batch.batchNbr, Equal <GLConsolBatch.batchNbr> > >,
                                                            Where
                                                            <GLConsolBatch.setupID, Equal <Required <GLConsolBatch.setupID> >,
                                                             And <Batch.posted, Equal <False>,
                                                                  And <Batch.module, Equal <BatchModule.moduleGL> > > > >(this);

            var pars = new List <object>()
            {
                glConsolSetup.SetupID
            };

            if (glConsolSetup.StartPeriod != null)
            {
                getUnpostedBatchesQuery.WhereAnd <Where <Batch.finPeriodID, GreaterEqual <Required <Batch.finPeriodID> > > >();
                pars.Add(glConsolSetup.StartPeriod);
            }
            if (glConsolSetup.EndPeriod != null)
            {
                getUnpostedBatchesQuery.WhereAnd <Where <Batch.finPeriodID, LessEqual <Required <Batch.finPeriodID> > > >();
                pars.Add(glConsolSetup.EndPeriod);
            }

            var unpostedBatch = (Batch)getUnpostedBatchesQuery.Select(pars.ToArray());

            if (unpostedBatch != null)
            {
                ConsolSetupRecords.Cache.RaiseExceptionHandling <GLConsolSetup.selected>(glConsolSetup, glConsolSetup.Selected,
                                                                                         new PXSetPropertyException(Messages.UnpostedBatchesExist, PXErrorLevel.RowWarning));
            }
        }
Esempio n. 8
0
        public IEnumerable documentlist()
        {
            PXSelectBase <APInvoice> cmd = new PXSelectJoin <APInvoice, LeftJoin <APTaxTran, On <APTaxTran.tranType, Equal <APInvoice.docType>, And <APTaxTran.refNbr, Equal <APInvoice.refNbr>, And <APTaxTran.taxID, Equal <Current <AddBillFilter.taxID> > > > > >, Where <APInvoice.released, Equal <True>, And <APInvoice.origModule, NotEqual <GL.BatchModule.moduleTX>, And <APTaxTran.refNbr, IsNull> > > >(this);

            if (string.IsNullOrEmpty(Filter.Current.TaxID))
            {
                yield break;
            }

            if (Filter.Current.StartDate != null)
            {
                cmd.WhereAnd <Where <APInvoice.docDate, GreaterEqual <Current <AddBillFilter.startDate> > > >();
            }

            if (Filter.Current.EndDate != null)
            {
                cmd.WhereAnd <Where <APInvoice.docDate, LessEqual <Current <AddBillFilter.endDate> > > >();
            }

            if (Filter.Current.VendorID != null)
            {
                cmd.WhereAnd <Where <APInvoice.vendorID, Equal <Current <AddBillFilter.vendorID> > > >();
            }

            if (string.IsNullOrEmpty(Filter.Current.InvoiceNbr) == false)
            {
                cmd.WhereAnd <Where <APInvoice.invoiceNbr, Equal <Current <AddBillFilter.invoiceNbr> > > >();
            }

            foreach (APInvoice item in cmd.Select())
            {
                yield return(item);
            }
        }
Esempio n. 9
0
        protected virtual IEnumerable expenseClaimRecords()
        {
            MyExpenseClaimsEnqFilter filter = Filter.Current as MyExpenseClaimsEnqFilter;

            PXSelectBase <EPExpenseClaim> select =
                new PXSelectJoin <EPExpenseClaim,
                                  LeftJoin <APInvoice, On <APInvoice.refNbr, Equal <EPExpenseClaim.aPRefNbr> >,
                                            InnerJoin <EPEmployee, On <EPEmployee.bAccountID, Equal <EPExpenseClaim.employeeID> > > >,
                                  Where <EPEmployee.userID, Equal <Current <AccessInfo.userID> > >,
                                  OrderBy <Desc <EPExpenseClaim.docDate,
                                                 Asc <EPExpenseClaim.refNbr> > > >(this);

            if (filter.StartDate.HasValue)
            {
                select.WhereAnd <Where <EPExpenseClaim.docDate, GreaterEqual <Current <MyExpenseClaimsEnqFilter.startDate> > > >();
            }
            if (filter.EndDate.HasValue)
            {
                select.WhereAnd <Where <EPExpenseClaim.docDate, LessEqual <Current <MyExpenseClaimsEnqFilter.endDate> > > >();
            }

            foreach (PXResult <EPExpenseClaim, APInvoice> res in select.Select())
            {
                EPExpenseClaim claim = (EPExpenseClaim)res;
                if ((((filter.Released ?? false) && claim.Status == EPClaimStatus.Released) ||
                     ((filter.Approved ?? false) && claim.Status == EPClaimStatus.Approved) ||
                     ((filter.Pending ?? false) && claim.Status == EPClaimStatus.Balanced) ||
                     ((filter.Voided ?? false) && claim.Status == EPClaimStatus.Voided) ||
                     ((filter.OnHold ?? false) && claim.Status == EPClaimStatus.Hold)))
                {
                    yield return(res);
                }
            }
        }
        private IEnumerable GetRelevantInventories(string showItemsMode)
        {
            if (ItemClasses.Current == null)
            {
                yield break;
            }

            var selectCommand = new PXSelectJoin <InventoryItem,
                                                  InnerJoin <INItemClass, On <InventoryItem.FK.ItemClass> >,
                                                  Where2 <
                                                      Where <InventoryItem.inventoryID, Equal <Current <InventoryByClassFilter.inventoryID> >, Or <Current <InventoryByClassFilter.inventoryID>, IsNull> >,
                                                      And <Match <Current <AccessInfo.userName> > > > >(this);

            if (showItemsMode == ShowItemsMode.ChildrenOfCurrentClass)
            {
                selectCommand.WhereAnd <Where <INItemClass.itemClassID, Equal <Required <INItemClass.itemClassID> > > >();
                foreach (var res in selectCommand.Select(ItemClasses.Current.ItemClassID))
                {
                    yield return(res);
                }
            }
            else if (showItemsMode == ShowItemsMode.AllChildren)
            {
                selectCommand.WhereAnd <Where <INItemClass.itemClassCD, Like <Required <INItemClass.itemClassCD> > > >();
                foreach (var res in selectCommand.Select(ItemClasses.Current.ItemClassCDWildcard))
                {
                    yield return(res);
                }
            }
            else
            {
                throw new PXInvalidOperationException();
            }
        }
Esempio n. 11
0
        public virtual IEnumerable cCTrans()
        {
            List <PXResult <CCProcTran, CustomerPaymentMethod, Customer, ARPayment> > res = new List <PXResult <CCProcTran, CustomerPaymentMethod, Customer, ARPayment> >();

            CCTransactionsHistoryFilter filter = (CCTransactionsHistoryFilter)this.Filter.Current;


            if (filter != null && string.IsNullOrEmpty(filter.PaymentMethodID) == false &&
                filter.StartDate.HasValue && filter.EndDate.HasValue && filter.PMInstanceID != null)
            {
                GetInternalData(filter.PaymentMethodID);

                PXSelectBase <CCProcTran> sel = new PXSelectJoin <CCProcTran,
                                                                  InnerJoin <CustomerPaymentMethod, On <CustomerPaymentMethod.pMInstanceID, Equal <CCProcTran.pMInstanceID> >,
                                                                             InnerJoin <Customer, On <CustomerPaymentMethod.bAccountID, Equal <Customer.bAccountID> >,
                                                                                        LeftJoin <ARPayment, On <ARPayment.docType, Equal <CCProcTran.docType>, And <ARPayment.refNbr, Equal <CCProcTran.refNbr> > > > > > >(this);

                if (string.IsNullOrEmpty(filter.PaymentMethodID) == false)
                {
                    sel.WhereAnd <Where <CustomerPaymentMethod.paymentMethodID, Equal <Current <CCTransactionsHistoryFilter.paymentMethodID> > > >();
                }
                if (string.IsNullOrEmpty(filter.ProcessingCenterID) == false)
                {
                    sel.WhereAnd <Where <CCProcTran.processingCenterID, Equal <Current <CCTransactionsHistoryFilter.processingCenterID> > > >();
                }
                if (filter.StartDate.HasValue)
                {
                    sel.WhereAnd <Where <CCProcTran.startTime, GreaterEqual <Current <CCTransactionsHistoryFilter.startDate> > > >();
                }
                if (filter.EndDate.HasValue)
                {
                    sel.WhereAnd <Where <CCProcTran.startTime, LessEqual <Current <CCTransactionsHistoryFilter.endDatePlusOne> > > >();
                }

                if (filter.PMInstanceID.HasValue)
                {
                    sel.WhereAnd <Where <CustomerPaymentMethod.pMInstanceID, Equal <Current <CCTransactionsHistoryFilter.pMInstanceID> > > >();
                }

                foreach (PXResult <CCProcTran, CustomerPaymentMethod, Customer, ARPayment> it in sel.Select(CardNumber_DetailID, NameOnCard_DetailID))
                {
                    ARPayment  payment = it;
                    CCProcTran ccTran  = it;
                    if (ccTran.TranType == CCTranTypeCode.Credit || ccTran.TranType == CCTranTypeCode.VoidTran)
                    {
                        ARPayment voiding = PXSelect <ARPayment, Where <ARPayment.refNbr, Equal <Required <ARPayment.refNbr> >,
                                                                        And <ARPayment.docType, Equal <ARDocType.voidPayment> > > > .Select(this, payment.RefNbr);

                        if (voiding != null)
                        {
                            ((ARPayment)it).DocType  = ARDocType.VoidPayment;
                            ((CCProcTran)it).DocType = ARDocType.VoidPayment;
                        }
                    }
                    yield return(it);
                }
            }
            yield break;
        }
Esempio n. 12
0
        public virtual IEnumerable transactions()
        {
            PXSelectBase <PMTran> select = new PXSelectJoin <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.tranType, Equal <PMTran.aRTranType>, And <ARTran.refNbr, Equal <PMTran.aRRefNbr>, And <ARTran.lineNbr, Equal <PMTran.refLineNbr> > > > > > >,
                                                             Where <PMTran.projectID, Equal <Current <TranFilter.projectID> > > >(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.CostCode != null)
                {
                    select.WhereAnd <Where <PMTran.costCodeID, Equal <Current <TranFilter.costCode> > > >();
                }
                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(TimeCardMaint.QSelect(this, select.View.BqlSelect));
        }
Esempio n. 13
0
        public override PXSelectBase <INLotSerialStatus> GetSerialStatusCmd(PXCache sender, ARTran row, PXResult <InventoryItem, INLotSerClass> item)
        {
            PXSelectBase <INLotSerialStatus> cmd = new PXSelectJoin <INLotSerialStatus, InnerJoin <INLocation, On <INLocation.locationID, Equal <INLotSerialStatus.locationID> >,
                                                                                                   InnerJoin <INSiteLotSerial, On <INSiteLotSerial.inventoryID, Equal <INLotSerialStatus.inventoryID>,
                                                                                                                                   And <INSiteLotSerial.siteID, Equal <INLotSerialStatus.siteID>, And <INSiteLotSerial.lotSerialNbr, Equal <INLotSerialStatus.lotSerialNbr> > > > > >,
                                                                     Where <INLotSerialStatus.inventoryID, Equal <Current <INLotSerialStatus.inventoryID> >,
                                                                            And <INLotSerialStatus.siteID, Equal <Current <INLotSerialStatus.siteID> >,
                                                                                 And <INLotSerialStatus.qtyOnHand, Greater <decimal0>,
                                                                                      And <INSiteLotSerial.qtyHardAvail, Greater <decimal0> > > > > >(sender.Graph);

            if (row.SubItemID != null)
            {
                cmd.WhereAnd <Where <INLotSerialStatus.subItemID, Equal <Current <INLotSerialStatus.subItemID> > > >();
            }
            if (row.LocationID != null)
            {
                cmd.WhereAnd <Where <INLotSerialStatus.locationID, Equal <Current <INLotSerialStatus.locationID> > > >();
            }
            else
            {
                cmd.WhereAnd <Where <INLocation.salesValid, Equal <boolTrue> > >();
            }
            if (string.IsNullOrEmpty(row.LotSerialNbr) == false)
            {
                cmd.WhereAnd <Where <INLotSerialStatus.lotSerialNbr, Equal <Current <INLotSerialStatus.lotSerialNbr> > > >();
            }

            switch (((INLotSerClass)item).LotSerIssueMethod)
            {
            case INLotSerIssueMethod.FIFO:
                cmd.OrderByNew <OrderBy <Asc <INLocation.pickPriority, Asc <INLotSerialStatus.receiptDate, Asc <INLotSerialStatus.lotSerialNbr> > > > >();
                break;

            case INLotSerIssueMethod.LIFO:
                cmd.OrderByNew <OrderBy <Asc <INLocation.pickPriority, Desc <INLotSerialStatus.receiptDate, Asc <INLotSerialStatus.lotSerialNbr> > > > >();
                break;

            case INLotSerIssueMethod.Expiration:
                cmd.OrderByNew <OrderBy <Asc <INLocation.pickPriority, Asc <INLotSerialStatus.expireDate, Asc <INLotSerialStatus.lotSerialNbr> > > > >();
                break;

            case INLotSerIssueMethod.Sequential:
                cmd.OrderByNew <OrderBy <Asc <INLocation.pickPriority, Asc <INLotSerialStatus.lotSerialNbr> > > >();
                break;

            case INLotSerIssueMethod.UserEnterable:
                if (string.IsNullOrEmpty(row.LotSerialNbr))
                {
                    cmd.WhereAnd <Where <boolTrue, Equal <boolFalse> > >();
                }
                break;

            default:
                throw new PXException();
            }

            return(cmd);
        }
        public virtual IEnumerable cards()
        {
            ARExpiringCardFilter filter = this.Filter.Current;

            if (filter != null)
            {
                PXSelectBase <CustomerPaymentMethod> select = null;
                select = new PXSelectJoin <CustomerPaymentMethod,
                                           InnerJoin <Customer, On <Customer.bAccountID, Equal <CustomerPaymentMethod.bAccountID>,
                                                                    And <Customer.status, NotEqual <BAccount.status.inactive> > >,
                                                      LeftJoin <CR.Contact, On <CR.Contact.bAccountID, Equal <CustomerPaymentMethod.bAccountID>,
                                                                                And <Where2 <Where <CustomerPaymentMethod.billContactID, IsNull,
                                                                                                    And <CR.Contact.contactID, Equal <Customer.defBillContactID> > >,
                                                                                             Or <Where <CustomerPaymentMethod.billContactID, IsNotNull,
                                                                                                        And <CustomerPaymentMethod.billContactID, Equal <CR.Contact.contactID> > > > > > > > >,
                                           Where <CustomerPaymentMethod.expirationDate, GreaterEqual <Required <CustomerPaymentMethod.expirationDate> >,
                                                  And <CustomerPaymentMethod.expirationDate, LessEqual <Required <CustomerPaymentMethod.expirationDate> > > > >(this);

                if (!string.IsNullOrEmpty(filter.CustomerClassID))
                {
                    select.WhereAnd <Where <Customer.customerClassID, Equal <Required <Customer.customerClassID> > > >();
                }

                if (filter.DefaultOnly == true)
                {
                    select.WhereAnd <Where <CustomerPaymentMethod.pMInstanceID, Equal <Customer.defPMInstanceID> > >();
                }
                if ((bool)filter.ActiveOnly)
                {
                    select.WhereAnd <Where <CustomerPaymentMethod.isActive, Equal <BQLConstants.BitOn> > >();
                }
                foreach (PXResult <CustomerPaymentMethod, Customer, Contact> it in select.Select(filter.BeginDate, filter.EndDate, filter.CustomerClassID, filter.ActiveOnly))
                {
                    CustomerPaymentMethod cpm = (CustomerPaymentMethod)it;
                    if (cpm.LastNotificationDate.HasValue && cpm.ExpirationDate.HasValue)
                    {
                        TimeSpan diff = cpm.ExpirationDate.Value - cpm.LastNotificationDate.Value;
                        if (diff.TotalDays > 0)
                        {
                            if (diff.TotalDays < filter.NoteLeftLimit)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            if (Math.Abs(diff.TotalDays) < filter.NoteRightLimit)
                            {
                                continue;
                            }
                        }
                    }

                    yield return(it);
                }
            }
            yield break;
        }
        public virtual IEnumerable contracts()
        {
            ExpiringContractFilter filter = this.Filter.Current;

            if (filter != null)
            {
                PXSelectBase <Contract> select = new PXSelectJoin <Contract
                                                                   , InnerJoin <ContractBillingSchedule, On <Contract.contractID, Equal <ContractBillingSchedule.contractID> >
                                                                                , InnerJoin <Customer, On <Customer.bAccountID, Equal <Contract.customerID> > > >,
                                                                   Where <Contract.isTemplate, Equal <False>,
                                                                          And <Contract.baseType, Equal <Contract.ContractBaseType>,
                                                                               And <Contract.expireDate, LessEqual <Current <ExpiringContractFilter.endDate> >,
                                                                                    And <Contract.expireDate, GreaterEqual <Current <ExpiringContractFilter.beginDate> >,
                                                                                         And <Contract.status, NotEqual <Contract.status.canceled> > > > > > >(this);

                if (filter.ShowAutoRenewable != true)
                {
                    select.WhereAnd <Where <Contract.autoRenew, Equal <False>, Or <Contract.autoRenew, IsNull> > >();
                }

                if (!string.IsNullOrEmpty(filter.CustomerClassID))
                {
                    select.WhereAnd <Where <Customer.customerClassID, Equal <Current <ExpiringContractFilter.customerClassID> > > >();
                }

                if (filter.TemplateID != null)
                {
                    select.WhereAnd <Where <Contract.templateID, Equal <Current <ExpiringContractFilter.templateID> > > >();
                }

                /*
                 * Expiring Contracts has a hierarchical structure and we need to show only the latest expiring node hidding
                 * all of its original contracts
                 */
                foreach (PXResult <Contract> result in select.Select())
                {
                    bool skipItem = false;
                    if (((Contract)result).Type == Contract.type.Expiring)
                    {
                        Contract child = PXSelect <Contract, Where <Contract.originalContractID, Equal <Required <Contract.originalContractID> > > > .Select(this, ((Contract)result).ContractID);

                        skipItem = child != null;
                    }

                    if (!skipItem)
                    {
                        yield return(result);
                    }
                }
            }
            else
            {
                yield break;
            }
        }
Esempio n. 16
0
        public virtual IEnumerable assets()
        {
            TransferFilter            filter = Filter.Current;
            PXSelectBase <FixedAsset> cmd    = new PXSelectJoin <FixedAsset,
                                                                 InnerJoin <FADetailsTransfer,
                                                                            On <FixedAsset.assetID, Equal <FADetailsTransfer.assetID> >,
                                                                            InnerJoin <Branch, On <FixedAsset.branchID, Equal <Branch.branchID> >,
                                                                                       LeftJoin <Account,
                                                                                                 On <FixedAsset.fAAccountID, Equal <Account.accountID> >,
                                                                                                 LeftJoin <FALocationHistory,
                                                                                                           On <FALocationHistory.assetID, Equal <FADetailsTransfer.assetID>,
                                                                                                               And <FALocationHistory.revisionID, Equal <FADetailsTransfer.locationRevID> > > > > > >,
                                                                 Where <FADetailsTransfer.status, NotEqual <FixedAssetStatus.hold>,
                                                                        And <FADetailsTransfer.status, NotEqual <FixedAssetStatus.disposed>,
                                                                             And <FADetailsTransfer.status, NotEqual <FixedAssetStatus.reversed> > > > >(this);

            if (filter.PeriodID != null)
            {
                cmd.WhereAnd <Where <FADetailsTransfer.transferPeriodID, IsNull, Or <FADetailsTransfer.transferPeriodID, LessEqual <Current <TransferFilter.periodID> > > > >();
            }
            if (PXAccess.FeatureInstalled <FeaturesSet.multipleCalendarsSupport>() || filter.OrganizationID != null)
            {
                cmd.WhereAnd <Where <Branch.organizationID, Equal <Current <TransferFilter.organizationID> > > >();
            }
            if (filter.BranchFrom != null)
            {
                cmd.WhereAnd <Where <FixedAsset.branchID, Equal <Current <TransferFilter.branchFrom> > > >();
            }
            if (filter.DepartmentFrom != null)
            {
                cmd.WhereAnd <Where <FALocationHistory.department, Equal <Current <TransferFilter.departmentFrom> > > >();
            }
            if (filter.ClassFrom != null)
            {
                cmd.WhereAnd <Where <FixedAsset.classID, Equal <Current <TransferFilter.classFrom> > > >();
            }

            int startRow  = PXView.StartRow;
            int totalRows = 0;
            List <PXFilterRow> newFilters = new List <PXFilterRow>();

            foreach (PXFilterRow f in PXView.Filters)
            {
                if (f.DataField.ToLower() == "status")
                {
                    f.DataField = "FADetailsTransfer__Status";
                }
                newFilters.Add(f);
            }
            List <object> list = cmd.View.Select(PXView.Currents, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, newFilters.ToArray(), ref startRow, PXView.MaximumRows, ref totalRows);

            PXView.StartRow = 0;
            return(list);
        }
Esempio n. 17
0
        public virtual IEnumerable records()
        {
            SchedulesFilter filter = this.Filter.Current;

            if (filter != null)
            {
                PXSelectBase <SchedulesInqResult> select = new PXSelectJoin <SchedulesInqResult,
                                                                             InnerJoin <DRSchedule, On <DRSchedule.scheduleID, Equal <SchedulesInqResult.scheduleID> >,
                                                                                        InnerJoin <DRDeferredCode, On <DRDeferredCode.deferredCodeID, Equal <SchedulesInqResult.defCode> >,
                                                                                                   LeftJoin <InventoryItem, On <InventoryItem.inventoryID, Equal <SchedulesInqResult.componentID> > > > >,
                                                                             Where <DRDeferredCode.accountType, Equal <Current <SchedulesFilter.accountType> > > >(this);

                if (!string.IsNullOrEmpty(filter.DeferredCode))
                {
                    select.WhereAnd <Where <SchedulesInqResult.defCode, Equal <Current <SchedulesFilter.deferredCode> > > >();
                }

                if (filter.AccountID != null)
                {
                    select.WhereAnd <Where <SchedulesInqResult.defAcctID, Equal <Current <SchedulesFilter.accountID> > > >();
                }

                if (filter.SubID != null)
                {
                    select.WhereAnd <Where <SchedulesInqResult.defSubID, Equal <Current <SchedulesFilter.subID> > > >();
                }

                if (filter.BAccountID != null)
                {
                    select.WhereAnd <Where <SchedulesInqResult.bAccountID, Equal <Current <SchedulesFilter.bAccountID> > > >();
                }

                if (filter.ComponentID != null)
                {
                    select.WhereAnd <Where <SchedulesInqResult.componentID, Equal <Current <SchedulesFilter.componentID> > > >();
                }


                foreach (PXResult <SchedulesInqResult, DRSchedule, DRDeferredCode, InventoryItem> record in select.Select())
                {
                    SchedulesInqResult sd   = (SchedulesInqResult)record;
                    InventoryItem      item = (InventoryItem)record;

                    sd.ComponentCD  = item.InventoryCD;
                    sd.DocumentType = DRScheduleDocumentType.BuildDocumentType(sd.Module, sd.DocType);

                    yield return(sd);
                }
            }
            else
            {
                yield break;
            }
        }
        public virtual IEnumerable items()
        {
            SchedulesFilter filter = this.Filter.Current;

            if (filter != null)
            {
                PXSelectBase <DRScheduleDetail> select = new PXSelectJoin <
                    DRScheduleDetail,
                    InnerJoin <DRSchedule,
                               On <DRSchedule.scheduleID, Equal <DRScheduleDetail.scheduleID> >,
                               InnerJoin <DRDeferredCode,
                                          On <DRDeferredCode.deferredCodeID, Equal <DRScheduleDetail.defCode> > > >,
                    Where <
                        DRDeferredCode.accountType, Equal <Current <SchedulesFilter.accountType> >,
                        And <DRScheduleDetail.status, Equal <DRScheduleStatus.DraftStatus>,
                             And <DRSchedule.isCustom, Equal <True> > > > >
                                                             (this);

                if (!string.IsNullOrEmpty(filter.DeferredCode))
                {
                    select.WhereAnd <Where <DRScheduleDetail.defCode, Equal <Current <SchedulesFilter.deferredCode> > > >();
                }

                if (filter.AccountID != null)
                {
                    select.WhereAnd <Where <DRScheduleDetail.defAcctID, Equal <Current <SchedulesFilter.accountID> > > >();
                }

                if (filter.SubID != null)
                {
                    select.WhereAnd <Where <DRScheduleDetail.defSubID, Equal <Current <SchedulesFilter.subID> > > >();
                }

                if (filter.BAccountID != null)
                {
                    select.WhereAnd <Where <DRScheduleDetail.bAccountID, Equal <Current <SchedulesFilter.bAccountID> > > >();
                }

                if (filter.ComponentID != null)
                {
                    select.WhereAnd <Where <DRScheduleDetail.componentID, Equal <Current <SchedulesFilter.componentID> > > >();
                }

                return(select.Select());
            }
            else
            {
                return(null);
            }
        }
Esempio n. 19
0
        protected virtual IEnumerable assets()
        {
            DisposalFilter filter = Filter.Current;

            PXSelectBase <FixedAsset> cmd = new PXSelectJoin <FixedAsset,
                                                              InnerJoin <FADetails, On <FixedAsset.assetID, Equal <FADetails.assetID> >,
                                                                         LeftJoin <Account, On <FixedAsset.fAAccountID, Equal <Account.accountID> > > >,
                                                              Where <FADetails.status, NotEqual <FixedAssetStatus.disposed>,
                                                                     And <FADetails.status, NotEqual <FixedAssetStatus.hold>,
                                                                          And <FADetails.status, NotEqual <FixedAssetStatus.suspended> > > > >(this);

            if (filter.BookID != null)
            {
                cmd.Join <InnerJoin <FABookBalance, On <FABookBalance.assetID, Equal <FixedAsset.assetID> > > >();
                cmd.WhereAnd <Where <FABookBalance.bookID, Equal <Current <DisposalFilter.bookID> > > >();
            }

            if (filter.ClassID != null)
            {
                cmd.WhereAnd <Where <FixedAsset.classID, Equal <Current <DisposalFilter.classID> > > >();
            }
            if (PXAccess.FeatureInstalled <FeaturesSet.multipleCalendarsSupport>() || filter.OrgBAccountID != null)
            {
                cmd.WhereAnd <Where <FixedAsset.branchID, Inside <Current <DisposalFilter.orgBAccountID> > > >();
            }
            if (filter.ParentAssetID != null)
            {
                cmd.WhereAnd <Where <FixedAsset.parentAssetID, Equal <Current <DisposalFilter.parentAssetID> > > >();
            }

            int startRow  = PXView.StartRow;
            int totalRows = 0;

            List <PXFilterRow> newFilters = new List <PXFilterRow>();

            foreach (PXFilterRow f in PXView.Filters)
            {
                if (f.DataField.ToLower() == "status")
                {
                    f.DataField = "FADetails__Status";
                }
                newFilters.Add(f);
            }
            List <object> list = cmd.View.Select(PXView.Currents, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, newFilters.ToArray(), ref startRow, PXView.MaximumRows, ref totalRows);

            PXView.StartRow = 0;
            return(list);
        }
        public virtual IEnumerable assets()
        {
            TransferFilter            filter = Filter.Current;
            PXSelectBase <FixedAsset> cmd    = new PXSelectJoin <FixedAsset,
                                                                 InnerJoin <FADetailsTransfer,
                                                                            On <FixedAsset.assetID, Equal <FADetailsTransfer.assetID> >,
                                                                            LeftJoin <Account,
                                                                                      On <FixedAsset.fAAccountID, Equal <Account.accountID> >,
                                                                                      LeftJoin <FALocationHistory,
                                                                                                On <FALocationHistory.assetID, Equal <FADetailsTransfer.assetID>,
                                                                                                    And <FALocationHistory.revisionID, Equal <FADetailsTransfer.locationRevID> > > > > >,
                                                                 Where <FADetailsTransfer.status, NotEqual <FixedAssetStatus.hold>,
                                                                        And <FADetailsTransfer.status, NotEqual <FixedAssetStatus.disposed> > > >(this);

            if (filter.PeriodID != null)
            {
                cmd.WhereAnd <Where <FADetailsTransfer.transferPeriodID, IsNull, Or <FADetailsTransfer.transferPeriodID, LessEqual <Current <TransferFilter.periodID> > > > >();
            }
            if (filter.BranchFrom != null)
            {
                cmd.WhereAnd <Where <FixedAsset.branchID, Equal <Current <TransferFilter.branchFrom> > > >();
            }
            if (filter.DepartmentFrom != null)
            {
                cmd.WhereAnd <Where <FALocationHistory.department, Equal <Current <TransferFilter.departmentFrom> > > >();
            }
            if (filter.ClassFrom != null)
            {
                cmd.WhereAnd <Where <FixedAsset.classID, Equal <Current <TransferFilter.classFrom> > > >();
            }

            int startRow  = 0;
            int totalRows = 0;
            List <PXFilterRow> newFilters = new List <PXFilterRow>();

            foreach (PXFilterRow f in PXView.Filters)
            {
                if (f.DataField.ToLower() == "status")
                {
                    f.DataField = "FADetailsTransfer__Status";
                }
                newFilters.Add(f);
            }
            // Full select - first page, query cache - next pages. SQL command is very difficult to part select for each page.
            List <object> list = cmd.View.Select(PXView.Currents, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, newFilters.ToArray(), ref startRow, 0, ref totalRows);

            return(list);
        }
        public virtual IEnumerable paymentTrans()
        {
            ExternalTransactionFilter filter = this.Filter.Current;

            if (filter != null)
            {
                PXSelectBase <ExternalTransactionExt> select = new PXSelectJoin <ExternalTransactionExt,
                                                                                 LeftJoin <Customer, On <Customer.bAccountID, Equal <ExternalTransactionExt.bAccountID> > >,
                                                                                 Where <ExternalTransactionExt.active, Equal <True>,
                                                                                        And <ExternalTransactionExt.refNbr, IsNotNull,
                                                                                             And <ExternalTransactionExt.docType, In <Required <ExternalTransactionExt.docType> >,
                                                                                                  And <ExternalTransactionExt.cCProcessingStatus, In <Required <ExternalTransactionExt.cCProcessingStatus> > > > > >,
                                                                                 OrderBy <Desc <ExternalTransactionExt.refNbr> > >(this);

                if (!string.IsNullOrEmpty(filter.ProcessingCenterID))
                {
                    select.WhereAnd <Where <ExternalTransactionExt.cCProcessingCenterID, Equal <Current <ExternalTransactionFilter.processingCenterID> > > >();
                }

                string[] docTypes = new string[] { ARDocType.CashSale, ARDocType.Payment, ARDocType.Prepayment };
                string[] statuses = new string[] { ExtTransactionProcStatusCode.AuthorizeHeldForReview, ExtTransactionProcStatusCode.CaptureHeldForReview };

                foreach (PXResult <ExternalTransactionExt, Customer> it in select.SelectWithViewContext(new object[] { docTypes, statuses }))
                {
                    yield return(it);
                }
            }

            yield break;
        }
        public override object Evaluate(PXCache cache, object item, Dictionary <Type, object> pars)
        {
            string         classID = (string)pars[typeof(ClassID)];
            CRContactClass cls     = PXSelect <CRContactClass, Where <CRContactClass.classID, Equal <Required <CRContactClass.classID> > > > .Select(cache.Graph, classID);

            if (cls == null)
            {
                return(null);
            }

            PXSelectBase <EPCompanyTreeMember> cmd = new PXSelectJoin <EPCompanyTreeMember,
                                                                       InnerJoin <EPCompanyTreeH, On <EPCompanyTreeMember.workGroupID, Equal <EPCompanyTreeH.workGroupID> > >,
                                                                       Where <EPCompanyTreeMember.userID, Equal <Required <EPCompanyTreeMember.userID> > > >(cache.Graph);

            if (cls.DefaultWorkgroupID != null && cls.OwnerIsCreatedUser != true)
            {
                return(cls.DefaultWorkgroupID);
            }
            else if (cls.DefaultWorkgroupID != null && cls.OwnerIsCreatedUser == true)
            {
                cmd.WhereAnd <Where <EPCompanyTreeH.parentWGID, Equal <Required <EPCompanyTreeH.parentWGID> > > >();
                EPCompanyTreeMember m = cmd.SelectSingle(cache.Graph.Accessinfo.UserID, cls.DefaultWorkgroupID);
                return(m.With(_ => _.WorkGroupID));
            }
            else if (cls.DefaultWorkgroupID == null && cls.OwnerIsCreatedUser == true && cls.DefaultOwnerWorkgroup == true)
            {
                EPCompanyTreeMember m = cmd.SelectSingle(cache.Graph.Accessinfo.UserID);
                return(m.With(_ => _.WorkGroupID));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 23
0
        public override void Verify(PXCache cache, object item, List <object> pars, ref bool?result, ref object value)
        {
            string         classID = (string)Calculate <ClassID>(cache, item);
            CRContactClass cls     = PXSelect <CRContactClass, Where <CRContactClass.classID, Equal <Required <CRContactClass.classID> > > > .Select(cache.Graph, classID);

            if (cls == null)
            {
                return;
            }

            PXSelectBase <EPCompanyTreeMember> cmd = new PXSelectJoin <EPCompanyTreeMember,
                                                                       InnerJoin <EPCompanyTreeH, On <EPCompanyTreeMember.workGroupID, Equal <EPCompanyTreeH.workGroupID> > >,
                                                                       Where <EPCompanyTreeMember.userID, Equal <Required <EPCompanyTreeMember.userID> > > >(cache.Graph);

            if (cls.DefaultWorkgroupID != null && cls.OwnerIsCreatedUser != true)
            {
                value = cls.DefaultWorkgroupID;
            }
            else if (cls.DefaultWorkgroupID != null && cls.OwnerIsCreatedUser == true)
            {
                cmd.WhereAnd <Where <EPCompanyTreeH.parentWGID, Equal <Required <EPCompanyTreeH.parentWGID> > > >();
                EPCompanyTreeMember m = cmd.SelectSingle(cache.Graph.Accessinfo.UserID, cls.DefaultWorkgroupID);
                value = m.With(_ => _.WorkGroupID);
            }
            else if (cls.DefaultWorkgroupID == null && cls.OwnerIsCreatedUser == true && cls.DefaultOwnerWorkgroup == true)
            {
                EPCompanyTreeMember m = cmd.SelectSingle(cache.Graph.Accessinfo.UserID);
                value = m.With(_ => _.WorkGroupID);
            }
            else
            {
                value = null;
            }
        }
Esempio n. 24
0
        protected PXResultset <Customer> GetCustomersToProcess(CreditHoldParameters header)
        {
            switch (header.Action)
            {
            case CreditHoldParameters.ActionApplyCreditHold:

                return(PXSelectJoin <Customer,
                                     InnerJoin <ARDunningLetter, On <Customer.bAccountID, Equal <ARDunningLetter.bAccountID>,
                                                                     And <ARDunningLetter.lastLevel, Equal <True>,
                                                                          And <ARDunningLetter.released, Equal <True>,
                                                                               And <ARDunningLetter.voided, NotEqual <True> > > > > >,
                                     Where <ARDunningLetter.dunningLetterDate,
                                            Between <Required <ARDunningLetter.dunningLetterDate>, Required <ARDunningLetter.dunningLetterDate> > >,
                                     OrderBy <Asc <ARDunningLetter.bAccountID> > > .Select(this, header.BeginDate, header.EndDate));

            case CreditHoldParameters.ActionReleaseCreditHold:

                PXSelectBase <Customer> select = new PXSelectJoin <Customer,
                                                                   LeftJoin <ARDunningLetter, On <Customer.bAccountID, Equal <ARDunningLetter.bAccountID>,
                                                                                                  And <ARDunningLetter.lastLevel, Equal <True>,
                                                                                                       And <ARDunningLetter.released, Equal <True>,
                                                                                                            And <ARDunningLetter.voided, NotEqual <True> > > > > > >(this);
                if (PXAccess.FeatureInstalled <FeaturesSet.parentChildAccount>())
                {
                    select.WhereAnd <Where <Customer.bAccountID, Equal <Customer.sharedCreditCustomerID> > >();
                }
                return(select.Select());

            default:
                return(new PXResultset <Customer>());
            }
        }
        protected virtual IEnumerable spdocs()
        {
            List <ARSPCommnDocResult> res = new List <ARSPCommnDocResult>();
            SPDocFilter filter            = Filter.Current;

            if (filter?.CommnPeriod != null)
            {
                PXSelectBase <ARSalesPerTran> sel = new PXSelectJoin <ARSalesPerTran,
                                                                      InnerJoin <ARRegister, On <ARSalesPerTran.docType, Equal <ARRegister.docType>,
                                                                                                 And <ARSalesPerTran.refNbr, Equal <ARRegister.refNbr> > >,
                                                                                 InnerJoinSingleTable <Customer, On <Customer.bAccountID, Equal <ARRegister.customerID>,
                                                                                                                     And <Match <Customer, Current <AccessInfo.userName> > > > > >,
                                                                      Where <ARSalesPerTran.actuallyUsed, Equal <BQLConstants.BitOn> > >(this);

                if (filter.SalesPersonID != null)
                {
                    sel.WhereAnd <Where <ARSalesPerTran.salespersonID, Equal <Current <SPDocFilter.salesPersonID> > > >();
                }
                if (filter.CommnPeriod != null)
                {
                    sel.WhereAnd <Where <ARSalesPerTran.commnPaymntPeriod, Equal <Current <SPDocFilter.commnPeriod> > > >();
                }
                if (filter.CustomerID != null)
                {
                    sel.WhereAnd <Where <ARRegister.customerID, Equal <Current <SPDocFilter.customerID> > > >();
                }
                if (filter.LocationID != null)
                {
                    sel.WhereAnd <Where <ARRegister.customerLocationID, Equal <Current <SPDocFilter.locationID> > > >();
                }

                PXView        view              = sel.View;
                int           startRow          = PXView.StartRow;
                int           totalRows         = 0;
                List <object> windowedSelection = view.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows);
                PXView.StartRow = 0;

                foreach (PXResult <ARSalesPerTran, ARRegister, Customer> it in windowedSelection)
                {
                    ARSPCommnDocResult m = new ARSPCommnDocResult();
                    Copy(m, ((ARSalesPerTran)it));
                    Copy(m, ((ARRegister)it));
                    res.Add(m);
                }
            }
            return(res);
        }
Esempio n. 26
0
        public virtual IEnumerable routeDocuments()
        {
            var commandFilter = new PXSelectJoin <FSRouteDocument,
                                                  InnerJoin <FSRoute,
                                                             On <FSRoute.routeID, Equal <FSRouteDocument.routeID> > > >(this);

            var filter = Filter.Current;

            //Filters
            if (filter.FromDate != null)
            {
                commandFilter.WhereAnd <Where <FSRouteDocument.date, GreaterEqual <CurrentValue <RouteDocumentFilter.fromDate> > > >();
            }

            if (filter.ToDate != null)
            {
                commandFilter.WhereAnd <Where <FSRouteDocument.date, LessEqual <CurrentValue <RouteDocumentFilter.toDate> > > >();
            }

            if (filter.RouteID != null)
            {
                commandFilter.WhereAnd <Where <FSRouteDocument.routeID, Equal <CurrentValue <RouteDocumentFilter.routeID> > > >();
            }

            if (filter.StatusOpen == true || filter.StatusInProcess == true || filter.StatusCanceled == true || filter.StatusCompleted == true || filter.StatusClosed == true)
            {
                SetWhereStatus(filter.StatusOpen, filter.StatusInProcess, filter.StatusCanceled, filter.StatusCompleted, filter.StatusClosed, commandFilter);
            }

            int startRow  = PXView.StartRow;
            int totalRows = 0;
            var list      = commandFilter.View.Select(
                PXView.Currents,
                PXView.Parameters,
                PXView.Searches,
                PXView.SortColumns,
                PXView.Descendings,
                PXView.Filters,
                ref startRow,
                PXView.MaximumRows,
                ref totalRows);

            PXView.StartRow = 0;

            return(list);
        }
Esempio n. 27
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);
            }
        }
Esempio n. 28
0
        public virtual IEnumerable records()
        {
            ScheduleTransFilter filter = this.Filter.Current;

            if (filter != null)
            {
                PXSelectBase <DRScheduleTran> select = new PXSelectJoin <DRScheduleTran,
                                                                         InnerJoin <DRScheduleDetail, On <DRScheduleTran.scheduleID, Equal <DRScheduleDetail.scheduleID>,
                                                                                                          And <DRScheduleTran.componentID, Equal <DRScheduleDetail.componentID>,
                                                                                                               And <DRScheduleTran.detailLineNbr, Equal <DRScheduleDetail.detailLineNbr> > > >,
                                                                                    InnerJoin <DRDeferredCode, On <DRDeferredCode.deferredCodeID, Equal <DRScheduleDetail.defCode> >,
                                                                                               LeftJoin <InventoryItem, On <InventoryItem.inventoryID, Equal <DRScheduleDetail.componentID> > > > >,
                                                                         Where <DRDeferredCode.accountType, Equal <Current <ScheduleTransFilter.accountType> >,
                                                                                And <DRScheduleTran.status, Equal <DRScheduleTranStatus.PostedStatus> > > >(this);

                if (!string.IsNullOrEmpty(filter.DeferredCode))
                {
                    select.WhereAnd <Where <DRScheduleDetail.defCode, Equal <Current <ScheduleTransFilter.deferredCode> > > >();
                }

                if (filter.UseMasterCalendar == true)
                {
                    select.WhereAnd <Where <DRScheduleTran.tranPeriodID, Equal <Current <ScheduleTransFilter.finPeriodID> > > >();
                }
                else
                {
                    select.WhereAnd <Where <DRScheduleTran.finPeriodID, Equal <Current <ScheduleTransFilter.finPeriodID> > > >();
                }

                if (filter.OrgBAccountID != null)
                {
                    select.WhereAnd <Where <DRScheduleTran.branchID, Inside <Current <ScheduleTransFilter.orgBAccountID> > > >();              //MatchWithOrg
                }

                if (filter.AccountID != null)
                {
                    select.WhereAnd <Where <DRScheduleTran.accountID, Equal <Current <ScheduleTransFilter.accountID> > > >();
                }

                if (filter.SubID != null)
                {
                    select.WhereAnd <Where <DRScheduleTran.subID, Equal <Current <ScheduleTransFilter.subID> > > >();
                }

                if (filter.BAccountID != null)
                {
                    select.WhereAnd <Where <DRScheduleDetail.bAccountID, Equal <Current <ScheduleTransFilter.bAccountID> > > >();
                }

                foreach (object x in this.QuickSelect(select.View.BqlSelect))
                {
                    yield return(x);
                }
            }
            else
            {
                yield break;
            }
        }
        public virtual IEnumerable records()
        {
            ScheduleTransFilter filter = this.Filter.Current;

            if (filter != null)
            {
                PXSelectBase <DRScheduleTran> select = new PXSelectJoin <DRScheduleTran,
                                                                         InnerJoin <DRScheduleDetail, On <DRScheduleTran.scheduleID, Equal <DRScheduleDetail.scheduleID>, And <DRScheduleTran.componentID, Equal <DRScheduleDetail.componentID> > >,
                                                                                    InnerJoin <DRDeferredCode, On <DRDeferredCode.deferredCodeID, Equal <DRScheduleDetail.defCode> >,
                                                                                               LeftJoin <InventoryItem, On <InventoryItem.inventoryID, Equal <DRScheduleDetail.componentID> > > > >,
                                                                         Where <DRDeferredCode.accountType, Equal <Current <ScheduleTransFilter.accountType> >,
                                                                                And <DRScheduleTran.status, Equal <DRScheduleTranStatus.PostedStatus>,
                                                                                     And <DRScheduleTran.finPeriodID, Equal <Current <ScheduleTransFilter.finPeriodID> > > > > >(this);

                if (!string.IsNullOrEmpty(filter.DeferredCode))
                {
                    select.WhereAnd <Where <DRScheduleDetail.defCode, Equal <Current <ScheduleTransFilter.deferredCode> > > >();
                }

                if (filter.AccountID != null)
                {
                    select.WhereAnd <Where <DRScheduleTran.accountID, Equal <Current <ScheduleTransFilter.accountID> > > >();
                }

                if (filter.SubID != null)
                {
                    select.WhereAnd <Where <DRScheduleTran.subID, Equal <Current <ScheduleTransFilter.subID> > > >();
                }

                if (filter.BAccountID != null)
                {
                    select.WhereAnd <Where <DRScheduleDetail.bAccountID, Equal <Current <ScheduleTransFilter.bAccountID> > > >();
                }

                foreach (object x in select.Select())
                {
                    yield return(x);
                }
            }
            else
            {
                yield break;
            }
        }
Esempio n. 30
0
        public virtual IEnumerable documents()
        {
            SurveyFilter filter = Filter.Current;
            var          action = filter.Action;
            var          cmd    = new PXSelectJoin <SurveyCollector,
                                                    LeftJoin <Survey, On <Survey.surveyID, Equal <SurveyCollector.surveyID> >,
                                                              LeftJoin <SurveyUser, On <SurveyUser.surveyID, Equal <SurveyCollector.surveyID>,
                                                                                        And <SurveyUser.lineNbr, Equal <SurveyCollector.userLineNbr> > > > >,
                                                    Where <SurveyUser.anonymous, IsNull, Or <SurveyUser.anonymous, Equal <False> > >
                                                    >(this);

            switch (action)
            {
            case SurveyAction.SendNew:
                cmd.WhereAnd <Where <SurveyCollector.sentOn, IsNull> >();
                break;

            case SurveyAction.ExpireOnly:
                //cmd.WhereAnd<Where<SurveyCollector.status, SurveyCollector.notProcessed>>();
                break;

            case SurveyAction.RemindOnly:
                cmd.WhereAnd <Where <SurveyCollector.sentOn, IsNotNull> >();
                //cmd.WhereAnd<Where<SurveyCollector.status, Equal<CollectorStatus.sent>>>();
                break;
            }
            /* Filter by SurveyID */
            if (!string.IsNullOrEmpty(filter.SurveyID))
            {
                cmd.WhereAnd <Where <SurveyCollector.surveyID, Equal <Current <SurveyFilter.surveyID> > > >();
            }
            /* Filter by ShowClosed */
            if (filter.ShowClosed != true)
            {
                cmd.WhereAnd <Where <Survey.status, NotEqual <SurveyStatus.closed> > >();
            }
            var rows = cmd.Select();

            return(rows);
        }