docs: def get_entry_query(self, start, end, data):
          """Builds Entry query from form data."""
          # Entry types.
          incl_billable = data.get('billable', True)
          incl_nonbillable = data.get('non_billable', True)
          incl_leave = data.get('paid_leave', True)
  
          # If no types are selected, shortcut & return nothing.
          if not any((incl_billable, incl_nonbillable, incl_leave)):
              return None
  
          # All entries must meet time period requirements.
          basicQ = Q(end_time__gte=start, end_time__lt=end)
  
          # Filter by project for HourlyReport.
          projects = data.get('projects', None)
          basicQ &= Q(project__in=projects) if projects else Q()
  
          # Filter by user, activity, and project type for BillableReport.
          if 'users' in data:
              basicQ &= Q(user__in=data.get('users'))
          if 'activities' in data:
              basicQ &= Q(activity__in=data.get('activities'))
          if 'project_types' in data:
              basicQ &= Q(project__type__in=data.get('project_types'))
  
          # If all types are selected, no further filtering is required.
          if all((incl_billable, incl_nonbillable, incl_leave)):
              return basicQ
  
          # Filter by whether a project is billable or non-billable.
          billableQ = None
          if incl_billable and not incl_nonbillable:
              billableQ = Q(activity__billable=True, project__type__billable=True)
          if incl_nonbillable and not incl_billable:
              billableQ = Q(activity__billable=False) | Q(project__type__billable=False)
  
          # Filter by whether the entry is paid leave.
          leave_ids = utils.get_setting('TIMEPIECE_PAID_LEAVE_PROJECTS').values()
          leaveQ = Q(project__in=leave_ids)
          if incl_leave:
              extraQ = (leaveQ | billableQ) if billableQ else leaveQ
          else:
              extraQ = (~leaveQ & billableQ) if billableQ else ~leaveQ
  
          return basicQ & extraQ