Ejemplo n.º 1
0
def raise_wage_request_for_all_members(gpm_id, bdo_id):
    """
    Function to raise the wage request for all the member lying under that gpm
    :param gpm_id: gpm id
    :param bdo_id: bdo id
    :return: null
    """
    table_name_wage_approval = 'WAGE_APPROVAL'
    table_name_project_details = "PROJECT_MEMBER_DETAIL"
    table_name_project = 'PROJECT'

    print(ct.Project_available_in_your_block)
    project_list = qb.get_item_for_asignee(table_name_project, bdo_id)
    print("-" * 60)
    for item in project_list:
        print('Project Id : {}  |   Project Name :{}'.format(item[0], item[1]))
        print("-" * 60)

    project_id = input(ct.Enter_the_project_id_for_wage_update)
    if qb.is_project_wage_not_pending(table_name_wage_approval, project_id):
        member_detail_list = qb.get_member_project_details(
            table_name_project_details, project_id, gpm_id)
        for item in member_detail_list:
            number_of_days_worked = int(
                (extras.convert_string_to_date(str(item[3]).strip()) -
                 extras.convert_string_to_date(str(item[2]).strip())).days)
            amount = number_of_days_worked * 100
            qb.insert_wage_table(table_name_wage_approval, item[0], item[1],
                                 amount, number_of_days_worked, bdo_id)
    else:
        print(ct.Request_for_project_still_pending)
Ejemplo n.º 2
0
def approving_projects(bdo_id):
    """
    function for the bdo to approve member into projects
    :param bdo_id:
    :return:
    """
    table_name_project = "PROJECT"
    table_name_project_details = "PROJECT_MEMBER_DETAIL"
    print(ct.Project_available_in_your_block)
    project_list = qb.get_item_for_asignee(table_name_project, bdo_id)
    print("-" * 60)
    if len(project_list) != 0:
        for item in project_list:
            print('Project Id : {}  |   Project Name :{}'.format(item[0], item[1]))
            print("-" * 60)

        project_id = input(ct.Enter_the_project_id_to_view_pending_request)
        result_data = qb.fetch_pending_request_for_project(table_name_project_details,
                                                           project_id,
                                                           bdo_id)
        if len(result_data) != 0:
            print('Choose the member id whom you wanna approve\n')
            print('Member Id\t\tProject Id\t\tOnboarding Date\n')
            for item in result_data:
                print('\t\t{member_id}\t\t\t{project_id}\t\t\t{onboarding_date}'.format(member_id=item[0],
                                                                                        project_id=item[1],
                                                                                        onboarding_date=item[2]))
            member_id = input(ct.Enter_the_member_id_to_be_allotted)
            qb.approve_pending_details_for_project(table_name_project_details, member_id, 'request_status', 1)
        else:
            print(' No Member Assigned Till now')

    else:
        print(" No Project Available")
Ejemplo n.º 3
0
def login_bdo():
    """
    Function for login through BDO
    :return: null
    """
    extras.decorate_break_message('Login For BDO')
    try:
        email = str(input(ct.Enter_email))
        while not extras.validate_email(email):
            print("Wrong Email Format. Please enter valid email \n")
            email = str(input(ct.Enter_email))

        password = int(input(ct.Enter_password))
        while not extras.validate_password(password):
            print(
                "Wrong Password Format. Please enter numeric password between 101 and 999\n"
            )
            password = int(input(ct.Enter_password))

        if qb.validate_credential(ct.BDO_TABLE, email, password):
            bdo_details = qb.get_bdo_details(ct.BDO_TABLE, email, password)
            bdo_id = int(bdo_details[0])
            bdo_name = str(bdo_details[1])
            bdo = BDO(bdo_id, bdo_name)
            bdo.welcome_screen()
            logging.info("Successfully logged in as BDO {}".format(bdo_name))
        else:
            print(ct.Wrong_credentials)
            login_bdo()
    except ValueError as e:
        print("Error is {}".format(e))
    finally:
        login_bdo()
