#!/usr/bin/env python3

import simplejsondb as sjdb
import json

# user { id, nickname, name, password, address, }
# 
# session { id, fk_user, last_login, last_activity, }
# 
# payee { id, name, desc, }
# 
# category { id, name, desc, parent_id, }
# 
# mode { id, name, }
# 
# bank { id, name, bic_code, sort_code, address, phone, mail, website,
#        contact_name, contact_mail, contact_phone, contact_fax, note, }
# 
# account { id, bank, user, name, iban, number,
#           min_authorised, min_desired, note, }
# 
# transaction { id, account, payee, category, mode, date, order,
#               amount, balance, number, note, scheduled, hidden, }
# 
# scheduler { id, transaction, next, frequency, automatic_add, }

with open('data/config.json', 'r') as f:
    config_data = json.load(f)

test = sjdb.SimpleJsonDB('test.json', config_data=config_data)

# test.set_indent(2)

test.save('transaction', amount='20.65') # 1
test.save_db()
# print(test.save('transaction', amount='30.47')) # 2
# print(test.save('transaction', convert=False, amount='40.86')) # 3
# print(test.save('transaction', amount='10.20')) # 4
# print(test.save('transaction', id=4, date='2013-01-05')) # 4
# print('# 1 ################')
# print(test.show('transaction'))
# print('# 2 ################')
# test.move('transaction', 3, 0)
# print('# 3 ################')
# print(test.show('transaction'))


# import time
# starttt = time.clock()
# for i in range(10000):
#     start = time.clock()
#     test.save('transaction')
#     print(i, time.clock() - start)
# print(time.clock() - starttt)

test.save_db()
