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); } }
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(); }
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); }