Beispiel #1
0
        public virtual void StartNonStockAction(FSAppointmentDet fsAppointmentDet)
        {
            if (fsAppointmentDet == null)
            {
                return;
            }

            FSAppointmentLog fsAppointmentLogRow = new FSAppointmentLog()
            {
                Type           = ID.Type_Log.NON_STOCK,
                BAccountID     = null,
                DetLineRef     = fsAppointmentDet.LineRef,
                DateTimeBegin  = PXDBDateAndTimeAttribute.CombineDateTime(AppointmentRecords.Current.ExecutionDate, PXTimeZoneInfo.Now),
                TimeDuration   = fsAppointmentDet.EstimatedDuration ?? 0,
                Status         = ID.Status_Log.IN_PROCESS,
                TrackTime      = false,
                Descr          = fsAppointmentDet.TranDesc,
                TrackOnService = true,
                ProjectID      = fsAppointmentDet.ProjectID,
                ProjectTaskID  = fsAppointmentDet.ProjectTaskID,
                CostCodeID     = fsAppointmentDet.CostCodeID
            };

            LogRecords.Cache.Insert(fsAppointmentLogRow);

            this.Actions.PressSave();
        }
Beispiel #2
0
        public virtual void StartServiceBasedOnAssignmentAction(IEnumerable <FSDetailFSLogAction> createLogItems = null)
        {
            IEnumerable <FSDetailFSLogAction> createLogItemsLocal = null;
            FSAppointmentLog fsAppointmentLogRow;

            if (createLogItems == null)
            {
                createLogItemsLocal = ServicesLogAction.Select().RowCast <FSDetailFSLogAction>().Where(x => x.Selected == true);
            }
            else
            {
                createLogItemsLocal = createLogItems;
            }

            if (createLogItemsLocal != null)
            {
                foreach (FSDetailFSLogAction fsDetailLogActionRow in createLogItemsLocal)
                {
                    var employeesRelatedToService = AppointmentServiceEmployees.Select().RowCast <FSAppointmentEmployee>()
                                                    .Where(x => x.ServiceLineRef == fsDetailLogActionRow.LineRef);

                    if (employeesRelatedToService.Count() > 0)
                    {
                        foreach (FSAppointmentEmployee employeeRow in employeesRelatedToService)
                        {
                            int?timeDuration = employeeRow != null && fsDetailLogActionRow.EstimatedDuration != null ? fsDetailLogActionRow.EstimatedDuration : 0;

                            fsAppointmentLogRow = new FSAppointmentLog()
                            {
                                Type          = ID.Type_Log.STAFF_ASSIGMENT,
                                BAccountID    = employeeRow.EmployeeID,
                                DetLineRef    = employeeRow.ServiceLineRef,
                                DateTimeBegin = LogActionFilter.Current.LogTime,
                                TimeDuration  = fsDetailLogActionRow.EstimatedDuration
                            };

                            LogRecords.Cache.Insert(fsAppointmentLogRow);
                        }
                    }
                    else
                    {
                        fsAppointmentLogRow = new FSAppointmentLog()
                        {
                            Type          = ID.Type_Log.SERVICE,
                            BAccountID    = null,
                            DetLineRef    = fsDetailLogActionRow.LineRef,
                            DateTimeBegin = LogActionFilter.Current.LogTime,
                            TimeDuration  = fsDetailLogActionRow.EstimatedDuration
                        };

                        LogRecords.Cache.Insert(fsAppointmentLogRow);
                    }
                }
            }
        }
 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);
 }
 private static object GetProjectTaskIDToUseInEPActivityApprove(FSAppointment fsAppointmentRow,
                                                                FSAppointmentLog fsAppointmentLogRow,
                                                                FSAppointmentDet fsAppointmentDetRow)
 {
     if (fsAppointmentLogRow != null && fsAppointmentLogRow.DetLineRef != null && fsAppointmentDetRow != null)
     {
         return(fsAppointmentDetRow.ProjectTaskID);
     }
     else
     {
         return(fsAppointmentRow.DfltProjectTaskID);
     }
 }
