MCPcopy Index your code
hub / github.com/geekcomputers/Python / setup_balance_operation_flow

Function setup_balance_operation_flow

bank_managment_system/QTFrontend.py:1516–1585  ·  view source on GitHub ↗
(
        stacked_widget,
        title_search,
        placeholder,
        title_form,
        action_button_text,
        success_message,
        backend_action_fn,
        stacked_page_index,
        search_index,
        page_index,
        need_input=True,
    )

Source from the content-addressed store, hash-verified

1514 )
1515
1516 def setup_balance_operation_flow(
1517 stacked_widget,
1518 title_search,
1519 placeholder,
1520 title_form,
1521 action_button_text,
1522 success_message,
1523 backend_action_fn,
1524 stacked_page_index,
1525 search_index,
1526 page_index,
1527 need_input=True,
1528 ):
1529 # Create search UI
1530 search_page, search_widgets = search_result(
1531 stacked_widget, title_search, placeholder
1532 )
1533 search_input = search_widgets[0]
1534 search_button = search_widgets[1]
1535
1536 # Create update UI
1537 form_page, form_widgets = update_user(
1538 stacked_widget, title_form, action_button_text, need_input
1539 )
1540 if need_input:
1541 name_field, balance_field, amount_field, action_button = form_widgets
1542 else:
1543 name_field, balance_field, action_button = form_widgets
1544
1545 def on_search_submit():
1546 try:
1547 account_number = int(search_input.text().strip())
1548 except ValueError:
1549 show_popup_message(
1550 stacked_widget, "Please enter a valid account number.", search_index
1551 )
1552 return
1553
1554 if backend.check_acc_no(account_number):
1555 account_data = backend.get_details(account_number)
1556 name_field.setText(str(account_data[1]))
1557 balance_field.setText(str(account_data[4]))
1558 stacked_widget.setCurrentIndex(page_index)
1559 else:
1560 show_popup_message(
1561 stacked_widget,
1562 "Account not found",
1563 search_index,
1564 show_cancel=True,
1565 cancel_page=EMPLOYEE_MENU_PAGE,
1566 )
1567
1568 def on_action_submit():
1569 try:
1570 account_number = int(search_input.text().strip())
1571 amount = int(amount_field.text().strip())
1572 backend_action_fn(amount, account_number)
1573 name_field.setText("")

Callers 1

setup_main_windowFunction · 0.85

Calls 2

search_resultFunction · 0.85
update_userFunction · 0.85

Tested by

no test coverage detected