protected virtual void EPActivityFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { EPActivityFilter row = (EPActivityFilter)e.Row; if (row != null) { row.BillableTime = 0; row.BillableOvertime = 0; row.BillableTotal = 0; row.RegularTime = 0; row.RegularOvertime = 0; row.RegularTotal = 0; foreach (PXResult <EPActivityApprove, CRActivityLink, EPEarningType> item in Activity.Select()) { EPActivityApprove rowActivity = (EPActivityApprove)item; EPEarningType rowEarningType = (EPEarningType)item; if (rowEarningType.IsOvertime == true) { row.RegularOvertime += rowActivity.TimeSpent.GetValueOrDefault(0); row.BillableOvertime += rowActivity.TimeBillable.GetValueOrDefault(0); } else { row.RegularTime += rowActivity.TimeSpent.GetValueOrDefault(0); row.BillableTime += rowActivity.TimeBillable.GetValueOrDefault(0); } row.BillableTotal = row.BillableTime + row.BillableOvertime; row.RegularTotal = row.RegularTime + row.RegularOvertime; } } }
protected virtual void EPActivityApprove_ProjectID_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e) { EPActivityApprove row = (EPActivityApprove)e.Row; if (row == null) { return; } if (Filter.Current.ProjectID != null) { e.NewValue = Filter.Current.ProjectID; e.Cancel = true; } else { EPEarningType earningType = PXSelect <EPEarningType, Where <EPEarningType.typeCD, Equal <Required <EPEarningType.typeCD> > > > .Select(this, row.EarningTypeID); if (earningType != null && earningType.ProjectID != null && row.ProjectID == null && PXSelectorAttribute.Select(cache, e.Row, cache.GetField(typeof(EPActivityApprove.projectID)), earningType.ProjectID) != null //available in selector ) { e.NewValue = earningType.ProjectID; e.Cancel = true; } } }
protected virtual void EPActivityApprove_ProjectTaskID_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e) { EPActivityApprove row = (EPActivityApprove)e.Row; if (row == null) { return; } if (Filter.Current.ProjectTaskID != null) { e.NewValue = Filter.Current.ProjectTaskID; e.Cancel = true; return; } if (row.ParentTaskID != null) { EPActivityApprove rowParentTask = PXSelect <EPActivityApprove> .Search <EPActivityApprove.taskID>(this, row.ParentTaskID); if (rowParentTask != null && rowParentTask.ProjectID == row.ProjectID) { e.NewValue = rowParentTask.ProjectTaskID; e.Cancel = true; } } EPEarningType earningRow = (EPEarningType)PXSelectorAttribute.Select <EPActivityApprove.earningTypeID>(cache, row); if (e.NewValue == null && earningRow != null && earningRow.ProjectID == row.ProjectID) { e.NewValue = earningRow.TaskID; e.Cancel = true; } }
protected virtual void PMTimeActivityFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { PXDBDateAndTimeAttribute.SetTimeVisible <EPActivityApprove.date>(Activity.Cache, null, EPsetingst.Current.RequireTimes == true); PMTimeActivityFilter row = (PMTimeActivityFilter)e.Row; if (row != null) { row.BillableTime = 0; row.BillableOvertime = 0; row.BillableTotal = 0; row.RegularTime = 0; row.RegularOvertime = 0; row.RegularTotal = 0; foreach (PXResult <EPActivityApprove, EPEarningType> item in Activity.Select()) { EPActivityApprove rowActivity = (EPActivityApprove)item; EPEarningType rowEarningType = (EPEarningType)item; if (rowEarningType.IsOvertime == true) { row.RegularOvertime += rowActivity.TimeSpent.GetValueOrDefault(0); row.BillableOvertime += rowActivity.TimeBillable.GetValueOrDefault(0); } else { row.RegularTime += rowActivity.TimeSpent.GetValueOrDefault(0); row.BillableTime += rowActivity.TimeBillable.GetValueOrDefault(0); } row.BillableTotal = row.BillableTime + row.BillableOvertime; row.RegularTotal = row.RegularTime + row.RegularOvertime; } } }
protected virtual void EPEarningType_IsActive_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { EPEarningType row = e.Row as EPEarningType; if (row == null) { return; } if (row.IsActive == false) { if (Setup.Current.RegularHoursType == row.TypeCD) { throw new PXException(String.Format(EP.Messages.EarningTypeDeactivate, row.TypeCD, PXUIFieldAttribute.GetDisplayName <EPSetup.regularHoursType>(Setup.Cache))); } if (Setup.Current.HolidaysType == row.TypeCD) { throw new PXException(String.Format(EP.Messages.EarningTypeDeactivate, row.TypeCD, PXUIFieldAttribute.GetDisplayName <EPSetup.holidaysType>(Setup.Cache))); } if (Setup.Current.VacationsType == row.TypeCD) { throw new PXException(String.Format(EP.Messages.EarningTypeDeactivate, row.TypeCD, PXUIFieldAttribute.GetDisplayName <EPSetup.vacationsType>(Setup.Cache))); } } }
protected void EPEarningType_RowDeleting(PXCache sender, PXRowDeletingEventArgs e) { EPEarningType row = (EPEarningType)e.Row; if (row == null) { return; } EPSetup setup = PXSelect < EPSetup , Where <EPSetup.regularHoursType, Equal <Required <EPEarningType.typeCD> > , Or <EPSetup.holidaysType, Equal <Required <EPEarningType.typeCD> > , Or <EPSetup.vacationsType, Equal <Required <EPEarningType.typeCD> > > > > > .Select(this, row.TypeCD, row.TypeCD, row.TypeCD); if (setup != null) { throw new PXException(Messages.CannotDeleteInUse); } CRCaseClassLaborMatrix caseClassLabor = PXSelect <CRCaseClassLaborMatrix, Where <CRCaseClassLaborMatrix.earningType, Equal <Required <EPEarningType.typeCD> > > > .Select(this, row.TypeCD); if (caseClassLabor != null) { throw new PXException(Messages.CannotDeleteInUse); } EPContractRate contractRate = PXSelect <EPContractRate, Where <EPContractRate.earningType, Equal <Required <EPEarningType.typeCD> > > > .Select(this, row.TypeCD); if (contractRate != null) { throw new PXException(Messages.CannotDeleteInUse); } EPEmployeeClassLaborMatrix employeeLabor = PXSelect <EPEmployeeClassLaborMatrix, Where <EPEmployeeClassLaborMatrix.earningType, Equal <Required <EPEarningType.typeCD> > > > .Select(this, row.TypeCD); if (employeeLabor != null) { throw new PXException(Messages.CannotDeleteInUse); } PMTimeActivity activity = PXSelect <PMTimeActivity, Where <PMTimeActivity.earningTypeID, Equal <Required <EPEarningType.typeCD> > > > .Select(this, row.TypeCD); if (activity != null) { throw new PXException(Messages.CannotDeleteInUse); } PMTran pmTran = PXSelect <PMTran, Where <PMTran.earningType, Equal <Required <EPEarningType.typeCD> > > > .Select(this, row.TypeCD); if (pmTran != null) { throw new PXException(Messages.CannotDeleteInUse); } }
protected virtual void EPActivityFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { if (!PXAccess.FeatureInstalled <FeaturesSet.timeReportingModule>()) { PXUIFieldAttribute.SetVisible(Activity.Cache, typeof(EPActivity.timeSpent).Name, false); PXUIFieldAttribute.SetVisible(Activity.Cache, typeof(EPActivity.timeBillable).Name, false); PXUIFieldAttribute.SetVisible(Activity.Cache, typeof(EPActivity.isBillable).Name, false); PXUIFieldAttribute.SetVisible <EPActivityFilter.regularOvertime>(sender, null, false); PXUIFieldAttribute.SetVisible <EPActivityFilter.regularTime>(sender, null, false); PXUIFieldAttribute.SetVisible <EPActivityFilter.regularTotal>(sender, null, false); PXUIFieldAttribute.SetVisible <EPActivityFilter.billableOvertime>(sender, null, false); PXUIFieldAttribute.SetVisible <EPActivityFilter.billableTime>(sender, null, false); PXUIFieldAttribute.SetVisible <EPActivityFilter.billableTotal>(sender, null, false); } if (!PXAccess.FeatureInstalled <FeaturesSet.projectModule>()) { PXUIFieldAttribute.SetVisible(Activity.Cache, typeof(EPActivity.projectTaskID).Name, false); PXUIFieldAttribute.SetVisible <EPActivityFilter.projectTaskID>(sender, null, false); } EPActivityFilter row = (EPActivityFilter)e.Row; if (row != null) { PXResult res = (PXResult)Activity.Select(); if (res == null || res[typeof(EPEarningType)] == null) { return; } row.BillableTime = 0; row.BillableOvertime = 0; row.BillableTotal = 0; row.RegularTime = 0; row.RegularOvertime = 0; row.RegularTotal = 0; foreach (PXResult <EPActivityApprove, EPEarningType> item in Activity.Select()) { EPActivityApprove rowActivity = (EPActivityApprove)item; EPEarningType rowEarningType = (EPEarningType)item; if (rowEarningType.IsOvertime == true) { row.RegularOvertime += rowActivity.TimeSpent.GetValueOrDefault(0); row.BillableOvertime += rowActivity.TimeBillable.GetValueOrDefault(0); } else { row.RegularTime += rowActivity.TimeSpent.GetValueOrDefault(0); row.BillableTime += rowActivity.TimeBillable.GetValueOrDefault(0); } row.BillableTotal = row.BillableTime + row.BillableOvertime; row.RegularTotal = row.RegularTime + row.RegularOvertime; } } }
protected virtual void RecalculateTotals(EPTimeCard timecard) { if (timecard == null) { throw new ArgumentNullException(); } int timeSpent = 0; int regularTime = 0; int overtimeSpent = 0; int timeBillable = 0; int overtimeBillable = 0; PXResultset <TimeCardMaint.EPTimecardDetail> resultset; if (timecard.IsHold == true) { resultset = PXSelectJoin <TimeCardMaint.EPTimecardDetail, InnerJoin <EPEarningType, On <TimeCardMaint.EPTimecardDetail.earningTypeID, Equal <EPEarningType.typeCD> >, InnerJoin <EPEmployee, On <EPEmployee.userID, Equal <TimeCardMaint.EPTimecardDetail.owner> > > >, Where <TimeCardMaint.EPTimecardDetail.weekID, Equal <Required <EPActivity.weekID> >, And <TimeCardMaint.EPTimecardDetail.timeCardCD, IsNull, And <EPEmployee.bAccountID, Equal <Required <EPEmployee.bAccountID> > > > > > .Select(this, timecard.WeekID, timecard.EmployeeID); } else { resultset = PXSelectJoin <TimeCardMaint.EPTimecardDetail, InnerJoin <EPEarningType, On <TimeCardMaint.EPTimecardDetail.earningTypeID, Equal <EPEarningType.typeCD> >, InnerJoin <EPEmployee, On <EPEmployee.userID, Equal <TimeCardMaint.EPTimecardDetail.owner> > > >, Where <TimeCardMaint.EPTimecardDetail.timeCardCD, Equal <Required <TimeCardMaint.EPTimecardDetail.timeCardCD> >, And <EPEmployee.bAccountID, Equal <Required <EPEmployee.bAccountID> > > > > .Select(this, timecard.TimeCardCD, timecard.EmployeeID); } foreach (PXResult <TimeCardMaint.EPTimecardDetail, EPEarningType> res in resultset) { TimeCardMaint.EPTimecardDetail activity = (TimeCardMaint.EPTimecardDetail)res; EPEarningType et = (EPEarningType)res; activity.IsOvertimeCalc = et.IsOvertime; RecalculateFields(activity); timeSpent += activity.TimeSpent.GetValueOrDefault(); regularTime += activity.RegularTimeCalc.GetValueOrDefault(); timeBillable += activity.BillableTimeCalc.GetValueOrDefault(); overtimeSpent += activity.OverTimeCalc.GetValueOrDefault(); overtimeBillable += activity.BillableOvertimeCalc.GetValueOrDefault(); } timecard.TimeSpentCalc = regularTime; timecard.OvertimeSpentCalc = overtimeSpent; timecard.TotalSpentCalc = timeSpent; timecard.TimeBillableCalc = timeBillable; timecard.OvertimeBillableCalc = overtimeBillable; timecard.TotalBillableCalc = timeBillable + overtimeBillable; }
public virtual decimal GetOvertimeMultiplier(string earningTypeID, Rate employeeRate) { if (employeeRate != null && employeeRate.Type == RateTypesAttribute.SalaryWithExemption) { return(1); } EPEarningType earningType = PXSelect <EPEarningType> .Search <EPEarningType.typeCD>(graph, earningTypeID); return(earningType != null && earningType.IsOvertime == true ? (decimal)earningType.OvertimeMultiplier : 1); }
protected virtual void EPActivityApprove_ProjectTaskID_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e) { EPActivityApprove row = (EPActivityApprove)e.Row; if (row == null) { return; } if (Filter.Current.ProjectTaskID != null) { e.NewValue = Filter.Current.ProjectTaskID; e.Cancel = true; return; } if (row.ParentTaskNoteID != null) { EPActivityApprove rowParentTask = PXSelect <EPActivityApprove> .Search <EPActivityApprove.noteID>(this, row.ParentTaskNoteID); if (rowParentTask != null && rowParentTask.ProjectID == row.ProjectID) { e.NewValue = rowParentTask.ProjectTaskID; e.Cancel = true; } } EPEarningType earningRow = (EPEarningType)PXSelectorAttribute.Select <EPActivityApprove.earningTypeID>(cache, row); if (e.NewValue == null && earningRow != null && earningRow.ProjectID == row.ProjectID) { PMTask defTask = PXSelectorAttribute.Select(cache, e.Row, cache.GetField(typeof(EPTimeCardSummary.projectTaskID)), earningRow.TaskID) as PMTask; if (defTask != null && defTask.VisibleInEP == true) { e.NewValue = earningRow.TaskID; e.Cancel = true; } } }