Example #1
0
 def project(self, id):
     c.project = Project.load_or_create(id)
     c.timesheets = Timesheet.for_project(id, unbilled=True)
     c.title = "Project Summary for %s" % id
     c.total_time = sum(t.duration for t in c.timesheets)
     c.total_fee = sum(t.fee for t in c.timesheets)
     c.invoices = Invoice.for_project(id)
     return render('/timesheet/project_summary.html')
Example #2
0
 def summary(self, id):
     c.invoice = Invoice.objects.get(number=int(id))
     c.timesheets = Timesheet.objects(invoice=c.invoice)
     c.title = "Invoice %s" % id
     c.total_time = sum(t.duration for t in c.timesheets)
     c.total_fee = sum(t.fee for t in c.timesheets)
     c.taxes = c.total_fee * c.invoice.tax * Decimal("0.01")
     c.after_taxes = c.total_fee + c.taxes
     return render("/invoice/invoice_summary.html")
Example #3
0
 def date(self, date):
     c.title = "Log Time for %s" % date
     c.entry_title = "Timesheets for %s" % date
     c.date = datetime.datetime.strptime(date, "%Y-%m-%d").date()
     c.timesheets = Timesheet.for_date(c.date)
     c.total_time = sum(t.duration for t in c.timesheets)
     c.total_fee = sum(t.fee for t in c.timesheets)
     c.project_list = Project.objects()
     return render('/timesheet/timeform.html')
Example #4
0
 def date(self, date):
     c.title = "Log Time for %s" % date
     c.entry_title = "Timesheets for %s" % date
     c.date = datetime.datetime.strptime(date, "%Y-%m-%d").date()
     c.timesheets = Timesheet.for_date(c.date)
     c.total_time = sum(t.duration for t in c.timesheets)
     c.total_fee = sum(t.fee for t in c.timesheets)
     c.project_list = Project.objects()
     return render('/timesheet/timeform.html')
Example #5
0
 def summary(self, id):
     c.timesheets = Timesheet.for_invoice(id)
     c.title = "Invoice %s" % id
     c.total_time = sum(t.duration for t in c.timesheets)
     c.total_fee = sum(t.fee for t in c.timesheets)
     c.invoice = Invoice.load(id)
     c.taxes = c.total_fee * c.invoice.tax * Decimal("0.01")
     c.after_taxes = c.total_fee + c.taxes
     return render("/invoice/invoice_summary.html")
Example #6
0
 def summary(self, id):
     c.invoice = Invoice.objects.get(number=int(id))
     c.timesheets = Timesheet.objects(invoice=c.invoice)
     c.title = "Invoice %s" % id
     c.total_time = sum(t.duration for t in c.timesheets)
     c.total_fee = sum(t.fee for t in c.timesheets)
     c.taxes = c.total_fee * c.invoice.tax * Decimal("0.01")
     c.after_taxes = c.total_fee + c.taxes
     return render('/invoice/invoice_summary.html')
Example #7
0
 def view(self, id):
     invoice = Invoice.load(id)
     c.invoice = invoice
     c.project = Project.load_or_create(invoice.project)
     c.timesheets = Timesheet.for_invoice(id)
     c.total_time = sum(t.duration for t in c.timesheets)
     c.total_fee = c.total_time * invoice.rate
     c.taxes = c.total_fee * invoice.tax * Decimal("0.01")
     c.after_taxes = c.total_fee + c.taxes
     return render("/invoice/invoice.html")
Example #8
0
 def date(self, date):
     c.title = "Log Time for %s" % date
     c.entry_title = "Timesheets for %s" % date
     c.timesheets = Timesheet.for_date(date)
     # Would it be optimal to do this inside couchdb using a reduce function?
     c.total_time = sum(t.duration for t in c.timesheets)
     c.total_fee = sum(t.fee for t in c.timesheets)
     c.date = datetime.datetime.strptime(date, "%Y-%m-%d").date()
     c.project_list = Project.project_list()
     return render('/timesheet/timeform.html')
Example #9
0
 def index(self):
     today = datetime.date.today()
     c.title = "Log Time"
     c.entry_title = "Uninvoiced Entries"
     c.timesheets = Timesheet.all_timesheets(unbilled=True)
     c.total_time = sum(t.duration for t in c.timesheets)
     c.total_fee = sum(t.fee for t in c.timesheets)
     c.project_list = Project.project_list()
     c.date = datetime.date.today()
     c.delete_column = True
     return render('/timesheet/timeform.html')