Beispiel #5
0
 public virtual void OnApptEndTimeChangeUpdateLogEndTime(FSAppointment fsAppointmentRow, FSSrvOrdType fsSrvOrdTypeRow,
                                                         AppointmentCore.AppointmentLog_View logRecords)
 {
     if (fsAppointmentRow != null && fsSrvOrdTypeRow?.OnEndTimeChangeUpdateLogEndTime == true)
     {
         foreach (FSAppointmentLog fsAppointmentLogRow in logRecords.Select().RowCast <FSAppointmentLog>()
                  .Where(_ => _.KeepDateTimes == false && _.Type != ID.Type_Log.TRAVEL))
         {
             FSAppointmentLog copy = (FSAppointmentLog)logRecords.Cache.CreateCopy(fsAppointmentLogRow);
             copy.DateTimeEnd = fsAppointmentRow.ActualDateTimeEnd;
             logRecords.Cache.Update(copy);
         }
     }
 }
        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);
            }
        }
        private static string GetDescriptionToUseInEPActivityApprove(FSAppointment fsAppointmentRow,
                                                                     FSAppointmentLog fsAppointmentLogRow,
                                                                     FSAppointmentDet fsAppointmentDetRow)
        {
            if (fsAppointmentLogRow != null)
            {
                if (fsAppointmentLogRow.Type == ID.Type_Log.TRAVEL)
                {
                    return(fsAppointmentLogRow.Descr);
                }
                else if (fsAppointmentLogRow.DetLineRef != null &&
                         fsAppointmentDetRow != null)
                {
                    return(fsAppointmentDetRow.TranDesc);
                }
            }

            return(fsAppointmentRow.DocDesc);
        }
Beispiel #8
0
        public virtual int CompleteMultipleLogs(DateTime?dateTimeEnd, string newApptDetStatus, bool completeRelatedItemLines, IEnumerable <ILogDetail> completeLogItems, PXSelectBase <FSAppointmentLog> logSelect, params object[] logSelectArgs)
        {
            if (dateTimeEnd == null)
            {
                dateTimeEnd = PXTimeZoneInfo.Now;
            }

            int rowsAffected = 0;
            List <FSAppointmentDet> apptDetRows = null;

            if (completeRelatedItemLines == true)
            {
                apptDetRows = AppointmentDetails.Select().RowCast <FSAppointmentDet>().ToList();
            }

            if (completeLogItems != null)
            {
                var logRows = LogRecords.Select();

                foreach (ILogDetail row in completeLogItems)
                {
                    FSAppointmentLog logRow = logRows.RowCast <FSAppointmentLog>().Where(_ => _.LineRef == row.LineRef).FirstOrDefault();

                    ProcessCompleteLog(dateTimeEnd.Value, newApptDetStatus, logRow, apptDetRows);
                    rowsAffected++;
                }
            }

            if (logSelect != null)
            {
                foreach (FSAppointmentLog logRow in logSelect.Select(logSelectArgs))
                {
                    ProcessCompleteLog(dateTimeEnd.Value, newApptDetStatus, logRow, apptDetRows);
                    rowsAffected++;
                }
            }

            return(rowsAffected);
        }
Beispiel #9
0
        public virtual void SetLogInfoFromDetails(PXCache cache, FSAppointmentLog fsLogRow)
        {
            string logType = fsLogRow.Travel == true ? ID.Type_Log.TRAVEL : ID.Type_Log.SERVICE;

            if (fsLogRow.DetLineRef != null)
            {
                FSAppointmentDet fsAppointmentDetRow = AppointmentDetails.Select().RowCast <FSAppointmentDet>().Where(_ => _.LineRef == fsLogRow.DetLineRef).FirstOrDefault();

                if (fsAppointmentDetRow != null)
                {
                    fsLogRow.Descr = fsAppointmentDetRow.TranDesc;
                    if (fsAppointmentDetRow.IsTravelItem == true)
                    {
                        logType = ID.Type_Log.TRAVEL;
                    }
                    else if (fsAppointmentDetRow.LineType == ID.LineType_ALL.NONSTOCKITEM)
                    {
                        logType = ID.Type_Log.NON_STOCK;
                    }
                    else
                    {
                        logType = ID.Type_Log.SERVICE;
                    }
                }
            }
            else if (fsLogRow.BAccountID != null)
            {
                if (fsLogRow.Travel == true)
                {
                    logType = ID.Type_Log.TRAVEL;
                }
                else
                {
                    logType = ID.Type_Log.STAFF_ASSIGMENT;
                }
            }

            cache.SetValueExt <FSAppointmentLog.type>(fsLogRow, logType);
        }
