Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Repented of Transaction having an __init__()

  • Loading branch information...
commit e840fed6347daa94f0ceb85fabef9d2138461605 1 parent e661cdb
@brandon-rhodes authored
View
3  publican/engine/models.py
@@ -24,9 +24,6 @@ class Transaction(types.Transaction, models.Model):
amount = models.DecimalField(max_digits=20, decimal_places=2)
comment = models.TextField(blank=True)
- def __init__(self, *args, **kw):
- models.Model.__init__(self, *args, **kw)
-
class Company(company.Company):
ein='38-0218963'
View
53 publican/engine/tests/sample.py
@@ -12,10 +12,11 @@
def build_company():
"""Create a sample `Company` with pre-loaded test data."""
- def A(type):
- a = Account()
- a.type = type
- return a
+ def make(cls, **kw):
+ thing = cls()
+ for k, v in kw.iteritems():
+ setattr(thing, k, v)
+ return thing
def F(region, name, period, date):
form = get_form(region, name)
@@ -23,8 +24,6 @@ def F(region, name, period, date):
f.date = date
return f
- T = Transaction
-
b = Company(
ein='38-0218963',
name='Crazy R Software',
@@ -32,12 +31,11 @@ def F(region, name, period, date):
)
b.today = Date(2012, 8, 20) # override, so tests are predictable!
- print b.today
- business = A('business')
- alice = A('employee')
- bob = A('employee')
- carol = A('consultant')
+ business = make(Account, type='business')
+ alice = make(Account, type='employee')
+ bob = make(Account, type='employee')
+ carol = make(Account, type='consultant')
business.id, alice.id, bob.id, carol.id = range(4)
@@ -48,18 +46,29 @@ def F(region, name, period, date):
F('us', '941', Quarter(2012, 1), Date(2012, 4, 15)),
]
- b._transactions = [
- T(Date(2011, 11, 29), business, alice, Decimal(1400)),
- T(Date(2011, 12, 29), business, alice, Decimal(2200)),
-
- T(Date(2012, 1, 29), business, alice, Decimal(2200)),
- T(Date(2012, 1, 29), business, bob, Decimal(900)),
- T(Date(2012, 1, 29), bob, business, Decimal(99)), # reimbursement
- T(Date(2012, 2, 29), business, carol, Decimal(1000)),
- T(Date(2012, 2, 29), business, alice, Decimal(2200)),
- T(Date(2012, 3, 29), business, alice, Decimal(2200)),
+ T = Transaction
- T(Date(2012, 4, 29), business, alice, Decimal(2200)),
+ b._transactions = [
+ make(T, date=Date(2011, 11, 29), debit_account=business,
+ credit_account=alice, amount=Decimal(1400)),
+ make(T, date=Date(2011, 12, 29), debit_account=business,
+ credit_account=alice, amount=Decimal(2200)),
+
+ make(T, date=Date(2012, 1, 29), debit_account=business,
+ credit_account=alice, amount=Decimal(2200)),
+ make(T, date=Date(2012, 1, 29), debit_account=business,
+ credit_account=bob, amount=Decimal(900)),
+ make(T, date=Date(2012, 1, 29), debit_account=bob,
+ credit_account=business, amount=Decimal(99)), # reimbursement
+ make(T, date=Date(2012, 2, 29), debit_account=business,
+ credit_account=carol, amount=Decimal(1000)),
+ make(T, date=Date(2012, 2, 29), debit_account=business,
+ credit_account=alice, amount=Decimal(2200)),
+ make(T, date=Date(2012, 3, 29), debit_account=business,
+ credit_account=alice, amount=Decimal(2200)),
+
+ make(T, date=Date(2012, 4, 29), debit_account=business,
+ credit_account=alice, amount=Decimal(2200)),
]
return b
View
14 publican/engine/types.py
@@ -29,6 +29,8 @@
saved for real when the application is up and running.
"""
+from .kit import zero
+
class Account(object):
"""An account in our system of double-entry bookkeeping.
@@ -51,10 +53,8 @@ class Transaction(object):
"invoice #24" or "for rebuilding my model classes".
"""
- def __init__(self, date, debit_account, credit_account, amount,
- comment=''):
- self.date = date
- self.debit_account = debit_account
- self.credit_account = credit_account
- self.amount = amount
- self.comment = comment
+ date = None
+ debit_account = None
+ credit_account = None
+ amount = zero
+ comment = u''
View
6 publican/frontend/views.py
@@ -5,7 +5,6 @@
from django.shortcuts import render_to_response
from publican.engine.kit import Interval, Month, dollars, cents, get_period
-#from publican.engine.tests.sample import company
from publican.forms import registry
@@ -100,11 +99,12 @@ def filing(request, region, name, period_name):
def _get_company(request):
"""Return a `Company` facade for the current user's data."""
+ if False:
+ from publican.engine.tests.sample import company
+ return company
from ..engine.models import CompanyUser, Company
cu = CompanyUser.objects.get(user=request.user)
- print cu
account = cu.company
- print account
return Company(account)
def _display_month(filing):
Please sign in to comment.
Something went wrong with that request. Please try again.