Example #10
0
 def create_form(self, id):
     project_name = id
     c.date = datetime.date.today()
     c.project = Project.load_or_create(project_name)
     c.timesheets = Timesheet.for_project(project_name, unbilled=True)
     c.total_time = sum(t.duration for t in c.timesheets)
     c.total_fee = c.total_time * c.project.rate
     c.next_invoice_number = Invoice.next_invoice_number()
     previous_invoices = Invoice.for_project(project_name)
     if previous_invoices.rows:
         c.bill_to = previous_invoices.rows[-1].bill_to
     return render("/invoice/invoice_form.html")
Example #11
0
 def create_form(self, id):
     project_name = id
     c.date = datetime.date.today()
     c.project = Project.objects.get(name=project_name)
     c.timesheets = Timesheet.objects(project=c.project, __raw__={"invoice": None})
     c.total_time = sum(t.duration for t in c.timesheets)
     c.total_fee = c.total_time * c.project.rate
     c.next_invoice_number = Invoice.next_invoice_number()
     previous_invoices = Invoice.objects(project=c.project)
     if previous_invoices.count():
         c.bill_to = previous_invoices[previous_invoices.count() - 1].bill_to
     return render("/invoice/invoice_form.html")
Example #12
0
 def index(self):
     today = datetime.date.today()
     c.title = "Log Time"
     c.entry_title = "Uninvoiced Entries"
     # FIXME: Surely mongoengine knows how to get References by not set?
     c.timesheets = Timesheet.objects(__raw__={'invoice': None}).order_by(
             "-date")
     c.total_time = sum(Decimal(t.duration) for t in c.timesheets)
     c.total_fee = sum(t.fee for t in c.timesheets)
     c.project_list = Project.objects()
     c.date = datetime.date.today()
     c.delete_column = True
     return render('/timesheet/timeform.html')
Example #13
0
 def project(self, id):
     c.project = Project.objects.get(name=id)
     c.timesheets = Timesheet.objects(project=c.project,
             __raw__={'invoice': None}).order_by("-date")
     c.title = "Project Summary for %s" % id
     c.total_time = sum(t.duration for t in c.timesheets)
     c.total_fee = sum(t.fee for t in c.timesheets)
     c.invoices = Invoice.objects(project=c.project)
     c.invoice_totals = {'duration': 0, 'fee': 0, 'total': 0}
     for i in c.invoices:
         c.invoice_totals['duration'] += i.total_duration()
         c.invoice_totals['fee'] += i.total_fee()
         c.invoice_totals['total'] += i.total()
     return render('/timesheet/project_summary.html')
Example #14
0
 def create_form(self, id):
     project_name = id
     c.date = datetime.date.today()
     c.project = Project.objects.get(name=project_name)
     c.timesheets = Timesheet.objects(project=c.project,
                                      __raw__={'invoice': None})
     c.total_time = sum(t.duration for t in c.timesheets)
     c.total_fee = c.total_time * c.project.rate
     c.next_invoice_number = Invoice.next_invoice_number()
     previous_invoices = Invoice.objects(project=c.project)
     if previous_invoices.count():
         c.bill_to = previous_invoices[previous_invoices.count() -
                                       1].bill_to
     return render("/invoice/invoice_form.html")
Example #15
0
 def index(self):
     today = datetime.date.today()
     c.title = "Log Time"
     c.entry_title = "Uninvoiced Entries"
     # FIXME: Surely mongoengine knows how to get References by not set?
     c.timesheets = Timesheet.objects(__raw__={
         'invoice': None
     }).order_by("-date")
     c.total_time = sum(Decimal(t.duration) for t in c.timesheets)
     c.total_fee = sum(t.fee for t in c.timesheets)
     c.project_list = Project.objects()
     c.date = datetime.date.today()
     c.delete_column = True
     return render('/timesheet/timeform.html')
