Exemple #1
0
        protected virtual void _(Events.FieldDefaulting <PMTimeActivity, PMTimeActivity.projectTaskID> e)
        {
            if (e.Row == null)
            {
                return;
            }

            if (e.Row.ParentTaskNoteID != null)
            {
                EPActivityApprove rowParentTask = PXSelect <EPActivityApprove> .Search <EPActivityApprove.noteID>(this, e.Row.ParentTaskNoteID);

                if (rowParentTask != null && rowParentTask.ProjectID == e.Row.ProjectID)
                {
                    e.NewValue = rowParentTask.ProjectTaskID;
                    e.Cancel   = true;
                }
            }

            EPEarningType earningRow = (EPEarningType)PXSelectorAttribute.Select <EPActivityApprove.earningTypeID>(e.Cache, e.Row);

            if (e.NewValue == null && earningRow != null && earningRow.ProjectID == e.Row.ProjectID)
            {
                PMTask defTask = PXSelectorAttribute.Select(e.Cache, e.Row, e.Cache.GetField(typeof(EPTimeCardSummary.projectTaskID)), earningRow.TaskID) as PMTask;
                if (defTask != null && defTask.VisibleInTA == true)
                {
                    e.NewValue = earningRow.TaskID;
                    e.Cancel   = true;
                }
            }
        }
Exemple #2
0
        protected virtual void EPActivityApprove_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            if (e.Row == null ||
                !TimeCardHelper.IsTheTimeCardIntegrationEnabled(Base))
            {
                return;
            }

            EPActivityApprove epActivityApproveRow = (EPActivityApprove)e.Row;

            TimeCardHelper.PMTimeActivity_RowSelected_Handler(cache, epActivityApproveRow);
        }
        protected virtual void _(Events.RowSelected <EPActivityApprove> e)
        {
            if (e.Row == null ||
                !TimeCardHelper.IsTheTimeCardIntegrationEnabled(Base))
            {
                return;
            }

            EPActivityApprove epActivityApproveRow = (EPActivityApprove)e.Row;

            TimeCardHelper.PMTimeActivity_RowSelected_Handler(e.Cache, epActivityApproveRow);
        }
 public static void FindEPActivityApprove(PXGraph graph,
                                          FSAppointmentLog fsAppointmentLogRow,
                                          TMEPEmployee epEmployeeRow,
                                          ref EPActivityApprove epActivityApproveRow)
 {
     epActivityApproveRow = PXSelect <EPActivityApprove,
                                      Where <
                                          EPActivityApprove.ownerID, Equal <Required <EPActivityApprove.ownerID> >,
                                          And <FSxPMTimeActivity.appointmentID, Equal <Required <FSxPMTimeActivity.appointmentID> >,
                                               And <FSxPMTimeActivity.logLineNbr, Equal <Required <FSxPMTimeActivity.logLineNbr> > > > > >
                            .Select(graph, epEmployeeRow.PKID, fsAppointmentLogRow.DocID, fsAppointmentLogRow.LineNbr);
 }
Exemple #5
0
        private static void DeleteEPActivityApprove(
            EmployeeActivitiesEntry graphEmployeeActivitiesEntry,
            EPActivityApprove epActivityApproveRow)
        {
            if (epActivityApproveRow != null)
            {
                if (epActivityApproveRow.ApprovalStatus == ActivityStatusListAttribute.Approved || epActivityApproveRow.TimeCardCD != null)
                {
                    return;
                }

                graphEmployeeActivitiesEntry.Activity.Delete(epActivityApproveRow);
                graphEmployeeActivitiesEntry.Save.Press();
            }
        }
        private static void SearchAndDeleteEPActivity(AppointmentEntry graphAppointmentEntry,
                                                      FSAppointmentLog fsAppointmentLogRow,
                                                      EmployeeActivitiesEntry graphEmployeeActivitiesEntry)
        {
            EPActivityApprove epActivityApproveRow = null;
            TMEPEmployee      epEmployeeRow        = null;

            FindTMEmployee(graphAppointmentEntry, fsAppointmentLogRow.BAccountID, ref epEmployeeRow);
            FindEPActivityApprove(graphAppointmentEntry, fsAppointmentLogRow, epEmployeeRow, ref epActivityApproveRow);

            if (epActivityApproveRow != null)
            {
                DeleteEPActivityApprove(graphEmployeeActivitiesEntry, epActivityApproveRow);
            }
        }
