예제 #1
0
파일: Warehouse.py 프로젝트: essenceD/GB
    def show(self):
        shw = fn.choose(self.show_case, title='Display method', new=False)

        if shw == self.show_case[1]:
            locations = []
            with open(fl.lines, 'r', encoding='utf-8') as file_r:
                data = file_r.readlines()
            for i in data:
                locations.append(i.split()[0])
            if len(locations) > 0:
                for j in locations[1:]:
                    print(f'\nStorage ~{j.upper()}~ contents:')
                    with open(fn.get_file_name(lines, j),
                              'r',
                              encoding='utf-8') as file_r:
                        data = file_r.readlines()
                    for x in data:
                        print(x[:-1])
                fn.update_log(action=f'VIEWED DataBase in case ~{shw}~.')
            else:
                print('There is nothing to show!')

        elif shw == self.show_case[2]:
            shw = fn.choose(fn.get_dict(fl.lines),
                            title=self.show_case[2],
                            new=False)
            if shw == '__empty__':
                print('There is nothing to show!')
            else:
                with open(fn.get_file_name(lines, shw), 'r',
                          encoding='utf-8') as file_r:
                    data = file_r.readlines()
                print(f'\nStorage ~{shw.upper()}~ contents:\n')
                for i in data:
                    print(i[:-1])
                fn.update_log(action=f'VIEWED DataBase in case ~{shw}~.')

        elif shw == self.show_case[3]:
            with open(fl.lines, 'r', encoding='utf-8') as file_r:
                data = file_r.readlines()
            for i in data:
                print(i[:-1])
            fn.update_log(action=f'VIEWED DataBase in case ~{shw}~.')

        elif shw == self.show_case[4]:
            with open(fl.cat, 'r', encoding='utf-8') as file_r:
                data = file_r.readlines()
            for i in data:
                print(i[:-1])
            fn.update_log(action=f'VIEWED DataBase in case ~{shw}~.')

        elif shw == self.show_case[5]:
            return
예제 #2
0
    def get_quantity(self):  # To set quantity

        quantity = [
            fn.get_float(name='Quantity',
                         attachment=self.brand,
                         unit=self.model),
            fn.choose(self.units, title='Units', new=False)
        ]
        print(f'Quantity has been set: {quantity[0]} {quantity[1]}\n')
        return quantity
예제 #3
0
    def __init__(self):

        req_prod = fn.choose(fn.get_dict(fl.cat), title=cats)
        if req_prod == '__empty__':
            print('You have to create category first.')
            return
        else:
            self.prod = req_prod
        self.brand = self.get_brand(self.prod)
        self.model = self.get_model(f'{self.prod} {self.brand}')
        self.name = f'{self.brand}_{self.model}'
        self.quantity = self.get_quantity()
        self.p_price = self.get_price_pur()
        self.r_price = self.get_price_rit()
        self.store = fn.choose(fn.get_dict(fl.lines), title=lines)
        self.bar_code = self.get_bar()
        self.info = {
            'bar': self.bar_code,
            'type': self.prod,
            'brand': self.brand,
            'model': self.model,
            'p_price': f'{self.p_price[0]} {self.p_price[1]}',
            'r_price': f'{self.r_price[0]} {self.r_price[1]}',
            'specs': ['None']
        }
        self.to_line = [
            self.bar_code, self.brand, self.model, f'{self.p_price[0]}',
            f'{self.p_price[1]}', f'{self.r_price[0]}', f'{self.r_price[1]}',
            f'{self.quantity[0]}', f'{self.quantity[1]}'
        ]
        fn.create_file(self.location, self.name, sample_prod)
        fn.update_prod(self.info, fn.get_file_name(self.location, self.name))
        fn.update_index(bar=self.bar_code,
                        type_=self.prod,
                        name=self.name,
                        folder=self.location)
        fn.update_line(fn.get_file_name('lines', self.store), self.to_line)
        fn.update_log(
            action=
            f'ADD SUCCESSFUL  New product ~{self.prod} {self.name}~ bar ~{self.bar_code}~ '
            f'added and placed to ~{self.store}~ in quantity of '
            f'~{self.quantity[0]} {self.quantity[1]}~ successfully.')