Example #16
0
 def project(self, id):
     c.project = Project.objects.get(name=id)
     c.timesheets = Timesheet.objects(project=c.project,
                                      __raw__={
                                          'invoice': None
                                      }).order_by("-date")
     c.title = "Project Summary for %s" % id
     c.total_time = sum(t.duration for t in c.timesheets)
     c.total_fee = sum(t.fee for t in c.timesheets)
     c.invoices = Invoice.objects(project=c.project)
     c.invoice_totals = {'duration': 0, 'fee': 0, 'total': 0}
     for i in c.invoices:
         c.invoice_totals['duration'] += i.total_duration()
         c.invoice_totals['fee'] += i.total_fee()
         c.invoice_totals['total'] += i.total()
     return render('/timesheet/project_summary.html')
Example #17
0
    def month(self, year, month):
        c.date = datetime.date(int(year), int(month), 1)
        c.title = "Timesheet summary for %s" % c.date.strftime("%B, %Y")
        c.timesheets = Timesheet.for_month(year, month)
        c.total_time = sum(t.duration for t in c.timesheets)
        c.total_fee = sum(t.fee for t in c.timesheets)
        c.invoice_column = True
        #FIXME: I'm really tired and suspect this is not the right way to do this
        project_summary = defaultdict(dict) 
        for timesheet in c.timesheets:
            project_summary[timesheet.project]['duration'] = \
                    project_summary[timesheet.project].setdefault(
                            'duration', 0) + timesheet.duration
            project_summary[timesheet.project]['fee'] = \
                    project_summary[timesheet.project].setdefault(
                            'fee', 0) + timesheet.fee

        c.project_summary = project_summary
        return render('/timesheet/month_summary.html')
Example #18
0
 def view(self, id):
     c.invoice = Invoice.objects.get(number=int(id))
     c.project = c.invoice.project
     c.timesheets = Timesheet.objects(invoice=c.invoice)
     types = defaultdict(int)
     rates = {}
     for timesheet in c.timesheets:
         if timesheet.type:
             types[timesheet.type.type] += timesheet.duration
             rates[timesheet.type.type] = timesheet.rate
         else:
             types[''] += timesheet.duration
             rates[''] = timesheet.rate
     c.types = {}
     for type, hours in types.items():
         c.types[type] = (hours, rates[type], hours * rates[type])
     c.total_time = sum(t.duration for t in c.timesheets)
     c.total_fee = sum(t.fee for t in c.timesheets)
     c.taxes = c.total_fee * c.invoice.tax * Decimal("0.01")
     c.after_taxes = c.total_fee + c.taxes
     return render("/invoice/invoice.html")
Example #19
0
 def save_edit(self, id):
     c.timesheet = Timesheet.objects.get(id=id)
     c.timesheet.date = datetime.datetime(
         self.form_result['date'].year,
         self.form_result['date'].month,
         self.form_result['date'].day,
     )
     c.timesheet.duration = self.form_result['duration']
     project, created = Project.objects.get_or_create(
         name=self.form_result['project'])
     if self.form_result['type']:
         type, created = ProjectType.objects.get_or_create(
             project=project, type=self.form_result['type'])
     else:
         type = None
     c.timesheet.project = project
     c.timesheet.type = type
     c.timesheet.description = self.form_result['description']
     c.timesheet.save()
     c.delete_column = True
     return render('/timesheet/timesheet_row_direct.html')
Example #20
0
 def save_edit(self, id):
     c.timesheet = Timesheet.objects.get(id=id)
     c.timesheet.date=datetime.datetime(
                 self.form_result['date'].year,
                 self.form_result['date'].month,
                 self.form_result['date'].day,
                 )
     c.timesheet.duration=self.form_result['duration']
     project, created = Project.objects.get_or_create(
             name=self.form_result['project'])
     if self.form_result['type']:
         type, created = ProjectType.objects.get_or_create(
                 project=project, type=self.form_result['type'])
     else:
         type = None
     c.timesheet.project=project
     c.timesheet.type=type
     c.timesheet.description=self.form_result['description']
     c.timesheet.save()
     c.delete_column = True
     return render('/timesheet/timesheet_row_direct.html')