Exemple #7
0
        public static void InsertUpdateEPActivityApprove(
            PXGraph graph,
            EmployeeActivitiesEntry graphEmployeeActivitiesEntry,
            FSAppointmentEmployee fsAppointmentEmployeeRow,
            FSAppointment fsAppointmentRow,
            FSServiceOrder fsServiceOrderRow,
            EPActivityApprove epActivityApproveRow,
            TMEPEmployee epEmployeeRow)
        {
            if (epActivityApproveRow != null &&
                (epActivityApproveRow.ApprovalStatus == ActivityStatusListAttribute.Approved || epActivityApproveRow.TimeCardCD != null))
            {
                return;
            }

            FSAppointmentDetService fsAppointmentDetServiceRow =
                PXSelectJoin <FSAppointmentDetService,
                              InnerJoin <FSSODet,
                                         On <FSSODet.sODetID, Equal <FSAppointmentDetService.sODetID> > >,
                              Where <
                                  FSSODet.lineRef, Equal <Required <FSSODet.lineRef> >,
                                  And <FSSODet.sOID, Equal <Required <FSAppointment.sOID> > > > >
                .Select(graph, fsAppointmentEmployeeRow.ServiceLineRef, fsAppointmentRow.SOID);

            if (fsAppointmentDetServiceRow != null &&
                fsAppointmentDetServiceRow.Status == ID.Status_AppointmentDet.CANCELED)
            {
                return;
            }

            if (epActivityApproveRow == null)
            {
                epActivityApproveRow         = new EPActivityApprove();
                epActivityApproveRow.OwnerID = epEmployeeRow.PKID;
                epActivityApproveRow         = graphEmployeeActivitiesEntry.Activity.Insert(epActivityApproveRow);
            }

            graphEmployeeActivitiesEntry.Activity.SetValueExt <EPActivityApprove.hold>(epActivityApproveRow, false);
            epActivityApproveRow.Date          = SharedFunctions.GetCustomDateTime(fsAppointmentRow.ExecutionDate, fsAppointmentEmployeeRow.ActualDateTimeBegin);
            epActivityApproveRow.EarningTypeID = fsAppointmentEmployeeRow.EarningType;
            epActivityApproveRow.TimeSpent     = fsAppointmentEmployeeRow.ActualDuration;
            epActivityApproveRow.Summary       = GetDescriptionToUseInEPActivityApprove(fsAppointmentRow, fsAppointmentEmployeeRow, fsAppointmentDetServiceRow);
            epActivityApproveRow.CostCodeID    = fsAppointmentEmployeeRow?.CostCodeID;

            FSxPMTimeActivity fsxPMTimeActivityRow = PXCache <PMTimeActivity> .GetExtension <FSxPMTimeActivity>((PMTimeActivity)epActivityApproveRow);

            fsxPMTimeActivityRow.SOID                  = fsAppointmentRow.SOID;
            fsxPMTimeActivityRow.AppointmentID         = fsAppointmentRow.AppointmentID;
            fsxPMTimeActivityRow.AppointmentCustomerID = fsServiceOrderRow.CustomerID;
            fsxPMTimeActivityRow.AppEmpID              = fsAppointmentEmployeeRow.LineNbr;

            if (fsAppointmentEmployeeRow.ServiceLineRef != null)
            {
                fsxPMTimeActivityRow.ServiceID = fsAppointmentDetServiceRow == null ? null : fsAppointmentDetServiceRow.InventoryID;
            }

            epActivityApproveRow = graphEmployeeActivitiesEntry.Activity.Update(epActivityApproveRow);

            graphEmployeeActivitiesEntry.Activity.SetValueExt <EPActivityApprove.projectID>(epActivityApproveRow, fsServiceOrderRow.ProjectID);
            graphEmployeeActivitiesEntry.Activity.SetValueExt <EPActivityApprove.projectTaskID>(epActivityApproveRow, GetProjectTaskIDToUseInEPActivityApprove(fsAppointmentRow, fsAppointmentEmployeeRow, fsAppointmentDetServiceRow));
            graphEmployeeActivitiesEntry.Activity.SetValueExt <EPActivityApprove.isBillable>(epActivityApproveRow, false);
            graphEmployeeActivitiesEntry.Activity.SetValueExt <EPActivityApprove.approvalStatus>(epActivityApproveRow, GetStatusToUseInEPActivityApprove());
            graphEmployeeActivitiesEntry.Activity.SetValueExt <EPActivityApprove.labourItemID>(epActivityApproveRow, fsAppointmentEmployeeRow.LaborItemID);

            graphEmployeeActivitiesEntry.Save.Press();
        }
