예제 #1
0
        public virtual Rate GetEmployeeRate(int?projectId, int?projectTaskId, int?employeeId, DateTime?date)
        {
            decimal?hourlyRate = null;
            decimal?rate       = null;
            PXResult <EPEmployeeRate, EPEmployeeRateByProject> result = ((PXResult <EPEmployeeRate, EPEmployeeRateByProject>)
                                                                         PXSelectJoin <
                                                                             EPEmployeeRate
                                                                             , LeftJoin <
                                                                                 EPEmployeeRateByProject
                                                                                 , On <
                                                                                     EPEmployeeRate.rateID, Equal <EPEmployeeRateByProject.rateID>
                                                                                     , And <EPEmployeeRateByProject.projectID, Equal <Required <EPEmployeeRateByProject.projectID> >
                                                                                            , And <Where <
                                                                                                       EPEmployeeRateByProject.taskID, Equal <Required <EPEmployeeRateByProject.taskID> >
                                                                                                       , Or <EPEmployeeRateByProject.taskID, IsNull>
                                                                                                       > >
                                                                                            >
                                                                                     >
                                                                                 >
                                                                             , Where <
                                                                                 EPEmployeeRate.employeeID, Equal <Required <EPEmployeeRate.employeeID> >
                                                                                 , And <EPEmployeeRate.effectiveDate, LessEqual <Required <EPEmployeeRate.effectiveDate> > >
                                                                                 >
                                                                             , OrderBy <Desc <EPEmployeeRate.effectiveDate, Desc <EPEmployeeRateByProject.taskID> > >
                                                                             > .SelectWindowed(graph, 0, 1, projectId, projectTaskId, employeeId, date)).
                                                                        With(_ => (_));

            EPEmployeeRateByProject employeeRateByProject = (EPEmployeeRateByProject)result;
            EPEmployeeRate          employeeRate          = (EPEmployeeRate)result;

            if (employeeRateByProject != null && employeeRateByProject.HourlyRate != null)
            {
                hourlyRate = employeeRateByProject.HourlyRate;
            }
            else if (employeeRate != null)
            {
                hourlyRate = employeeRate.HourlyRate;
            }
            else
            {
                CR.BAccountR baccount = PXSelect <CR.BAccountR, Where <CR.BAccountR.bAccountID, Equal <Required <CR.BAccountR.bAccountID> > > > .Select(graph, employeeId);

                throw new PXException(string.Format(Messages.HourlyRateIsNotSet, date, baccount.AcctCD));
            }
            if (employeeRate.RateType == RateTypesAttribute.Hourly)
            {
                rate = hourlyRate;
            }
            else
            {
                rate = hourlyRate * employeeRate.RegularHours;
            }

            return(new Rate(employeeId, employeeRate.RateType, hourlyRate, defaultUOM, employeeRate.RegularHours, rate));
        }
예제 #2
0
        public virtual decimal GetOvertimeMultiplier(string earningTypeID, int employeeID, DateTime effectiveDate)
        {
            EPEmployeeRate employeeRate = GetEmployeeRate(employeeID, effectiveDate);

            if (employeeRate != null && employeeRate.RateType == RateTypesAttribute.SalaryWithExemption)
            {
                return(1);
            }
            EPEarningType earningType = PXSelect <EPEarningType> .Search <EPEarningType.typeCD>(graph, earningTypeID);

            return(earningType != null && earningType.IsOvertime == true ? (decimal)earningType.OvertimeMultiplier : 1);
        }