예제 #1
0
async def finish_report(call: CallbackQuery, state: FSMContext):
    await call.answer()
    await call.message.delete()
    await state.update_data(finish_report='+')

    if call.data == 'confirm':
        data_state = await state.get_data()
        text = data_state['daily_report_text']

        await call.message.answer(text=text,
                                  reply_markup=create_kb_coustom_main_menu(
                                      call.message.chat.id))

        await state.finish()

        return

    if call.data == 'raise_problem':
        result = await call.message.answer(
            'Подробно изложите выявленные расхождения')
        await state.update_data(message_to_delete=result.message_id)

        await Reportsstate.text_problem.set()

        return

    if call.data == 'back__main_menu':
        await call.message.answer(
            text='Выход из меню "Отчетность". Используйте главное меню.',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id))
        await state.finish()

        return
예제 #2
0
async def question_who_waste(message: Message, state: FSMContext):
    sms_numb = message.text

    try:
        sms_numb = int(message.text)
        if sms_numb <= 0:
            raise ValueError('f**k off')
    except Exception as e:
        print(e)
        await message.answer_sticker(sticker['false_data'])
        await message.answer(
            text='Неправильный формат номера смс. Возврат в главное меню.',
            reply_markup=create_kb_coustom_main_menu(message.chat.id))
        await state.finish()

        return

    sms_numb = str(sms_numb)

    await state.update_data(sms_numb=sms_numb)

    data_state = await state.get_data()
    await bot.delete_message(chat_id=message.chat.id,
                             message_id=data_state['message_to_delete'])
    await bot.delete_message(chat_id=message.chat.id,
                             message_id=message.message_id)

    try:
        result = await message.answer_sticker(
            sticker['go_to_table'], reply_markup=ReplyKeyboardRemove())
        is_checked = smsinfo.check_sms(sms_numb)

    except Exception as e:
        print(e)
        await message.answer_sticker(sticker['not_connection'])
        await message.answer(text='Не удалось получить данные google таблицы',
                             reply_markup=create_kb_coustom_main_menu(
                                 message.chat.id))

        return

    await bot.delete_message(chat_id=message.chat.id,
                             message_id=result.message_id)

    if is_checked == False:
        await message.answer(text='Нет такой смс',
                             reply_markup=create_kb_coustom_main_menu(
                                 message.chat.id))
        await state.finish()

        return

    if is_checked == None: is_checked = '-'

    await message.answer(text='Кто тратит?',
                         reply_markup=create_kb_who_waste())
    await state.update_data(for_what_waste='-')
    await state.update_data(note_waste=is_checked)
    await SMSstate.who_waste.set()
예제 #3
0
async def add_permit_data(message: Message, state: FSMContext):
    data_state = await state.get_data()

    await bot.delete_message(chat_id=message.chat.id,
                             message_id=data_state['message_to_delete'])
    await bot.delete_message(chat_id=message.chat.id,
                             message_id=message.message_id)

    request = data_state['chosen_request']
    permit_id = request[1]
    request_numb = request[2]
    permit_date = request[0]
    old_permit_text = permit.get_old_permit_text_or_empty(permit_id)

    if old_permit_text == 'данных нет...':
        new_permit_text = message.text

    else:
        new_permit_text = old_permit_text + ', ' + message.text

    username = message.chat.username

    user = message.chat.username
    request[9] = updating_log('PERMIT',
                              user,
                              request,
                              update_data='Добавлен пропуск')

    try:
        result = await message.answer_sticker(sticker['go_to_table'])
        permit.clear_table()
        permit.write_new_permit(permit_id,
                                request_numb,
                                permit_date,
                                permit_text=new_permit_text)
        sheet.replace_row(request)

    except Exception:
        await bot.delete_message(chat_id=message.chat.id,
                                 message_id=result.message_id)
        await message.answer_sticker(sticker['not_connection'])
        await message.answer(text='Не удалось соединиться с гугл таблицей',
                             reply_markup=create_kb_coustom_main_menu(
                                 message.chat.id))

        return

    await bot.delete_message(chat_id=message.chat.id,
                             message_id=result.message_id)

    await notify_about_permit_to_order(request_numb, username)

    await message.answer(text='Новый пропуск добавлен, секретарь оповещен!',
                         reply_markup=create_kb_coustom_main_menu(
                             message.from_user.id))
    await state.finish()