Exemple #8
0
        public static void InsertUpdateDeleteTimeActivities(
            AppointmentEntry graphAppointmentEntry,
            PXCache appointmentCache,
            FSAppointment fsAppointmentRow,
            FSServiceOrder fsServiceOrderRow,
            AppointmentCore.AppointmentEmployees_View appointmentEmployees,
            List <FSAppointmentEmployee> deleteReleatedTimeActivity,
            List <FSAppointmentEmployee> createReleatedTimeActivity)
        {
            if (!TimeCardHelper.IsTheTimeCardIntegrationEnabled(graphAppointmentEntry) ||
                (fsAppointmentRow.Status != ID.Status_Appointment.COMPLETED &&
                 fsAppointmentRow.Status != ID.Status_Appointment.MANUAL_SCHEDULED))
            {
                return;
            }

            if (PXAccess.FeatureInstalled <FeaturesSet.timeReportingModule>() == false)
            {
                return;
            }

            EmployeeActivitiesEntry graphEmployeeActivitiesEntry = PXGraph.CreateInstance <EmployeeActivitiesEntry>();

            if (IsNecessaryToUpdateTimeCards(appointmentCache, appointmentEmployees, fsAppointmentRow))
            {
                foreach (FSAppointmentEmployee fsAppointmentEmployee in appointmentEmployees.Select().Where(y => ((FSAppointmentEmployee)y).Type == BAccountType.EmployeeType))
                {
                    EPActivityApprove epActivityApproveRow    = null;
                    EPActivityApprove oldEPActivityApproveRow = null;
                    TMEPEmployee      epEmployeeRow           = null;
                    int?oldEmployeeIDValue;

                    FindTMEmployee(graphAppointmentEntry, fsAppointmentEmployee.EmployeeID, ref epEmployeeRow);
                    FindEPActivityApprove(graphAppointmentEntry, fsAppointmentEmployee, epEmployeeRow, ref epActivityApproveRow);

                    if (fsAppointmentEmployee.TrackTime == true)
                    {
                        oldEmployeeIDValue = (int?)graphAppointmentEntry.AppointmentEmployees.Cache.GetValueOriginal <FSAppointmentEmployee.employeeID>(fsAppointmentEmployee);
                        if (oldEmployeeIDValue != fsAppointmentEmployee.EmployeeID)
                        {
                            TMEPEmployee oldEPEmployeeRow = null;
                            FindTMEmployee(graphAppointmentEntry, oldEmployeeIDValue, ref oldEPEmployeeRow);
                            FindEPActivityApprove(graphAppointmentEntry, fsAppointmentEmployee, oldEPEmployeeRow, ref oldEPActivityApproveRow);
                            DeleteEPActivityApprove(graphEmployeeActivitiesEntry, oldEPActivityApproveRow);
                        }

                        InsertUpdateEPActivityApprove(graphAppointmentEntry, graphEmployeeActivitiesEntry, fsAppointmentEmployee, fsAppointmentRow, fsServiceOrderRow, epActivityApproveRow, epEmployeeRow);
                    }
                    else
                    {
                        if (epActivityApproveRow != null)
                        {
                            DeleteEPActivityApprove(graphEmployeeActivitiesEntry, epActivityApproveRow);
                        }
                    }
                }

                foreach (FSAppointmentEmployee fsAppointmentEmployee in appointmentEmployees.Cache.Deleted)
                {
                    if (fsAppointmentEmployee.Type == BAccountType.EmployeeType)
                    {
                        SearchAndDeleteEPActivity(graphAppointmentEntry, fsAppointmentEmployee, graphEmployeeActivitiesEntry);
                    }
                }
            }
            else if ((string)appointmentCache.GetValueOriginal <FSAppointment.status>(fsAppointmentRow) == ID.Status_Appointment.COMPLETED &&
                     fsAppointmentRow.Status == ID.Status_Appointment.MANUAL_SCHEDULED)
            {
                foreach (FSAppointmentEmployee fsAppointmentEmployee in appointmentEmployees.Select().Where(y => ((FSAppointmentEmployee)y).Type == BAccountType.EmployeeType))
                {
                    SearchAndDeleteEPActivity(graphAppointmentEntry, fsAppointmentEmployee, graphEmployeeActivitiesEntry);
                }

                foreach (FSAppointmentEmployee fsAppointmentEmployee in appointmentEmployees.Cache.Deleted)
                {
                    if (fsAppointmentEmployee.Type == BAccountType.EmployeeType)
                    {
                        SearchAndDeleteEPActivity(graphAppointmentEntry, fsAppointmentEmployee, graphEmployeeActivitiesEntry);
                    }
                }
            }

            if (deleteReleatedTimeActivity != null)
            {
                //Deleting time activities related with cancelled service lines
                foreach (FSAppointmentEmployee fsAppointmentEmployee in deleteReleatedTimeActivity)
                {
                    if (fsAppointmentEmployee.Type == BAccountType.EmployeeType)
                    {
                        SearchAndDeleteEPActivity(graphAppointmentEntry, fsAppointmentEmployee, graphEmployeeActivitiesEntry);
                    }
                }
            }

            if (createReleatedTimeActivity != null)
            {
                //Creating time activities related with re-opened service lines
                foreach (FSAppointmentEmployee fsAppointmentEmployee in createReleatedTimeActivity)
                {
                    TMEPEmployee epEmployeeRow = null;
                    FindTMEmployee(graphAppointmentEntry, fsAppointmentEmployee.EmployeeID, ref epEmployeeRow);
                    InsertUpdateEPActivityApprove(graphAppointmentEntry, graphEmployeeActivitiesEntry, fsAppointmentEmployee, fsAppointmentRow, fsServiceOrderRow, null, epEmployeeRow);
                }
            }
        }
        public static void InsertUpdateEPActivityApprove(PXGraph graph,
                                                         EmployeeActivitiesEntry graphEmployeeActivitiesEntry,
                                                         FSAppointmentLog fsAppointmentLogRow,
                                                         FSAppointment fsAppointmentRow,
                                                         FSServiceOrder fsServiceOrderRow,
                                                         EPActivityApprove epActivityApproveRow,
                                                         TMEPEmployee epEmployeeRow)
        {
            if (epActivityApproveRow != null &&
                (epActivityApproveRow.ApprovalStatus == ActivityStatusListAttribute.Approved || epActivityApproveRow.TimeCardCD != null))
            {
                return;
            }

            FSAppointmentDet fsAppointmentDetServiceRow =
                PXSelect <FSAppointmentDet,
                          Where <
                              FSAppointmentDet.lineRef, Equal <Required <FSAppointmentDet.lineRef> >,
                              And <FSAppointmentDet.appointmentID, Equal <Required <FSAppointmentDet.appointmentID> > > > >
                .Select(graph, fsAppointmentLogRow.DetLineRef, fsAppointmentRow.AppointmentID);

            if (fsAppointmentDetServiceRow != null &&
                fsAppointmentDetServiceRow.IsCanceledNotPerformed == true)
            {
                return;
            }

            if (epActivityApproveRow == null)
            {
                epActivityApproveRow         = new EPActivityApprove();
                epActivityApproveRow.OwnerID = epEmployeeRow.PKID;
                epActivityApproveRow         = graphEmployeeActivitiesEntry.Activity.Insert(epActivityApproveRow);
            }

            graphEmployeeActivitiesEntry.Activity.SetValueExt <EPActivityApprove.hold>(epActivityApproveRow, false);
            epActivityApproveRow.Date          = PXDBDateAndTimeAttribute.CombineDateTime(fsAppointmentRow.ExecutionDate, fsAppointmentLogRow.DateTimeBegin);
            epActivityApproveRow.EarningTypeID = fsAppointmentLogRow.EarningType;
            epActivityApproveRow.TimeSpent     = fsAppointmentLogRow.TimeDuration;
            epActivityApproveRow.Summary       = GetDescriptionToUseInEPActivityApprove(fsAppointmentRow, fsAppointmentLogRow, fsAppointmentDetServiceRow);
            epActivityApproveRow.CostCodeID    = fsAppointmentLogRow?.CostCodeID;

            FSxPMTimeActivity fsxPMTimeActivityRow = PXCache <PMTimeActivity> .GetExtension <FSxPMTimeActivity>((PMTimeActivity)epActivityApproveRow);

            fsxPMTimeActivityRow.SOID                  = fsAppointmentRow.SOID;
            fsxPMTimeActivityRow.AppointmentID         = fsAppointmentRow.AppointmentID;
            fsxPMTimeActivityRow.AppointmentCustomerID = fsServiceOrderRow.CustomerID;
            fsxPMTimeActivityRow.LogLineNbr            = fsAppointmentLogRow.LineNbr;

            if (fsAppointmentLogRow.DetLineRef != null)
            {
                fsxPMTimeActivityRow.ServiceID = fsAppointmentDetServiceRow == null ? null : fsAppointmentDetServiceRow.InventoryID;
            }

            epActivityApproveRow = graphEmployeeActivitiesEntry.Activity.Update(epActivityApproveRow);

            graphEmployeeActivitiesEntry.Activity.SetValueExt <EPActivityApprove.projectID>(epActivityApproveRow, fsServiceOrderRow.ProjectID);
            graphEmployeeActivitiesEntry.Activity.SetValueExt <EPActivityApprove.projectTaskID>(epActivityApproveRow, GetProjectTaskIDToUseInEPActivityApprove(fsAppointmentRow, fsAppointmentLogRow, fsAppointmentDetServiceRow));
            graphEmployeeActivitiesEntry.Activity.SetValueExt <EPActivityApprove.isBillable>(epActivityApproveRow, fsAppointmentLogRow.IsBillable);
            graphEmployeeActivitiesEntry.Activity.SetValueExt <EPActivityApprove.timeBillable>(epActivityApproveRow, fsAppointmentLogRow.BillableTimeDuration);
            graphEmployeeActivitiesEntry.Activity.SetValueExt <EPActivityApprove.approvalStatus>(epActivityApproveRow, GetStatusToUseInEPActivityApprove());
            graphEmployeeActivitiesEntry.Activity.SetValueExt <EPActivityApprove.labourItemID>(epActivityApproveRow, fsAppointmentLogRow.LaborItemID);
        }