Exemple #1
0
    def _examine_condition(self):
        super(TriggerEmployeeNoWorkTimeTracking, self)._examine_condition()

        # Only proceed if schedule met
        if (self._check_schedule()):

            send_email_service = SendEmailService()

            # Use the appropriate service to get the list of companies that
            # do not use this feature
            app_feature_service = ApplicationFeatureService()
            timesheet_disabled_company_list = app_feature_service.get_company_list_with_feature_disabled(APP_FEATURE_WORKTIMESHEET)
            ranged_timecard_enabled_company_list = app_feature_service.get_company_list_with_feature_enabled(APP_FEATURE_RANGEDTIMECARD)
            feature_disabled_company_list = [c for c in timesheet_disabled_company_list if c not in ranged_timecard_enabled_company_list]

            timesheet_notify_enabled_company_list = app_feature_service.get_company_list_with_feature_enabled(APP_FEATURE_WORKTIMESHEETNOTIFICATION)

            # Get the start date of the past week (starting Sunday)
            week_start_date = self._get_last_week_start_date()

            # Get the list of users that have submitted the timesheet
            # for the week
            time_tracking_service = TimeTrackingService()
            submitted_users = time_tracking_service.get_all_users_submitted_work_timesheet_by_week_start_date(week_start_date)

            # Get the list of users that have the notification of this feature blocked
            blocked_users = send_email_service.get_all_users_blocked_for_email_feature(
                    EMAIL_BLOCK_FEATURE_WORKTIMESHEETNOTIFICATION
                )

            # Only include the employee for reporting if all of the below hold
            #   - Company has the feature on
            #   - Company has the notification feature on
            #   - User is not blocked for this notification 
            #   - User has not submitted yet
            company_users = CompanyUser.objects.filter(
                    company_user_type=USER_TYPE_EMPLOYEE,
                    company__in=timesheet_notify_enabled_company_list,
                ).exclude(
                    company__in=feature_disabled_company_list
                ).exclude(
                    user__in=blocked_users
                ).exclude(
                    user__in=submitted_users
                )

            for company_user in company_users:
                user = company_user.user
                company = company_user.company

                self._cache_company_user(company.id, user.id)

        return (not self._is_cached_data_empty())
    def test_get_company_list_with_feature_disabled(self):
        service = ApplicationFeatureService()

        result = service.get_company_list_with_feature_disabled(
            'DentalBenefit')
        self.assertEqual(type(result), list)
        self.assertEqual(len(result), 1)
        self.assertIn(2, result)

        result = service.get_company_list_with_feature_disabled('DD')
        self.assertEqual(type(result), list)
        self.assertEqual(len(result), 0)
    def test_get_company_list_with_feature_enabled(self):
        service = ApplicationFeatureService()

        result = service.get_company_list_with_feature_enabled('FSA')
        self.assertEqual(type(result), list)
        self.assertEqual(len(result), 4)
        self.assertIn(1, result)
        self.assertIn(2, result)

        result = service.get_company_list_with_feature_enabled(
            'RangedTimeCard')
        self.assertEqual(type(result), list)
        self.assertEqual(len(result), 4)
Exemple #4
0
class DailyEmployeeDataChangeReportHandler(EventHandlerBase):
    _aws_event_bus_service = AwsEventBusService()
    _application_feature_service = ApplicationFeatureService()

    def __init__(self):
        super(DailyEmployeeDataChangeReportHandler,
              self).__init__(Time11PMUTCEvent)

    def _internal_handle(self, event):
        # Fan out (sub) events for each company that currently the feature is enabled
        company_list = self._application_feature_service.get_company_list_with_feature_enabled(
            APP_FEATURE_EMPLOYEEDATACHANGENOTIFICATION)

        for company in company_list:
            event = CompanyDailyEmployeeDataChangeReportEvent(company)
            self._aws_event_bus_service.publish_event(event)
Exemple #5
0
class DailyTimeCardAuditReportHandler(EventHandlerBase):
    _aws_event_bus_service = AwsEventBusService()
    _application_feature_service = ApplicationFeatureService()

    def __init__(self):
        super(DailyTimeCardAuditReportHandler, self).__init__(Time12AMESTEvent)

    def _internal_handle(self, event):
        # Fan out (sub) events for each company that currently has the time card
        # feature on and has the audit enabled
        with_time_card_feature_on = self._application_feature_service.get_company_list_with_feature_enabled(
            APP_FEATURE_RANGEDTIMECARD)
        with_report_feature_on = self._application_feature_service.get_company_list_with_feature_enabled(
            APP_FEATURE_TIMEPUNCHCARDAUDITREPORT)

        company_list = list(
            set(with_time_card_feature_on) & set(with_report_feature_on))

        for company in company_list:
            event = CompanyDailyTimeCardAuditEvent(company)
            self._aws_event_bus_service.publish_event(event)
Exemple #6
0
 def get(self, request, company_id, format=None):
     appFeatureService = ApplicationFeatureService()
     complete_features = appFeatureService.get_complete_application_feature_status_by_company(
         company_id)
     return Response(complete_features)
Exemple #7
0
    def _get_user_data(self, user):
        result = {}

        # User info
        user_info = {}

        ## Basic info
        user_info['user_id'] = user.id
        user_info[
            'user_id_env_encode'] = self.hash_key_service.encode_key_with_environment(
                user.id)
        user_info['account_email'] = user.email

        ## Person and Compensation Info
        persons = Person.objects.filter(user=user.id, relationship='self')
        if (len(persons) > 0):
            person_model = persons[0]
            person_data = PersonInfo(person_model)
            user_info['first_name'] = person_data.first_name
            user_info['last_name'] = person_data.last_name

            compensation_info = CompensationService(person_model=person_model)
            hourly_rate = compensation_info.get_current_hourly_rate()
            if (hourly_rate):
                hourly_rate = round(hourly_rate, 2)
            user_info['hourly_rate'] = hourly_rate

        result['user_info'] = user_info

        # Company Info
        company_info = {}

        company_users = CompanyUser.objects.filter(user=user.id)
        company_id = None
        if (len(company_users) > 0):
            company_user = company_users[0]
            company_id = company_user.company_id
            company_info['company_id'] = company_id
            company_info[
                'company_id_env_encode'] = self.hash_key_service.encode_key_with_environment(
                    company_user.company_id)
            if (company_user.company):
                company_info['company_name'] = company_user.company.name

        result['company_info'] = company_info

        # Application Features
        application_features = None
        if (company_id):
            application_feature_service = ApplicationFeatureService()
            application_features = application_feature_service.get_complete_application_feature_status_by_company(
                company_id)
            result['app_features_info'] = application_features

        # Projects
        if (application_features
                and application_features[APP_FEATURE_PROJECTMANAGEMENT]):
            project_service = ProjectService()
            result['project_list'] = project_service.get_projects_by_company(
                company_id, active_only=True)

        return result