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.baseType, Equal <CTPRType.contract>,
                                                                          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;
            }
        }
Example #2
0
        protected virtual IEnumerable items()
        {
            ExpiringContractFilter filter = Filter.Current;

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

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


            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 <boolFalse>,
                                                                      And <Contract.baseType, Equal <Contract.ContractBaseType>,
                                                                           And <Contract.expireDate, LessEqual <Current <ExpiringContractFilter.endDate> >,
                                                                                And <Contract.type, NotEqual <ContractType.ContractUnlimited>,
                                                                                     And <Contract.autoRenew, Equal <boolTrue>,
                                                                                          And <Where <Contract.status, Equal <ContractStatus.ContractStatusActivated>, Or <Contract.status, Equal <ContractStatus.ContractStatusExpired> > > > > > > > > >(this);


            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, ContractBillingSchedule, Customer> resultSet in select.Select())
            {
                Contract contract = (Contract)resultSet;
                ContractBillingSchedule schedule = (ContractBillingSchedule)resultSet;
                Customer customer = (Customer)resultSet;

                bool skipItem = false;
                if (contract.Type == ContractType.Expiring)
                {
                    Contract child = PXSelect <Contract, Where <Contract.originalContractID, Equal <Required <Contract.originalContractID> > > > .Select(this, contract.ContractID);

                    skipItem = child != null;
                }

                if (!skipItem)
                {
                    ContractsList result = new ContractsList();
                    result.ContractID   = contract.ContractID;
                    result.Description  = contract.Description;
                    result.Type         = contract.Type;
                    result.ExpireDate   = contract.ExpireDate;
                    result.CustomerID   = contract.CustomerID;
                    result.CustomerName = customer.AcctName;
                    result.LastDate     = schedule.LastDate;
                    result.NextDate     = schedule.NextDate;
                    result.ExpireDate   = contract.ExpireDate;
                    result.TemplateID   = contract.TemplateID;
                    result.Status       = contract.Status;
                    result.StartDate    = contract.StartDate;

                    yield return(Items.Insert(result));
                }
            }

            Items.Cache.IsDirty = false;
        }
Example #3
0
        protected virtual void ExpiringContractFilter_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            ExpiringContractFilter filter = Filter.Current;

            Items.SetProcessDelegate <ContractMaint>(RenewContract);
        }