Beispiel #10
0
        /// <summary>
        /// Update ApprovedTime and actualDuration fields in the <c>AppointmentDetInfo</c> lines.
        /// </summary>
        public virtual void UpdateAppointmentFromApprovedTimeCard(PXCache cache)
        {
            FSxPMTimeActivity fsxPMTimeActivityRow = null;

            var graphAppointmentEntry = PXGraph.CreateInstance <AppointmentEntry>();

            foreach (TimeCardMaint.EPTimecardDetail ePTimeCardDetailRow in this.Base.Activities.Select())
            {
                fsxPMTimeActivityRow = this.Base.Activities.Cache.GetExtension <FSxPMTimeActivity>(ePTimeCardDetailRow);

                if (fsxPMTimeActivityRow.LogLineNbr.HasValue == false)
                {
                    continue;
                }

                FSAppointment fsAppointmentRow = PXSelect <FSAppointment,
                                                           Where <
                                                               FSAppointment.appointmentID, Equal <Required <FSAppointment.appointmentID> > > >
                                                 .Select(Base, fsxPMTimeActivityRow.AppointmentID);

                FSAppointmentLog fsAppointmentLogRow = PXSelect <FSAppointmentLog,
                                                                 Where <
                                                                     FSAppointmentLog.docID, Equal <Required <FSAppointmentLog.docID> >,
                                                                     And <FSAppointmentLog.lineNbr, Equal <Required <FSAppointmentLog.lineNbr> > > > >
                                                       .Select(Base, fsxPMTimeActivityRow.AppointmentID, fsxPMTimeActivityRow.LogLineNbr);

                graphAppointmentEntry.SkipTimeCardUpdate = true;

                fsAppointmentRow = graphAppointmentEntry.AppointmentRecords.Current = graphAppointmentEntry.AppointmentRecords.Search <FSAppointment.appointmentID>
                                                                                          (fsAppointmentRow.AppointmentID, fsAppointmentRow.SrvOrdType);

                fsAppointmentLogRow.TimeCardCD   = ePTimeCardDetailRow.TimeCardCD;
                fsAppointmentLogRow.ApprovedTime = true;
                fsAppointmentLogRow = graphAppointmentEntry.LogRecords.Update(fsAppointmentLogRow);

                graphAppointmentEntry.Save.Press();
            }
        }
Beispiel #11
0
        /// <summary>
        /// Resets certain Log fields when there's no employee selected.
        /// </summary>
        /// <param name="fsLogRow"></param>
        public virtual void ResetLogFieldsNoEmployee(FSAppointmentLog fsLogRow)
        {
            if (fsLogRow.BAccountID == null)
            {
                fsLogRow.EarningType = null;
                fsLogRow.LaborItemID = null;

                FSAppointmentDet fsAppointmentDetRow = null;

                if (string.IsNullOrWhiteSpace(fsLogRow.DetLineRef) == false)
                {
                    fsAppointmentDetRow = AppointmentDetails.Select().RowCast <FSAppointmentDet>().Where(_ => _.LineRef == fsLogRow.DetLineRef).FirstOrDefault();
                }

                if (fsAppointmentDetRow != null &&
                    (fsAppointmentDetRow.LineType == ID.LineType_ALL.SERVICE ||
                     fsAppointmentDetRow.LineType == ID.LineType_ALL.NONSTOCKITEM))
                {
                    fsLogRow.ProjectID     = fsAppointmentDetRow.ProjectID;
                    fsLogRow.ProjectTaskID = fsAppointmentDetRow.ProjectTaskID;
                    fsLogRow.CostCodeID    = fsAppointmentDetRow.CostCodeID;
                }
            }
        }
