예제 #1
0
def validcompany(option: int) -> object:
    regsyndok = False
    while not regsyndok:
        regsynd: Syndicate = validsyndicate(0)   # search
        if int(regsynd.codeSynd) > 0:
            regsyndok = True
            regcompok = False
            while not regcompok:
                regcomp: Company = search_name_comp(regsynd.codeSynd)
                # the code informed is ok
                if int(regcomp.codeComp) == 0:
                    regcomp: Company = Company(0, 0, '')
                    return (regsynd, regcomp)
                if option == 1:   # INSERT
                    if regcomp.nameComp == '':
                        # the company not exist
                        regcompok = True
                    else:
                        print(f'\33[1;31mCompany Code exist\33[m')
                else:   # UPDATE / DELETE
                    if regcomp.nameComp != '':
                        # the company exist
                        regcompok = True
                    else:
                        print(f'\33[1;31mCompany Code not exist\33[m')
        else:
            regcomp: Company = Company(0, 0, '')
            break

    return (regsynd, regcomp)
예제 #2
0
def search_name_comp(codesynd: int) -> object:
    codeComp: int = inform_code('Company')

    if codeComp == 0:
        return Company(0, 0, '')
    # Checks if have the card is registered
    regcomp: Company = Company(codesynd, codeComp,
                               Company.findcode(codesynd, codeComp).strip())
    return regcomp
예제 #3
0
def insert(option: int) -> None:
    resp = 'Y'
    while resp.upper() == 'Y':
        regsynd, regcomp = validcompany(option)
        if int(regcomp.codeComp) > 0:
            regcomp.nameComp = inform_name('Company')
            Company.insertdb(regcomp)

        resp = ' '
        while resp.upper() not in 'YN':
            resp = input('Do you want continue [Y/N]? ')
예제 #4
0
    def get_jobs_with_companies(self, applicant_email_id):
        jobs = list()

        self.cursor.execute(
            '''
            SELECT * FROM company INNER JOIN job WHERE company.email_id = job.company_email_id
            AND job.job_id NOT IN (
                SELECT application.job_id FROM application WHERE applicant_email_id = ?
            )
        ''', (applicant_email_id, ))
        result = self.cursor.fetchall()

        if result is None:
            return None
        else:
            for row in result:
                company = Company()
                job = Job()
                company.email_id = row[0]
                company.name = row[1]
                company.location = row[2]
                company.website = row[3]
                company.description = row[4]
                job.job_id = row[6]
                job.location = row[7]
                job.requirements = row[8]
                job.company_email_id = row[9]
                jobs.append({'company': company, 'job': job})

            return jobs
예제 #5
0
def generate_companies():
    for i in range(0, 20):
        list_of_companies.append(
            Company(
                i,
                list_of_funds[random.randint(0, len(list_of_funds) - 1)],
                list_of_regions[random.randint(0, len(list_of_regions) - 1)],
                list_of_sectors[random.randint(0, len(list_of_sectors) - 1)],
                list_of_strategies[random.randint(0, len(list_of_strategies) - 1)],
                list_of_risks[random.randint(0, len(list_of_risks) - 1)]
            )
        )
예제 #6
0
def delete(option: int) -> None:
    resp = 'Y'
    while resp.upper() == 'Y':
        regsynd, regcomp = validcompany(3)
        if int(regcomp.codeComp) > 0:
            countcodepouch = Pouch.countcodepouchcomp(regcomp.codeComp)

            if countcodepouch == 0:
                resp = ' '
                while resp.upper() not in 'YN':
                    resp = input(f'Confirm the delete the {regsynd.codeSynd} - '
                                 f'{regsynd.nameSynd} - {regcomp.codeComp} - '
                                 f'{regcomp.nameComp} [Y/N]? ')
                if resp.upper() == 'Y':
                   Company.deletedb(regcomp)
            else:
                print(f'\33[1;31mHave Pouch registered\33[m')

        resp = ' '
        while resp.upper() not in 'YN':
            resp = input('Do you want continue [Y/N}? ')
예제 #7
0
    def get_by_email_id(self, email_id):
        company = Company()
        self.cursor.execute('''SELECT * FROM company WHERE email_id = ?''',
                            (email_id, ))
        result = self.cursor.fetchone()
        if result is None:
            return None
        else:
            company.email_id = result[0]
            company.name = result[1]
            company.location = result[2]
            company.website = result[3]
            company.description = result[4]
            company.password = result[5]

        return company
예제 #8
0
    def update(self, company_details):
        company = Company()
        company_details['where_email_id'] = company_details['email_id']
        company_tuple = tuple(values
                              for keys, values in company_details.items())

        self.connection.execute(
            '''UPDATE company SET email_id = ?, password = ?, name = ?, location = ?, website = ?, description = ? WHERE email_id = ?''',
            company_tuple)
        company.email_id = company_details['email_id']
        company.password = company_details['password']
        company.name = company_details['name']
        company.location = company_details['location']
        company.website = company_details['website']
        company.description = company_details['description']

        self.connection.commit()

        return company