Ejemplo n.º 4
0
def login_gpm():
    """
    Function for login through GPM
    :return: null
    """
    extras.decorate_break_message('Login For GPM')
    try:
        email = str(input(ct.Enter_email))
        while not extras.validate_email(email):
            print("Wrong Email Format. Please enter valid email \n")
            email = str(input(ct.Enter_email))

        password = int(input(ct.Enter_password))
        while not extras.validate_password(password):
            print(
                "Wrong Password Format. Please enter numeric password between 101 and 999\n"
            )
            password = int(input(ct.Enter_password))

        if qb.validate_credential(ct.GPM_TABLE, email, password):
            gpm_details = qb.get_gpm_or_member_details(ct.GPM_TABLE, email,
                                                       password)
            gpm_id = int(gpm_details[0])
            gpm_name = str(gpm_details[1])
            asignee_bdo_id = int(gpm_details[2])
            gpm = GPM(gpm_id, gpm_name, asignee_bdo_id)
            gpm.welcome_screen()
        else:
            print(ct.Wrong_credentials)
            login_gpm()

    except ValueError as e:
        print("Error is {}".format(e))
    finally:
        login_gpm()
Ejemplo n.º 5
0
def delete_gpm(bdo_id):
    """
    Function to delete the gpm
    :param bdo_id: bdo_id
    :return: null
    """
    print(ct.Enter_the_email_to_delete_gpm)
    gpm_email = input(ct.Enter_email)
    table_name = 'GPM'
    qb.delete_gpm(table_name, bdo_id, gpm_email)
Ejemplo n.º 6
0
def create_gpm(bdo_id):
    """
    Method to create a new gpm under a bdo
    :param bdo_id: assignee_bdo_id
    :return: null
    """
    gpm_name = input(ct.Enter_name)
    gpm_email = input(ct.Enter_email)
    gpm_password = input(ct.Enter_password)
    gpm_area = input(ct.Enter_area)
    gpm_pincode = input(ct.Enter_pincode)
    table_name = 'GPM'

    qb.insert_gpm_table(table_name, gpm_name, gpm_email, gpm_password, gpm_area, gpm_pincode, bdo_id)
Ejemplo n.º 7
0
def approving_wages(bdo_id):
    """
    function to approve the pending wages
    :param bdo_id: bdo _id
    :return: null
    """
    table_name_project = "PROJECT"
    table_name_wage_approval = "WAGE_APPROVAL"
    table_name_member = 'MEMBER'
    print(ct.Project_available_in_your_block)
    project_list = qb.get_item_for_asignee(table_name_project, bdo_id)
    print("-" * 60)
    for item in project_list:
        print('Project Id : {}  |   Project Name :{}'.format(item[0], item[1]))
        print("-" * 60)

    project_id = input(ct.Enter_the_project_id_to_view_wage_request)
    member_wage_data = qb.fetch_wage_data_for_project(table_name_wage_approval, project_id, bdo_id)
    if len(member_wage_data) != 0:
        print('\t\t\t WAGE DATA FOR MEMBER \t\t\t')
        print('Member Id\t\tAmount\t\tDays Worked')
        for item in member_wage_data:
            print('\t\t{member_id}\t\t{amount}\t\t{days_worked}'.format(member_id=item[0],
                                                                        amount=item[1],
                                                                        days_worked=item[2]))

        member_id = input(ct.Enter_the_member_id_to_be_allotted)
        wage = input(ct.Enter_his_wage)
        days_worked = input(ct.Enter_days_worked)
        qb.delete_member_wage_data(table_name_wage_approval, member_id)
        qb.update_item_details(table_name_member, member_id, 'wage', wage)
        qb.update_item_details(table_name_member, member_id, 'days_worked', days_worked)
    else:
        print()