Example #21
0
 def view(self, id):
     c.invoice = Invoice.objects.get(number=int(id))
     c.project = c.invoice.project
     c.timesheets = Timesheet.objects(invoice=c.invoice)
     types = defaultdict(int)
     rates = {}
     for timesheet in c.timesheets:
         if timesheet.type:
             types[timesheet.type.type] += timesheet.duration
             rates[timesheet.type.type] = timesheet.rate
         else:
             types[""] += timesheet.duration
             rates[""] = timesheet.rate
     c.types = {}
     for type, hours in types.items():
         c.types[type] = (hours, rates[type], hours * rates[type])
     c.total_time = sum(t.duration for t in c.timesheets)
     c.total_fee = sum(t.fee for t in c.timesheets)
     c.taxes = c.total_fee * c.invoice.tax * Decimal("0.01")
     c.after_taxes = c.total_fee + c.taxes
     return render("/invoice/invoice.html")
Example #22
0
    def month(self, year, month):
        month_start = datetime.datetime(int(year), int(month), 1)
        month_end = month_start + relativedelta(months=1) - relativedelta(days=1)
        c.date = month_start.date()
        c.title = "Timesheet summary for %s" % c.date.strftime("%B, %Y")
        c.timesheets = Timesheet.objects(date__gte=month_start,
                date__lte=month_end).order_by("-date")
        c.total_time = sum(t.duration for t in c.timesheets)
        c.total_fee = sum(t.fee for t in c.timesheets)
        c.invoice_column = True
        #FIXME: I'm really tired and suspect this is not the right way to do this
        project_summary = defaultdict(dict) 
        for timesheet in c.timesheets:
            project_summary[timesheet.project.name]['duration'] = \
                    project_summary[timesheet.project.name].setdefault(
                            'duration', 0) + timesheet.duration
            project_summary[timesheet.project.name]['fee'] = \
                    project_summary[timesheet.project.name].setdefault(
                            'fee', 0) + timesheet.fee

        c.project_summary = project_summary
        return render('/timesheet/month_summary.html')
Example #23
0
    def month(self, year, month):
        month_start = datetime.datetime(int(year), int(month), 1)
        month_end = month_start + relativedelta(months=1) - relativedelta(
            days=1)
        c.date = month_start.date()
        c.title = "Timesheet summary for %s" % c.date.strftime("%B, %Y")
        c.timesheets = Timesheet.objects(date__gte=month_start,
                                         date__lte=month_end).order_by("-date")
        c.total_time = sum(t.duration for t in c.timesheets)
        c.total_fee = sum(t.fee for t in c.timesheets)
        c.invoice_column = True
        #FIXME: I'm really tired and suspect this is not the right way to do this
        project_summary = defaultdict(dict)
        for timesheet in c.timesheets:
            project_summary[timesheet.project.name]['duration'] = \
                    project_summary[timesheet.project.name].setdefault(
                            'duration', 0) + timesheet.duration
            project_summary[timesheet.project.name]['fee'] = \
                    project_summary[timesheet.project.name].setdefault(
                            'fee', 0) + timesheet.fee

        c.project_summary = project_summary
        return render('/timesheet/month_summary.html')
Example #24
0
 def list(self):
     c.projects = Project.objects()
     return render("/project/project_list.html")
Example #25
0
 def list(self):
     c.invoices = Invoice.objects(number__ne=-1).order_by('-number')
     return render("/invoice/invoice_list.html")
Example #26
0
 def list(self):
     c.invoices = Invoice.objects(number__ne=-1).order_by("-number")
     return render("/invoice/invoice_list.html")
Example #27
0
 def view(self, id):
     c.project, created = Project.objects.get_or_create(name=id)
     return render("/project/project_form.html")
Example #28
0
 def edit(self, id):
     c.timesheet = Timesheet.objects.get(id=id)
     return render('/timesheet/edit_timesheet_form.html')
Example #29
0
 def list(self):
     c.invoices = Invoice.all_invoices()
     return render("/invoice/invoice_list.html")
Example #30
0
 def list(self):
     c.projects = Project.objects()
     return render('/project/project_list.html')
Example #31
0
 def view(self, id):
     project = Project.load_or_create(id)
     c.project = project
     return render('/project/project_form.html')
Example #32
0
 def edit(self, id):
     c.timesheet = Timesheet.objects.get(id=id)
     return render('/timesheet/edit_timesheet_form.html')
Example #33
0
 def view(self, id):
     c.project, created = Project.objects.get_or_create(name=id)
     return render('/project/project_form.html')
Example #34
0
 def list(self):
     c.projects = Project.project_list()
     return render('/project/project_list.html')