예제 #4
0
async def show_current_requests(message: Message, state: FSMContext):
    '''
    Обрабатывает команду (button) "в работе" и отображает список текущих
    заявок в виде кнопок с номером и суммами. Если текущих заявок
    нет, то отвечает - "Все заявки исполненны."
    '''
    await message.delete()

    result = await message.answer_sticker(sticker['go_to_table'],
                                          reply_markup=ReplyKeyboardRemove())

    try:
        current_requests,\
        in_processing_requests,\
        ready_to_give_requests =\
        sheet.get_numbs_processing_and_ready_requests()

    except Exception as e:
        traceback.print_exc()

        await message.answer_sticker(sticker['not_connection'])

        await message.answer(text='Не удалось получить данные с гугл таблицы',
                             reply_markup=create_kb_coustom_main_menu(
                                 message.chat.id))

        await state.finish()

        return

    await bot.delete_message(chat_id=message.chat.id,
                             message_id=result.message_id)

    await state.update_data(current_requests=current_requests)
    await state.update_data(in_processing_requests=in_processing_requests)
    await state.update_data(ready_to_give_requests=ready_to_give_requests)

    if len(in_processing_requests) == 0 and len(ready_to_give_requests) == 0:

        await message.answer(text='Все заявки исполненны.',
                             reply_markup=create_kb_coustom_main_menu(
                                 message.chat.id))

        await state.finish()

    else:

        await message.answer('Текущие заявки:',
                             reply_markup=create_kb_current_requests(
                                 in_processing_requests,
                                 ready_to_give_requests))

        await Processing.chosen_request.set()
예제 #5
0
async def show_current_requests(message: Message, state: FSMContext):
    '''
    Обрабатывает команду "пропуска" и отображает список текущих
    пропусков. Если текущих пропусков
    нет, то отвечает - "На сегодня и последующие даты пропусков нет."
    '''
    await message.delete()

    try:
        result = await message.answer_sticker(
            'CAACAgIAAxkBAAL9pmBTBOfTdmX0Vi66ktpCQjUQEbHZAAIGAAPANk8Tx8qi9LJucHYeBA',
            reply_markup=ReplyKeyboardRemove())

        permits = permit.get_all_permits()
        current_requests,\
        in_processing_requests,\
        ready_to_give_requests =\
        sheet.get_numbs_processing_and_ready_requests()
        # time.sleep(1)

    except Exception as e:
        print(e)
        # traceback.print_exception()
        await message.answer_sticker(
            'CAACAgIAAxkBAAL9rGBTCImgCvHJBZ-doEYr2jkvs6UEAAIaAAPANk8TgtuwtTwGQVceBA'
        )
        await message.answer(
            text='Не удалось получить данные таблицы пропусков...',
            reply_markup=create_kb_coustom_main_menu(message.from_user.id))

        return

    await state.update_data(all_permits=permits)
    await state.update_data(all_requests=current_requests)

    if len(permits) == 0:
        await bot.delete_message(chat_id=message.chat.id,
                                 message_id=result.message_id)
        await message.answer(
            text='На сегодня и последующие даты пропусков нет.',
            reply_markup=create_kb_coustom_main_menu(message.from_user.id))
        await state.finish()

        return

    else:
        await bot.delete_message(chat_id=message.chat.id,
                                 message_id=result.message_id)
        await message.answer(text='Пропуска:',
                             reply_markup=create_kb_all_permits(permits))

        await Permitstate.chosen_permit.set()
예제 #6
0
async def set_other_message(message: Message, state: FSMContext):
    data_state = await state.get_data()
    chosen_request = data_state['chosen_request']

    await bot.delete_message(chat_id=message.chat.id,
                             message_id=data_state['message_to_delete'])

    await bot.delete_message(chat_id=message.chat.id,
                             message_id=message.message_id)

    persone = all_emoji['персона']
    user = '******' + message.chat.username
    text = data_state['other_message'] + message.text + '\n'
    log_text = data_state['log_text'] + message.text

    chosen_request[9] = updating_log('MESSAGE',
                                     message.chat.username,
                                     chosen_request,
                                     update_data=log_text)

    try:
        result = await message.answer_sticker(sticker['go_to_table'])
        sheet.replace_row(chosen_request)

    except Exception as e:
        print(e)
        await bot.delete_message(chat_id=message.chat.id,
                                 message_id=result.message_id)
        await message.answer_sticker(sticker['not_connection'])
        await message.answer(text='Не удалось соединиться с гугл таблицей',
                             reply_markup=create_kb_coustom_main_menu(
                                 message.chat.id))

        return

    await bot.delete_message(chat_id=message.chat.id,
                             message_id=result.message_id)

    await message.answer(text='Cообщение отправлено!',
                         reply_markup=create_kb_coustom_main_menu(
                             message.chat.id))

    text = text + persone + user

    await notify_someone(text, 'admin', 'changer', 'executor')
    await notify_in_group_chat(text)

    await state.finish()

    return
