Esempio n. 1
0
        public virtual int?GetDefaultLaborItem(int?employeeID, string earningType, int?projectID)
        {
            if (employeeID == null)
            {
                return(null);
            }

            int?result = null;

            if (ProjectDefaultAttribute.IsProject(this, projectID))
            {
                result = EPContractRate.GetProjectLaborClassID(this, projectID.Value, employeeID.Value, earningType);
            }

            if (result == null)
            {
                result = EPEmployeeClassLaborMatrix.GetLaborClassID(this, employeeID, earningType);
            }

            if (result == null)
            {
                EPEmployee employee = PXSelect <EPEmployee, Where <EPEmployee.bAccountID, Equal <Current <EPTimeCard.employeeID> > > > .Select(this);

                if (employee != null)
                {
                    result = employee.LabourItemID;
                }
            }

            return(result);
        }
Esempio n. 2
0
        ///NO CRM Mode
        public static int?GetContractLaborClassID(PXGraph graph, int?contractID, PMTimeActivity activity)
        {
            EPContractRate matrix =
                PXSelectJoin <
                    EPContractRate,
                    InnerJoin <EPEmployee,
                               On <EPContractRate.employeeID, Equal <EPEmployee.bAccountID> > >,
                    Where <EPContractRate.contractID, Equal <Required <EPContractRate.contractID> >,
                           And <EPContractRate.earningType, Equal <Required <CRPMTimeActivity.earningTypeID> >,
                                And <EPEmployee.userID, Equal <Required <CRPMTimeActivity.ownerID> > > > > > .Select(graph, contractID, activity.EarningTypeID, activity.OwnerID);

            if (matrix == null)
            {
                matrix =
                    PXSelect <
                        EPContractRate,
                        Where <EPContractRate.contractID, Equal <Required <EPContractRate.contractID> >,
                               And <EPContractRate.earningType, Equal <Required <CRPMTimeActivity.earningTypeID> >,
                                    And <EPContractRate.employeeID, IsNull> > > > .Select(graph, contractID, activity.EarningTypeID);
            }
            if (matrix != null)
            {
                return(matrix.LabourItemID);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 3
0
        public virtual int?GetLaborClass(PMTimeActivity activity, EPEmployee employee, CRCase refCase)
        {
            if (employee == null)
            {
                throw new ArgumentNullException("employee", Messages.EmptyEmployeeID);
            }

            int?laborClassID = null;

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

            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);
        }
        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);
            }
        }
Esempio n. 5
0
        public static int?GetProjectLaborClassID(PXGraph graph, int projectID, int employeeID, string earningType)
        {
            EPContractRate projectSettings = PXSelect
                                             <EPContractRate, Where <EPContractRate.contractID, Equal <Required <EPContractRate.contractID> >,
                                                                     And
                                                                     <EPContractRate.employeeID, Equal <Required <EPContractRate.employeeID> >,
                                                                      And <EPContractRate.earningType, Equal <Required <EPEarningType.typeCD> > > > > > .Select(graph, projectID, employeeID, earningType);

            return(projectSettings != null ? projectSettings.LabourItemID : null);
        }
Esempio n. 6
0
        public static int?GetContractLaborClassID(PXGraph graph, PMTimeActivity activity)
        {
            EPContractRate matrix =
                PXSelectJoin <
                    EPContractRate,
                    InnerJoin <CRCase,
                               On <CRCase.contractID, Equal <EPContractRate.contractID> >,
                               InnerJoin <CRActivityLink,
                                          On <CRActivityLink.refNoteID, Equal <CRCase.noteID> >,
                                          InnerJoin <EPEmployee,
                                                     On <EPContractRate.employeeID, Equal <EPEmployee.bAccountID> > > > >,
                    Where <CRActivityLink.noteID, Equal <Required <PMTimeActivity.refNoteID> >,
                           And <EPContractRate.earningType, Equal <Required <PMTimeActivity.earningTypeID> >,
                                And <EPEmployee.userID, Equal <Required <PMTimeActivity.ownerID> > > > > >
                .Select(graph, new object[] { activity.RefNoteID, activity.EarningTypeID, activity.OwnerID });

            if (matrix == null)
            {
                matrix =
                    PXSelectJoin <
                        EPContractRate,
                        InnerJoin <CRCase,
                                   On <CRCase.contractID, Equal <EPContractRate.contractID> >,
                                   InnerJoin <CRActivityLink,
                                              On <CRActivityLink.refNoteID, Equal <CRCase.noteID> > > >,
                        Where <CRActivityLink.noteID, Equal <Required <PMTimeActivity.refNoteID> >,
                               And <EPContractRate.earningType, Equal <Required <PMTimeActivity.earningTypeID> >,
                                    And <EPContractRate.employeeID, IsNull> > > >
                    .Select(graph, new object[] { activity.RefNoteID, activity.EarningTypeID });
            }

            if (matrix != null)
            {
                return(matrix.LabourItemID);
            }
            else
            {
                return(null);
            }
        }
        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);
        }