Skip to content

Commit

Permalink
adding pay date to available options when creating batch
Browse files Browse the repository at this point in the history
  • Loading branch information
WalrusSoup committed Feb 5, 2021
1 parent 9a34aec commit d2a9d2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/PrismApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,16 +300,17 @@ public function approveTimesheetUpload(string $batchId, string $clientId, string
*
* @param \DateTimeInterface $startDate
* @param \DateTimeInterface $endDate
* @param \DateTimeInterface $payDate
* @param string $clientId the client(company) specified - example: 1111 for DEMO
* @param array $employeeIds the employee ID's eligible to be put into this batch
* @return string the ID of the batch created
* @throws Exceptions\ApiException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function createPayrollBatch(\DateTimeInterface $startDate, \DateTimeInterface $endDate, string $clientId, array $employeeIds)
public function createPayrollBatch(\DateTimeInterface $startDate, \DateTimeInterface $endDate, \DateTimeInterface $payDate, string $clientId, array $employeeIds)
{
$payrollService = new PayrollService($this->client);
return $payrollService->createBatch($startDate, $endDate, $clientId, $employeeIds);
return $payrollService->createBatch($startDate, $endDate, $payDate, $clientId, $employeeIds);
}

/**
Expand Down
10 changes: 6 additions & 4 deletions src/Services/PayrollService.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,14 @@ public function executeGetBatchInfo(string $clientId, string $batchId)
*
* @param \DateTimeInterface $startDate
* @param \DateTimeInterface $endDate
* @param \DateTimeInterface $payDate
* @param string $clientId
* @param array $employeeIds
* @return mixed
* @throws ApiException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function createBatch(\DateTimeInterface $startDate, \DateTimeInterface $endDate, string $clientId, array $employeeIds)
public function createBatch(\DateTimeInterface $startDate, \DateTimeInterface $endDate, \DateTimeInterface $payDate, string $clientId, array $employeeIds)
{
if(empty($clientId)) {
throw new \InvalidArgumentException('Client ID cannot be empty');
Expand All @@ -211,7 +212,7 @@ public function createBatch(\DateTimeInterface $startDate, \DateTimeInterface $e
$startDate = $startDate->format('Y-m-d');
$endDate = $endDate->format('Y-m-d');
try {
$response = $this->decodeRestResponse($this->executeCreateBatch($startDate, $endDate, $clientId, $employeeIds));
$response = $this->decodeRestResponse($this->executeCreateBatch($startDate, $endDate, $payDate, $clientId, $employeeIds));
return $response['batchNum'];
} catch (ClientException $exception) {
$response = $exception->getResponse();
Expand All @@ -233,12 +234,13 @@ public function createBatch(\DateTimeInterface $startDate, \DateTimeInterface $e
*
* @param $startDate
* @param $endDate
* @param $payDate
* @param $clientId
* @param $employeeIds
* @return \Psr\Http\Message\ResponseInterface
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function executeCreateBatch($startDate, $endDate, $clientId, $employeeIds)
public function executeCreateBatch($startDate, $endDate, $payDate, $clientId, $employeeIds)
{
$employeeData = [];
foreach($employeeIds as $employee) {
Expand All @@ -251,7 +253,7 @@ public function executeCreateBatch($startDate, $endDate, $clientId, $employeeIds
return $this->client->request('POST', 'payroll/createPayrollBatches', [
'json' => [
'clientId' => $clientId,
'payDate' => $endDate,
'payDate' => $payDate,
'batchType' => 'M',
'employee' => $employeeData
]
Expand Down

0 comments on commit d2a9d2f

Please sign in to comment.