예제 #7
0
async def confirm_single_permit(call:CallbackQuery, state:FSMContext):
    await call.answer()
    await call.message.delete()

    if call.data == 'confirm':
        data_state = await state.get_data()

        permit_id = data_state['single_permit_id']
        permit_numb = data_state['single_permit_numb']
        permit_full_name = data_state['single_permit_full_name']
        permit_date = data_state['single_permit_date']
        username = call.message.chat.username

        permit.write_new_permit(permit_id, permit_numb, permit_date, permit_text=permit_full_name)
        await notify_about_permit_to_order(permit_numb, username)

        await call.message.answer (
            text=f'Новый пропуск #N{permit_numb} добавлен, секретарь оповещен!',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id)
        )

        await state.finish()

        return

    elif call.data == 'edit_numb':
        result = await call.message.answer(text='Введите номер пропуска')

        await state.update_data(message_to_delete=result.message_id)
        await Permitstate.single_permit_numb.set()

        return

    elif call.data == 'edit_full_name':
        result = await call.message.answer(text='Введите ФИО')

        await state.update_data(message_to_delete=result.message_id)
        await Permitstate.single_permit_full_name.set()

        return

    elif call.data == 'back__main_menu':
        await call.message.answer (
            text='Выход в главное меню. Используйте главное меню.',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id)
        )
        await state.finish()
        
        return
async def set_how_much_give(message: types.Message, state: FSMContext):
    try:
        summ = int(message.text)
        await state.update_data(how_much_give=summ)
        data = await state.get_data()
        await bot.delete_message(chat_id=message.chat.id,
                                 message_id=data['_del_message'])
        request_data = await state.get_data()
        await bot.delete_message(chat_id=message.chat.id,
                                 message_id=message.message_id)
        await message.answer(f'Выберете валюту:',
                             reply_markup=create_kb_smart_choose_curr(
                                 request_data['currencies__give'])
                             # reply_markup=create_kb_choose_currency()
                             )
        ### for logs ### delete later
        request_data = await state.get_data()
        print('=== state: ===')
        print(request_data)
        print('==============')
        ### for logs ### delete later

        await Request.currency__how_much__give.set()
        # currensy_for_how_much.py
    except Exception as e:
        print(e)
        print("EXEPTION HOW MACH GIVE")
        await message.answer(
            f'Формат суммы неправильный. Создание заявки отменено\n===========',
            reply_markup=create_kb_coustom_main_menu(message.chat.id))
        await state.finish()
        await message.delete()
async def set_how_much_give_curr(call: types.CallbackQuery, state: FSMContext):
    await call.answer()
    await call.message.delete()

    if call.data == 'exit':
        await call.message.answer(
            f'Создание заявки отменено. Испльзуйте меню\n===========',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id))
        await state.finish()

        return

    currency = call.data
    request_data = await state.get_data()
    # получаем список уже имеющихся валют либо пустой список
    currencies__give = request_data['currencies__give']

    if currency not in currencies__give:
        currencies__give.append(currency)
        await state.update_data(currencies__give=currencies__give)

    if currency == 'rub':
        await state.update_data(sum_give_RUB=request_data['how_much_give'])
    if currency == 'usd':
        await state.update_data(sum_give_USD=request_data['how_much_give'])
    if currency == 'eur':
        await state.update_data(sum_give_EUR=request_data['how_much_give'])

    request_data = await state.get_data()
    result_data_to_show, keyboard = get_data_to_show(request_data)

    await call.message.answer(text=result_data_to_show, reply_markup=keyboard)
    await Request.type_end.set()