Ejemplo n.º 8
0
def update_gpm(bdo_id):
    """
    Function to update the gpm details
    :param bdo_id: bdo _id
    :return: null
    """
    print(ct.Enter_the_email_to_update_gpm)
    gpm_email = input(ct.Enter_email)
    table_name = 'GPM'

    print(ct.Choose_Update_Option_For_GPM)
    choice = input(ct.Enter_choice)

    if int(choice) in [1, 2, 3, 4]:
        if int(choice) == 1:
            updated_name = input(ct.Enter_new_name)
            qb.update_gpm_data(table_name, gpm_email, 'name', "'{}'".format(updated_name), bdo_id)
        elif int(choice) == 2:
            updated_password = input(ct.Enter_new_password)
            qb.update_gpm_data(table_name, gpm_email, 'password', updated_password, bdo_id)
        elif int(choice) == 3:
            updated_area = input(ct.Enter_new_area)
            qb.update_gpm_data(table_name, gpm_email, 'area', "'{}'".format(updated_area), bdo_id)
        else:
            updated_pincode = input(ct.Enter_new_pincode)
            qb.update_gpm_data(table_name, gpm_email, 'pincode', updated_pincode, bdo_id)
    else:
        print(ct.Wrong_choice)
Ejemplo n.º 9
0
def issue_job_card(gpm_id):
    """
    Method to issue a job card for a member
    :param gpm_id: gpm id
    :return: null
    """
    table_name = 'MEMBER'
    print(ct.Member_available_in_your_zone)
    member_list = qb.get_item_for_asignee(table_name, gpm_id)
    print("-" * 60)
    for item in member_list:
        print('Member Id : {}  |   Member Name :{}'.format(item[0], item[1]))
        print("-" * 60)
    item_id = input(ct.Enter_the_member_id_to_be_deleted)
    member_job_data = qb.fetch_job_id_data(table_name, item_id)
    extras.display_job_card(member_job_data)
Ejemplo n.º 10
0
def delete_project(bdo_id):
    """
    Function for the bdo to delete the project
    :param bdo_id: bdo _id
    :return: null
    """
    table_name = 'PROJECT'
    print(ct.Project_available_in_your_block)
    project_list = qb.get_item_for_asignee(table_name, bdo_id)
    print("-" * 60)
    for item in project_list:
        print('Project Id : {}  |   Project Name :{}'.format(item[0], item[1]))
        print("-" * 60)

    item_id = input(ct.Enter_the_project_id_to_be_deleted)
    qb.delete_item_from_table(table_name, item_id, 'id')
    qb.delete_item_from_table(ct.PROJECT_MEMBER_DETAIL_TABLE, item_id, 'project_id')
Ejemplo n.º 11
0
def check_wage(member_id):
    """
    Function to check the wage of member
    :param member_id: member id
    :return: null
    """
    wage_data = int(qb.fetch_wage_for_member(member_id))
    print('WAGE FOR YOUR PROJECT TASK : {}'.format(wage_data))
Ejemplo n.º 12
0
def raise_complaint(member_id, asignee_gpm_id, reviewer_bdo_id):
    """
    Function to raise a complaint by the member
    :param member_id: member id
    :param asignee_gpm_id: gpm id
    :param reviewer_bdo_id: bdo id
    :return: null
    """
    table_name = 'COMPLAINT'

    print(ct.Raise_complaint_to)
    choice = input(ct.Enter_choice)
    message = input('Enter Complaint Message : ')
    complaint_date = input(ct.Enter_complaint_date)
    qb.raise_complaint(table_name, member_id, message,
                       'BDO' if int(choice) == 1 else 'GPM',
                       reviewer_bdo_id if int(choice) == 1 else asignee_gpm_id,
                       complaint_date)
Ejemplo n.º 13
0
def create_member(gpm_id):
    """
    Function to create a member
    :param gpm_id: gpm id
    :return: null
    """
    table_name = 'MEMBER'
    name = input(ct.Enter_name)
    email = input(ct.Enter_email)
    password = input(ct.Enter_password)
    gender = input(ct.Enter_gender)
    while gender not in ['M', 'F']:
        print(ct.Warning_wrong_gender_entry)
        gender = input(ct.Enter_gender)
    address = input(ct.Enter_address)
    area = input(ct.Enter_area)
    age = input(ct.Enter_age)
    pincode = input(ct.Enter_pincode)

    qb.insert_member_table(table_name, name, email, password, gender, age,
                           address, area, pincode, gpm_id)