예제 #9
0
    def create(self, company_details):
        company = Company()
        company.email_id = company_details['email_id']
        company.password = company_details['password']
        company.name = company_details['name']
        company.location = company_details['location']
        company.website = company_details['website']
        company.description = company_details['description']

        company_tuple = tuple(values
                              for keys, values in company_details.items())

        self.connection.execute(
            '''INSERT INTO company( email_id, password, name, location, website, description )VALUES (?, ?, ?, ?, ?, ?);''',
            company_tuple)

        self.connection.commit()

        return company
예제 #10
0
def insert() -> None:
    resp = 'Y'
    while resp.upper() == 'Y':
        code = input('Pouch Code (0 - exit): ').strip()

        if code == '0':
            return

        if code == '' or code is None:
            print('\33[1;31mPouch is empty\33[m')
            continue
        # verify if code pouch have only zeros
        if len(code) == code.count('0'):
            print('\33[1;31mPouch have only zeros\33[m')
            continue

        codePouchIN: str = code
        # check if codePouch exist
        codePouchOUT = Pouch.findcodepouch(codePouchIN)

        if codePouchOUT == '' or codePouchOUT == None:
            # the codePouch isn't exist
            regcard: Card = Card.validcard(0)  # SEARCH
            if int(regcard.codeCard) > 0:
                regsynd, regcomp = Company.validcompany(0)
                if int(regcomp.codeComp) > 0:
                    dtarrived = inform_date(False)
                    quant = inform_quant()
                    value = inform_value()
                    regpouch: Pouch = Pouch(codePouchIN, regcard.codeCard,
                                            regsynd.codeSynd, regcomp.codeComp,
                                            dtarrived, quant, value)
                    Pouch.insertdb(regpouch)
        else:
            print(f'\33[1;31mCode already exist\33[m')
            continue

        resp = ' '
        while resp.upper() not in 'YN':
            resp = input('Do you want continue [Y/N]? ')
예제 #11
0
def list():
    # list the all syndicate/company
    Company.findall(self=object)
예제 #12
0
import os
import globals
from Models.Employee import Employee
from Models.Company import Company
from Utilities.FileOperation import FileOperation

#----------------------------------------------------------------------
if __name__ == "__main__":

    c = Company()

    var = ""
    while var not in ("q", "quit"):
        #os.system('cls')

        for e in globals.main_menu:
            print(e)

        var = input()
        print(c.do_operation(var))
예제 #13
0
def menu():
    month, year = util.valid_month_year()

    if year == 0:
        return

    regcard: Card = Card.validcard(0)  # SEARCH
    regsynd, regcomp = Company.validcompany(0)

    conn = Database.conn
    cursor = Database.cursor

    filepdf = FPDF('P', 'mm', 'A4')  # Portrait

    dtini, dtfinal = util.first_last_day(month, year)

    data: cursor = Pouch.finddate(dtini, dtfinal, regcard.codeCard,
                                  regsynd.codeSynd, regcomp.codeComp)

    if len(data) == 0:
        print("\33[1;31mDon't have register\33[m")
    else:
        filepdf.add_page()
        filepdf.set_font('Arial', '', 10)
        filepdf.cell(190, 4, 'Página ' + str(filepdf.page_no()), 0, 1, 'R')
        filepdf.set_font('Arial', 'B', 16)
        filepdf.cell(
            190, 4,
            'Monthly Report - ' + str(month) + '/' + str(year) + '          ' +
            datetime.strftime(datetime.today().now(), '%m/%d/%Y %H:%M'), 0, 1,
            'C')
        filepdf.set_font('Courier', '', 10)
        filepdf.cell(190, 4, ' ', 0, 1, 'R')
        # 60 = weight 20 = height by cell 0 = border 1 = break line L = align
        subtitle = '   Date    Pouch      Card       Syndicate       Company        Quant  Value'
        filepdf.set_font('Courier', '', 10)
        filepdf.cell(190, 4, subtitle, 0, 1, 'L')
        contline = 2
        for reg in data:
            dtarrived = reg[0]
            codepouch = reg[1]
            namecard = reg[2]
            namesynd = reg[3]
            namecomp = reg[4]
            quant = reg[5]
            value = reg[6]

            if contline > 59:
                filepdf.add_page()
                filepdf.set_font('Arial', '', 10)
                filepdf.cell(190, 4, 'Página ' + str(filepdf.page_no()), 0, 1,
                             'R')
                subtitle = 'Arrived    Pouch      Card       Syndicate       Company        Quant  Value'
                filepdf.set_font('Courier', '', 10)
                filepdf.cell(190, 4, subtitle, 0, 1, 'L')
                contline = 2

            contline += 1

            filepdf.cell(
                210, 4, f'{dtarrived} {codepouch:<10} {namecard:<10} '
                f'{namesynd:<15} {namecomp:<15} {quant:>4} {value:>6.2f}', 0,
                1, 'L')
        try:
            filepdf.output(f'ReportMonthly_{year}{month:0>2}.pdf',
                           'F')  # D - Web   F- Local
            print('Generated Report')
        except Exception:
            print('\33[1;31mThe file pdf is open\33[m')

    return