search billable
MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -755,6 +755,7 @@ export default class UserService {
roles: (filteredRequest.Role ? filteredRequest.Role.split('|') : null),
statuses: (filteredRequest.Status ? filteredRequest.Status.split('|') : null),
technical: Utils.isBoolean(filteredRequest.Technical) ? filteredRequest.Technical : null,
+ billable: Utils.isBoolean(filteredRequest.Billable) ? filteredRequest.Billable : null,
excludeSiteID: filteredRequest.ExcludeSiteID,
...authorizationUsersFilters.filters
},

MODIFY
src/storage/mongodb/UserStorage.ts
src/storage/mongodb/UserStorage.ts
@@ -571,7 +571,7 @@ export default class UserStorage {
notificationsActive?: boolean; siteIDs?: string[]; excludeSiteID?: string; search?: string;
userIDs?: string[]; email?: string; issuer?: boolean; passwordResetHash?: string; roles?: string[];
statuses?: string[]; withImage?: boolean; billingUserID?: string; notSynchronizedBillingData?: boolean;
- withTestBillingData?: boolean; notifications?: any; noLoginSince?: Date; technical?: boolean;
+ withTestBillingData?: boolean; notifications?: any; noLoginSince?: Date; technical?: boolean; billable?: boolean;
},
dbParams: DbParams, projectFields?: string[]): Promise<DataResult<User>> {
// Debug
@@ -685,6 +685,24 @@ export default class UserStorage {
}
}
}
+ // Select (non) billable users
+ if (Utils.objectHasProperty(params, 'billable') && Utils.isBoolean(params.billable)) {
+ if (params.billable) {
+ filters.billable = true;
+ } else {
+ const billableFilter = {
+ $or: [
+ { billable: { $in: [false, null] } },
+ { billable: { $exists: false } }
+ ]
+ };
+ if (filters.$and) {
+ filters.$and.push(billableFilter);
+ } else {
+ filters.$and = [ billableFilter ];
+ }
+ }
+ }
// Add filters
aggregation.push({
$match: filters

MODIFY
src/types/requests/HttpUserRequest.ts
src/types/requests/HttpUserRequest.ts
@@ -39,6 +39,7 @@ export interface HttpUsersRequest extends HttpDatabaseRequest {
Role: string;
Status: string;
Technical?: boolean;
+ Billable?: boolean;
ErrorType?: string;
VisualTagID?: string;
ExcludeSiteID: string;

search billable