Ejemplo n.º 14
0
def view_complaints(bdo_id):
    """
    Function to view the  complaints registered under BDO
    :param bdo_id: bdo+id
    :return: null
    """
    table_name = 'COMPLAINT'
    result_data = qb.fetch_complaints_by_authority(table_name, bdo_id, 'BDO')
    if len(result_data) != 0:
        print("-" * 140)
        for item in result_data:
            print('Complaint Id : {complaint_id} |  Member Id : {member_id} | '
                  'Message : {message} | Complaint Date : {date}'.format(complaint_id=item[0],
                                                                         member_id=item[1],
                                                                         message=item[2],
                                                                         date=item[3]))
            print("-" * 140)
        complaint_id = input(ct.Choose_complaint_that_has_been_resolved)
        qb.delete_item_from_table(table_name, complaint_id, 'id')
    else:
        print(ct.No_Complaint_present)
Ejemplo n.º 15
0
def delete_member(gpm_id):
    """
     Function to delete a member form the table
    :param gpm_id: gpm id
    :return: null
    """
    table_name = 'MEMBER'
    print(ct.Member_available_in_your_zone)
    member_list = qb.get_item_for_asignee(table_name, gpm_id)
    print("-" * 60)
    for item in member_list:
        print('Member Id : {}  |   Member Name :{}'.format(item[0], item[1]))
        print("-" * 60)

    item_id = input(ct.Enter_the_member_id_to_be_deleted)
    qb.delete_item_from_table(table_name, item_id, 'id')
    qb.delete_item_from_table(ct.PROJECT_MEMBER_DETAIL_TABLE, item_id,
                              'member_id')
    qb.delete_item_from_table(ct.WAGE_APPROVAL_TABLE, item_id, 'member_id')
    qb.delete_item_from_table(ct.COMPLAINT_TABLE, item_id, 'member_id')
Ejemplo n.º 16
0
def login_member():
    """
    Function for login through Member
    :return:  null
    """
    extras.decorate_break_message('Login For MEMBER')
    try:
        email = str(input(ct.Enter_email))
        while not extras.validate_email(email):
            print("Wrong Email Format. Please enter valid email \n")
            email = str(input(ct.Enter_email))

        password = int(input(ct.Enter_password))
        while not extras.validate_password(password):
            print(
                "Wrong Password Format. Please enter numeric password between 101 and 999\n"
            )
            password = int(input(ct.Enter_password))
        if qb.validate_credential(ct.MEMBER_TABLE, email, password):
            member_details = qb.get_gpm_or_member_details(
                ct.MEMBER_TABLE, email, password)
            member_id = int(member_details[0])
            member_name = str(member_details[1])
            asignee_gpm_id = int(member_details[2])
            reviewer_bdo_id = int(qb.fetch_bdo_id(asignee_gpm_id))
            member = MEMBER(member_id, member_name, asignee_gpm_id,
                            reviewer_bdo_id)
            member.welcome_screen()
        else:
            print(ct.Wrong_credentials)
            login_member()

    except ValueError as e:
        print("Error as {}".format(e))
    finally:
        login_member()
Ejemplo n.º 17
0
def create_project(bdo_id):
    """
    Function to create a new project as assigned per the the norms by the bdo
    :param bdo_id: bdo_id
    :return: null
    """
    table_name = "PROJECT"
    project_name = input(ct.Enter_name)
    project_area = input(ct.Enter_area)
    member_count = input(ct.Enter_total_member_required)
    project_cost = input(ct.Enter_project_cost_estimate)
    project_type = input(ct.Enter_project_type)

    while project_type not in ["RC", "ST", "BC"]:
        print(ct.Warning_wrong_project_type)
        project_type = input(ct.Enter_project_type)

    start_date = input(ct.Enter_start_date)
    end_date = input(ct.Enter_end_date)
    project_start_date = extras.convert_string_to_date(start_date)
    project_end_date = extras.convert_string_to_date(end_date)

    while project_end_date < project_start_date:
        print(ct.Warning_wrong_end_date)
        end_date = input(ct.Enter_end_date)
        project_end_date = extras.convert_string_to_date(end_date)

    qb.insert_project_table(table_name,
                            project_name,
                            project_area,
                            member_count,
                            project_cost,
                            project_type,
                            start_date,
                            end_date,
                            bdo_id)
