示例#1
0
def delete() -> 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.findcode(codePouchIN)

        if codePouchOUT != '':
            resp = ' '
            while resp.upper() not in 'YN':
                resp = input(f'Confirm the delete the {codePouchIN} [Y/N]? ')
            if resp.upper() == 'Y':
                Pouch.deletedb(codePouchIN)
        else:
            print(f'\33[1;31mPouch Code not exist {codePouchOUT}\33[m')
            continue

        resp = ' '
        while resp.upper() not in 'YN':
            resp = input('Do you want continue [Y/N}? ')
示例#2
0
def searchdtarrived():
    # list specific date
    resp = 'Y'
    while resp.upper() == 'Y':
        dtarrived = inform_date(True)
        if dtarrived == '0':
            return

        conn = sqlite3.connect('POUCH.db')
        cursor = conn.cursor()

        dtarrivedinv = dtarrived[6:] + '-' + dtarrived[
            3:5] + '-' + dtarrived[:2]

        data: cursor = Pouch.finddate(dtarrivedinv, dtarrivedinv, 0, 0, 0)

        if len(data) > 0:
            lstcodepouch = []
            lstcodecard = []
            lstcodesynd = []
            lstcodecomp = []
            lstdtarrived = []
            lstquant = []
            lstvalue = []

            for reg in data:
                lstcodepouch.append(reg[0])
                lstcodecard.append(reg[1])
                lstcodesynd.append(reg[2])
                lstcodecomp.append(reg[3])
                lstdtarrived.append(reg[4])
                lstquant.append(reg[5])
                lstvalue.append(reg[6])

            dct: dict = {
                'CodePouch': lstcodepouch,
                'CodeCard': lstcodecard,
                'CodeSynd': lstcodesynd,
                'CodeComp': lstcodecomp,
                'DtArriveD': lstdtarrived,
                'Quant': lstquant,
                'Value': lstvalue
            }

            df = DataFrame(dct)
            frame = DataFrame(df,
                              columns=[
                                  'CodePouch', 'CodeCard', 'CodeSynd',
                                  'CodeComp', 'DtArriveD', 'Quant', 'Value'
                              ])
            print('-' * 40)
            print(frame)
            print('-' * 40)
        else:
            print("\33[1;31mDon't have register\33[m")

        resp = ' '
        while resp.upper() not in 'YN':
            resp = input('Do you want continue [Y/N]? ')
示例#3
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]? ')
示例#4
0
def delete(option: int) -> None:
    resp = 'Y'
    while resp.upper() == 'Y':
        regcard: Card = validcard(option)
        if int(regcard.codeCard) > 0:
            countcodepouch = Pouch.countcodepouchcard(regcard.codeCard)

            if countcodepouch == 0:
                resp = ' '
                while resp.upper() not in 'YN':
                    resp = input(
                        f'Confirm the delete the {regcard.codeCard} - '
                        f'{regcard.nameCard} [Y/N]? ')
                    if resp.upper() == 'Y':
                        Card.deletedb(regcard)
            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}? ')
示例#5
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}? ')
示例#6
0
def listall():
    # list all pouchs
    Pouch.findall(0)
示例#7
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