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')
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")
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')
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")
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')
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")
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')
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')
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")
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 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')
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_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 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')
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 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')
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")
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')
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')
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")
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')
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')
def list(self): c.projects = Project.objects() return render("/project/project_list.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")
def view(self, id): c.project, created = Project.objects.get_or_create(name=id) return render("/project/project_form.html")
def edit(self, id): c.timesheet = Timesheet.objects.get(id=id) return render('/timesheet/edit_timesheet_form.html')
def list(self): c.invoices = Invoice.all_invoices() return render("/invoice/invoice_list.html")
def list(self): c.projects = Project.objects() return render('/project/project_list.html')
def view(self, id): project = Project.load_or_create(id) c.project = project return render('/project/project_form.html')
def view(self, id): c.project, created = Project.objects.get_or_create(name=id) return render('/project/project_form.html')
def list(self): c.projects = Project.project_list() return render('/project/project_list.html')