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
some helper functions for project tracking
lincolnloop (author)
Sun Jan 04 18:15:06 -0800 2009
commit  1c4c5ca68bda347f824ba4c41b41a8025e664750
tree    8730dce53b70f547b7428c2d5ff680b7f6cfa199
parent  e4ceba0f2e7b7cb07b007110926bc02104c52120
...
30
31
32
33
 
34
35
36
...
30
31
32
 
33
34
35
36
0
@@ -30,7 +30,7 @@ class ProjectInvoiceInline(admin.TabularInline):
0
     model = ProjectInvoice
0
 
0
 class ProjectAdmin(admin.ModelAdmin):
0
-    list_display = ('name','start_date')
0
+    list_display = ('name','start_date', 'total_invoiced', 'total_cost', 'profit')
0
     inlines = [ProjectInvoiceInline,]
0
     
0
 class ProjectTimeAdmin(admin.ModelAdmin):
...
1
 
2
3
4
...
118
119
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
122
123
...
1
2
3
4
5
...
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
0
@@ -1,4 +1,5 @@
0
 import datetime
0
+import decimal
0
 
0
 from django.db import models
0
 from django.contrib.localflavor.us.models import PhoneNumberField
0
@@ -118,6 +119,24 @@ class Project(models.Model):
0
 
0
     def __unicode__(self):
0
         return self.name
0
+        
0
+    def total_invoiced(self):
0
+        #TODO aggregate support
0
+        total = decimal.Decimal("0.00")
0
+        for invoice in self.projectinvoice_set.all():
0
+            total += invoice.amount
0
+        return total
0
+    
0
+    def total_cost(self):
0
+        #TODO aggregate support
0
+        total = decimal.Decimal("0.00")
0
+        for time in self.projecttime_set.all():
0
+            total += time.cost_converted
0
+        return total
0
+    
0
+    def profit(self):
0
+        return self.total_invoiced() - self.total_cost()
0
+            
0
 
0
 class ProjectInvoice(models.Model):
0
     """

Comments