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))
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")
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")
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')
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))
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')
def list(self): c.invoices = Invoice.objects(number__ne=-1).order_by('-number') return render("/invoice/invoice_list.html")
def list(self): c.invoices = Invoice.objects(number__ne=-1).order_by("-number") return render("/invoice/invoice_list.html")