Beispiel #12
0
        public virtual void StartStaffAction(IEnumerable <FSStaffLogActionDetail> createLogItems = null)
        {
            IEnumerable <FSStaffLogActionDetail> createLogItemsLocal = null;

            if (createLogItems == null)
            {
                if (LogActionFilter.Current.Me == true)
                {
                    EPEmployee employeeByUserID = PXSelect <EPEmployee,
                                                            Where <
                                                                EPEmployee.userID, Equal <Current <AccessInfo.userID> > > >
                                                  .Select(this);

                    if (employeeByUserID != null)
                    {
                        bool isEmployeeInGrid = AppointmentServiceEmployees.Select().RowCast <FSAppointmentEmployee>()
                                                .Where(x => x.EmployeeID == employeeByUserID.BAccountID)
                                                .Count() > 0;

                        bool isTherePrimaryDriver = AppointmentServiceEmployees.Select().RowCast <FSAppointmentEmployee>()
                                                    .Where(x => x.PrimaryDriver == true)
                                                    .Count() > 0;

                        if (isEmployeeInGrid == false)
                        {
                            FSAppointmentEmployee fsAppointmentEmployeeRow = new FSAppointmentEmployee()
                            {
                                EmployeeID = employeeByUserID.BAccountID
                            };

                            if (isTherePrimaryDriver == false)
                            {
                                fsAppointmentEmployeeRow.PrimaryDriver = true;
                            }

                            AppointmentServiceEmployees.Cache.Insert(fsAppointmentEmployeeRow);

                            FSAppointmentLog fsAppointmentLogRow = new FSAppointmentLog()
                            {
                                Type          = ID.Type_Log.STAFF_ASSIGMENT,
                                BAccountID    = employeeByUserID.BAccountID,
                                DetLineRef    = null,
                                DateTimeBegin = LogActionFilter.Current.LogTime
                            };

                            LogRecords.Cache.Insert(fsAppointmentLogRow);
                        }
                        else
                        {
                            createLogItemsLocal = LogStaffActionDetails.Select().RowCast <FSStaffLogActionDetail>()
                                                  .Where(x => x.Selected == true);
                        }
                    }
                }
                else
                {
                    createLogItemsLocal = LogStaffActionDetails.Select().RowCast <FSStaffLogActionDetail>()
                                          .Where(x => x.Selected == true);
                }
            }
            else
            {
                createLogItemsLocal = createLogItems;
            }

            if (createLogItemsLocal != null)
            {
                foreach (FSStaffLogActionDetail fsStaffLogActionDetailRow in createLogItemsLocal)
                {
                    int?timeDuration = fsStaffLogActionDetailRow != null && fsStaffLogActionDetailRow.EstimatedDuration != null ? fsStaffLogActionDetailRow.EstimatedDuration : 0;

                    FSAppointmentLog fsAppointmentLogRow = new FSAppointmentLog()
                    {
                        Type          = ID.Type_Log.STAFF_ASSIGMENT,
                        BAccountID    = fsStaffLogActionDetailRow.BAccountID,
                        DetLineRef    = fsStaffLogActionDetailRow.DetLineRef,
                        DateTimeBegin = LogActionFilter.Current.LogTime,
                        TimeDuration  = timeDuration
                    };

                    LogRecords.Cache.Insert(fsAppointmentLogRow);
                }
            }
        }
Beispiel #13
0
        public virtual FSAppointmentLog ProcessCompleteLog(DateTime dateTimeEnd, string newApptDetStatus, FSAppointmentLog logRow, List <FSAppointmentDet> apptDetRows)
        {
            if (logRow == null)
            {
                return(null);
            }

            logRow = PXCache <FSAppointmentLog> .CreateCopy(logRow);

            logRow.Status = ID.Status_Log.COMPLETED;
            if (logRow.KeepDateTimes == false)
            {
                logRow.DateTimeEnd = dateTimeEnd;
            }

            if (apptDetRows != null && string.IsNullOrWhiteSpace(logRow.DetLineRef) == false)
            {
                FSAppointmentDet apptDet = apptDetRows.Where(r => r.LineRef == logRow.DetLineRef).FirstOrDefault();
                if (apptDet != null)
                {
                    ProcessStopItemLine(apptDet, newApptDetStatus);
                }
            }

            return((FSAppointmentLog)LogRecords.Cache.Update(logRow));
        }
