Esempio n. 1
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());
        }
Esempio n. 2
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));
        }
        public virtual IEnumerable transactions()
        {
            TranFilter filter = this.Filter.Current;

            if (filter != null && (
                    filter.ProjectID != null ||
                    filter.AccountID != null ||
                    filter.AccountGroupID != null ||
                    filter.ARRefNbr != null ||
                    filter.TranID != null))
            {
                var parameters = new List <object>();
                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> > > > >,
                                                                 Where <True, Equal <True> > >(this);

                if (filter.ARRefNbr != null)
                {
                    //nbrs of batches originated from invoice
                    var refNbrs = PXSelectJoin <ARInvoice,
                                                InnerJoin <PMRegister, On <PMRegister.origNoteID, Equal <ARInvoice.noteID> > >,
                                                Where <ARRegister.docType, Equal <Current <TranFilter.aRDocType> >,
                                                       And <ARRegister.refNbr, Equal <Current <TranFilter.aRRefNbr> > > > > .Select(this)
                                  .Select(r => ((PMRegister)(PXResult <ARInvoice, PMRegister>)r).RefNbr).ToArray();

                    if (refNbrs.Any())
                    {
                        parameters.Add(refNbrs);
                        select.WhereAnd <Where2
                                         <Where <PMTran.aRTranType, Equal <Current <TranFilter.aRDocType> >, And <PMTran.aRRefNbr, Equal <Current <TranFilter.aRRefNbr> > > >,
                                          Or
                                          <Where <PMTran.refNbr, In <Required <PMTran.refNbr> > > > > >();
                    }
                    else
                    {
                        select.WhereAnd <Where <PMTran.aRTranType, Equal <Current <TranFilter.aRDocType> >, And <PMTran.aRRefNbr, Equal <Current <TranFilter.aRRefNbr> > > > >();
                    }
                }

                if (filter.TranID != null)
                {
                    select.WhereAnd <Where <PMTran.tranID, Equal <Current <TranFilter.tranID> > > >();
                }

                if (filter.ProjectID != null)
                {
                    select.WhereAnd <Where <PMTran.projectID, Equal <Current <TranFilter.projectID> > > >();
                }

                if (filter.AccountGroupID != null)
                {
                    select.WhereAnd <Where <PMTran.accountGroupID, Equal <Current <TranFilter.accountGroupID> >, Or <Account.accountGroupID, Equal <Current <TranFilter.accountGroupID> > > > >();
                }

                if (filter.AccountID != null)
                {
                    select.WhereAnd <Where <PMTran.accountID, Equal <Current <TranFilter.accountID> >, Or <Account.accountID, Equal <Current <TranFilter.accountID> > > > >();
                }

                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.IncludeUnreleased.GetValueOrDefault() == false)
                {
                    select.WhereAnd <Where <PMRegister.released, 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, parameters.ToArray()));
            }
            return(Enumerable.Empty <PMTran>());
        }
        protected virtual void TranFilter_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            TranFilter filter = Filter.Current;

            Items.SetProcessDelegate(ReverseAllocatedTran);
        }
        protected virtual IEnumerable items()
        {
            PXSelectBase <PMTran> select = new PXSelectJoin <PMTran,
                                                             InnerJoin <PMRegister, On <PMRegister.module, Equal <PMTran.tranType>, And <PMRegister.refNbr, Equal <PMTran.refNbr> > >,
                                                                        InnerJoin <PMProject, On <PMProject.contractID, Equal <PMTran.projectID> >,
                                                                                   InnerJoin <PMTask, On <PMTask.projectID, Equal <PMTran.projectID>, And <PMTask.taskID, Equal <PMTran.taskID> > >,
                                                                                              LeftJoin <Customer, On <Customer.bAccountID, Equal <PMProject.customerID> > > > > >,
                                                             Where <PMTran.allocated, Equal <True>,
                                                                    And <PMTran.billed, Equal <False>,
                                                                         And <PMTran.released, Equal <True>,
                                                                              And <PMTran.reversed, Equal <False> > > > > >(this);

            TranFilter filter = this.Filter.Current;

            if (filter != null)
            {
                if (Filter.Current.BillingID != null)
                {
                    select.WhereAnd <Where <PMTran.billingID, Equal <Current <TranFilter.billingID> > > >();
                }

                if (Filter.Current.ProjectID != null)
                {
                    select.WhereAnd <Where <PMTran.projectID, Equal <Current <TranFilter.projectID> > > >();

                    if (Filter.Current.ProjectTaskID != null)
                    {
                        select.WhereAnd <Where <PMTran.taskID, Equal <Current <TranFilter.projectTaskID> > > >();
                    }
                }

                if (Filter.Current.CustomerID != null)
                {
                    select.WhereAnd <Where <PMProject.customerID, Equal <Current <TranFilter.customerID> > > >();
                }

                if (Filter.Current.CustomerClassID != null)
                {
                    select.WhereAnd <Where <Customer.customerClassID, Equal <Current <TranFilter.customerClassID> > > >();
                }
                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.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> > > >();
                }
            }

            foreach (PXResult <PMTran, PMRegister, PMProject, PMTask, Customer> res in select.Select())
            {
                PMTran tran = (PMTran)res;
                PMTask task = (PMTask)res;

                if (!IsUnbilled(tran, task.BillingID))
                {
                    continue;
                }

                yield return(res);
            }
        }