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 #319 from kmcwebdev/development
Browse files Browse the repository at this point in the history
Add date range filter to getAllReimbursementRequest endpoint
  • Loading branch information
csulit authored Oct 9, 2023
2 parents e90e161 + dfa9412 commit f9bb0b2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/finance/common/dto/get-all-reimbursement-request.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ const GetAllReimbursementRequestSchema = z
(val) => (val === 'true' ? true : false),
z.boolean().default(false),
),
// TODO: Add message and description for this
from: z.string().datetime(),
to: z.string().datetime(),
})
.partial()
.refine(
Expand Down
8 changes: 8 additions & 0 deletions src/finance/services/reimbursement.get-all.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@ export class ReimbursementGetAllService {
);
}

if (filter?.from && filter?.to) {
const { from, to } = filter;

query = query.where(
sql`DATE(finance_reimbursement_requests.created_at) BETWEEN ${from} AND ${to}`,
);
}

return await query
.orderBy('finance_reimbursement_requests.created_at', 'desc')
.limit(default_page_limit || filter?.page_limit)
Expand Down

0 comments on commit f9bb0b2

Please sign in to comment.