public
Description: Django-beancounter is a simple app I built to track my income and expenses.
Homepage: http://github.com/lincolnloop/django-beancounter
Clone URL: git://github.com/lincolnloop/django-beancounter.git
added project/employee tracking
lincolnloop (author)
Sun Jan 04 17:31:35 -0800 2009
commit  9d6640ef13f8d884d66657479d19b7d3fb239a70
tree    df0ac3a134d5c5ebfc2a33369284eaafcb4e4925
parent  b13309e1114595408aae42b9c4cd4e9184804a63
...
1
2
3
 
 
 
4
5
6
...
20
21
22
 
 
 
 
 
 
 
 
 
 
 
23
24
25
...
31
32
33
 
34
35
36
37
38
 
 
 
39
...
 
1
 
2
3
4
5
6
7
...
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
...
43
44
45
46
47
48
49
50
51
52
53
54
55
0
@@ -1,6 +1,7 @@
0
-from beancounter.models import Category, BankAccount, AccountTransfer, Person, Entry
0
 from django.contrib import admin
0
-from django.utils.translation import ugettext_lazy as _
0
+
0
+from beancounter.models import (Category, BankAccount, AccountTransfer,
0
+                                Person, Entry, Employee, Project, ProjectTime)
0
 
0
 class CategoryOptions(admin.ModelAdmin):
0
     fieldsets = (
0
@@ -20,6 +21,17 @@ class BankAccountOptions(admin.ModelAdmin):
0
 class PersonOptions(admin.ModelAdmin):
0
     list_display = ('name','phone','email')
0
 
0
+class EmployeeAdmin(admin.ModelAdmin):
0
+    list_display = ('name', 'gmt_offset', 'rate')
0
+    search_fields = ('name',)
0
+
0
+class ProjectAdmin(admin.ModelAdmin):
0
+    list_display = ('name','start_date')
0
+    
0
+class ProjectTimeAdmin(admin.ModelAdmin):
0
+    list_display = ('project', 'employee', 'hours', 'cost_converted')
0
+    list_filter = ('project', 'employee')
0
+
0
 class AccountTransferOptions(admin.ModelAdmin):
0
     list_display = ('date','amount','from_account','to_account')
0
     list_filter = ('to_account','from_account')
0
@@ -31,9 +43,13 @@ class EntryOptions(admin.ModelAdmin):
0
     search_fieldsets = ('name','memo')
0
     list_filter = ('category','name','bank_account')
0
 
0
+
0
 admin.site.register(Category, CategoryOptions)
0
 admin.site.register(BankAccount, BankAccountOptions)
0
 admin.site.register(Person, PersonOptions)
0
 admin.site.register(AccountTransfer, AccountTransferOptions)
0
 admin.site.register(Entry, EntryOptions)
0
+admin.site.register(Employee, EmployeeAdmin)
0
+admin.site.register(Project, ProjectAdmin)
0
+admin.site.register(ProjectTime, ProjectTimeAdmin)
0
 
...
 
 
1
2
 
3
4
5
...
63
64
65
66
67
 
 
68
69
70
71
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
74
75
 
 
 
 
 
 
 
 
 
 
 
 
 
76
77
78
...
1
2
3
4
5
6
7
8
...
66
67
68
 
 
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
 
 
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
0
@@ -1,5 +1,8 @@
0
+import datetime
0
+
0
 from django.db import models
0
 from django.contrib.localflavor.us.models import PhoneNumberField
0
+from tagging.fields import TagField
0
 
0
 TYPE_CHOICES = (
0
     ('INC', 'Income'),
0
@@ -63,16 +66,78 @@ class Person(models.Model):
0
     email = models.EmailField(null=True,blank=True)
0
     notes = models.CharField(max_length=100,null=True,blank=True)
0
     
0
-    def __str__(self):
0
-        return "%s" % (self.name)
0
+    def __unicode__(self):
0
+        return self.name
0
     
0
     class Meta:
0
         verbose_name_plural = 'People'
0
         ordering = ['name']
0
         
0
+        
0
+class Employee(Person):
0
+    PAYMENT_CHOICES = (
0
+        ('paypal', 'PayPal'),
0
+        ('check', 'Mail Check'),
0
+        ('wire', 'Wire Transfer'),
0
+        ('elance', 'Elance'),
0
+        ('other', 'Other'),
0
+    )
0
+    gmt_offset = models.DecimalField(max_digits=3, decimal_places=1)
0
+    skills = TagField()
0
+    payment_preference = models.CharField(blank=True, max_length=100, choices=PAYMENT_CHOICES)
0
+    payment_notes = models.TextField(blank=True)
0
+    contract = models.DateField(blank=True, null=True, help_text="Date contractor contract was signed and received.")
0
+    hourly_rate = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True, help_text="If rate varies, enter average and note below.")
0
+    currency = models.CharField(default="USD", max_length=3)
0
+    rate_notes = models.TextField(blank=True, help_text="Additional notes regarding contractor rates.")
0
+
0
+
0
+    def timezone(self):
0
+        if self.gmt_offset == int(self.gmt_offset):
0
+            gmt_offset = int(self.gmt_offset)
0
+        else:
0
+            gmt_offset = self.gmt_offset
0
+        if gmt_offset > 0:
0
+            gmt_offset = '+%s' % gmt_offset
0
+        return 'GMT%s' % gmt_offset
0
+
0
+    def under_contract(self):
0
+        if self.contract:
0
+            return True
0
+        return False
0
+    under_contract.boolean = True
0
+
0
+    def rate(self):
0
+        return "%s %s" % (self.hourly_rate, self.currency)
0
+
0
+class Project(models.Model):
0
+    name = models.CharField(max_length=100)
0
+    employees = models.ManyToManyField(Employee)
0
+    start_date = models.DateField()
0
+    #bid = models.DecimalField(max_digits=8, decimal_places=2)
0
+    active = models.BooleanField(default=True)
0
+
0
+    def __unicode__(self):
0
+        return self.name
0
+        
0
+        
0
+class ProjectTime(models.Model):
0
+    """
0
+    Hours spent by an employee on a project
0
     
0
-    class Admin:
0
-        list_display = ('name','phone','email')
0
+    """
0
+    
0
+    employee = models.ForeignKey(Employee)
0
+    project = models.ForeignKey(Project)
0
+    start_date = models.DateField(default=datetime.date.today())
0
+    end_date = models.DateField(default=datetime.date.today())
0
+    hours = models.DecimalField(max_digits=6, decimal_places=3)
0
+    cost = models.DecimalField(max_digits=9, decimal_places=2, blank=True, null=True, help_text="Leave blank to automatically calculate")
0
+    cost_converted = models.DecimalField(max_digits=9, decimal_places=2, blank=True, null=True, help_text="Cost converted to local currency")
0
+
0
+    def __unicode__(self):
0
+        return "%s on %s (%s-%s)" % (self.employee, self.project, self.start_date, self.end_date)
0
+
0
 
0
 class Entry(models.Model):
0
     category = models.ForeignKey(Category)

Comments