Ejemplo n.º 18
0
def assign_project(gpm_id, bdo_id):
    """
    function to assign project to a member
    :param gpm_id: gpm id
    :param bdo_id: bdo id
    :return: null
    """
    table_name_project_detail = 'PROJECT_MEMBER_DETAIL'
    table_name_project = "PROJECT"
    table_name_member = 'MEMBER'

    print(ct.Project_available_in_your_block)
    project_list = qb.get_item_for_asignee(table_name_project, bdo_id)
    print("-" * 60)
    for item in project_list:
        print('Project Id : {}  |   Project Name :{}'.format(item[0], item[1]))
        print("-" * 60)

    project_id = input(ct.Enter_the_project_id_to_be_member_allotted)
    project_data = qb.get_project_details(table_name_project, project_id)
    total_strength = project_data[0]
    start_date = str(project_data[1])
    end_date = str(project_data[2])
    current_strength = qb.get_project_allocated_strength(
        table_name_project_detail, project_id)

    if current_strength < total_strength:
        print(ct.Member_available_in_your_zone)
        member_list = qb.get_item_for_asignee(table_name_member, gpm_id)
        print("-" * 60)
        for item in member_list:
            print('Member Id : {}  |   Member Name :{}'.format(
                item[0], item[1]))
            print("-" * 60)

        item_id = input(ct.Enter_the_member_id_to_be_allotted)
        if qb.check_member_not_present(table_name_project_detail, item_id):
            onboarding_date = input(ct.Enter_project_assigned_date)
            while extras.convert_string_to_date(start_date) > extras.convert_string_to_date(str(onboarding_date)) \
                    or extras.convert_string_to_date(end_date) < extras.convert_string_to_date(str(onboarding_date)):
                print(ct.Warning_invalid_onboarding_date)
                onboarding_date = input(ct.Enter_project_assigned_date)
            qb.assign_member_to_project(table_name_project_detail, item_id,
                                        project_id, gpm_id, bdo_id,
                                        onboarding_date, end_date)
        else:
            print(ct.Member_already_in_list)
    else:
        print(ct.Project_slots_already_occupied)
Ejemplo n.º 19
0
def create_tables():
    """
    Fucntion to Create the table in database
    :return: null
    """
    qb.create_table(ct.BDO_TABLE, 'id integer PRIMARY KEY AUTOINCREMENT',
                    'name varchar(25)', 'email varchar(50)',
                    'password varchar(10)')

    qb.create_table(ct.GPM_TABLE, 'id integer PRIMARY KEY AUTOINCREMENT',
                    'name varchar(25)', 'email varchar(50)',
                    'password varchar(10)', 'area varchar[50]',
                    'pincode integer', 'asignee_id integer')

    qb.create_table(ct.MEMBER_TABLE, 'id integer PRIMARY KEY AUTOINCREMENT',
                    'name varchar(25)', 'email varchar(50)',
                    'password varchar(10)', 'gender varchar(5)', 'age integer',
                    'address varchar(50)', 'area varchar[50]',
                    'pincode integer', 'days_worked integer DEFAULT 0',
                    'wage integer DEFAULT 0', 'asignee_id integer')

    qb.create_table(ct.PROJECT_TABLE, 'id integer PRIMARY KEY AUTOINCREMENT',
                    'name varchar(50)', 'area varchar[50]',
                    'total_member integer', 'cost_estimate integer',
                    'type varchar(5)', 'start_date  varchar(15)',
                    'end_date varchar(15)', 'asignee_id integer')

    qb.create_table(ct.PROJECT_MEMBER_DETAIL_TABLE,
                    'member_id integer PRIMARY KEY', 'project_id integer',
                    'request_status integer DEFAULT 0',
                    'onboarding_date varchar(15)', 'end_date varchar(15)',
                    'asignee_id int', 'reviewer_id int')

    qb.create_table(ct.WAGE_APPROVAL_TABLE, 'member_id integer PRIMARY KEY',
                    'project_id integer', 'amount integer',
                    'days_worked integer', 'reviewer_id integer')

    qb.create_table(ct.COMPLAINT_TABLE,
                    'id integer PRIMARY KEY AUTOINCREMENT ',
                    'member_id integer', 'message varchar(255)',
                    'raise_to varchar(5)', 'authority_id integer',
                    'date varchar(15)')
