コード例 #1
0
ファイル: exact_online.py プロジェクト: mcgege/openstudio
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)
コード例 #2
0
ファイル: exact_online.py プロジェクト: mcgege/openstudio
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)
コード例 #3
0
ファイル: exact_online.py プロジェクト: mcgege/openstudio
def relations():
    """

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

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

    relations = api.relations.all()

    return locals()
コード例 #4
0
ファイル: exact_online.py プロジェクト: mcgege/openstudio
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'))
コード例 #5
0
ファイル: exact_online.py プロジェクト: mcgege/openstudio
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)
コード例 #6
0
ファイル: exact_online.py プロジェクト: mcgege/openstudio
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!'
コード例 #7
0
ファイル: exact_online.py プロジェクト: mcgege/openstudio
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'))