예제 #4
0
    def get_price_rit(self):  # To set retail price

        self.r_price = [
            fn.get_float(name='Retail price',
                         attachment=self.prod,
                         unit=self.name),
            fn.choose(self.cur, title='Currency', new=False)
        ]
        print(
            f'Retail price has been set: {self.r_price[0]} {self.r_price[1]}\n'
        )
        return self.r_price
예제 #5
0
파일: Warehouse.py 프로젝트: essenceD/GB
    def create(self):
        cr = fn.choose(self.create_case,
                       title='what do you want to create',
                       new=False)
        if cr == self.create_case[1]:
            name = input('Enter new category\'s name: ')
            fn.update_categories(name)

        elif cr == self.create_case[2]:
            self.add_storage()

        elif cr == self.create_case[3]:
            return
예제 #6
0
def start_menu(begin, end, choices, actions):
    menu_win = c.newwin(end[0] - begin[0], end[1] - begin[1], begin[0],
                        begin[1])
    menu_panel = cp.new_panel(menu_win)
    menu_win.border('|', '|', '-', '-', '+', '+', '+', '+')
    menu_win.noutrefresh()
    choices_win = menu_win.derwin(end[0] - begin[0] - 2, end[1] - begin[1] - 2,
                                  1, 1)
    choices['x'] = 'EXIT'
    actions['x'] = lambda: None

    key = choose(choices_win, choices)
    menu_panel.hide()
    actions[key]()
예제 #7
0
파일: Warehouse.py 프로젝트: essenceD/GB
 def move_prod(self):  # to do!!!!!!
     # what = bar_code
     with open(fl.lines, 'r', encoding='utf-8') as file_r:
         data = file_r.readlines()
     locations = [data[i][:-1] for i in range(len(data)) if i != 0]
     contains = {}
     moving = {}
     units = {}
     if len(locations) > 0:
         for j in locations:
             print(f'\nStorage ~{j.upper()}~ contents:')
             with open(fn.get_file_name(lines, j), 'r',
                       encoding='utf-8') as file_r:
                 data = file_r.readlines()
             contains[j] = {i.split()[0]: i.split()[-2] for i in data[1:]}
             moving[j] = [i.strip() for i in data]
             units[j] = {i.split()[0]: i.split()[-1] for i in data[1:]}
             for x in data:
                 print(x[:-1])
     else:
         print('There is nothing to show!')
     with open(fl.bar, 'r', encoding='utf-8') as file_r:
         data = file_r.readlines()
     bar = {i.split()[0]: i.split()[1] for i in data[1:]}
     while True:
         ask = input('\nPress 0 to go back\nPress 1 to go next\nCOMMAND: ')
         if ask == '0':
             return
         elif ask == '1':
             break
     what = fn.choose(fn.get_dict(fl.bar),
                      title='PRODUCT you want to move',
                      new=False).split()[0]
     stock = [i for i in locations if what in contains[i].keys()]
     storage_from = {i: stock[i - 1] for i in range(1, len(stock) + 1)}
     from_ = fn.choose(storage_from, title='FROM where to move', new=False)
     while True:
         quantity = fn.get_float(name='Number of products',
                                 attachment='moving',
                                 unit='')
         if 0 <= quantity <= float(contains[from_][what]):
             break
         else:
             if quantity > 0:
                 print(
                     f'Not enough {bar[what]} on {from_}. Maximum to move: {contains[from_][what]}'
                 )
             elif quantity < 0:
                 print('Enter positive integer!')
     locations.remove(from_)
     storage_to = {
         i: locations[i - 1]
         for i in range(1,
                        len(locations) + 1)
     }
     to_ = fn.choose(storage_to, title='TO there to move', new=False)
     to_add_from = []
     to_add_to = []
     for i in moving[from_]:
         if i.split()[0] == what:
             to_add_from = [
                 f'-{quantity}' if i.split().index(j) == 7 else j
                 for j in i.split()
             ]
             to_add_to = [
                 f'{quantity}' if i.split().index(j) == 7 else j
                 for j in i.split()
             ]
     fn.update_line(fn.get_file_name(lines, from_), to_add_from, log=False)
     fn.update_line(fn.get_file_name(lines, to_), to_add_to, log=False)
     fn.update_log(
         action=
         f'MOVED ~{what}~ from ~{from_}~ to ~{to_}~ in quantity ~{quantity}~'
     )
     print('MOVING COMPLETE')