Ejemplo n.º 1
0
def load_gui():
    utils.log_debug('load_gui')
    url = 'https://app.youneedabudget.com/%s/accounts' % afy.settings.budget_id
    d = gui.driver()
    if url in d.current_url:
        return
    d.get(url)
    if not gui.get('user-logged-in', require=False):
        selection = input('Must be logged in. Try again? [Y/n]')
        if selection.lower() != 'n':
            load_gui()
Ejemplo n.º 2
0
def delete_accounts(accounts):
    utils.log_info('Deleting %s accounts via Web App' % len(accounts))
    load_gui()
    navlink_accounts = gui.get('navlink-accounts')
    gui.scroll_to(navlink_accounts)
    gui.click(navlink_accounts)
    for a in accounts:
        edit_account = gui.get_by_text('nav-account-name', a.name)
        utils.log_debug(edit_account)
        gui.scroll_to(edit_account)
        gui.right_click(edit_account)
        gui.get_by_text('button-red', ['Close Account', 'Delete', 'Delete Account'], partial=True).click()
Ejemplo n.º 3
0
def adjust_subtransaction_rows(t):
    utils.log_debug('add_subtransactions_rows', len(t.subtransactions))
    # Remove existing subtransactions
    memo = gui.get_by_text('user-entered-text', t.id, count=1)  # TODO: why was this partial?
    gui.click(memo, 2)
    removes = gui.get('ynab-grid-sub-remove', require=False, wait=1)
    while removes:
        gui.click(removes)
        removes = gui.get('ynab-grid-sub-remove', require=False, wait=.5)

    # Add rows for the new ones
    n = len(t.subtransactions)
    if n == 0:
        return
    gui.get_by_placeholder('accounts-text-field', 'category').clear()  # needed?
    category_dropdown = gui.get_by_placeholder('dropdown-text-field', 'category')
    category_dropdown.send_keys(' ')
    split = gui.get('modal-account-categories-split-transaction')
    gui.click(split)
    for i in range(n - 2):
        # gui.clicking split means we already have two
        gui.click(gui.get('ynab-grid-split-add-sub-transaction'))
    if n == 1:
        # which is weird but in principle OK
        gui.click(gui.get('ynab-grid-sub-remove'))
    assert len(gui.get('ynab-grid-sub-remove')) == n
Ejemplo n.º 4
0
def delete_transactions():
    load_gui()
    search('Memo: ' + afy.ynab.ynab.delete_key)
    if not isinstance(gui.get('ynab-checkbox-button-square'), list):
        return  # Means no transactions in results to delete, because only one element
    select_all()
    gui.send_keys(gui.Keys.TAB)
    gui.send_keys(gui.Keys.TAB)
    gui.send_keys(gui.Keys.DELETE)
    # Only gives confirm modal over some number of transactions. TODO: cut down this wait.
    confirm_delete = gui.get_by_text('button-primary', 'Delete', require=False, wait=7)
    if confirm_delete:
        gui.click(confirm_delete)
Ejemplo n.º 5
0
def add_unlinked_account(account_name, balance=0, account_type='credit'):
    utils.log_debug('add_unlinked_account')
    assert account_type in {'credit'}
    load_gui()
    # TODO: other account types? linked?
    time.sleep(1)
    add_account = gui.get('nav-add-account')
    add_account.click()
    unlinked = gui.get_by_text('select-linked-unlinked-box-title', 'UNLINKED')
    unlinked.click()
    gui.send_keys(account_type)
    gui.send_keys(gui.Keys.TAB)
    gui.send_keys(account_name)
    gui.send_keys(gui.Keys.TAB)
    gui.send_keys(str(balance))
    gui.send_keys(gui.Keys.TAB)
    gui.send_keys(gui.Keys.ENTER)
    time.sleep(2)
    gui.get_by_text('pull-right', 'Done').click()
Ejemplo n.º 6
0
def enter_all_transactions(transactions):
    utils.log_debug('enter_all_transactions', len(transactions))
    load_gui()
    for t in transactions:
        utils.log_info(t)
        if len(t.subtransactions) > 5:
            utils.log_info(
                '''Skipping purchase with %s items for speed reasons during alpha test.
                   Feel free to remove this check.''' % len(t.subtransactions))
            continue
        try:
            enter_transaction(t)
        except BaseException:
            ' Likely because there were multiple search results '
            utils.log_exception()
            utils.log_error('Error on transaction', t)
            search = gui.get('transaction-search-input')
            search.clear()
    gui.quit()
Ejemplo n.º 7
0
def select_all():
    gui.click(gui.get('ynab-checkbox-button-square'))
Ejemplo n.º 8
0
def search(query):
    utils.log_debug('search', query)
    search = gui.get('transaction-search-input')
    search.clear()
    search.send_keys(query)
    search.send_keys(gui.Keys.ENTER)