Exemple #1
0
    def CreateProject(self , **kwargs):
      
        contract             =  kwargs['contract'] if('contract' in kwargs) else None;
        workOrderNumber      =  kwargs['work_order_number'] if('work_order_number' in kwargs) else "";
        project_type         =  kwargs['project_type'] if('project_type' in kwargs) else ProjectType.USER_DEFINED_PROJECT;
        
        if(contract is None):
            raise TypeError("@CreateProject: expect the contract number of the project");
        project  = Project(workOrderNumber,project_type);
        project.ContractNumber  = contract ;

        if(project.Type  == ProjectType.USER_DEFINED_PROJECT):
            self.Timesheet.Projects.Records.append(project)
        else:
            self.Timesheet.Projects.FixedRecords.append(project)
        return project;
Exemple #2
0
    def __ParseProject(self, project_rec:list,  project_type:int):
        project  = None
        
        if(len(project_rec) > 4):
            #Filter out unfilled timesheet projects
            #get the  project details'
            details    =  project_rec[0:5]
            hours_recs =  project_rec[5:]
                                  
            if(len(hours_recs) >= 0) and (len(details) == 5):
                orderno =  str(details[1]).strip();
                #Only allow if order number is not empty or the project type is a fixed project.
                if(orderno != "") or (project_type  ==  ProjectType.FIXED_PROJECT):
                    #Create the project objects.
                    project                 =  Project(orderno,project_type)
                    project.RSRCE           =  str(details[0]).strip()
                    contractNumber  = details[2];
                    if(type(contractNumber) != str):
                        contractNumber = str(int(contractNumber));
                    project.ContractNumber  =  contractNumber.strip()
                    project.Description     =  str(details[4]).strip()

                    #Load the project hours
                    ndays  =  len(hours_recs)
                    if(ndays > 0):
                        project.TimeHistory.Insert( DayOfWeekType.MONDAY ,  self.__GetMillseconds(hours_recs[0]))                                            
                    if(ndays > 1):
                         project.TimeHistory.Insert(DayOfWeekType.TUESDAY ,  self.__GetMillseconds(hours_recs[1]))
                            
                    if(ndays > 2):
                        project.TimeHistory.Insert(DayOfWeekType.WEDNESDAY,  self.__GetMillseconds(hours_recs[2]))

                    if(ndays > 3):
                        project.TimeHistory.Insert(DayOfWeekType.THURSDAY, self.__GetMillseconds(hours_recs[3]))

                    if(ndays > 4):
                        project.TimeHistory.Insert(DayOfWeekType.FRIDAY,self.__GetMillseconds(hours_recs[4]))
                                                
                    if(ndays > 5):
                        project.TimeHistory.Insert(DayOfWeekType.SATURDAY, self.__GetMillseconds(hours_recs[5]))

                    if(ndays > 6):
                        project.TimeHistory.Insert(DayOfWeekType.SUNDAY, self.__GetMillseconds(hours_recs[6]))
        return project