Exemple #1
0
class APITest(unittest.TestCase):
    def setUp(self):
        '''Sets up the test rig with API information and loads settings from config file'''
        config_path = os.path.join(os.path.dirname(__file__), 'config.ini')
        config = configparser.ConfigParser()
        config.read(config_path)

        self.API_token = config['YNAB']['API_token']
        self.budget_id = config['YNAB']['budget_id']
        self.session = BudgetSession(self.API_token)

    def test_accountlist_islist(self):
        '''Tests to make sure the account list is a list'''
        account_list = self.session.retrieve_account_list(self.budget_id)
        self.assertTrue(isinstance(account_list, list))
        pass

    def test_txnlist_islist(self):
        '''Tests to make sure the transaction list is a list using imported account info'''
        account_list = self.session.retrieve_account_list(self.budget_id)
        first_account_id = account_list[0]['id']
        txn_list = self.session.retrieve_txn_list(self.budget_id,
                                                  first_account_id)
        self.assertTrue(isinstance(txn_list, list))
        pass
Exemple #2
0
    def setUp(self):
        '''Sets up the test rig with API information and loads settings from config file'''
        config_path = os.path.join(os.path.dirname(__file__), 'config.ini')
        config = configparser.ConfigParser()
        config.read(config_path)

        self.API_token = config['YNAB']['API_token']
        self.budget_id = config['YNAB']['budget_id']
        self.session = BudgetSession(self.API_token)
from context import BudgetSession, CategoryGroup
import os
import glob
import configparser

config_path = os.path.join(os.path.dirname(__file__), 'config.ini')
config = configparser.ConfigParser()
config.read(config_path)

crn = config['ANZ']['crn']
pswd = config['ANZ']['pass']
download_path = config['TEMP']['path']

API_token = config['YNAB']['API_token']
budget_id = config['YNAB']['budget_id']

session = BudgetSession(API_token)

session.retrieve_category_list(budget_id)

print(session.category_list)
Exemple #4
0
logging.basicConfig(level=logging.DEBUG)

config_path = os.path.join(os.path.dirname(__file__),'config.ini')
config = configparser.ConfigParser()
config.read(config_path)

crn = config['ANZ']['crn']
pswd = config['ANZ']['pass']
download_path = config['TEMP']['path']

API_token = config['YNAB']['API_token']
budget_id = config['YNAB']['budget_id']

list_of_ofx_paths = glob.glob('{}/*.ofx'.format(download_path))

session = BudgetSession(API_token)

for ofx_path in list_of_ofx_paths:

    with codecs.open(ofx_path) as account_file:
        acct_dat_raw = OfxParser.parse(account_file)
        acct_dat = acct_dat_raw.accounts[0]

        account_number = acct_dat.account_id

        YNAB_account_list = session.retrieve_account_list(budget_id)
        account_id = session.find_account_id(YNAB_account_list, account_number)

        transactions = acct_dat.statement.transactions

        json_txn_list = []
Exemple #5
0
import datetime

logging.basicConfig(level=logging.DEBUG)

config_path = os.path.join(os.path.dirname(__file__), 'config.ini')
config = configparser.ConfigParser()
config.read(config_path)

crn = config['ANZ']['crn']
pswd = config['ANZ']['pass']
download_path = config['TEMP']['path']

API_token = config['YNAB']['API_token']
budget_id = config['YNAB']['budget_id']

session = BudgetSession(API_token)

account_list = [
    '4be706e3-6443-4e2f-94ba-2b29657f46f7',
    '0eae96b6-3ab5-4d78-a570-5ecd96c29a5f',
    'a6d76618-cf55-b693-2ec6-02471c25627b',
    'bb25c9bb-e8e3-49ce-a36a-d1d1f5d7c319',
    '9e5de04c-fee5-4b98-90ec-1700dd311389',
    'ea06aa86-dfdd-dd45-33a9-02471c25dd1a',
    '3d6b5c89-76ef-4d98-4f6d-02471c25c28b',
    'cb1dcc46-7cc1-10a6-9c12-02471c251504',
    '0b80c649-ad31-418c-a16e-fa33589ed1d6',
    'fd770d7c-e196-4f24-a3a6-7571fe9e14d1',
    '49a06e4b-1b2c-413c-8aa5-db20c8f0c79e',
    'cec70cec-e94d-4e48-8eb6-cc5afc4a6635',
    '2eea73e1-6f92-0525-35ee-02471c25b85d',
Exemple #6
0
import configparser
import logging
import os
import glob
import codecs
from ofxparse import OfxParser

from context import BudgetSession
from anzapi.sdriver import BankingSession

logging.basicConfig(level=logging.DEBUG)

config_path = os.path.join(os.path.dirname(__file__), 'config.ini')
config = configparser.ConfigParser()
config.read(config_path)

crn = config['ANZ']['crn']
pswd = config['ANZ']['pass']
download_path = config['TEMP']['path']

API_token = config['YNAB']['API_token']
budget_id = config['YNAB']['budget_id']

session = BudgetSession(API_token)

acct_list = session.retrieve_account_list(budget_id)

print(acct_list)
print(session.find_account_id(acct_list, '555794334'))
logging.info("Loading configuration file")
config_path = os.path.join(os.path.dirname(__file__), 'config.ini')

if os.path.exists(config_path) is False:
    logging.error(
        "The config file does not exist. Make sure you have written the config.ini"
    )
    sys.exit(1)

config = configparser.ConfigParser()
config.read(config_path)

ynab_api_token = config['YNAB']['API_token']
budget_id = config['YNAB']['budget_id']

session = BudgetSession(ynab_api_token)

ledger = Book(config, session)

at_date = datetime(2019, 8, 1)
date_from = datetime(2017, 8, 13)
date_to = datetime(2019, 10, 1)

#av = AlphaVantage(config)
#av.unit_price_at_date('HACK', datetime(2019, 3, 13))
#symbol = ledger.security_account_list[1].symbol
#valuator = ledger.security_account_list[1].valuator
#country = ledger.security_account_list[1].country

#av_session = AlphaVantage(config)