def get_goods_name(goods_code): """повертає назву по коду Args: goods_code([type]): код товару Returns: [type]: назва товару """ goods = get_goods() for goods in goods: if goods[0] == goods_code: return goods[1]
def create_gross_income(): """формування списку валового доходу Returns: gross_income_list: список валового доходу """ def get_name_of_goods_group(good_code): """знаходить товар по коду""" for good in goods: if good_code == good[0]: return good[1] return "*** Назва не знайдена ***" def get_trade_discount(trade_discount_code): """знаходить скидку по коду""" for trade_discount in goods: if trade_discount_code == trade_discount[0]: return trade_discount[2] return "*** Назва не знайдена ***" #накопичувач валового доходу gross_income_list = [] goods = get_goods() goods_circulations = get_goods_circulations() for goods_circulation in goods_circulations: #робоча змінна gross_income_work = gross_income.copy() gross_income_work['name_of_goods_group'] = get_name_of_goods_group( goods_circulation[0]) gross_income_work['trade_discount'] = get_trade_discount( goods_circulation[0]) gross_income_work['year'] = goods_circulation[3] gross_income_work[ 'plan_of_commodity_circulations'] = goods_circulation[1] gross_income_work[ 'expected_performance_of_commodity_circulations'] = goods_circulation[ 2] gross_income_work['plan_of_gross_income'] = float( gross_income_work['plan_of_commodity_circulations']) * float( gross_income_work['trade_discount']) * 0.01 gross_income_work['expected_performance_of_gross_income'] = float( gross_income_work['expected_performance_of_commodity_circulations'] ) * float(gross_income_work['trade_discount']) * 0.01 gross_income_list.append(gross_income_work) return gross_income_list
def create_analiz(): """ створення заявки на аналіз ринкових цін """ analiz = { 'index': '', # код 'goods_name': '', # назва товару 'month_name': '', # назва місяця 'averageprice': '', # середня ціна за місяць 'rozdribprice': '', # роздрібна ціна 'pricechange': '', # зміна ціни } prices = get_prices() def get_goods_name(goods_code): """повертає назву по коду Args: goods_code([type]): код товару Returns: [type]: назва товару """ goods = get_goods() for goods in goods: if goods[0] == goods_code: return goods[1] analiz_list = [] goods = get_goods() for price in prices: price[0] = float(price[0].strip()) price[2] = float(price[2].strip()) price[3] = float(price[3].strip()) price[4] = float(price[4].strip()) price[5] = float(price[5].strip()) analiz_tmp = analiz.copy() analiz_tmp['index'] = price[0] analiz_tmp['goods_name'] = price[1] analiz_tmp['month_name'] = price[6] analiz_tmp['averageprice'] = (price[2] + price[3] + price[4] + price[5]) / 4 if price[0] == 10: analiz_tmp['rozdribprice'] = float(goods[0][2].strip()) if price[0] == 20: analiz_tmp['rozdribprice'] = float(goods[1][2].strip()) if price[0] == 30: analiz_tmp['rozdribprice'] = float(goods[2][2].strip()) analiz_tmp['pricechange'] = float(analiz_tmp['averageprice']) / float( analiz_tmp['rozdribprice']) analiz_list.append(analiz_tmp) return analiz_list
print('Файл успішно записано ...') while True: # вивід головного меню os.system('cls') print(MAIN_MENU) command_number = input("Введіть номер команди: ") #команди користувача if command_number == '0': print('\nПрограма завершила роботу') exit(0) elif command_number == '4': analiz_list = create_analiz() show_analiz(analiz_list) input(STOP_MESSAGE) elif command_number == '2': analiz_list = create_analiz() write_analiz(analiz_list) input(STOP_MESSAGE) elif command_number == '1': goods = get_goods() show_goods(goods) input(STOP_MESSAGE) elif command_number == '3': prices = get_prices() show_prices(prices) input(STOP_MESSAGE)