コード例 #1
0
ファイル: timesheet.py プロジェクト: zoranzaric/prickle
 def logit(self):
     timesheet = Timesheet(
             date=self.form_result['date'],
             duration=self.form_result['duration'],
             project=self.form_result['project'],
             description=self.form_result['description'])
     timesheet.store()
     path = request.params.get('next')
     if not path:
         path = url(controller="timesheet", action="index")
     return redirect(path)
コード例 #2
0
ファイル: invoice.py プロジェクト: shashishailaj/prickle
 def create(self, id):
     # yes, the swapping of id is confusing, thanks laziness
     # from default routes
     # id = name of the project
     # invoice.id = invoice number
     project_name = id
     project = Project.objects.get(name=project_name)
     invoice = Invoice(project=project,
                       number=self.form_result['invoice_number'],
                       bill_to=self.form_result['bill_to'],
                       tax=self.form_result['tax'],
                       date=datetime.datetime(
                           self.form_result['date'].year,
                           self.form_result['date'].month,
                           self.form_result['date'].day,
                       ),
                       rate=project.rate)
     invoice.save()
     timesheets = Timesheet.objects(project=project,
                                    __raw__={'invoice': None})
     for timesheet in timesheets:
         timesheet.archived_rate = timesheet.rate
         timesheet.invoice = invoice
         timesheet.save()
     return redirect(
         url(controller="invoice", action="summary", id=invoice.number))
コード例 #3
0
ファイル: timesheet.py プロジェクト: zoranzaric/prickle
 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')
コード例 #4
0
ファイル: invoice.py プロジェクト: buchuki/prickle
 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")
コード例 #5
0
ファイル: timesheet.py プロジェクト: buchuki/prickle
 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')
コード例 #6
0
ファイル: invoice.py プロジェクト: zoranzaric/prickle
 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")
コード例 #7
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')
コード例 #8
0
ファイル: invoice.py プロジェクト: shashishailaj/prickle
 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')
コード例 #9
0
ファイル: timesheet.py プロジェクト: zoranzaric/prickle
 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')
コード例 #10
0
ファイル: invoice.py プロジェクト: zoranzaric/prickle
 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")
コード例 #11
0
ファイル: timesheet.py プロジェクト: zoranzaric/prickle
 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')
コード例 #12
0
ファイル: invoice.py プロジェクト: zoranzaric/prickle
 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")
コード例 #13
0
ファイル: invoice.py プロジェクト: buchuki/prickle
 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")
コード例 #14
0
 def logit(self):
     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
     timesheet = Timesheet(date=datetime.datetime(
         self.form_result['date'].year,
         self.form_result['date'].month,
         self.form_result['date'].day,
     ),
                           duration=self.form_result['duration'],
                           project=project,
                           type=type,
                           description=self.form_result['description'])
     timesheet.save()
     path = request.params.get('next')
     if not path:
         path = url(controller="timesheet", action="index")
     return redirect(path)
コード例 #15
0
ファイル: timesheet.py プロジェクト: buchuki/prickle
 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')
コード例 #16
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')
コード例 #17
0
ファイル: invoice.py プロジェクト: shashishailaj/prickle
 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")
コード例 #18
0
ファイル: timesheet.py プロジェクト: buchuki/prickle
 def logit(self):
     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
     timesheet = Timesheet(
             date=datetime.datetime(
                 self.form_result['date'].year,
                 self.form_result['date'].month,
                 self.form_result['date'].day,
                 ),
             duration=self.form_result['duration'],
             project=project,
             type=type,
             description=self.form_result['description'])
     timesheet.save()
     path = request.params.get('next')
     if not path:
         path = url(controller="timesheet", action="index")
     return redirect(path)
コード例 #19
0
ファイル: timesheet.py プロジェクト: buchuki/prickle
 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')
コード例 #20
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')
コード例 #21
0
ファイル: invoice.py プロジェクト: buchuki/prickle
    def mark_billed(self, id):
        """Sometimes we want to record timesheets as invoiced
        without creating an invoice (ie: to clear out unbilled
        stuff or because it was invoiced in another application.

        We do this by attaching those timesheets to a single
        invoice named 'no invoice'."""
        project_name = id
        project, cr = Project.objects.get_or_create(name=project_name)
        invoice, cr = Invoice.objects.get_or_create(number=-1)

        timesheets = Timesheet.objects(project=project, __raw__={"invoice": None})
        for timesheet in timesheets:
            print timesheet
            timesheet.invoice = invoice
            timesheet.save()
        return redirect(url(controller="timesheet", action="index"))
