Esempio n. 1
0
def authorize():
    from openstudio.os_exact_online import OSExactOnline

    os_eo = OSExactOnline()
    api = os_eo.get_api()

    url = api.create_auth_request_url()
    redirect(url)
Esempio n. 2
0
def divisions():
    """
    List divisions
    """
    def get_button_set_default(division_id):
        if division_id == selected_division:
            return DIV(os_gui.get_label(
                'success',
                T('Selected'),
            ),
                       _class='pull-right')

        else:
            return os_gui.get_button('noicon',
                                     URL('division_set_default',
                                         vars={'division_id': division_id}),
                                     _class='pull-right',
                                     btn_class='btn-link',
                                     title=T("Select this division"))

    from ConfigParser import NoOptionError
    from openstudio.os_exact_online import OSExactOnline
    from openstudio.os_gui import OsGui

    response.title = T("Exact online")
    response.subtitle = T("Divisions")
    response.view = 'general/only_content.html'

    os_gui = OsGui()
    os_eo = OSExactOnline()
    api = os_eo.get_api()
    storage = os_eo.get_storage()
    try:
        selected_division = int(storage.get('transient', 'division'))
    except NoOptionError:
        selected_division = None

    division_choices, current_division = api.get_divisions()

    header = THEAD(TR(TH('Name'), TH('Exact ID'), TH()))

    table = TABLE(header, _class="table table-striped table-hover")

    for division_id in division_choices:
        tr = TR(
            TD(division_choices[division_id]),
            TD(division_id),
            TD(get_button_set_default(division_id))  # buttons
        )

        table.append(tr)

    content = table

    back = os_gui.get_button('back', URL('settings_integration',
                                         'exact_online'))

    return dict(content=content, back=back)
Esempio n. 3
0
def relations():
    """

    :return:
    """
    from openstudio.os_exact_online import OSExactOnline

    os_eo = OSExactOnline()
    api = os_eo.get_api()

    relations = api.relations.all()

    return locals()
Esempio n. 4
0
def division_set_default():
    """
    Set default division
    """
    from openstudio.os_exact_online import OSExactOnline

    division_id = request.vars['division_id']

    os_eo = OSExactOnline()
    api = os_eo.get_api()

    api.set_division(division_id)  # select ID of given division

    session.flash = T("Changed selected division")
    redirect(URL('divisions'))
Esempio n. 5
0
def financial_glaccounts():
    """
    List G/L accounts
    """
    from ConfigParser import NoOptionError
    from openstudio.os_exact_online import OSExactOnline

    from exactonline.exceptions import ObjectDoesNotExist
    from exactonline.resource import GET, POST, PUT, DELETE

    from openstudio.os_gui import OsGui

    response.title = T("Exact online")
    response.subtitle = T("G/L Accounts")
    response.view = 'general/only_content.html'

    os_gui = OsGui()
    os_eo = OSExactOnline()
    api = os_eo.get_api()
    storage = os_eo.get_storage()
    try:
        selected_division = int(storage.get('transient', 'division'))
    except NoOptionError:
        selected_division = None

    items = api.financialglaccounts.all()
    sorted_items = sorted(items, key=lambda k: k['Code'])

    header = THEAD(
        TR(
            TH('G/L Account code'),
            TH('G/L Account Description'),
            TH('G/L Account ID'),
        ))

    table = TABLE(header, _class="table table-striped table-hover")

    for item in sorted_items:
        tr = TR(TD(item['Code']), TD(item['Description']), TD(item['ID']))

        table.append(tr)

    content = table

    back = os_gui.get_button('back', URL('settings_integration',
                                         'exact_online'))

    return dict(content=content, back=back)
Esempio n. 6
0
def invoices():
    """

    :return:
    """
    import pprint
    from openstudio.os_exact_online import OSExactOnline

    os_eo = OSExactOnline()
    api = os_eo.get_api()

    invoices = api.invoices.all()

    pp = pprint.PrettyPrinter(depth=6)
    pp.pprint(invoices)

    return 'got it!'
Esempio n. 7
0
def oauth2_success():
    """

    :return:
    """
    from openstudio.os_exact_online import OSExactOnline
    code = request.vars['code']

    os_eo = OSExactOnline()
    api = os_eo.get_api()

    # Set transient api client access data like access code, token and expiry
    api.request_token(code)

    # Set authorized to true in database
    set_sys_property('exact_online_authorized', 'True')

    session.flash = T(
        "Authorization success! You can now select a default division.")
    redirect(URL('divisions'))