예제 #10
0
async def set_currency_to_correct(call: CallbackQuery, state: FSMContext):
    '''
    Обрабатывает клавиатуру create_kb_which_sum_close(request)
    - sum rub
    - sum usd
    - sum eur
    - back_main_menu
    '''
    await call.answer()
    await call.message.delete()
    await state.update_data(which_sum_correct_menu='+')

    data_btn = cb_which_sum_close.parse(call.data)

    if data_btn['type_btn'] == 'change_curr':
        await state.update_data(close__currency=data_btn['curr'])
        # data_state = await state.get_data()

        result = await call.message.answer(
            text='C какой суммой хотите закрыть?')
        await state.update_data(message_to_delete=result.message_id)
        await Processing.close__sum.set()

    else:
        await call.message.answer(
            text='Выход из меню "В РАБОТЕ". Используйте главное меню.',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id))
        await state.finish()

        return
예제 #11
0
async def set_who_waste(call: CallbackQuery, state: FSMContext):
    await call.answer()
    await call.message.delete()

    data_btn = cb_who_waste.parse(call.data)

    if data_btn['type_btn'] == 'back__main_menu':
        await call.message.answer(
            f'===========\nВыход в главное меню\n===========',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id))
        await state.finish()

        return

    await state.update_data(who_waste=data_btn['type_btn'])

    data_state = await state.get_data()
    who_waste = data_state['who_waste']

    if who_waste == 'Личные Вит' or \
        who_waste == 'Личные Кэт' or \
        who_waste == 'Ошибка':

        await call.message.answer(text='Добавить примечание?',
                                  reply_markup=create_kb_yes_no_note())

        await SMSstate.yes_no_note.set()

    else:
        await call.message.answer(
            text='На что потрачено?',
            reply_markup=create_kb_for_what_waste(who_waste))
        await SMSstate.for_what_waste.set()
예제 #12
0
async def send_problem_text_to_admins(message:Message, state:FSMContext):
    data_state = await state.get_data()
    await bot.delete_message (
        chat_id=message.chat.id,
        message_id=data_state['message_to_delete']
    )
    await bot.delete_message (
        chat_id=message.chat.id,
        message_id=message.message_id
    )

    text_start = 'Ваш запрос следующего содержания:\n'
    text_problem = '*' + message.text + '*' + '\n'
    text_end = 'отправлен администратору'
    text = text_start + text_problem + text_end

    await message.answer (
        text=text,
        reply_markup=create_kb_coustom_main_menu(message.chat.id)
    )

    kvz = all_emoji['квз']
    user = message.chat.username
    text_start_admin = f'{kvz}{kvz}{kvz}{kvz}{kvz}\nУведомление о #КАССА от @{user}\n\n'
    text = text_start_admin + message.text

    await notify_someone(text, 'admin')

    await state.finish()

    return
예제 #13
0
async def confirm_give_cash_box(call:CallbackQuery, state:FSMContext):
    await call.answer()
    await call.message.delete()
    await state.update_data(confirm_give_box_office='+')

    if call.data == 'confirm_box_office':
        data_state = await state.get_data()
        text_balance = data_state['cash_box_text']
        user = '******' + call.message.chat.username
        give_cash_box = all_emoji['give_cash_box']

        text_start = f'#КАССА {give_cash_box}\n'
        text_end = f'\nКАССУ СДАЛ\n{user}'

        text = text_start + text_balance + text_end
   
        await call.message.answer (
            text=text,
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id)
        )
        await notify_in_group_chat(text)

        await state.finish()
        
        return


    if call.data == 'raise_problem':
        result = await call.message.answer('Подробно изложите выявленные расхождения')
        await state.update_data(message_to_delete=result.message_id)

        await Reportsstate.text_problem.set()

        return


    elif call.data == 'back__main_menu':
        await call.message.answer (
            text='Выход из меню "ОТЧЕТНОСТЬ". Используйте главное меню.',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id)
        )

        await state.finish()

        return
예제 #14
0
async def bot_start(message:types.Message):
    user_id = message.from_user.id
    text = 'Здравствуйте, Владыка!'

    await bot.send_message (
        chat_id=user_id, 
        text=text, 
        reply_markup=create_kb_coustom_main_menu(user_id)
    )
