Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: alexamici/thinkfar
base: 014f0358f8
...
head fork: alexamici/thinkfar
compare: 2a601f8cf5
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 30 additions and 1 deletion.
  1. +25 −0 thinkfar/backoffice/views.py
  2. +5 −1 thinkfar/rest.py
View
25 thinkfar/backoffice/views.py
@@ -21,3 +21,28 @@ def init_datastore_view(request):
init_datastore()
return Response('Ok')
+@view_config(name='init_testdata', request_method='GET')
+def init_testdata(request):
+ from datetime import date
+
+ from thinkfar.inventory import User
+ from thinkfar.accounting import ItemClass
+
+ me = User.get_by_key_name('alexamici')
+ book = me.books.fetch(1)[0]
+ car_class = ItemClass.get_by_key_name('GIFI/1740')
+ car = car_class.create_itemset(book=book, uid='0123', name='My Car')
+ car.description = 'A 2003 Honda'
+ car.put()
+ buy_a_car = car.item_class.transaction_template('buy')
+ buy_a_car(car, date(2003, 2, 5), gross_price_paid=15000, taxes_paid=3500, resell_value=10000)
+ sell_a_car = car.item_class.transaction_template('sell')
+ sell_a_car.sell(car, date(2012, 5, 5), net_resell_value=3000, taxes_paid=50, fees_paid=250)
+
+ shares_class = ItemClass.get_by_key_name('GIFI/3500')
+ ge_plan = shares_class.create_itemset(book=book, uid='0124', name='GE shares')
+ ge_plan.description = 'GE shares accumulation plan'
+ ge_plan.put()
+ # ge_plan.buy(start_date=date(2009, 12, 31), end_date=date(2010, 12, 31), amount=365, gross_price_paid=5530, commissions_paid=55)
+ # ge_plan.sell(start_date=date(2029, 12, 31), end_date=date(2030, 12, 31), amount=365, net_resell_value=6880, taxes_paid=365, commissions_paid=55)
+ return Response('Ok')
View
6 thinkfar/rest.py
@@ -1,4 +1,6 @@
+from datetime import date
+
from pyramid.httpexceptions import HTTPNotFound
from pyramid.view import view_config
@@ -47,6 +49,8 @@ def books_json(request, page=1, start=0, limit=25):
def inventory_json(request, page=1, start=0, limit=25):
user_uid = request.matchdict['user_uid']
book_uid = request.matchdict['book_uid']
+ isodate = request.params.get('date', date.today().isoformat())
+ ref_date = date(*map(int, isodate.split('-')))
user = User.get_by_key_name(user_uid)
if user is None:
raise HTTPNotFound
@@ -59,7 +63,7 @@ def inventory_json(request, page=1, start=0, limit=25):
'uid': itemset.uid,
'name': itemset.name,
'accounting_universe_uid': itemset.item_class.uid,
- 'inventory_count': itemset.balance(),
+ 'inventory_count': itemset.balance(ref_date),
} for itemset in itemsets
]
return retval

No commit comments for this range

Something went wrong with that request. Please try again.