public static void RenewContract(ContractMaint docgraph, ContractsList item, RenewalContractFilter filter)
        {
            docgraph.Contracts.Current = PXSelect <Contract, Where <Contract.contractID, Equal <Required <Contract.contractID> > > > .Select(docgraph, item.ContractID);

            docgraph.Billing.Current = docgraph.Billing.Select();
            docgraph.RenewContract(filter.RenewalDate.Value);
        }
        protected virtual void RenewalContractFilter_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            RenewalContractFilter filter = Filter.Current;

            Items.SetProcessDelegate <ContractMaint>(delegate(ContractMaint graph, ContractsList item)
            {
                RenewContract(graph, item, filter);
            });
        }
示例#3
0
        protected virtual IEnumerable items()
        {
            RenewalContractFilter filter = Filter.Current;
            BqlCommand            select = new Select <ContractsList,
                                                       Where <Add <ContractsList.expireDate, IsNull <Minus <ContractsList.autoRenewDays>, Zero> >, LessEqual <Current <RenewalContractFilter.renewalDate> > >,
                                                       OrderBy <Asc <ContractsList.contractCD> > >();


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

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

            return(this.QuickSelect(select));
        }
        protected virtual IEnumerable items()
        {
            RenewalContractFilter 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, NotEqual <True>,
                                                                      And <Contract.baseType, Equal <Contract.ContractBaseType>,
                                                                           And <Contract.type, NotEqual <Contract.type.unlimited>,
                                                                                And <Contract.autoRenew, Equal <True>,
                                                                                     And <Where <Contract.status, Equal <Contract.status.active>,
                                                                                                 Or <Contract.status, Equal <Contract.status.expired> > > > > > > > >(this);


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

            if (filter.TemplateID != null)
            {
                select.WhereAnd <Where <Contract.templateID, Equal <Current <RenewalContractFilter.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 = resultSet;
                ContractBillingSchedule schedule = resultSet;
                Customer customer = resultSet;

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

                    skipItem = child != null;
                }

                if (!skipItem && contract.ExpireDate != null &&
                    ((DateTime)contract.ExpireDate).AddDays(-(contract.AutoRenewDays ?? 0)) <= filter.RenewalDate)
                {
                    yield return(Items.Insert(new ContractsList
                    {
                        ContractID = contract.ContractID,
                        Description = contract.Description,
                        Type = contract.Type,
                        ExpireDate = contract.ExpireDate,
                        CustomerID = contract.CustomerID,
                        CustomerName = customer.AcctName,
                        LastDate = schedule.LastDate,
                        NextDate = schedule.NextDate,
                        TemplateID = contract.TemplateID,
                        Status = contract.Status,
                        StartDate = contract.StartDate
                    }));
                }
            }

            Items.Cache.IsDirty = false;
        }