def addAllInRange(clientKeyUrlSafe, request): clientKey = ClientService.getClientKey(clientKeyUrlSafe) serviceKeyUrlSafe = request.get("serviceKeyUrlSafe") service = ServiceService.get(serviceKeyUrlSafe) dateFromString = request.get("dateFrom") dateToString = request.get("dateTo") repeatMonday = request.get("repeatMonday") repeatTuesday = request.get("repeatTuesday") repeatWednesday = request.get("repeatWednesday") repeatThursday = request.get("repeatThursday") repeatFriday = request.get("repeatFriday") repeatSaturday = request.get("repeatSaturday") repeatSunday = request.get("repeatSunday") startDate = datetime.strptime(dateFromString, "%m/%d/%Y").date() endDate = datetime.strptime(dateToString, "%m/%d/%Y").date() dateRange = endDate - startDate for i in range(dateRange.days + 1): currentDay = startDate + timedelta(days=i) if repeatSunday == LineItemService.FLAGACTIVE and currentDay.isoweekday() == LineItemService.SUNDAY: LineItemService.add(clientKey, service, currentDay) if repeatMonday == LineItemService.FLAGACTIVE and currentDay.isoweekday() == LineItemService.MONDAY: LineItemService.add(clientKey, service, currentDay) if repeatTuesday == LineItemService.FLAGACTIVE and currentDay.isoweekday() == LineItemService.TUESDAY: LineItemService.add(clientKey, service, currentDay) if repeatWednesday == LineItemService.FLAGACTIVE and currentDay.isoweekday() == LineItemService.WEDNESDAY: LineItemService.add(clientKey, service, currentDay) if repeatThursday == LineItemService.FLAGACTIVE and currentDay.isoweekday() == LineItemService.THURSDAY: LineItemService.add(clientKey, service, currentDay) if repeatFriday == LineItemService.FLAGACTIVE and currentDay.isoweekday() == LineItemService.FRIDAY: LineItemService.add(clientKey, service, currentDay) if repeatSaturday == LineItemService.FLAGACTIVE and currentDay.isoweekday() == LineItemService.SATURDAY: LineItemService.add(clientKey, service, currentDay)
def addAllInList(clientKeyUrlSafe, request): dateList = request.get("multiDatesPickerSelectedDates") clientKey = ClientService.getClientKey(clientKeyUrlSafe) dateList = dateList.split(",") serviceKeyUrlSafe = request.get("serviceKeyUrlSafe") service = ServiceService.get(serviceKeyUrlSafe) for dateString in dateList: dateString = dateString.strip() currentDate = datetime.strptime(dateString, "%m/%d/%Y").date() LineItemService.add(clientKey, service, currentDate)
def getAllInRange(clientKeyUrlSafe, viewDateFrom, viewDateTo): try: viewDateFrom = datetime.strptime(viewDateFrom, "%m/%d/%Y").date() viewDateTo = datetime.strptime(viewDateTo, "%m/%d/%Y").date() clientKey = ClientService.getClientKey(clientKeyUrlSafe) lineItems = LineItem.query(ancestor=clientKey) lineItems = lineItems.filter(LineItem.dateOfService <= viewDateTo, LineItem.dateOfService >= viewDateFrom) lineItems = lineItems.order(LineItem.dateOfService).fetch() return lineItems except: logging.error("LineItemService.py => getAllInRang") return None
def getAll(clientKeyUrlSafe): clientKey = ClientService.getClientKey(clientKeyUrlSafe) lineItems = LineItem.query(ancestor=clientKey).order(LineItem.dateOfService).fetch() return lineItems