Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #320 from kmcwebdev/development
Browse files Browse the repository at this point in the history
Add expense type filter to getAllReimbursementRequest endpoint
  • Loading branch information
csulit authored Oct 9, 2023
2 parents f9bb0b2 + 396bdc7 commit 82460d8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const GetAllReimbursementRequestSchema = z
z.boolean().default(false),
),
// TODO: Add message and description for this
expense_type_ids: z.string().nonempty(),
from: z.string().datetime(),
to: z.string().datetime(),
})
Expand Down
14 changes: 14 additions & 0 deletions src/finance/services/reimbursement.get-all.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,20 @@ export class ReimbursementGetAllService {
);
}

if (filter?.expense_type_ids) {
const expenseTypeIds = filter.expense_type_ids
.replace(/"/g, '')
.split(',');

// TODO: Do the check here if all items in array is a valid uuid

query = query.where(
'finance_reimbursement_requests.expense_type_id',
'in',
expenseTypeIds,
);
}

if (filter?.text_search) {
query = query.where(
sql`to_tsvector('english', finance_reimbursement_requests.reference_no || ' ' || coalesce(users.full_name, '') || ' ' || users.email || ' ' ||
Expand Down

0 comments on commit 82460d8

Please sign in to comment.