예제 #15
0
async def set_blue_amount(message: Message, state: FSMContext):
    data_state = await state.get_data()
    await bot.delete_message(chat_id=message.chat.id,
                             message_id=data_state['message_to_delete'])
    await bot.delete_message(chat_id=message.chat.id,
                             message_id=message.message_id)

    try:
        chosen_request = data_state['chosen_request']
        blue_amount_close = int(message.text)
        blue_amount_close = str(blue_amount_close)

    except Exception as e:
        print(e)
        await message.answer(
            text='Изменение заявки отменено. Неправильный формат синих.',
            reply_markup=create_kb_coustom_main_menu(message.chat.id))
        await state.finish()

        return

    data_state = await state.get_data()
    chosen_request = data_state['chosen_request']

    if chosen_request[5][0] == '-':
        symbol_blue = -1
    else:
        symbol_blue = 1

    if blue_amount_close[0] == '-':
        blue_amount_close = blue_amount_close[1:]
        blue_amount_close = int(blue_amount_close)
        blue_amount_close = blue_amount_close * symbol_blue * -1
        blue_amount_close = str(blue_amount_close)
    else:
        blue_amount_close = int(blue_amount_close)
        blue_amount_close = blue_amount_close * symbol_blue
        blue_amount_close = str(blue_amount_close)

    chosen_request[16] = blue_amount_close
    await state.update_data(chosen_request=chosen_request)

    text = get_text_before_close_request(chosen_request)

    await message.answer(
        text=text,
        reply_markup=create_kb_confirm_close_request(chosen_request)
        # > подтверждаю!
        # > закрыть с другой суммой
        # > скорректировать синие
        # > вернуться к заявке
        # > назад - главное меню
    )
    await Processing.close_request_menu.set()

    return
예제 #16
0
async def show_chosen_request(call:CallbackQuery, state:FSMContext):
    '''
    Обрабатывает нажатие на одну из заявок, выведенных списком
    '''
    await call.answer()
    await call.message.delete()

    data_btn = cb_current_requests.parse(call.data)

    if data_btn['type_btn'] == 'exit':
        await call.message.answer (
            text='Выход из меню "В РАБОТЕ". Используйте главное меню.',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id)
        )
        await state.finish()
        
        return

    data_state = await state.get_data()
    current_requests = data_state['current_requests']

    for request in current_requests:

        if data_btn['id'] == request[1]:
            await state.update_data(chosen_request=request)

            break

    data_state = await state.get_data()
    request = data_state['chosen_request']
    text = get_data_chosen_request(request)
    
    await call.message.answer (
        text=text,
        reply_markup=create_kb_chosen_request(request)
        # > отложить на выдачу (для доставки, кэшина, обмена)
        # > принято частично (для приема кэша, снятия с карт, обмена)
        # > закрыть заявку
        # > сообщение
        # > изменить заявку
        # > добавить пропуск
        # > добавить комментарий
        # > распаковать
        # > отменить заявку
        # > посмотреть историю
        # > назад
        # > главное меню
    )

    await Processing.enter_chosen_request_menu.set()

    return
    
예제 #17
0
async def set_how_much(message: types.Message, state: FSMContext):
    try:
        summ = int(message.text)
        await state.update_data(temp_sum_state=summ)

        request_data = await state.get_data()
        await bot.delete_message(chat_id=message.chat.id,
                                 message_id=request_data['_del_message'])
        await bot.delete_message(chat_id=message.chat.id,
                                 message_id=message.message_id)

        await message.answer(f'Выберете валюту:',
                             reply_markup=create_kb_smart_choose_curr(
                                 request_data['currencies__how_much']))

        operation_type = request_data['operation_type']
        print('WE ARE HERE 0000000')

        if \
        operation_type == 'get_in' or \
        operation_type == 'get_out' or \
        operation_type == 'cash_in_ATM' or operation_type == 'cash_out_ATM':
            print('WE ARE HERE')
            await Request.currencies__how_much.set()
            # to currency__how_much.py

    # if operation_type == 'change':
    #     request_data = await state.get_data()
    #     if len(request_data['currencies__recive']) != 0:

    #     await Request.currency__how_much__recive.set()
    #     # to currency__how_much__recive.py

    #     await Request.currency__how_much__recive.set()
    #     # to currency__how_much__recive.py

    ### for logs ### delete later
        request_data = await state.get_data()
        print('=== state: ===')
        print(request_data)
        print('==============')
        ### for logs ### delete later

    except Exception as e:
        print(e)
        await message.answer(
            f'Формат суммы неправильный. Создание заявки отменено\n===========',
            reply_markup=create_kb_coustom_main_menu(message.chat.id))
        await state.finish()
        await message.delete()
