def update_player_fine(
        self,
        payload: dict,
    ) -> dict:
        if not payload['banker']:
            raise AuthorizationError(error_code='player_unauthorized')

        player = Player.get_player_by_uuid(player_uuid=payload['player_uuid'])

        if not player:
            raise EntityNotFound(error_code='player_not_found')

        if not payload['fine_uuid']:
            raise ModelCreationError(error_code='missing_parameter')

        fine = Fine.get_fine_by_uuid(uuid=payload['fine_uuid'])

        if not fine:
            raise EntityNotFound(error_code='fine_not_found')

        player_fine = PlayerFines(player_fines_id=str(uuid.uuid4()))
        player_fine.fine = fine
        player.fines.append(player_fine)
        db.session.commit()

        return player.to_dict()
    def delete_player_fines(
        self,
        banker: bool,
        player_uuid: uuid,
    ) -> bool:
        if not banker:
            raise AuthorizationError(error_code='player_unauthorized')

        player = Player.get_player_by_uuid(player_uuid=player_uuid)

        if not player:
            raise EntityNotFound(error_code='player_not_found')

        Player.delete_player_fines(player_uuid)

        return True
    def get_player_fines(
        self,
        player_uuid: uuid,
    ) -> collections:
        result = []

        player = Player.get_player_by_uuid(player_uuid=player_uuid)

        if not player:
            raise EntityNotFound(error_code='player_not_found')

        player_fines = Player.get_player_fines_by_uuid(player_uuid=player_uuid)

        for player_fine in player_fines:
            result.append(player_fine.fine.label, )
        # return the count of each fines a player has
        # ex: {'toto':2, 'titi':1}
        final_result = collections.Counter(result)
        return final_result
    def get_all_players_from_team(
        self,
        team_uuid,
        additional_filters,
    ):
        total_players = Player.get_total_players_by_team(team_uuid)
        if not total_players:
            raise EntityNotFound(error_code='team_not_found')
        players = Player.get_all_players_by_team(team_uuid)

        if (additional_filters.get('lastUuid')
                and additional_filters.get('lastUuid') != ''):
            from_last_uuid = Player.get_player_by_uuid(
                player_uuid=additional_filters.get('lastUuid'))
            if not from_last_uuid:
                raise EntityNotFound(error_code='player_not_found')

        # FILTER BY FIRST NAME OR LAST NAME
        if (additional_filters.get('filter')
                and additional_filters.get('filter') != ''):
            players = Player.get_player_by_name(
                players=players, filter=additional_filters.get('filter'))
            return {
                'players': players,
                'total_rows': total_players,
            }

        # FIRST PAGE
        if int(additional_filters.get('currentPage')) == 1:
            players = Player.get_players_by_limit_per_page(
                players=players, limit=int(additional_filters.get('perPage')))
        else:
            players = Player.get_players_by_lastuuid(
                players=players,
                from_last_uuid=from_last_uuid,
                limit=int(additional_filters.get('perPage')))
        return {
            'players': players,
            'total_rows': total_players,
        }