コード例 #1
0
ファイル: controller.py プロジェクト: pavle10/project_m
    def _update_uniform_piece(self, values):
        # Input data validation
        # Check required fields
        if not funcs.check_required_fields(values[1], values[3], values[4],
                                           values[6]):
            return Response(ResponseStatus.fail,
                            strs.REQUIRED_FIELDS_NOT_FILLED_MSG)

        if not funcs.convert_to_int(values, [3, 4]):
            return Response(ResponseStatus.fail, strs.NOT_INTEGER_MSG)

        if values[3] < 0 or values[4] < 0:
            return Response(ResponseStatus.fail, strs.INVALID_MEASURE_MSG)

        uniform_name = self._get_uniform_name(values[1])

        if uniform_name is None:
            # TODO write to log
            return Response(ResponseStatus.fail, strs.INTERNAL_ERROR_MSG)

        response = self._database_manager.actions(Actions.update_uniform_piece,
                                                  values)

        if response.get_status() == ResponseStatus.success:
            for uniform_piece in self._uniform_pieces:
                if uniform_piece.get_uniform_piece_id() == values[0]:
                    uniform_piece.update_data(values)
                    uniform_piece.set_uniform_name(uniform_name)
                    break

        return response
コード例 #2
0
ファイル: controller.py プロジェクト: pavle10/project_m
    def _add_salary_2(self, values):
        # Input data validation
        if not funcs.convert_to_int(values, [2, 4, 6, 8, 9, 10, 11]):
            return Response(ResponseStatus.fail, strs.NOT_INTEGER_MSG)

        if values[2] < 0 or values[4] < 0 or values[6] < 0 or values[8] < 0 \
                or values[9] < 0 or values[10] < 0 or values[11] < 0:
            # TODO write to log
            return Response(ResponseStatus.fail, strs.INVALID_MEASURE_MSG)

        if values[11] > 0 and (values[2] > 0 or values[4] > 0 or values[6] > 0
                               or values[8] > 0 or values[9] > 0
                               or values[10] > 0):
            return Response(ResponseStatus.fail,
                            strs.NOT_ALLOWED_FIX_AND_OTHER_MSG)

        employee_id = self._get_employee_id(values[0])

        if employee_id is None:
            return Response(ResponseStatus.fail, strs.INTERNAL_ERROR_MSG)

        response = self._get_employee_wage(values)
        wage = response.get_data()
        if response.get_status() == ResponseStatus.fail or wage is None:
            return Response(
                ResponseStatus.fail,
                strs.WAGE_FOR_EMPLOYEE_MISSING_MSG.format(employee=values[0]))

        values[0] = employee_id
        values[3] = wage[0].get_day()
        values[5] = wage[0].get_hour()
        values[7] = wage[0].get_meal()

        return self._database_manager.actions(Actions.add_salary_2, values)
コード例 #3
0
ファイル: controller.py プロジェクト: pavle10/project_m
    def _add_salary_1(self, values):
        # Input data validation
        # Check required fields
        if not funcs.check_required_fields(values[0], values[1], values[2]):
            return Response(ResponseStatus.fail,
                            strs.REQUIRED_FIELDS_NOT_FILLED_MSG)

        if not funcs.convert_to_int(values, [1, 2]):
            return Response(ResponseStatus.fail, strs.NOT_INTEGER_MSG)

        if values[1] < 0 or values[2] < 0:
            # TODO write to log
            return Response(ResponseStatus.fail, strs.INVALID_MEASURE_MSG)

        if values[1] > values[2]:
            return Response(ResponseStatus.fail,
                            strs.INVALID_NET_GROSS_RATIO_MSG)

        employee_id = self._get_employee_id(values[0])

        if employee_id is None:
            return Response(ResponseStatus.fail, strs.INTERNAL_ERROR_MSG)

        values[0] = employee_id

        return self._database_manager.actions(Actions.add_salary_1, values)
コード例 #4
0
ファイル: controller.py プロジェクト: pavle10/project_m
    def _add_wage(self, values):
        # Input data validation
        # Check required fields
        if not funcs.check_required_fields(values[0], values[1], values[2],
                                           values[3]):
            return Response(ResponseStatus.fail,
                            strs.REQUIRED_FIELDS_NOT_FILLED_MSG)

        if not funcs.convert_to_int(values, [1, 2, 3]):
            return Response(ResponseStatus.fail, strs.NOT_INTEGER_MSG)

        if values[1] < 0 or values[2] < 0 or values[3] < 0:
            # TODO write to log
            return Response(ResponseStatus.fail, strs.INVALID_MEASURE_MSG)

        employee_id = self._get_employee_id(values[0])

        if employee_id is None:
            return Response(ResponseStatus.fail, strs.INTERNAL_ERROR_MSG)

        values[0] = employee_id

        response = self._database_manager.actions(Actions.add_wage, values)

        if response.get_status() == ResponseStatus.success:
            self._wages.append(response.get_data())
            self._update_wages_employees_names([-1])

        return response