예제 #18
0
async def delete_permit(call: CallbackQuery, state: FSMContext):
    await call.answer()
    await call.message.delete()

    if call.data == 'confirm':
        data_state = await state.get_data()
        permit_id = data_state['status_permit']
        permit_numb = data_state['permit_numb']
        username = call.message.chat.username

        permit.delete_permit(permit_id)

        permit_warning = 'пропуск удален'
        permit_notify = f'#N{permit_numb} пропуск удален @{username}'

        await notify_someone(permit_notify, 'admin', 'changer', 'executor')
        # await notify_in_group_chat(permit_notify)

        text = f'Все оповещены о том, что по заявке #N{permit_numb} {permit_warning}'

        await call.message.answer(text=text,
                                  reply_markup=create_kb_coustom_main_menu(
                                      call.message.chat.id))

        await state.finish()

        return

    elif call.data == 'back__main_menu':
        await call.message.answer(
            f'Выход из меню "ПРОПУСКА". Используйте главное меню.',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id))

        await state.finish()

        return
예제 #19
0
async def log_message_handler(call: CallbackQuery, state: FSMContext):
    await call.answer()
    await call.message.delete()

    if call.data == 'back_to_request':
        data_state = await state.get_data()
        chosen_request = data_state['chosen_request']

        text = get_data_finished_request(chosen_request)

        await call.message.answer(text=text,
                                  reply_markup=create_kb_change_fin_request())

        await Reportsstate.change_fin_request.set()

        return

    elif call.data == 'back_to_main_menu':

        await call.message.answer(
            text='Выход из меню "В РАБОТЕ". Используйте главное меню.',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id))

        await state.finish()

        return

    else:

        await call.message.answer(
            text='Выход из меню "В РАБОТЕ". Используйте главное меню.',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id))

        await state.finish()

        return
async def set_blue_amount(message:Message, state:FSMContext):
    data_state = await state.get_data()
    await bot.delete_message (
        chat_id=message.chat.id,
        message_id=data_state['message_to_delete']
    )
    await bot.delete_message (
        chat_id=message.chat.id,
        message_id=message.message_id
    )

    try:
        chosen_request = data_state['chosen_request']
        blue_amount_chunk = int(message.text)
        blue_amount_chunk = str(blue_amount_chunk)
        
    except Exception as e:
        print(e)
        await message.answer (
            text='Изменение заявки отменено. Неправильный формат синих.',
            reply_markup=create_kb_coustom_main_menu(message.chat.id)
        )
        await state.finish()
        
        return
    
    data_state = await state.get_data()
    chosen_request = data_state['chosen_request']
    
    if chosen_request[5][0] == '-':
        blue_amount_chunk = '-' + blue_amount_chunk

    chosen_request[16] = blue_amount_chunk
    await state.update_data(chosen_request=chosen_request)

    text = get_data_chosen_request(chosen_request)

    await message.answer (
        text=text,
        reply_markup=create_kb_confirm_blue()
        # > подтвердить
        # > вернуться к заявке
        # > назад - главное меню
    )

    await Processing.enter_to_confirm_blue_menu_chunk.set()

    return
예제 #21
0
async def set_type_of_card(call: types.CallbackQuery, state: FSMContext):
    await call.answer()
    await call.message.delete()

    if call.data == 'exit':
        await call.message.answer(
            f'Создание заявки отменено. Испльзуйте меню\n===========',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id))
        await state.finish()

        return

    await state.update_data(type_of_card=call.data)

    result = await call.message.answer(f'укажите сумму:')
    await state.update_data(_del_message=result.message_id)

    await Request.temp_sum_state.set()
예제 #22
0
async def show_chosen_request(call: CallbackQuery, state: FSMContext):
    '''
    Обрабатывает нажатие на один из пропусков, выведенных списком
    '''
    await call.answer()
    await call.message.delete()

    data_btn = cb_all_permits.parse(call.data)

    if data_btn['type_btn'] == 'back__main_menu':
        await call.message.answer(
            f'Выход из меню "ПРОПУСКА". Используйте главное меню.',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id))
        await state.finish()

        return

    data_state = await state.get_data()
    all_permits = data_state['all_permits']

    for permit in all_permits:
        if data_btn['id'] == permit[0]:
            await state.update_data(chosen_permit=permit)

            break

    data_state = await state.get_data()
    chosen_permit = data_state['chosen_permit']

    request_numb = chosen_permit[1]
    permit_status = all_emoji[chosen_permit[4]]
    permit_date = chosen_permit[3]
    permit_text = chosen_permit[2]
    text = f'Пропуск\n#N{request_numb} {permit_status} {permit_date}\n{permit_text}'

    await call.message.answer(
        text=text,
        reply_markup=create_kb_set_status_permit()
        # > пропуск заказан
        # > в офисе
        # > назад главное меню
    )

    await Permitstate.status_permit.set()
