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

Conversation

DulsaraNethmin
Copy link

No description provided.

@DulsaraNethmin DulsaraNethmin marked this pull request as ready for review April 3, 2023 03:38
@RajithaKumara RajithaKumara changed the base branch from 5.4 to 5.5 April 10, 2023 09:58
Comment on lines 66 to 79
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',
Copy link
Member

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';
Copy link
Member

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
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
* @param array $claimRequests
* @param ClaimRequest[] $claimRequests

🤔

Comment on lines +354 to +356
if (!$this->isSelfByEmpNumber($empNumber)) {
throw $this->getForbiddenException();
}
Copy link
Member

Choose a reason for hiding this comment

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

bit confusing

Comment on lines +390 to +401
$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
)
);
Copy link
Member

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
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
* @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")
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
* @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)) {
Copy link
Member

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
Copy link
Member

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"
Copy link
Member

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

@RajithaKumara RajithaKumara merged commit b9518be into orangehrm:5.5 Apr 10, 2023
RajithaKumara pushed a commit to RajithaKumara/orangehrm that referenced this pull request May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants