Example #1
0
        public virtual void VerifyOnCompleteApptRequireLog(PXCache cache)
        {
            int?servicesWithOutLog = AppointmentDetails.Select().RowCast <FSAppointmentDet>()
                                     .Where(_ => _.LineType == ID.LineType_ALL.SERVICE &&
                                            _.IsTravelItem == false &&
                                            _.IsCanceledNotPerformed == false &&
                                            _.LogRelatedCount == 0).Count();

            if (servicesWithOutLog > 0)
            {
                throw new PXException(TX.Error.LOG_DATE_TIMES_ARE_REQUIRED_FOR_SERVICES);
            }
        }
Example #2
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);
        }
Example #3
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);
        }
Example #4
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;
                }
            }
        }