예제 #23
0
async def set_yes_no_note(call: CallbackQuery, state: FSMContext):
    await call.answer()
    await call.message.delete()

    data_btn = cb_for_what_waste.parse(call.data)

    if data_btn['type_btn'] == 'back__main_menu':
        await call.message.answer(
            f'===========\nВыход в главное меню\n===========',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id))
        await state.finish()

        return

    await state.update_data(for_what_waste=data_btn['type_btn'])

    await call.message.answer(text='Добавить примечание?',
                              reply_markup=create_kb_yes_no_note())
    await SMSstate.yes_no_note.set()
예제 #24
0
async def set_how_much_recive(message: types.Message, state: FSMContext):
    try:
        summ = int(message.text)
        await state.update_data(how_much_recive=summ)
        request_data = await state.get_data()
        await bot.delete_message(chat_id=message.chat.id,
                                 message_id=request_data['_del_message'])
        await bot.delete_message(chat_id=message.chat.id,
                                 message_id=message.message_id)
        await message.answer(f'Выберете валюту:',
                             reply_markup=create_kb_smart_choose_curr(
                                 request_data['currencies__recive']))
        await Request.currency__how_much__recive.set()
        # to currency__how_much__recive.py

    except Exception:
        await message.answer(
            f'Формат суммы неправильный. Создание заявки отменено\n===========',
            reply_markup=create_kb_coustom_main_menu(message.chat.id))
        await state.finish()
        await message.delete()
예제 #25
0
async def set_new_curr_finished_req(call: CallbackQuery, state: FSMContext):
    '''
    - RUB
    - USD
    - EUR
    - back_main_menu
    '''
    await call.answer()
    await call.message.delete()
    # await state.update_data(set_change_curr='+')

    data_btn = cb_change_finished_req.parse(call.data)

    if data_btn['type_btn'] == 'change_sum':
        await state.update_data(set_change_curr=data_btn['curr'])

        # data_state = await state.get_data()
        # chosen_request = data_state['chosen_request']

        # if chosen_request[3] == 'выдача в офисе' or chosen_request[3] == 'доставка' or chosen_request[3] == 'кэшин':
        #     await state.update_data(new_curr_sign='-')

        # else:
        #     await state.update_data(new_curr_sign='')

        result = await call.message.answer(text='Введите новую сумму')
        await state.update_data(message_to_delete=result.message_id)

        await Reportsstate.change_curr_amount.set()

        return

    else:
        await call.message.answer(
            text='Выход из меню "Отчетность". Используйте главное меню.',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id))

        await state.finish()

        return
async def set_currency_to_correct(call: CallbackQuery, state: FSMContext):
    '''
    Обрабатывает клавиатуру create_kb_what_sum_correct(request)
    из keyboards_sum_ready.py
    - sum rub
    - sum usd
    - sum eur
    - back_main_menu
    '''
    await call.answer()
    await call.message.delete()
    await state.update_data(enter_correct_sum_to_ready_menu='+')

    data_btn = cb_sum_correct_chunk.parse(call.data)

    if data_btn['type_btn'] == 'change_curr':
        await state.update_data(chunk_recive__currency=data_btn['curr'])
        data_state = await state.get_data()
        chosen_request = data_state['chosen_request']
        rub, usd, eur = get_plus_FGH(chosen_request)

        if data_btn['curr'] == 'rub': initial_sum = rub
        if data_btn['curr'] == 'usd': initial_sum = usd
        if data_btn['curr'] == 'eur': initial_sum = eur

        result = await call.message.answer(
            f'По заявке нужно принять сумму {initial_sum},\nсколько принято по факту?'
        )
        await state.update_data(message_to_delete=result.message_id)
        await Processing.chunk_recive__sum.set()

    else:
        await call.message.answer(
            text='Выход из меню "В РАБОТЕ". Используйте главное меню.',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id))
        await state.finish()

        return