Ejemplo n.º 20
0
def update_project(bdo_id):
    """
    Functions to update the project details by the bdo
    :param bdo_id: bdo_id
    :return: null
    """
    table_name = 'PROJECT'
    print(ct.Project_available_in_your_block)
    project_list = qb.get_item_for_asignee(table_name, bdo_id)
    print("-" * 60)
    for item in project_list:
        print('Project Id : {}  |   Project Name :{}'.format(item[0], item[1]))
        print("-" * 60)

    item_id = input(ct.Enter_the_project_id_to_be_updated)
    print(ct.Choose_Update_Option_For_Project)
    choice = input(ct.Enter_choice)

    if int(choice) in [1, 2, 3, 4, 5]:
        if int(choice) == 1:
            updated_name = input(ct.Enter_new_name)
            qb.update_item_details(table_name, item_id, 'name', "'{}'".format(updated_name))
        elif int(choice) == 2:
            updated_area = input(ct.Enter_new_area)
            qb.update_item_details(table_name, item_id, 'area', "'{}'".format(updated_area))
        elif int(choice) == 3:
            updated_member_count = input(ct.Enter_new_total_member_required)
            qb.update_item_details(table_name, item_id, 'total_member', updated_member_count)
        elif int(choice) == 4:
            updated_cost_estimate = input(ct.Enter_new_project_cost_estimate)
            qb.update_item_details(table_name, item_id, 'cost_estimate', updated_cost_estimate)
        else:
            updated_project_type = input(ct.Enter_new_project_type)
            while updated_project_type not in ["RC", "ST", "BC"]:
                print(ct.Warning_wrong_project_type)
                updated_project_type = input(ct.Enter_new_project_type)
            qb.update_item_details(table_name, item_id, 'type', "'{}'".format(updated_project_type))
    else:
        print(ct.Wrong_choice)
Ejemplo n.º 21
0
def update_member(gpm_id):
    """
    Function to update the details of the member
    :param gpm_id: gpm id
    :return: null
    """
    table_name = 'MEMBER'
    print(ct.Member_available_in_your_zone)
    member_list = qb.get_item_for_asignee(table_name, gpm_id)
    print("-" * 60)
    for item in member_list:
        print('Member Id : {}  |   Member Name :{}'.format(item[0], item[1]))
        print("-" * 60)

    item_id = input(ct.Enter_the_member_id_to_be_deleted)
    print(ct.Choose_Update_Option_For_Member)
    choice = input(ct.Enter_choice)

    if int(choice) in [1, 2, 3, 4, 5, 6]:
        if int(choice) == 1:
            updated_name = input(ct.Enter_new_name)
            qb.update_item_details(table_name, item_id, 'name',
                                   "'{}'".format(updated_name))
        elif int(choice) == 2:
            update_password = input(ct.Enter_new_password)
            qb.update_item_details(table_name, item_id, 'password',
                                   update_password)
        elif int(choice) == 3:
            updated_area = input(ct.Enter_new_area)
            qb.update_item_details(table_name, item_id, 'area',
                                   "'{}'".format(updated_area))
        elif int(choice) == 4:
            update_address = input(ct.Enter_new_address)
            qb.update_item_details(table_name, item_id, 'address',
                                   "'{}'".format(update_address))
        elif int(choice) == 5:
            updated_pincode = input(ct.Enter_new_pincode)
            qb.update_item_details(table_name, item_id, 'pincode',
                                   updated_pincode)
        else:
            updated_age = input(ct.Enter_new_age)
            qb.update_item_details(table_name, item_id, 'age', updated_age)
    else:
        print(ct.Wrong_choice)