Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OHRM5X-1959: Develop ClaimRequest getAll API #1656

Merged
merged 7 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
OHRM5X-1959: Soring from employee name added
  • Loading branch information
DulsaraNethmin committed Mar 29, 2023
commit 23c0f297cdcbeded797fc2af7dfa85bd02f53b82
25 changes: 15 additions & 10 deletions src/plugins/orangehrmClaimPlugin/Api/EmployeeClaimRequestAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ protected function setClaimRequest(ClaimRequest $claimRequest, int $empNumber):
* name="sortField",
* in="query",
* required=false,
* @OA\Schema(type="string", enum=ClaimRequestSearchFilterParams::ALLOWED_SORT_FIELDS)
* @OA\Schema(type="string", enum=EmployeeClaimRequestSearchFilterParams::ALLOWED_SORT_FIELDS)
DulsaraNethmin marked this conversation as resolved.
Show resolved Hide resolved
* ),
* @OA\Parameter(
* name="referenceId",
Expand Down Expand Up @@ -355,36 +355,36 @@ protected function setEmpNumbers(ClaimRequestSearchFilterParams $claimRequestSea
}

/**
* @param ClaimRequestSearchFilterParams $myClaimRequestSearchFilterParams
* @param ClaimRequestSearchFilterParams $claimRequestSearchFilterParams
* @return void
DulsaraNethmin marked this conversation as resolved.
Show resolved Hide resolved
*/
private function getCommonFilterParams(ClaimRequestSearchFilterParams $myClaimRequestSearchFilterParams): void
private function getCommonFilterParams(ClaimRequestSearchFilterParams $claimRequestSearchFilterParams): void
{
$myClaimRequestSearchFilterParams->setReferenceId(
$claimRequestSearchFilterParams->setReferenceId(
$this->getRequestParams()->getStringOrNull(
RequestParams::PARAM_TYPE_QUERY,
self::PARAMETER_REFERENCE_ID
)
);
$myClaimRequestSearchFilterParams->setEventId(
$claimRequestSearchFilterParams->setEventId(
$this->getRequestParams()->getIntOrNull(
RequestParams::PARAM_TYPE_QUERY,
self::PARAMETER_EVENT_ID
)
);
$myClaimRequestSearchFilterParams->setStatus(
$claimRequestSearchFilterParams->setStatus(
$this->getRequestParams()->getStringOrNull(
RequestParams::PARAM_TYPE_QUERY,
self::PARAMETER_STATUS
)
);
$myClaimRequestSearchFilterParams->setFromDate(
$claimRequestSearchFilterParams->setFromDate(
$this->getRequestParams()->getDateTimeOrNull(
RequestParams::PARAM_TYPE_QUERY,
self::PARAMETER_FROM_DATE
)
);
$myClaimRequestSearchFilterParams->setToDate(
$claimRequestSearchFilterParams->setToDate(
$this->getRequestParams()->getDateTimeOrNull(
RequestParams::PARAM_TYPE_QUERY,
self::PARAMETER_TO_DATE
Expand Down Expand Up @@ -427,8 +427,7 @@ protected function getCommonParamRuleCollectionGetAll(): ParamRuleCollection
self::PARAMETER_TO_DATE,
new Rule(Rules::DATE_TIME)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
new Rule(Rules::DATE_TIME)
new Rule(Rules::API_DATE)

)
),
...$this->getSortingAndPaginationParamsRules(ClaimRequestSearchFilterParams::ALLOWED_SORT_FIELDS)
)
);
}

Expand All @@ -446,6 +445,12 @@ public function getValidationRuleForGetAll(): ParamRuleCollection
)
)
);
$sortFieldParamRules = $this->getSortingAndPaginationParamsRules(
EmployeeClaimRequestSearchFilterParams::ALLOWED_SORT_FIELDS
);
foreach ($sortFieldParamRules as $sortFieldParamRule) {
$paramRuleCollection->addParamValidation($sortFieldParamRule);
}

return $paramRuleCollection;
}
Expand Down
10 changes: 9 additions & 1 deletion src/plugins/orangehrmClaimPlugin/Api/MyClaimRequestAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ protected function setEmpNumbers(ClaimRequestSearchFilterParams $claimRequestSea
*/
public function getValidationRuleForGetAll(): ParamRuleCollection
{
return $this->getCommonParamRuleCollectionGetAll();
$paramRuleCollection = $this->getCommonParamRuleCollectionGetAll();
$sortFieldParamRules = $this->getSortingAndPaginationParamsRules(
ClaimRequestSearchFilterParams::ALLOWED_SORT_FIELDS
);
foreach ($sortFieldParamRules as $sortFieldParamRule) {
$paramRuleCollection->addParamValidation($sortFieldParamRule);
}

return $paramRuleCollection;
}
}
2 changes: 2 additions & 0 deletions src/plugins/orangehrmClaimPlugin/Dao/ClaimDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ public function getClaimRequestList(ClaimRequestSearchFilterParams $myClaimReque
protected function getClaimRequestPaginator(ClaimRequestSearchFilterParams $myClaimRequestSearchFilterParams): Paginator
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
protected function getClaimRequestPaginator(ClaimRequestSearchFilterParams $myClaimRequestSearchFilterParams): Paginator
protected function getClaimRequestPaginator(ClaimRequestSearchFilterParams $claimRequestSearchFilterParams): Paginator

{
$q = $this->createQueryBuilder(ClaimRequest::class, 'claimRequest');
$q->leftJoin('claimRequest.claimEvent', 'claimEvent');
$q->leftJoin('claimRequest.employee', 'employee');
$this->setSortingAndPaginationParams($q, $myClaimRequestSearchFilterParams);

if (!is_null($myClaimRequestSearchFilterParams->getEmpNumbers())) {
Expand Down