예제 #27
0
async def set_date_from_buttons(call: types.CallbackQuery, state: FSMContext):
    await call.answer()
    await call.message.delete()

    if call.data == 'set_current_date':
        current_date = datetime.today().strftime('%d.%m')
        await state.update_data(data_request=current_date)

    elif call.data == 'set_tomorrow_date':
        tomorrow_date = (datetime.now() + timedelta(days=1)).strftime("%d.%m")
        await state.update_data(data_request=tomorrow_date)

    elif call.data == 'set_after_tomorrow_date':
        after_tomorrow_date = (datetime.now() +
                               timedelta(days=2)).strftime("%d.%m")
        await state.update_data(data_request=after_tomorrow_date)

    elif call.data == 'exit':
        await call.message.answer(
            f'Создание заявки отменено\n========================',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id))
        await state.finish()

        return

    else:  # call.data == 'enter_coustom_date'
        result = await call.message.answer('Введите дату в формате ЧЧ.ММ')
        await state.update_data(_del_message=result.message_id)
        await state.update_data(data_request='')
        await Request.data_request.set()

        return

    request_data = await state.get_data()
    result_data_to_show, keyboard = get_data_to_show(request_data)

    await call.message.answer(text=result_data_to_show, reply_markup=keyboard)
    await Request.type_end.set()
예제 #28
0
async def set_plus_or_minus_summ(call: types.CallbackQuery, state: FSMContext):
    await call.answer()
    await call.message.delete()

    if call.data == 'exit':
        await call.message.answer(
            f'Создание заявки отменено. Испльзуйте меню\n===========',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id))
        await state.finish()

        return

    await state.update_data(plus_minus='yes')

    if call.data == 'sum_plus':
        result = await call.message.answer('Введите сумму:')
        await Request.how_much_recive.set()
        await state.update_data(_del_message=result.message_id)
        # to how_much_recive.py
    if call.data == 'sum_minus':
        result = await call.message.answer('Введите сумму:')
        await state.update_data(_del_message=result.message_id)
        await Request.how_much_give.set()
예제 #29
0
async def show_finished_request(call: CallbackQuery, state: FSMContext):
    await call.answer()
    await call.message.delete()
    await state.update_data(return_request_menu='+')

    data_btn = cb_finished_requests.parse(call.data)

    if data_btn['type_btn'] == 'exit':
        await call.message.answer(
            text='Выход из меню "ОТЧЕТНОСТЬ". Используйте главное меню.',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id))

        await state.finish()

        return

    data_state = await state.get_data()
    finished_requests = data_state['finished_requests']

    for request in finished_requests:

        if data_btn['id'] == request[1]:
            await state.update_data(chosen_request=request)

            break

    data_state = await state.get_data()
    request = data_state['chosen_request']
    text = get_data_finished_request(request)

    await call.message.answer(text=text,
                              reply_markup=create_kb_change_fin_request())

    await Reportsstate.change_fin_request.set()

    return
예제 #30
0
async def close__sum_set(message: Message, state: FSMContext):
    data_state = await state.get_data()

    await bot.delete_message(chat_id=message.chat.id,
                             message_id=data_state['message_to_delete'])
    await bot.delete_message(chat_id=message.chat.id,
                             message_id=message.message_id)

    try:
        which_sum_change__amount = int(message.text)

        if which_sum_change__amount < 0:
            raise ValueError('f**k off')
        which_sum_change__amount = str(which_sum_change__amount)

    except Exception as e:
        await message.answer(
            text='Изменение заявки отменено. Формат суммы не правильный.',
            reply_markup=create_kb_coustom_main_menu(message.chat.id))

        await state.finish()

        return

    await state.update_data(which_sum_change__amount=which_sum_change__amount)

    data_state = await state.get_data()

    which_sum_change__sign = data_state['which_sum_change__sign']
    currency = data_state['which_sum_change__currency']

    if which_sum_change__sign == 'minus':
        sum = '-' + which_sum_change__amount
    else:
        sum = which_sum_change__amount

    changed_request = data_state['changed_request']

    if currency == 'rub':
        changed_request[5] = sum

    if currency == 'usd':
        changed_request[6] = sum

    if currency == 'eur':
        changed_request[7] = sum

    is_changed = True

    await state.update_data(is_changed=is_changed)
    await state.update_data(changed_request=changed_request)

    all_changes_data = data_state['all_changes_data']

    if 'sum' not in all_changes_data:
        all_changes_data.append('sum')
        await state.update_data(all_changes_data=all_changes_data)

    text = get_data_chosen_request(changed_request) + \
    '\n\n Выберите изменение:'

    await message.answer(text,
                         reply_markup=create_kb_change_request(
                             changed_request, is_changed))

    await Processing.change_request_menu.set()

    return