Skip to main content

Timesheets v2

The import/timesheets endpoints allows you to import the timesheets properties.

Authorisation

A function key is required. The name of Key must match Software Key

Request format

Method and URL

The HTTP method and URL is as follows:

HTTP
POST https://payandbill-cloud-api.azurewebsites.net/api/import/timesheets?version=2

Request Headers

NameTypeDescription
headerX-Functions-KeyFunction Api Key
headerX-Software-KeySoftware Key for this Integration

Request Body

NameTypeDescription
bodyTimesheets[]Timesheets schema

Request Body Example

Example Request Body
[
{
"TimesheetNumber": "TS0001",
"EmployerRef": "ER1",
"PersonnelRef": "WORKER1",
"ClientRef": "CLIENT1",
"AssignmentRef": "ASSIGN1",
"DivisionRef": "DIV1",
"DepartmentRef": "DEPT1",
"JobLocation": "LOC1",
"TaxYear": 2021,
"TaxPeriod": 5,
"TimesheetDate": "2021-04-01T00:00:00",
"PurchaseOrderNumber": "PO1",
"InvoiceRef": "1",
"WorkLocation": "WorkLoc1",
"JobDescription": "Job 1",
"BookedBy": "Booked By",
"JobCategoryRef": "JC1",
"IsAdjustment": false,
"IsIgnoredByPayroll": false,
"CreditCode": "CR1",
"ConsultantRef": "CONS1",
"CostCentre": "CC1",
"ReportToClientRef": "CLIENT1",
"InvoiceToClientRef": "CLIENT1",
"InvoiceAddressNumber": 1,
"DeliveryAddressNumber": 1,
"SalesTaxArea": "UK",
"HolidayOverrideWeeks": 2.0,
"HolidayOverrideHourPerc": 10.0,
"NoOfDaysWorked": 5.0,
"IsReverseChargeVAT": false,
"Lines": [
{
"RateFrequency": "Hourly",
"RateCode": "BAS1",
"Description": "Line 1",
"Units": 5.0,
"PayRate": 5.0,
"PayAmount": 10.0,
"BillRate": 5.0,
"BillAmount": 10.0,
"IsWTDAccrued": false,
"VATCode": "S",
"IsAWRable": false,
"IsPensionable": false,
"VATCodeSource": "DefaultVATRate"
},
{
"RateFrequency": "Daily",
"RateCode": "BAS2",
"Description": "Line 2",
"Units": 5.0,
"PayRate": 5.0,
"PayAmount": 10.0,
"BillRate": 5.0,
"BillAmount": 10.0,
"IsWTDAccrued": false,
"VATCode": "S",
"IsAWRable": false,
"IsPensionable": false,
"VATCodeSource": "DefaultVATRate"
}
],
"AdHocLines": [
{
"InvoiceVATCodeSource": "SpecifiedVATRate",
"InvoiceVATCode": "S",
"IsPayment": true,
"IsTaxable": false,
"IsNIable": false,
"ReceiptOption": "None",
"RateCode": "AD1",
"Description": "AdHoc1",
"Units": 5.0,
"PayRate": 5.0,
"PayAmount": 10.0,
"BillRate": 5.0,
"BillAmount": 10.0,
"IsWTDAccrued": false,
"VATCode": "S",
"IsAWRable": false,
"IsPensionable": false,
"VATCodeSource": "DefaultVATRate"
},
{
"InvoiceVATCodeSource": "SpecifiedVATRate",
"InvoiceVATCode": "S",
"IsPayment": true,
"IsTaxable": false,
"IsNIable": false,
"ReceiptOption": "None",
"RateCode": "AD1",
"Description": "AdHoc2",
"Units": 5.0,
"PayRate": 5.0,
"PayAmount": 10.0,
"BillRate": 5.0,
"BillAmount": 10.0,
"IsWTDAccrued": false,
"VATCode": "S",
"IsAWRable": false,
"IsPensionable": false,
"VATCodeSource": "DefaultVATRate"
}
],
"ConsultantSplits": [
{
"ConsultantRef": "CON1",
"Split": 50.0
},
{
"ConsultantRef": "CON2",
"Split": 50.0
}
],
"ClientRequiredFields": [
{
"Code": "CRF1",
"AlphaValue": "Value1"
},
{
"Code": "CRF2",
"AlphaValue": "Value2"
}
]
}
]

Responses

NameTypeDescription
200 OkResults[]successful operation
400 Bad RequeststringInvalid Json request or Invalid DB Version
401 UnauthorizedstringInvalid/Missing API Key
403 ForbiddenstringKey name does not match Software Key
403 ForbiddenstringIntegration missing for Software Key or disabled
403 ForbiddenstringPay and Bill Database not active
501 Not ImplementedstringMessage Type not found/implemented
501 Not ImplementedstringPayload data not supported

Response Example

Example Response
{
"results": [
{
"recordIds": [
{
"field": "TimesheetNumber",
"value": "000005355"
}
],
"importStatus": "OK",
"errorCount": 0,
"warningCount": 0,
"infoCount": 0
}
]
}

400 Response

Response when Invalid Json Request Body is sent to API.

Message will contain parsing error message.

400 Error Response
{
"message": "<string>"
}

200 Response

A results array is returned which will include an item for each array item in the original request body.

Each item will identify the recordId's relevant for this message type.

Import Status, errorCount & warningCount will indicate the status of that row.

Messages will contain any error/warning messages relevant.

Note: Each row is treated as a separate commit to the database, so if multiple items are included in the import, the response will indicate which have been imported successfully & which have failed to import.

200 Ok Response
{  "results": [
{
"recordIds": [
"field": "<string>",
"value": "<string>"
],
"importStatus": "<string>",
"errorCount": <number>,
"warningCount": <number>,
"messages": [
{
"messageType": "<string>",
"message": "<string>",
"fieldName": "<string>"
}
]
}
]
}

Results

This is the response output from the import/timesheets endpoint

PropertyTypeDefined
RecordIdsrecordIds[]Timesheets Results
ImportStatusstringTimesheets Results
ErrorCountintegerTimesheets Results
WarningCountintegerTimesheets Results
InfoCountintegerTimesheets Results
Messagesmessages[]Timesheets Results

RecordIds

A record id of the imported Timesheets

RecordIds

  • Type: array
PropertyTypeDefined
FieldstringTimesheets Results
ValuestringTimesheets Results
Example
{
"recordIds": [
{
"field": "TimesheetNumber",
"value": "000005355"
}
]
}

ImportStatus

The import status of the request

ImportStatus

  • Type: string

  • defined in: Timesheets Results

ErrorCount

Number of errors in the request

ErrorCount

  • Type: integer

  • defined in: Timesheets Results

WarningCount

Number of warnings in the request

WarningCount

  • Type: integer

  • defined in: Timesheets Results

InfoCount

Number of Information messages in the request

InfoCount

  • Type: integer

  • defined in: Timesheets Results

Messages

An output of the info, warning or error messages.

Messages

  • Type: array
PropertyTypeDefined
MessageTypestringTimesheets Results
MessagestringTimesheets Results
FieldNamestringTimesheets Results
FieldValuestringTimesheets Results
ErrorIdintegerTimesheets Results
Example
{
"messages": [
{
"messageType": "Error",
"message": "Timesheet already exists in the system",
"fieldName": "TimesheetNumber",
"fieldValue": "000005354",
"errorID": 10000
}
]
}