Exemplo n.º 1
0
        protected virtual List <PMTran> CreateExpenseTransactions(PMTask task, out DateTime?lastDate)
        {
            lastDate = null;

            PXSelectBase <PMProjectStatus> select = new PXSelectJoin <PMProjectStatus,
                                                                      InnerJoin <PMTask, On <PMTask.projectID, Equal <PMProjectStatus.projectID>, And <PMTask.taskID, Equal <PMProjectStatus.projectTaskID> > >,
                                                                                 InnerJoin <PMAccountGroup, On <PMProjectStatus.accountGroupID, Equal <PMAccountGroup.groupID> >,
                                                                                            LeftJoin <InventoryItem, On <PMProjectStatus.inventoryID, Equal <InventoryItem.inventoryID> > > > >,
                                                                      Where <PMProjectStatus.projectID, Equal <Required <PMTask.projectID> >,
                                                                             And <PMProjectStatus.projectTaskID, Equal <Required <PMTask.taskID> >,
                                                                                  And <PMAccountGroup.type, Equal <AccountType.expense> > > > >(this);

            List <PMTran> trans = new List <PMTran>();

            foreach (PXResult <PMProjectStatus, PMTask, PMAccountGroup, InventoryItem> res in select.Select(task.ProjectID, task.TaskID))
            {
                PMProjectStatus ps   = (PMProjectStatus)res;
                InventoryItem   item = (InventoryItem)res;

                PMTran tran = new PMTran();
                tran.AccountGroupID = ps.AccountGroupID;
                tran.ProjectID      = ps.ProjectID;
                tran.TaskID         = ps.ProjectTaskID;
                tran.InventoryID    = ps.InventoryID;
                tran.AccountID      = item.InventoryID != null ? item.COGSAcctID : null;
                tran.SubID          = item.InventoryID != null ? item.COGSSubID : null;
                tran.Amount         = ps.Amount;
                tran.Qty            = ps.Qty;
                tran.UOM            = ps.UOM;
                tran.BAccountID     = task.CustomerID;
                tran.LocationID     = task.LocationID;
                tran.Billable       = true;
                tran.UseBillableQty = true;
                tran.BillableQty    = ps.RevisedQty;
                tran.Date           = FinPeriodIDAttribute.PeriodEndDate(this, ps.PeriodID);
                tran.StartDate      = tran.Date;
                tran.EndDate        = tran.Date;
                tran.FinPeriodID    = ps.PeriodID;
                tran.TranPeriodID   = ps.PeriodID;
                tran.Released       = true;

                if (lastDate != null)
                {
                    if (lastDate < tran.Date)
                    {
                        lastDate = tran.Date;
                    }
                }
                else
                {
                    lastDate = tran.Date;
                }
                trans.Add(Transactions.Insert(tran));
            }

            return(trans);
        }
Exemplo n.º 2
0
        protected virtual void RunAutoBudget(PMTask task)
        {
            PXSelectBase <PMProjectStatus> select = new PXSelectJoin <PMProjectStatus,
                                                                      InnerJoin <PMTask, On <PMTask.projectID, Equal <PMProjectStatus.projectID>, And <PMTask.taskID, Equal <PMProjectStatus.projectTaskID> > >,
                                                                                 InnerJoin <PMAccountGroup, On <PMProjectStatus.accountGroupID, Equal <PMAccountGroup.groupID> >,
                                                                                            LeftJoin <InventoryItem, On <PMProjectStatus.inventoryID, Equal <InventoryItem.inventoryID> > > > >,
                                                                      Where <PMProjectStatus.projectID, Equal <Required <PMTask.projectID> >,
                                                                             And <PMProjectStatus.projectTaskID, Equal <Required <PMTask.taskID> >,
                                                                                  And <PMAccountGroup.type, Equal <AccountType.expense> > > > >(this);

            List <PMTran> trans = new List <PMTran>();

            foreach (PXResult <PMProjectStatus, PMTask, PMAccountGroup, InventoryItem> res in select.Select(task.ProjectID, task.TaskID))
            {
                PMProjectStatus ps   = (PMProjectStatus)res;
                InventoryItem   item = (InventoryItem)res;

                PMTran tran = new PMTran();
                tran.AccountGroupID = ps.AccountGroupID;
                tran.ProjectID      = ps.ProjectID;
                tran.TaskID         = ps.ProjectTaskID;
                tran.InventoryID    = ps.InventoryID;
                tran.AccountID      = item.InventoryID != null ? item.SalesAcctID : null;
                tran.Amount         = ps.RevisedAmount;
                tran.Qty            = ps.RevisedQty;
                tran.UOM            = ps.UOM;
                tran.BAccountID     = task.CustomerID;
                tran.LocationID     = task.LocationID;
                tran.Billable       = true;
                tran.BillableQty    = ps.RevisedQty;
                tran.Date           = FinPeriodIDAttribute.PeriodEndDate(this, ps.PeriodID);
                tran.StartDate      = tran.Date;
                tran.EndDate        = tran.Date;
                tran.FinPeriodID    = ps.PeriodID;
                tran.TranPeriodID   = ps.PeriodID;

                trans.Add(tran);
            }
        }
Exemplo n.º 3
0
 public DateTime PeriodEndDate(PXGraph graph, string financialPeriodID)
 {
     return(FinPeriodIDAttribute.PeriodEndDate(graph, financialPeriodID));
 }