Beispiel #14
0
        public virtual void StartServiceAction(IEnumerable <FSAppointmentEmployeeFSLogStart> createLogItems = null)
        {
            IEnumerable <FSAppointmentEmployeeFSLogStart> createLogItemsLocal = null;
            FSAppointmentLog fsAppointmentLogRow;
            FSAppointmentDet fsAppointmentDetRow = null;
            string           detLineRef          = null;
            DateTime?        dateTimeBegin       = null;
            int timeDuration = 0;

            if (LogActionFilter.Current?.DetLineRef == null)
            {
                return;
            }

            if (createLogItems == null)
            {
                detLineRef    = LogActionFilter.Current?.DetLineRef;
                dateTimeBegin = LogActionFilter.Current?.LogTime;

                if (LogActionFilter.Current.DetLineRef != null)
                {
                    fsAppointmentDetRow = PXSelect <FSAppointmentDet,
                                                    Where <
                                                        FSAppointmentDet.appointmentID, Equal <Required <FSAppointmentDet.appointmentID> >,
                                                        And <FSAppointmentDet.lineRef, Equal <Required <FSAppointmentDet.lineRef> > > > >
                                          .Select(this, AppointmentRecords.Current.AppointmentID, LogActionFilter.Current.DetLineRef);

                    if (fsAppointmentDetRow != null)
                    {
                        timeDuration = fsAppointmentDetRow.EstimatedDuration ?? 0;
                    }
                }

                if (LogActionFilter.Current.Me == true)
                {
                    EPEmployee employeeByUserID = PXSelect <EPEmployee,
                                                            Where <
                                                                EPEmployee.userID, Equal <Current <AccessInfo.userID> > > >
                                                  .Select(this);

                    if (employeeByUserID != null)
                    {
                        bool isEmployeeInGrid = AppointmentServiceEmployees.Select().RowCast <FSAppointmentEmployee>()
                                                .Where(x => x.EmployeeID == employeeByUserID.BAccountID)
                                                .Count() > 0;

                        bool isTherePrimaryDriver = AppointmentServiceEmployees.Select().RowCast <FSAppointmentEmployee>()
                                                    .Where(x => x.PrimaryDriver == true)
                                                    .Count() > 0;

                        if (isEmployeeInGrid == false)
                        {
                            FSAppointmentEmployee fsAppointmentEmployeeRow = new FSAppointmentEmployee()
                            {
                                EmployeeID = employeeByUserID.BAccountID,
                            };

                            if (isTherePrimaryDriver == false)
                            {
                                fsAppointmentEmployeeRow.PrimaryDriver = true;
                            }

                            AppointmentServiceEmployees.Cache.Insert(fsAppointmentEmployeeRow);
                        }

                        fsAppointmentLogRow = new FSAppointmentLog()
                        {
                            Type          = ID.Type_Log.SERVICE,
                            BAccountID    = employeeByUserID.BAccountID,
                            DetLineRef    = detLineRef,
                            DateTimeBegin = dateTimeBegin,
                            TimeDuration  = timeDuration
                        };

                        LogRecords.Cache.Insert(fsAppointmentLogRow);
                    }
                }
                else
                {
                    createLogItemsLocal = StaffMemberLogStartAction.Select().RowCast <FSAppointmentEmployeeFSLogStart>()
                                          .Where(x => x.Selected == true);
                }
            }
            else
            {
                detLineRef          = null;
                dateTimeBegin       = PXDBDateAndTimeAttribute.CombineDateTime(AppointmentRecords.Current.ExecutionDate, PXTimeZoneInfo.Now);
                createLogItemsLocal = createLogItems;
            }

            if (createLogItemsLocal != null)
            {
                foreach (FSAppointmentEmployeeFSLogStart row in createLogItemsLocal)
                {
                    fsAppointmentLogRow = new FSAppointmentLog()
                    {
                        Type          = ID.Type_Log.SERVICE,
                        BAccountID    = row.BAccountID,
                        DetLineRef    = detLineRef,
                        DateTimeBegin = dateTimeBegin,
                        TimeDuration  = timeDuration
                    };

                    LogRecords.Cache.Insert(fsAppointmentLogRow);
                }
            }
        }
        public static void PMTimeActivity_RowPersisting_Handler(PXCache cache, PXGraph graph, PMTimeActivity pmTimeActivityRow, PXRowPersistingEventArgs e)
        {
            FSxPMTimeActivity fsxPMTimeActivityRow = PXCache <PMTimeActivity> .GetExtension <FSxPMTimeActivity>(pmTimeActivityRow);

            if (e.Operation == PXDBOperation.Delete &&
                graph.Accessinfo.ScreenID != SharedFunctions.SetScreenIDToDotFormat(ID.ScreenID.APPOINTMENT))
            {
                if (fsxPMTimeActivityRow.AppointmentID != null &&
                    fsxPMTimeActivityRow.LogLineNbr != null)
                {
                    PXUpdate <
                        Set <FSAppointmentLog.trackTime, False>,
                        FSAppointmentLog,
                        Where <
                            FSAppointmentLog.docID, Equal <Required <FSAppointmentLog.docID> >,
                            And <FSAppointmentLog.lineNbr, Equal <Required <FSAppointmentLog.lineNbr> > > > >
                    .Update(graph, fsxPMTimeActivityRow.AppointmentID, fsxPMTimeActivityRow.LogLineNbr);
                }
            }

            if ((e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update) &&
                !IsAccessedFromAppointment(graph.Accessinfo.ScreenID))
            {
                if (fsxPMTimeActivityRow.AppointmentID != null &&
                    fsxPMTimeActivityRow.LogLineNbr != null &&
                    (
                        (int?)cache.GetValueOriginal <EPActivityApprove.timeSpent>(pmTimeActivityRow) != pmTimeActivityRow.TimeSpent ||
                        (int?)cache.GetValueOriginal <EPActivityApprove.timeBillable>(pmTimeActivityRow) != pmTimeActivityRow.TimeBillable ||
                        (bool?)cache.GetValueOriginal <EPActivityApprove.isBillable>(pmTimeActivityRow) != pmTimeActivityRow.IsBillable))
                {
                    AppointmentEntry graphAppointmentEntry = PXGraph.CreateInstance <AppointmentEntry>();

                    FSAppointment fsAppointmentRow = PXSelect <FSAppointment,
                                                               Where <
                                                                   FSAppointment.appointmentID, Equal <Required <FSAppointment.appointmentID> > > >
                                                     .Select(graph, fsxPMTimeActivityRow.AppointmentID);

                    FSAppointmentLog fsAppointmentLogRow = PXSelect <FSAppointmentLog,
                                                                     Where <
                                                                         FSAppointmentLog.docID, Equal <Required <FSAppointmentLog.docID> >,
                                                                         And <FSAppointmentLog.lineNbr, Equal <Required <FSAppointmentLog.lineNbr> > > > >
                                                           .Select(graph, fsxPMTimeActivityRow.AppointmentID, fsxPMTimeActivityRow.LogLineNbr);

                    fsAppointmentRow = graphAppointmentEntry.AppointmentRecords.Current = graphAppointmentEntry.AppointmentRecords.Search <FSAppointment.appointmentID>
                                                                                              (fsAppointmentRow.AppointmentID, fsAppointmentRow.SrvOrdType);

                    graphAppointmentEntry.SkipTimeCardUpdate = true;
                    fsAppointmentLogRow.TimeDuration         = pmTimeActivityRow.TimeSpent;
                    fsAppointmentLogRow.EarningType          = pmTimeActivityRow.EarningTypeID;

                    FSSrvOrdType fsSrvOrdTypeRow = graphAppointmentEntry.ServiceOrderTypeSelected.Current;

                    if (fsSrvOrdTypeRow != null &&
                        fsSrvOrdTypeRow.PostTo == ID.SrvOrdType_PostTo.PROJECTS &&
                        fsSrvOrdTypeRow.BillingType == ID.SrvOrdType_BillingType.COST_AS_COST &&
                        fsSrvOrdTypeRow.CreateTimeActivitiesFromAppointment == true)
                    {
                        fsAppointmentLogRow.IsBillable           = pmTimeActivityRow.IsBillable;
                        fsAppointmentLogRow.BillableTimeDuration = pmTimeActivityRow.TimeBillable;
                    }

                    fsAppointmentLogRow = graphAppointmentEntry.LogRecords.Update(fsAppointmentLogRow);
                    graphAppointmentEntry.Save.Press();
                }
            }
        }
        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);
        }