コード例 #5
0
ファイル: controller.py プロジェクト: pavle10/project_m
    def _update_salary_2(self, values):
        # Input data validation
        if not funcs.convert_to_int(values, [3, 5, 7, 9, 10, 11, 12]):
            return Response(ResponseStatus.fail, strs.NOT_INTEGER_MSG)

        if values[3] < 0 or values[5] < 0 or values[7] < 0 or values[9] < 0 \
                or values[10] < 0 or values[11] < 0 or values[12] < 0:
            # TODO write to log
            return Response(ResponseStatus.fail, strs.INVALID_MEASURE_MSG)

        return self._database_manager.actions(Actions.update_salary_2, values)
コード例 #6
0
    def _prepare_data(self):
        table_data = self.table.get_data()
        data = dict()

        data["dates"] = [[
            self.start_date_line.date().toPyDate().strftime(
                cons.DATE_FORMAT_PYTHON),
            self.end_date_line.date().toPyDate().strftime(
                cons.DATE_FORMAT_PYTHON)
        ]]

        for index, row in enumerate(table_data):
            date = row[0]
            employee = row[1]

            funcs.convert_to_int(row, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11])

            day_pay = row[2] * row[3]
            hour_pay = row[4] * row[5]
            meal_pay = row[6] * row[7]
            vacation_pay = row[9] * row[10] * (-1)
            rate_pay = row[8] * (-1)
            fix_pay = row[11]
            overall_pay = day_pay + hour_pay + meal_pay + vacation_pay + rate_pay + fix_pay

            day = ("Dan", str(row[2]), str(row[3]), str(day_pay))
            hour = ("Sat", str(row[4]), str(row[5]), str(hour_pay))
            meal = ("Obrok", str(row[6]), str(row[7]), str(meal_pay))
            vacation = ("Odmor", str(row[9]), str(row[10]), str(vacation_pay))
            rate = ("Rate", "", "", str(rate_pay))
            fix = ("Fiksno", "", "", str(fix_pay))
            overall = ("Ukupno", "", "", str(overall_pay))

            data[index] = [
                date, employee, day, hour, meal, vacation, rate, fix, overall
            ]

        return data
コード例 #7
0
ファイル: controller.py プロジェクト: pavle10/project_m
    def _update_salary_1(self, values):
        # Input data validation
        # Check required fields
        if not funcs.check_required_fields(values[2], values[3]):
            return Response(ResponseStatus.fail,
                            strs.REQUIRED_FIELDS_NOT_FILLED_MSG)

        if not funcs.convert_to_int(values, [2, 3]):
            return Response(ResponseStatus.fail, strs.NOT_INTEGER_MSG)

        if values[2] < 0 or values[3] < 0:
            # TODO write to log
            return Response(ResponseStatus.fail, strs.INVALID_MEASURE_MSG)

        if values[2] > values[3]:
            return Response(ResponseStatus.fail,
                            strs.INVALID_NET_GROSS_RATIO_MSG)

        return self._database_manager.actions(Actions.update_salary_1, values)
コード例 #8
0
ファイル: controller.py プロジェクト: pavle10/project_m
    def _update_employee(self, values):
        # Input data validation
        # Check required fields
        if not funcs.check_required_fields(values[1], values[2], values[4],
                                           values[7], values[9]):
            return Response(ResponseStatus.fail,
                            strs.REQUIRED_FIELDS_NOT_FILLED_MSG)

        # Check before m fields
        before_m = values[11]

        if not funcs.convert_to_int(before_m, range(3)):
            return Response(ResponseStatus.fail, strs.NOT_INTEGER_MSG)

        years = before_m[0]
        months = before_m[1]
        days = before_m[2]

        if years < 0 or months < 0 or months > 11 or days < 0 or days > 30:
            # TODO write to log
            return Response(ResponseStatus.fail, strs.INVALID_DATE_FORMAT_MSG)

        values[11] = funcs.to_days(years, months, days)

        position_id = self._get_position_id(values[7])

        # Check position id
        if position_id is None:
            # TODO write to log
            return Response(ResponseStatus.fail, strs.INTERNAL_ERROR_MSG)

        values[7] = position_id

        response = self._database_manager.actions(Actions.update_employee,
                                                  values)

        if response.get_status() == ResponseStatus.success:
            for employee in self._employees:
                if employee.get_employee_id() == values[0]:
                    employee.update_data(values)
                    break

        return response
コード例 #9
0
ファイル: controller.py プロジェクト: pavle10/project_m
    def _update_wage(self, values):
        # Input data validation
        # Check required fields
        if not funcs.check_required_fields(values[2], values[3], values[4]):
            return Response(ResponseStatus.fail,
                            strs.REQUIRED_FIELDS_NOT_FILLED_MSG)

        if not funcs.convert_to_int(values, [2, 3, 4]):
            return Response(ResponseStatus.fail, strs.NOT_INTEGER_MSG)

        if values[2] < 0 or values[3] < 0 or values[4] < 0:
            # TODO write to log
            return Response(ResponseStatus.fail, strs.INVALID_MEASURE_MSG)

        response = self._database_manager.actions(Actions.update_wage, values)

        if response.get_status() == ResponseStatus.success:
            for wage in self._wages:
                if wage.get_wage_id() == values[0]:
                    wage.update_data(values)
                    break

        return response