コード例 #22
0
ファイル: invoice.py プロジェクト: zoranzaric/prickle
    def mark_billed(self, id):
        """Sometimes we want to record timesheets as invoiced
        without creating an invoice (ie: to clear out unbilled
        stuff or because it was invoiced in another application.

        We do this by attaching those timesheets to a single
        invoice named 'no invoice'."""
        project_name = id
        invoice = Invoice.load("no invoice")
        if not invoice:
            invoice = Invoice(id="no invoice")
            invoice.store()

        timesheets = Timesheet.for_project(project_name, unbilled=True)
        for timesheet in timesheets:
            timesheet.invoice = invoice.id
            timesheet.store()
        return redirect(url(controller="timesheet", action="index"))
コード例 #23
0
ファイル: invoice.py プロジェクト: shashishailaj/prickle
    def mark_billed(self, id):
        '''Sometimes we want to record timesheets as invoiced
        without creating an invoice (ie: to clear out unbilled
        stuff or because it was invoiced in another application.

        We do this by attaching those timesheets to a single
        invoice named 'no invoice'.'''
        project_name = id
        project, cr = Project.objects.get_or_create(name=project_name)
        invoice, cr = Invoice.objects.get_or_create(number=-1)

        timesheets = Timesheet.objects(project=project,
                                       __raw__={'invoice': None})
        for timesheet in timesheets:
            print timesheet
            timesheet.invoice = invoice
            timesheet.save()
        return redirect(url(controller="timesheet", action="index"))
コード例 #24
0
ファイル: timesheet.py プロジェクト: zoranzaric/prickle
    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')
コード例 #25
0
ファイル: invoice.py プロジェクト: zoranzaric/prickle
 def create(self, id):
     # yes, the swapping of id is confusing, thanks laziness
     # from default routes
     # id = name of the project
     # invoice.id = invoice number
     project_name = id
     project = Project.load_or_create(project_name)
     invoice = Invoice(
         project=project_name,
         id=self.form_result["invoice_number"],
         bill_to=self.form_result["bill_to"],
         tax=self.form_result["tax"],
         date=self.form_result["date"],
         rate=project.rate,
     )
     invoice.store()
     timesheets = Timesheet.for_project(project_name, unbilled=True)
     for timesheet in timesheets:
         timesheet.invoice = invoice.id
         timesheet.store()
     return redirect(url(controller="invoice", action="summary", id=invoice.id))
コード例 #26
0
ファイル: invoice.py プロジェクト: shashishailaj/prickle
 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")
コード例 #27
0
ファイル: invoice.py プロジェクト: buchuki/prickle
 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")
コード例 #28
0
ファイル: timesheet.py プロジェクト: buchuki/prickle
    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')
コード例 #29
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')
コード例 #30
0
ファイル: invoice.py プロジェクト: buchuki/prickle
 def create(self, id):
     # yes, the swapping of id is confusing, thanks laziness
     # from default routes
     # id = name of the project
     # invoice.id = invoice number
     project_name = id
     project = Project.objects.get(name=project_name)
     invoice = Invoice(
         project=project,
         number=self.form_result["invoice_number"],
         bill_to=self.form_result["bill_to"],
         tax=self.form_result["tax"],
         date=datetime.datetime(
             self.form_result["date"].year, self.form_result["date"].month, self.form_result["date"].day
         ),
         rate=project.rate,
     )
     invoice.save()
     timesheets = Timesheet.objects(project=project, __raw__={"invoice": None})
     for timesheet in timesheets:
         timesheet.archived_rate = timesheet.rate
         timesheet.invoice = invoice
         timesheet.save()
     return redirect(url(controller="invoice", action="summary", id=invoice.number))
コード例 #31
0
ファイル: timesheet.py プロジェクト: zoranzaric/prickle
 def delete(self, id):
     timesheet = Timesheet.load(id)
     timesheets.delete(timesheet)
     return "deleted"