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 getAllInRangeForEmployee(employeeKeyUrlSafe, clients, viewDateFrom, viewDateTo): try: viewDateFrom = datetime.strptime(viewDateFrom, "%m/%d/%Y").date() viewDateTo = datetime.strptime(viewDateTo, "%m/%d/%Y").date() listLineItems = [] accountManagers = AccountManagerService.getAllByEmployeeKeyUrlSafe(employeeKeyUrlSafe) for client in clients: for accountManager in accountManagers: if client.key.urlsafe() == accountManager.clientKeyUrlSafe: lineItems = LineItem.query(ancestor=client.key) lineItems = lineItems.filter( LineItem.dateOfService <= viewDateTo, LineItem.dateOfService >= viewDateFrom ) listLineItems += lineItems.order(LineItem.dateOfService).fetch() return listLineItems 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
def add(clientKey, service, dateOfService): lineItem = LineItem(parent=clientKey) lineItem.dateOfService = dateOfService lineItem.service = service lineItem.put()