-
Notifications
You must be signed in to change notification settings - Fork 578
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
Conversation
src/plugins/orangehrmClaimPlugin/Api/EmployeeClaimRequestAPI.php
Outdated
Show resolved
Hide resolved
src/plugins/orangehrmClaimPlugin/Api/EmployeeClaimRequestAPI.php
Outdated
Show resolved
Hide resolved
src/plugins/orangehrmClaimPlugin/Api/Model/MyClaimRequestModel.php
Outdated
Show resolved
Hide resolved
src/plugins/orangehrmClaimPlugin/Api/Model/EmployeeClaimRequestModel.php
Show resolved
Hide resolved
src/plugins/orangehrmClaimPlugin/Api/Model/MyClaimRequestModel.php
Outdated
Show resolved
Hide resolved
public const PARAMETER_CLAIM_EVENT_ID = 'claimEventId'; | ||
public const PARAMETER_CURRENCY_ID = 'currencyId'; | ||
public const PARAMETER_REMARKS = 'remarks'; | ||
public const REMARKS_MAX_LENGTH = 1000; | ||
public const PARAMETER_ALLOWED_ACTIONS = 'allowedActions'; | ||
public const PARAMETER_EMPLOYEE_NUMBER = 'empNumber'; | ||
public const PARAMETER_REFERENCE_ID = 'referenceId'; | ||
public const PARAMETER_EVENT_ID = 'eventId'; | ||
public const PARAMETER_STATUS = 'status'; | ||
public const PARAMETER_FROM_DATE = 'fromDate'; | ||
public const PARAMETER_TO_DATE = 'toDate'; | ||
public const ACTIONABLE_STATES_MAP = [ | ||
WorkflowStateMachine::CLAIM_ACTION_SUBMIT => 'SUBMIT', | ||
WorkflowStateMachine::CLAIM_ACTION_APPROVE => 'APPROVE', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public const PARAMETER_CLAIM_EVENT_ID = 'claimEventId';
public const PARAMETER_CURRENCY_ID = 'currencyId';
public const PARAMETER_REMARKS = 'remarks';
public const PARAMETER_ALLOWED_ACTIONS = 'allowedActions';
public const PARAMETER_EMPLOYEE_NUMBER = 'empNumber';
public const PARAMETER_REFERENCE_ID = 'referenceId';
public const PARAMETER_EVENT_ID = 'eventId';
public const PARAMETER_STATUS = 'status';
public const PARAMETER_FROM_DATE = 'fromDate';
public const PARAMETER_TO_DATE = 'toDate';
public const REMARKS_MAX_LENGTH = 1000;
public const ACTIONABLE_STATES_MAP = [
WorkflowStateMachine::CLAIM_ACTION_SUBMIT => 'SUBMIT',
WorkflowStateMachine::CLAIM_ACTION_APPROVE => 'APPROVE',
WorkflowStateMachine::CLAIM_ACTION_PAY => 'PAY',
WorkflowStateMachine::CLAIM_ACTION_CANCEL => 'CANCEL',
WorkflowStateMachine::CLAIM_ACTION_REJECT => 'REJECT'
];
prefer if you can organize
@@ -56,13 +61,19 @@ class EmployeeClaimRequestAPI extends Endpoint implements CrudEndpoint | |||
use AuthUserTrait; | |||
use NormalizerServiceTrait; | |||
use UserRoleManagerTrait; | |||
use EmployeeServiceTrait; | |||
|
|||
public const PARAMETER_CLAIM_EVENT_ID = 'claimEventId'; | |||
public const PARAMETER_CURRENCY_ID = 'currencyId'; | |||
public const PARAMETER_REMARKS = 'remarks'; | |||
public const REMARKS_MAX_LENGTH = 1000; | |||
public const PARAMETER_ALLOWED_ACTIONS = 'allowedActions'; | |||
public const PARAMETER_EMPLOYEE_NUMBER = 'empNumber'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can use from common params
} | ||
|
||
/** | ||
* @param array $claimRequests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param array $claimRequests | |
* @param ClaimRequest[] $claimRequests |
🤔
if (!$this->isSelfByEmpNumber($empNumber)) { | ||
throw $this->getForbiddenException(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bit confusing
$claimRequestSearchFilterParams->setFromDate( | ||
$this->getRequestParams()->getDateTimeOrNull( | ||
RequestParams::PARAM_TYPE_QUERY, | ||
self::PARAMETER_FROM_DATE | ||
) | ||
); | ||
$claimRequestSearchFilterParams->setToDate( | ||
$this->getRequestParams()->getDateTimeOrNull( | ||
RequestParams::PARAM_TYPE_QUERY, | ||
self::PARAMETER_TO_DATE | ||
) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any idea to validate toDate > fromDate
} | ||
|
||
/** | ||
* @param array|null $empNumbers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param array|null $empNumbers | |
* @param int[]|null $empNumbers |
@@ -118,11 +113,11 @@ class ClaimRequest | |||
private DateTime $createdDate; | |||
|
|||
/** | |||
* @var DateTime | |||
* @var DateTime|null | |||
* | |||
* @ORM\Column(name="submitted_date", type="datetime") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @ORM\Column(name="submitted_date", type="datetime") | |
* @ORM\Column(name="submitted_date", type="datetime", nullable=true) |
$claimExpenseSearchFilterParams = new ClaimExpenseSearchFilterParams(); | ||
$claimExpenseSearchFilterParams->setRequestId($requestId); | ||
$totalExpense = $this->getClaimService()->getClaimDao()->getClaimExpenseTotal($claimExpenseSearchFilterParams); | ||
if (is_null($totalExpense)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this covered by unit tests?
/** | ||
* @return float | ||
*/ | ||
public function getTotalExpense(): float |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any other way to improve this. since if you have 50 items in API response then, this will call 50 times
"referenceId": "202301170000009", | ||
"claimEvent": { | ||
"id": 3, | ||
"name": "Travel Expenses" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to check whether we need claim event status
also in the response
No description provided.