Ejemplo n.º 1
0
        public virtual decimal?CalculateEmployeeCost(CR.EPActivity activity, int?employeeID, DateTime date)
        {
            decimal?cost;
            Rate    employeeRate = GetEmployeeRate(activity.ProjectID, activity.ProjectTaskID, employeeID, date);

            if (employeeRate.Type == RateTypesAttribute.SalaryWithExemption && activity.TimeCardCD != null)
            {
                //Overtime is not applicable. Rate is prorated based on actual hours worked on the given week

                EPTimeCard timecard = PXSelect <EPTimeCard, Where <EPTimeCard.timeCardCD, Equal <Required <EPTimeCard.timeCardCD> > > > .Select(graph, activity.TimeCardCD);

                if (timecard.TotalSpentCalc <= employeeRate.RegularHours * 60)
                {
                    cost = employeeRate.RateByType / employeeRate.RegularHours;
                }
                else
                {
                    cost = employeeRate.RateByType / (timecard.TotalSpentCalc / 60);
                }
            }
            else
            {
                cost = employeeRate.HourlyRate * GetOvertimeMultiplier(activity.EarningTypeID, (int)employeeID, date);
            }

            return(cost);
        }
Ejemplo n.º 2
0
        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);
            }

            CR.CRCaseClassLaborMatrix caseClassLabor = PXSelect <CR.CRCaseClassLaborMatrix, Where <CR.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);
            }

            CR.EPActivity activity = PXSelect <CR.EPActivity, Where <CR.EPActivity.earningTypeID, Equal <Required <EPEarningType.typeCD> > > > .Select(this, row.TypeCD);

            if (activity != null)
            {
                throw new PXException(Messages.CannotDeleteInUse);
            }

            PM.PMTran pmTran = PXSelect <PM.PMTran, Where <PM.PMTran.earningType, Equal <Required <EPEarningType.typeCD> > > > .Select(this, row.TypeCD);

            if (pmTran != null)
            {
                throw new PXException(Messages.CannotDeleteInUse);
            }
        }
Ejemplo n.º 3
0
        public static int?GetContractLaborClassID(PXGraph graph, CR.EPActivity activity)
        {
            EPContractRate matrix =
                PXSelectJoin <
                    EPContractRate
                    , InnerJoin <CR.CRCase, On <CR.CRCase.contractID, Equal <EPContractRate.contractID> >
                                 , InnerJoin <EPEmployee, On <EPContractRate.employeeID, Equal <EPEmployee.bAccountID> > >
                                 >
                    , Where <
                        CR.CRCase.noteID, Equal <Required <CR.EPActivity.refNoteID> >
                        , And <EPContractRate.earningType, Equal <Required <CR.EPActivity.earningTypeID> >
                               , And <EPEmployee.userID, Equal <Required <CR.EPActivity.owner> > >
                               >
                        >
                    > .Select(graph, new object[] { activity.RefNoteID, activity.EarningTypeID, activity.Owner });

            if (matrix == null)
            {
                matrix =
                    PXSelectJoin <
                        EPContractRate
                        , InnerJoin <CR.CRCase, On <CR.CRCase.contractID, Equal <EPContractRate.contractID> > >
                        , Where <
                            CR.CRCase.noteID, Equal <Required <CR.EPActivity.refNoteID> >
                            , And <EPContractRate.earningType, Equal <Required <CR.EPActivity.earningTypeID> >
                                   , And <EPContractRate.employeeID, IsNull>
                                   >
                            >
                        > .Select(graph, new object[] { activity.RefNoteID, activity.EarningTypeID });
            }
            if (matrix != null)
            {
                return(matrix.LabourItemID);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
        public virtual int?GetLaborClass(CR.EPActivity activity)
        {
            int?laborClassID = null;

            CR.CRCase refCase = PXSelect <CR.CRCase, Where <CR.CRCase.noteID, Equal <Required <CR.EPActivity.refNoteID> > > > .Select(graph, activity.RefNoteID);

            if (refCase != null)
            {
                CR.CRCaseClass caseClass = (CR.CRCaseClass)PXSelectorAttribute.Select <CR.CRCase.caseClassID>(graph.Caches[typeof(CR.CRCase)], refCase);
                laborClassID = CR.CRCaseClassLaborMatrix.GetLaborClassID(graph, caseClass.CaseClassID, activity.EarningTypeID);
            }

            EPEmployee employee = PXSelect <EPEmployee> .Search <EPEmployee.userID>(graph, activity.Owner);

            if (employee == null)
            {
                throw new Exception(Messages.EmptyEmployeeID);
            }

            if (laborClassID == null && activity.ProjectID != null && employee.BAccountID != null)
            {
                laborClassID = EPContractRate.GetProjectLaborClassID(graph, (int)activity.ProjectID, (int)employee.BAccountID, activity.EarningTypeID);
            }

            if (laborClassID == null)
            {
                laborClassID = EPEmployeeClassLaborMatrix.GetLaborClassID(graph, employee.BAccountID, activity.EarningTypeID);
            }

            if (laborClassID == null)
            {
                laborClassID = employee.LabourItemID;
            }

            return(laborClassID);
        }