def get(self, clientKeyUrlSafe): user = Authorization.isAuthenticated() if user: monthStart = DateService.getFirstDateOfMonth().strftime('%m/%d/%Y') monthEnd = DateService.getLastDateOfMonth().strftime('%m/%d/%Y') try: radLineItemType = LineItemsClient.radLineItemType except: radLineItemType = 'irregular' try: dateFrom = LineItemsClient.dateFrom dateTo = LineItemsClient.dateTo except: dateFrom = monthStart dateTo = monthEnd try: viewDateFrom = LineItemsClient.viewDateFrom viewDateTo = LineItemsClient.viewDateTo except: viewDateFrom = monthStart viewDateTo = monthEnd try: serviceKeyUrlSafe = LineItemsClient.serviceKeyUrlSafe except: serviceKeyUrlSafe = '' services = ServiceService.getAll() client = ClientService.get(clientKeyUrlSafe) # lineItems = LineItemService.getAll(clientKeyUrlSafe) lineItems = LineItemService.getAllInRange(clientKeyUrlSafe, viewDateFrom, viewDateTo) template_values = { 'services':services, 'client' : client, 'postUrl' : '/lineItem/client/' + clientKeyUrlSafe, 'lineItems' : lineItems, 'getUrl' : '/lineItem/client/' + clientKeyUrlSafe, 'viewDateFrom' : viewDateFrom, 'viewDateTo' : viewDateTo, 'dateFrom' : dateFrom, 'dateTo' : dateTo, 'serviceKeyUrlSafe' : serviceKeyUrlSafe, 'radLineItemType' : radLineItemType } template = JINJA_ENVIRONMENT.get_template('partials/lineItemClient.html') self.response.write(template.render(template_values)) else: self.redirect('/')
def post(self): user = Authorization.isAuthenticated() if user: dateFrom = self.request.get('dateFrom') dateTo = self.request.get('dateTo') clientKeyUrlSafe = self.request.get("clientKeyUrlSafe") client = ClientService.get(clientKeyUrlSafe) clientName = client.primaryFirstName + " " + client.primaryLastName lineItems = LineItemService.getAllInRange(clientKeyUrlSafe, dateFrom, dateTo) today = datetime.now().strftime('%m/%d/%Y') clientAddressLine1 = client.primaryAddress clientAddressLine2 = client.primaryCity + ", " + client.primaryState + " " + client.primaryZip tax = 7.77 subtotal = 0 for lineItem in lineItems: subtotal += lineItem.service.servicePrice total = subtotal * (1 + (7.77/100)) template_values = { 'lineItems' : lineItems, 'subtotal': subtotal, 'tax' : tax, 'total':total, 'today': today, 'clientAddressLine1': clientAddressLine1, 'clientAddressLine2' : clientAddressLine2, 'clientName' : clientName } template = JINJA_ENVIRONMENT.get_template('partials/reportPrint.html') self.response.write(template.render(template_values)) # ClientService.update(clientKeyUrlSafe, self.request) # client = ClientService.getClient(clientKeyUrlSafe) # # pets = PetService.getPetsFromClient(client) # clientService = ClientService(self.request) # clientService.update(client, pets) else: self.redirect('/report')