InTime provides a SOAP Web Service Interface that allows two-way flow of information to external systems. This enables automated and efficient transfer of data to and from your other systems reducing effort and duplication.
...
try { //Create an instance of the stub IntimeServiceV2_0Stub stub = new IntimeServiceV2_0Stub("https://demo.in-time.co.uk/services/IntimeServiceV2_0?wsdl"); //Get an authentication token IntimeServiceV2_0Stub.Authenticate auth=new IntimeServiceV2_0Stub.Authenticate(); auth.setAgencyRefCode("<supplied_credentials>"); auth.setUsername("<supplied_credentials>"); auth.setPassword("<supplied_credentials>"); IntimeServiceV2_0Stub.AuthenticateResponse authResp=stub.authenticate(auth); String ticket=authResp.get_return(); System.out.println("Authentication token:" + ticket); //Use this authentication token (ticket) to pass in to any of the other WebService calls } catch (java.lang.Exception e) { System.out.println("Exception occurred: " + e); } |
---|
...
Read a
...
Placement
try { IntimeServiceV2_0Stub. |
---|
GetPlacementByExternalId request=new IntimeServiceV2_0Stub. |
---|
GetPlacementByExternalId(); |
---|
request. |
---|
setId(" |
---|
WEB-PLC-001"); |
---|
request. |
---|
setToken( |
---|
ticket); |
---|
try{
IntimeServiceV2_0Stub.Placement placement = new IntimeServiceV2_0Stub.Placement();
IntimeServiceV2_0Stub.Worker worker = new IntimeServiceV2_0Stub.Worker();
worker.setExternalId("WKR_LTD_001");
worker.setEmail("x@x.com");
worker.setFirstname("Ltd");
worker.setLastname("Worker");
placement.setWorker(worker);
IntimeServiceV2_0Stub.Consultant consultant = new IntimeServiceV2_0Stub.Consultant();
consultant.setExternalId("CONS_001");
consultant.setEmail("y@y.com");
consultant.setFirstname("Web");
consultant.setLastname("Consultant");
placement.setConsultant(consultant);
IntimeServiceV2_0Stub.Client client = new IntimeServiceV2_0Stub.Client();
client.setExternalId("CLIENT_001");
client.setName("Web Client 001");
client.setTermsTemplateName("Default Charge Terms");
placement.setClient(client);
IntimeServiceV2_0Stub.Manager manager = new IntimeServiceV2_0Stub.Manager();
manager.setExternalId("MGR_001");
manager.setEmail("z@z.com");
manager.setFirstname("Web");
manager.setLastname("Manager");
manager.setClientExternalId("CLIENT_001");
placement.setManager(manager);
placement.setExternalId("WEB-PLC-001");
placement.setContractedHours(new BigDecimal(37.5));
placement.setCurrencyForCharge("GBP");
placement.setCurrencyForPayExpenses("GBP");
placement.setCurrencyForPayTimesheets("GBP");
placement.setChargeableExpenseApprovalRoute("Client Manager Approval");
placement.setNonChargeableExpenseApprovalRoute("Auto Approval");
placement.setTimesheetApprovalRoute("Auto Approval");
placement.setExpenseTemplate("Default");
placement.setHolidayAccuralRate(0.12);
placement.setJobDescription("Web Placement 1");
placement.setJobTitle("Web Test 001");
placement.setNoCommunications("");
placement.setPurchaseOrderNum("po_num");
placement.setSalesCostCentre("scc");
placement.setTimesheetDateCalculatorName("weekly");
placement.setPerm(false);
Calendar cal1 = Calendar.getInstance(java.util.TimeZone.getTimeZone("GMT"));
cal1.set(2017, 3, 1, 0, 0, 0);
placement.setStart(cal1);
Calendar cal2 = Calendar.getInstance(java.util.TimeZone.getTimeZone("GMT"));
cal2.set(2019, 3, 1, 0, 0, 0);
placement.setEnd(cal2);
IntimeServiceV2_0Stub.Rate[] rates = new IntimeServiceV2_0Stub.Rate[1];
IntimeServiceV2_0Stub.Rate rate1 = new IntimeServiceV2_0Stub.Rate();
rate1.setName("Standard Hours");
rate1.setPay(new BigDecimal(9.99));
rate1.setCharge(new BigDecimal(11.11));
rate1.setPayElementCode("001");
rate1.setPeriod("Hourly");
rate1.setPeriodDuration(60);
rate1.setPriorityOrder(0);
rate1.setTimePattern("DEFAULT");
rate1.setTimesheetFields("START_FINISH_BREAK");
rate1.setSelectableByWorkers(true);
rates[0] = rate1;
placement.setRates(rates);
IntimeServiceV2_0Stub.CreateOrUpdatePlacement request = new IntimeServiceV2_0Stub.CreateOrUpdatePlacement(//from authenticate call GetPlacementByExternalIdResponse placementResponse=stub.getPlacementByExternalId(request); |
---|
worker.setEmail("x@x.com");
worker.setTitle("Mrs");
worker.setWorkerType("ltd");
worker.setGender("F");
worker.setSelfBilling(false);
worker.setAccountsReference("ACC_REF");
worker.setPaymentFrequency("Monthly");
String[] wConsolidation = new String[] { "destination","source","pay-currency","purchase-tax-code","worker","placement" };
worker.setConsolidation(wConsolidation);
String[] wCrouping = new String[] { "sheet","sheet-rate" };
worker.setGrouping(wCrouping);
Calendar cal = Calendar.getInstance(java.util.TimeZone.getTimeZone("GMT"));
cal.set(1980, 0, 1, 0, 0, 0);
cal.set(Calendar.MILLISECOND, 0);
worker.setDateOfBirth(cal);
Calendar cal2 = Calendar.getInstance(java.util.TimeZone.getTimeZone("GMT"));
cal2.set(2017, 0, 1, 0, 0, 0);
cal2.set(Calendar.MILLISECOND, 0);
worker.setDateOfJoining(cal2);
IntimeServiceV2_0Stub.Address address = new IntimeServiceV2_0Stub.Address();
address.setLine1("Address1");
address.setLine2("Add2");
address.setTown("Town");
address.setCounty("County");
address.setCountry("UK");
address.setPostcode("AB1 2CD");
address.setCountryCode("GB");
worker.setAddress(address);
BankAccount bank = new BankAccount();
bank.setAccountName("Ltd Wkr");
bank.setAccountNumber("12345678");
bank.setBank("bank");
bank.setSortCode("11-22-33");
worker.setBankAccount(bank);
Company ltdCompany = new Company();
ltdCompany.setName("Ltd Co Name");
ltdCompany.setCompanyNo("123456789");
ltdCompany.setCompanyVatNo("1234567890");
ltdCompany.setVatCode("T0");
worker.setLimitedCompany(ltdCompany);
IntimeServiceV2_0Stub.CreateOrUpdateWorker request = new IntimeServiceV2_0Stub.CreateOrUpdateWorker();
request.setToken(ticket);
request.setWorker(worker);
IntimeServiceV2_0Stub.CreateOrUpdateWorkerResponse result=stub.createOrUpdateWorker(request);
if (result != null) {
System.out.println("Created/updated Worker with ID:" + result.get_return());
}
} catch (java.lang.Exception e) {
System.out.println("Exception occurred: " + e);
}
Create or update a Placement
Placement placement=placementResponse.get_return(); if (placement != null) { System.out.println("Read Placement with External Id: " + placement.getExternalId() + " Internal Id: " + placement.getId()); System.out.println("RefCode: " + placement.getRefCode()); System.out.println("Worker:" + placement.getWorker().getExternalId() + " " + placement.getWorker().getLastname()); System.out.println("Consultant: " + placement.getConsultant().getExternalId() + " " + placement.getConsultant().getLastname()); System.out.println("Manager: " + placement.getManager().getExternalId() + " " + placement.getManager().getLastname()); System.out.println("Client: " + placement.getClient().getExternalId() + " " + placement.getClient().getName()); System.out.println("Start: " + placement.getStart().getTime()); if (placement.getEnd() != null) { System.out.println("End: " + placement.getEnd().getTime()); } System.out.println("Created: " + placement.getCreated().getTime()); System.out.println("Modified: " + placement.getModified().getTime()); System.out.println("TimesheetDateCalculatorName: " + placement.getTimesheetDateCalculatorName()); System.out.println("Timesheeet Approval Route: " + placement.getTimesheetApprovalRoute()); System.out.println("Chargeable Expense Approval Route: " + placement.getChargeableExpenseApprovalRoute()); System.out.println("Non-Chargeable Expense Approval Route: " + placement.getNonChargeableExpenseApprovalRoute()); System.out.println("ContractedHours: " + placement.getContractedHours()); System.out.println("JobDescription :" + placement.getJobDescription()); System.out.println("JobTitle: " + placement.getJobTitle()); System.out.println("NoCommunications: " + placement.getNoCommunications()); System.out.println("PurchaseOrderNum: " + placement.getPurchaseOrderNum()); System.out.println("SalesProject: " + placement.getSalesProject()); System.out.println("PurchaseBranch: " + placement.getPurchaseBranch()); System.out.println("CurrencyForCharge: " + placement.getCurrencyForCharge()); System.out.println("CurrencyForPayExpenses: " + placement.getCurrencyForPayExpenses()); System.out.println("CurrencyForPayTimesheets: " + placement.getCurrencyForPayTimesheets()); System.out.println("Perm: " + placement.getPerm()); System.out.println("TimesheetEmailApproval: " + placement.getTimesheetEmailApproval()); System.out.println("Timesheet layout: " + placement.getLayout()); System.out.println("Internal Agency Comments: " + placement.getInternalAgencyComments()); System.out.println("Holiday Accural Rate: " + placement.getHolidayAccuralRate()); System.out.println("Expenses Template: " + placement.getExpenseTemplate()); System.out.println("Charge Tax Code Override: " + placement.getChargeTaxCodeOverride()); System.out.println("Self Bill Tax Code Override: " + placement.getSelfBillTaxCodeOverride()); System.out.println("PAYEDeductionsOnLtd: " + placement.getPAYEDeductionsOnLtd()); if (placement.getInvoiceContactOverride() != null) { Contact contact = placement.getInvoiceContactOverride(); Address address = contact.getAddress(); System.out.println("Placement charge invoice contact override: "); System.out.println(" Firstname: " + contact.getFirstname()); System.out.println(" Lastname: " + contact.getLastname()); System.out.println(" Email: " + contact.getEmail()); System.out.println(" Phone: " + contact.getPhone()); System.out.println(" Fax: " + contact.getFax()); System.out.println(" Mobile: " + contact.getMobile()); System.out.println("Address:"); System.out.println(" Line 1:" + address.getLine1()); System.out.println(" Line 2:" + address.getLine2()); System.out.println(" Town:" + address.getTown()); System.out.println(" County:" + address.getCounty()); System.out.println(" Postcode: " + address.getPostcode()); System.out.println(" Country:" + address.getCountry()); System.out.println(" Country Code:" + address.getCountryCode()); } if (placement.getRates() != null) { for (Rate rate : placement.getRates()) { System.out.println("Rate Name:" + rate.getName()); System.out.println("Pay:" + rate.getPay()); System.out.println("Charge:" + rate.getCharge()); System.out.println("Priority:" + rate.getPriorityOrder()); System.out.println("ID:" + rate.getId()); System.out.println("Period:" + rate.getPeriod()); System.out.println("PeriodDuration:" + rate.getPeriodDuration()); System.out.println("SelectableByWorkers:" + rate.getSelectableByWorkers()); System.out.println("TimePattern:" + rate.getTimePattern()); System.out.println("TimesheetFields:" + rate.getTimesheetFields()); System.out.println("PayElementCode:" + rate.getPayElementCode()); System.out.println("Payable:" + rate.getPayable()); System.out.println("Chargeable:" + rate.getChargeable()); System.out.println("Taxable:" + rate.getTaxable()); System.out.println("RefCode:" + rate.getRefCode()); } } if (placement.getSplitCommissions() != null) { for (SplitCommission split : placement.getSplitCommissions()) { System.out.println("\nCommission UserID:"+split.getUserId()+" Percentage:"+split.getWeight()); } } if (placement.getAlternativeManagers() != null) { for (User altMan : placement.getAlternativeManagers()) { System.out.println("Alternative Manager:" + altMan.getFirstname() + " " + altMan.getLastname()); System.out.println("External Id: " + altMan.getExternalId() + " Internal ID:" + altMan.getId()); } } } } catch (java.lang.Exception e) { System.out.println("Exception occurred: " + e); } |
---|
Read a Timesheet including any invoices
try { IntimeServiceV2_0Stub.GetTimesheetById request=new IntimeServiceV2_0Stub.GetTimesheetById(); request.setId(<timesheet_id>); request.setToken(ticket); //from authenticate call GetTimesheetByIdResponse timesheetResp=stub.getTimesheetById(request |
---|
); Timesheet timesheet = timesheetResp.get_return(); |
---|
IntimeServiceV2_0Stub.CreateOrUpdatePlacementResponse result=stub.createOrUpdatePlacement(request);
System.out.println("Read Timesheet ID:" + timesheet.getId()); System.out.println("Status:" + timesheet.getStatus()); System.out.println(" |
---|
Placement |
---|
:" + |
---|
timesheet. |
---|
getPlacementId()); |
---|
}
} catch (java.lang.Exception e) {
if (timesheet.getPeriodEndDate() != null) System.out.println(" |
---|
End Date:" + |
---|
try {
IntimeServiceV2_0Stub.GetPlacementByExternalId request=new IntimeServiceV2_0Stub.GetPlacementByExternalId();
request.setId("WEB-PLC-001");
request.setToken(ticket);
GetPlacementByExternalIdResponse placementResponse=stub.getPlacementByExternalId(request);
Placement placement=placementResponse.get_return();
if (placement != null) {
timesheet.getPeriodEndDate()); |
---|
}
Read a Placement
if (timesheet.getCreated() != null) System.out.println("Created:" + timesheet.getCreated().getTime()); if (timesheet.getModified() != null) System.out.println(" |
---|
Modified:" + |
---|
timesheet. |
---|
getModified() |
---|
.getTime()); if (timesheet.getSubmitted() != null) System.out.println(" |
---|
Submitted:" + |
---|
timesheet.getSubmitted().getTime()); |
---|
if (timesheet.getApproved() != null) System.out.println(" |
---|
Approved:" + |
---|
timesheet. |
---|
getApproved(). |
---|
getTime()); System.out.println(" |
---|
timesheetPay: " + |
---|
timesheet. |
---|
getTimesheetPay() |
---|
); System.out.println("timesheetCharge: " + timesheet.getTimesheetCharge()); System.out.println(" |
---|
ERNI: " + |
---|
timesheet. |
---|
getErni()); System.out. |
---|
println( |
---|
"Pension: " + |
---|
timesheet. |
---|
getPension() |
---|
) |
---|
; System.out.println(" |
---|
Holiday: " + |
---|
timesheet. |
---|
getHoliday() |
---|
) |
---|
; System.out.println(" |
---|
getFullyInvoiced: " + |
---|
timesheet. |
---|
getFullyInvoiced() |
---|
) |
---|
; |
---|
System.out.println("getPurchaseWrittenOff: " + timesheet.getPurchaseWrittenOff()); System.out.println(" |
---|
getSalesWrittenOff: " + |
---|
timesheet.getSalesWrittenOff()); |
---|
}
System.out.println(" |
---|
Worker:" + |
---|
timesheet.getWorkerId()); System.out.println(" |
---|
Adjusts:" + timesheet.getAdjustsRefCode()); //Shifts if (timesheet.getShifts() != null && timesheet.getShifts().length > 0) { for (Shift shift : timesheet.getShifts()) { System.out.println(" |
---|
Shift ID:"+ |
---|
shift. |
---|
getId()); System.out.println(" |
---|
hours:"+ |
---|
shift. |
---|
getHours()); System.out.println(" |
---|
Decimal:"+ |
---|
shift. |
---|
getDecimal()); System.out.println(" |
---|
Day:" + |
---|
new Date(shift.getDay()) |
---|
+ " (" + |
---|
shift.getDay()+ ")"); System.out.println(" |
---|
PO:" + |
---|
shift. |
---|
getPurchaseOrderNumber()); System.out.println(" |
---|
Start:"+ |
---|
new Date(shift.getStartTime()) |
---|
+" (" |
---|
+ |
---|
shift. |
---|
getStartTime()+ ")"); System.out.println(" |
---|
Rate Name:"+ |
---|
shift. |
---|
getRateName()); System.out.println(" |
---|
Rate Pay:"+ |
---|
shift.getRate().getPay()); System.out.println(" |
---|
Rate Charge:"+ |
---|
shift.getRate().getCharge()); |
---|
System.out.println("CurrencyForPayExpenses: " + placement.getCurrencyForPayExpenses());
System.out.println("CurrencyForPayTimesheets: " + placement.getCurrencyForPayTimesheets());} } //Associated Invoices & credits if (timesheet.getInvoiceInfo() != null) { for (InvoiceInfo invoice : timesheet.getInvoiceInfo()){ System.out.println(" |
---|
Invoice Number:" + |
---|
invoice. |
---|
getInvoiceNumber()); System.out.println(" |
---|
Invoice date:" + |
---|
invoice. |
---|
getInvoiceDate() |
---|
.getTime()); System.out.println(" |
---|
Invoice Type:" + |
---|
invoice. |
---|
getInvoiceDescription()); System.out.println(" |
---|
Invoice GUID:" + |
---|
invoice. |
---|
getInvoiceGUID()); System.out.println(" |
---|
Invoice Net:" + |
---|
invoice. |
---|
getNet()); System.out.println(" |
---|
Invoice Gross:" + |
---|
invoice. |
---|
getGross()); System.out.println(" |
---|
Invoice VAT:" + |
---|
invoice. |
---|
getVat()); System.out.println(" |
---|
Invoice Currency:" + |
---|
invoice. |
---|
getCurrency()); if ( |
---|
invoice. |
---|
getExported() != null) { |
---|
Contact contact = placement.getInvoiceContactOverride();
Address address = contact.getAddress();System.out.println(" |
---|
Exported date:" + invoice.getExported().getTime()); } } } } catch (Exception e) { System.out.println(" |
---|
Exception occurred: " + |
---|
System.out.println(" Email: " + contact.getEmail());
System.out.println(" Phone: " + contact.getPhone());
System.out.println(" Fax: " + contact.getFax());
System.out.println(" Mobile: " + contact.getMobile());
System.out.println("Address:");
System.out.println(" Line 1:" + address.getLine1());
System.out.println(" Line 2:" + address.getLine2());
System.out.println(" Town:" + address.getTown());
System.out.println(" County:" + address.getCounty());
System.out.println(" Postcode: " + address.getPostcode());
System.out.println(" Country:" + address.getCountry());
System.out.println(" Country Code:" + address.getCountryCode());
}
if (placement.getRates() != null) {
for (Rate rate : placement.getRates()) {
System.out.println("Rate Name:" + rate.getName());
System.out.println("Pay:" + rate.getPay());
System.out.println("Charge:" + rate.getCharge());
System.out.println("Priority:" + rate.getPriorityOrder());
System.out.println("ID:" + rate.getId());
System.out.println("Period:" + rate.getPeriod());
System.out.println("PeriodDuration:" + rate.getPeriodDuration());
System.out.println("SelectableByWorkers:" + rate.getSelectableByWorkers());
System.out.println("TimePattern:" + rate.getTimePattern());
System.out.println("TimesheetFields:" + rate.getTimesheetFields());
System.out.println("PayElementCode:" + rate.getPayElementCode());
System.out.println("Payable:" + rate.getPayable());
System.out.println("Chargeable:" + rate.getChargeable());
System.out.println("Taxable:" + rate.getTaxable());
System.out.println("RefCode:" + rate.getRefCode());
}
}
if (placement.getSplitCommissions() != null) {
for (SplitCommission split : placement.getSplitCommissions()) {
System.out.println("\nCommission UserID:"+split.getUserId()+" Percentage:"+split.getWeight());
}
}
if (placement.getAlternativeManagers() != null) {
for (User altMan : placement.getAlternativeManagers()) {
System.out.println("Alternative Manager:" + altMan.getFirstname() + " " + altMan.getLastname());
System.out.println("External Id: " + altMan.getExternalId() + " Internal ID:" + altMan.getId());
}
}
}
} catch (java.lang.Exception e) {
System.out.println("Exception occurred: " + e);
}
Create or update a Timesheet
try{
//Read the associated placement so we can reference the rates & participants
IntimeServiceV2_0Stub.GetPlacementByExternalId getPlacementRequest=new IntimeServiceV2_0Stub.GetPlacementByExternalId();
getPlacementRequest.setId("WEB-PLC-001");
getPlacementRequest.setToken(ticket);
GetPlacementByExternalIdResponse placementResponse=stub.getPlacementByExternalId(getPlacementRequest);
Placement placement=placementResponse.get_return();
//identify the required rate
Rate rate1 = null;
for (Rate rate : placement.getRates()) {
if (rate.getName().equals("Standard Hours")) {
rate1 = rate;
}
}
Calendar cal = Calendar.getInstance(java.util.TimeZone.getTimeZone("GMT"));
cal.set(2017,9,1,0,0,0);
cal.set(Calendar.MILLISECOND, 0);
//create a timesheetSubmission
IntimeServiceV2_0Stub.Timesheet timesheetSubmission = new IntimeServiceV2_0Stub.Timesheet();
timesheetSubmission.setPlacementExternalRef(placement.getExternalId());
timesheetSubmission.setSubmitterId(placement.getWorker().getId()); //Whoever is creating the Timesheet
timesheetSubmission.setPeriodEndDate(cal.getTime());
//Add the Shifts
IntimeServiceV2_0Stub.Shift shift = new IntimeServiceV2_0Stub.Shift();
shift.setComment("Shift 1 comment");
shift.setDay(cal.getTimeInMillis()); //set the day the shift relates to
shift.setRateId(rate1.getId());
if (rate1.getTimesheetFields().equals("START_FINISH_BREAK")) {
//This rate requires start, finish and break times entered for the shift
Calendar calStart = Calendar.getInstance(java.util.TimeZone.getTimeZone("GMT"));
calStart.set(2017,9,1,0,0,0);
calStart.set(Calendar.MILLISECOND, 0);
calStart.set(Calendar.HOUR_OF_DAY, 8);
shift.setStartTime(calStart.getTimeInMillis());
Calendar calEnd = Calendar.getInstance(java.util.TimeZone.getTimeZone("GMT"));
calEnd.set(2017,9,1,0,0,0);
calStart.set(Calendar.MILLISECOND, 0);
calEnd.set(Calendar.HOUR_OF_DAY, 17);
shift.setFinishTime(calEnd.getTimeInMillis());
shift.setMealBreak(3600000L); //1 hour in milliseconds
} else if (rate1.getTimesheetFields().equals("HOURS")) {
shift.setHours(8 * 60 * 60 * 1000L);
} else if (rate1.getTimesheetFields().equals("DECIMAL")) {
shift.setDecimal(new BigDecimal(1));
} else if (rate1.getTimesheetFields().equals("DAY")) {
shift.setDecimal(new BigDecimal(1));
}
Shift[] shifts = new Shift[1];
shifts[0] = shift;
timesheetSubmission.setShifts(shifts);
IntimeServiceV2_0Stub.UpdateTimesheet updateTimesheetRequest=new IntimeServiceV2_0Stub.UpdateTimesheet();
updateTimesheetRequest.setToken(ticket);
updateTimesheetRequest.setTimesheet(timesheetSubmission);
UpdateTimesheetResponse updateTimesheetResponse=stub.updateTimesheet(updateTimesheetRequest);
Long timesheetId=updateTimesheetResponse.get_return();
System.out.println("Update Timesheet returned:"+timesheetId);
} catch (Exception e) {
System.out.println("Exception occurred: " + e);
}
Submit a Timesheet
...
try {
IntimeServiceV2_0Stub.SubmitTimesheet submitTimesheetRequest=new IntimeServiceV2_0Stub.SubmitTimesheet();
submitTimesheetRequest.setToken(ticket);
submitTimesheetRequest.setTimesheetId(<timesheet_id>);
SubmitTimesheetResponse submitTimesheetResponse=stub.submitTimesheet(submitTimesheetRequest);
System.out.println("Submit Timesheet returned: "+submitTimesheetResponse.get_return());
} catch (Exception e) {
System.out.println("Exception occurred: " + e);
}
Read a Timesheet including invoices
try {
IntimeServiceV2_0Stub.GetTimesheetById request=new IntimeServiceV2_0Stub.GetTimesheetById();
request.setId(<timesheet_id>);
request.setToken(ticket);
GetTimesheetByIdResponse timesheetResp=stub.getTimesheetById(request);
Timesheet timesheet = timesheetResp.get_return();
System.out.println("Read Timesheet ID:" + timesheet.getId());
System.out.println("Status:" + timesheet.getStatus());
System.out.println("Placement:" + timesheet.getPlacementId());
if (timesheet.getPeriodEndDate() != null) System.out.println("End Date:" + timesheet.getPeriodEndDate());
if (timesheet.getCreated() != null) System.out.println("Created:" + timesheet.getCreated().getTime());
if (timesheet.getModified() != null) System.out.println("Modified:" + timesheet.getModified().getTime());
if (timesheet.getSubmitted() != null) System.out.println("Submitted:" + timesheet.getSubmitted().getTime());
if (timesheet.getApproved() != null) System.out.println("Approved:" + timesheet.getApproved().getTime());
System.out.println("timesheetPay: " + timesheet.getTimesheetPay());
System.out.println("timesheetCharge: " + timesheet.getTimesheetCharge());
System.out.println("ERNI: " + timesheet.getErni());
System.out.println("Pension: " + timesheet.getPension());
System.out.println("Holiday: " + timesheet.getHoliday());
System.out.println("getFullyInvoiced: " + timesheet.getFullyInvoiced());
System.out.println("getPurchaseWrittenOff: " + timesheet.getPurchaseWrittenOff());
System.out.println("getSalesWrittenOff: " + timesheet.getSalesWrittenOff());
System.out.println("Worker:" + timesheet.getWorkerId());
System.out.println("Adjusts:" + timesheet.getAdjustsRefCode());
//Shifts
if (timesheet.getShifts() != null && timesheet.getShifts().length > 0) {
for (Shift shift : timesheet.getShifts()) {
System.out.println("Shift ID:"+shift.getId());
System.out.println("hours:"+shift.getHours());
System.out.println("Decimal:"+shift.getDecimal());
System.out.println("Day:" + new Date(shift.getDay()) + " (" + shift.getDay()+ ")");
System.out.println("PO:" + shift.getPurchaseOrderNumber());
System.out.println("Start:"+new Date(shift.getStartTime()) +" (" + shift.getStartTime()+ ")");
System.out.println("Rate Name:"+shift.getRateName());
System.out.println("Rate Pay:"+shift.getRate().getPay());
System.out.println("Rate Charge:"+shift.getRate().getCharge());
}
}
//Associated Invoices & credits
if (timesheet.getInvoiceInfo() != null) {
for (InvoiceInfo invoice : timesheet.getInvoiceInfo()){
System.out.println("Invoice Number:" + invoice.getInvoiceNumber());
System.out.println("Invoice date:" + invoice.getInvoiceDate().getTime());
System.out.println("Invoice Type:" + invoice.getInvoiceDescription());
System.out.println("Invoice GUID:" + invoice.getInvoiceGUID());
System.out.println("Invoice Net:" + invoice.getNet());
System.out.println("Invoice Gross:" + invoice.getGross());
System.out.println("Invoice VAT:" + invoice.getVat());
System.out.println("Invoice Currency:" + invoice.getCurrency());
if (invoice.getExported() != null) {
System.out.println("Exported date:" + invoice.getExported().getTime());
}
}
}e); } |
---|
Create or update a Worker
try { //Attempt to read the worker first as it may already exist IntimeServiceV2_0Stub.GetWorkerByExternalId getWorkerRequest=new IntimeServiceV2_0Stub.GetWorkerByExternalId(); getWorkerRequest.setId("WEB-WKR01"); getWorkerRequest.setToken(ticket); //from authenticate call GetWorkerByExternalIdResponse workerResponse=stub.getWorkerByExternalId(getWorkerRequest); Worker worker=workerResponse.get_return(); if (worker == null) { //Worker did not exist worker.setExternalId("WEB-WKR01"); } //set or update any fields as required worker.setFirstname("Ltd"); worker.setLastname("Worker"); worker.setEmail("x@x.com"); worker.setTitle("Mrs"); worker.setWorkerType("ltd"); worker.setGender("F"); worker.setSelfBilling(false); worker.setAccountsReference("ACC_REF"); worker.setPaymentFrequency("Monthly"); String[] wConsolidation = new String[] { "destination","source","pay-currency","purchase-tax-code","worker","placement" }; worker.setConsolidation(wConsolidation); String[] wCrouping = new String[] { "sheet","sheet-rate" }; worker.setGrouping(wCrouping); Calendar cal = Calendar.getInstance(java.util.TimeZone.getTimeZone("GMT")); cal.set(1980, 0, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); worker.setDateOfBirth(cal); Calendar cal2 = Calendar.getInstance(java.util.TimeZone.getTimeZone("GMT")); cal2.set(2017, 0, 1, 0, 0, 0); cal2.set(Calendar.MILLISECOND, 0); worker.setDateOfJoining(cal2); IntimeServiceV2_0Stub.Address address = new IntimeServiceV2_0Stub.Address(); address.setLine1("Address1"); address.setLine2("Add2"); address.setTown("Town"); address.setCounty("County"); address.setCountry("UK"); address.setPostcode("AB1 2CD"); address.setCountryCode("GB"); worker.setAddress(address); BankAccount bank = new BankAccount(); bank.setAccountName("Ltd Wkr"); bank.setAccountNumber("12345678"); bank.setBank("bank"); bank.setSortCode("11-22-33"); worker.setBankAccount(bank); Company ltdCompany = new Company(); ltdCompany.setName("Ltd Co Name"); ltdCompany.setCompanyNo("123456789"); ltdCompany.setCompanyVatNo("1234567890"); ltdCompany.setVatCode("T0"); worker.setLimitedCompany(ltdCompany); IntimeServiceV2_0Stub.CreateOrUpdateWorker request = new IntimeServiceV2_0Stub.CreateOrUpdateWorker(); request.setToken(ticket); //from authenticate call request.setWorker(worker); IntimeServiceV2_0Stub.CreateOrUpdateWorkerResponse result=stub.createOrUpdateWorker(request); if (result != null) { System.out.println("Created/updated Worker with ID:" + result.get_return()); } } catch (java.lang.Exception e) { System.out.println("Exception occurred: " + e); } |
---|
Create or update a Placement
try{ IntimeServiceV2_0Stub.Placement placement = new IntimeServiceV2_0Stub.Placement(); IntimeServiceV2_0Stub.Worker worker = new IntimeServiceV2_0Stub.Worker(); worker.setExternalId("WKR_LTD_001"); worker.setEmail("x@x.com"); worker.setFirstname("Ltd"); worker.setLastname("Worker"); placement.setWorker(worker); IntimeServiceV2_0Stub.Consultant consultant = new IntimeServiceV2_0Stub.Consultant(); consultant.setExternalId("CONS_001"); consultant.setEmail("y@y.com"); consultant.setFirstname("Web"); consultant.setLastname("Consultant"); placement.setConsultant(consultant); IntimeServiceV2_0Stub.Client client = new IntimeServiceV2_0Stub.Client(); client.setExternalId("CLIENT_001"); client.setName("Web Client 001"); client.setTermsTemplateName("Default Charge Terms"); placement.setClient(client); IntimeServiceV2_0Stub.Manager manager = new IntimeServiceV2_0Stub.Manager(); manager.setExternalId("MGR_001"); manager.setEmail("z@z.com"); manager.setFirstname("Web"); manager.setLastname("Manager"); manager.setClientExternalId("CLIENT_001"); placement.setManager(manager); placement.setExternalId("WEB-PLC-001"); placement.setContractedHours(new BigDecimal(37.5)); placement.setCurrencyForCharge("GBP"); placement.setCurrencyForPayExpenses("GBP"); placement.setCurrencyForPayTimesheets("GBP"); placement.setChargeableExpenseApprovalRoute("Client Manager Approval"); placement.setNonChargeableExpenseApprovalRoute("Auto Approval"); placement.setTimesheetApprovalRoute("Auto Approval"); placement.setExpenseTemplate("Default"); placement.setHolidayAccuralRate(0.12); placement.setJobDescription("Web Placement 1"); placement.setJobTitle("Web Test 001"); placement.setNoCommunications(""); placement.setPurchaseOrderNum("po_num"); placement.setSalesCostCentre("scc"); placement.setTimesheetDateCalculatorName("weekly"); placement.setPerm(false); Calendar cal1 = Calendar.getInstance(java.util.TimeZone.getTimeZone("GMT")); cal1.set(2017, 3, 1, 0, 0, 0); placement.setStart(cal1); Calendar cal2 = Calendar.getInstance(java.util.TimeZone.getTimeZone("GMT")); cal2.set(2019, 3, 1, 0, 0, 0); placement.setEnd(cal2); IntimeServiceV2_0Stub.Rate[] rates = new IntimeServiceV2_0Stub.Rate[1]; IntimeServiceV2_0Stub.Rate rate1 = new IntimeServiceV2_0Stub.Rate(); rate1.setName("Standard Hours"); rate1.setPay(new BigDecimal(9.99)); rate1.setCharge(new BigDecimal(11.11)); rate1.setPayElementCode("001"); rate1.setPeriod("Hourly"); rate1.setPeriodDuration(60); rate1.setPriorityOrder(0); rate1.setTimePattern("DEFAULT"); rate1.setTimesheetFields("START_FINISH_BREAK"); rate1.setSelectableByWorkers(true); rates[0] = rate1; placement.setRates(rates); IntimeServiceV2_0Stub.CreateOrUpdatePlacement request = new IntimeServiceV2_0Stub.CreateOrUpdatePlacement(); request.setToken(ticket); request.setPlacement(placement); IntimeServiceV2_0Stub.CreateOrUpdatePlacementResponse result=stub.createOrUpdatePlacement(request); if (result != null) { System.out.println("Created/updated Placement with ID:" + result.get_return()); } } catch (java.lang.Exception e) { System.out.println("Exception occurred: " + e); } |
---|
Create or update a Timesheet
try{ //Read the associated placement so we can reference the rates & participants IntimeServiceV2_0Stub.GetPlacementByExternalId getPlacementRequest=new IntimeServiceV2_0Stub.GetPlacementByExternalId(); getPlacementRequest.setId("WEB-PLC-001"); getPlacementRequest.setToken(ticket); GetPlacementByExternalIdResponse placementResponse=stub.getPlacementByExternalId(getPlacementRequest); Placement placement=placementResponse.get_return(); //identify the required rate Rate rate1 = null; for (Rate rate : placement.getRates()) { if (rate.getName().equals("Standard Hours")) { rate1 = rate; } } Calendar cal = Calendar.getInstance(java.util.TimeZone.getTimeZone("GMT")); cal.set(2017,9,1,0,0,0); cal.set(Calendar.MILLISECOND, 0); //create a timesheetSubmission IntimeServiceV2_0Stub.Timesheet timesheetSubmission = new IntimeServiceV2_0Stub.Timesheet(); timesheetSubmission.setPlacementExternalRef(placement.getExternalId()); timesheetSubmission.setSubmitterId(placement.getWorker().getId()); //Whoever is creating the Timesheet timesheetSubmission.setPeriodEndDate(cal.getTime()); //Add the Shifts IntimeServiceV2_0Stub.Shift shift = new IntimeServiceV2_0Stub.Shift(); shift.setComment("Shift 1 comment"); shift.setDay(cal.getTimeInMillis()); //set the day the shift relates to shift.setRateId(rate1.getId()); if (rate1.getTimesheetFields().equals("START_FINISH_BREAK")) { //This rate requires start, finish and break times entered for the shift Calendar calStart = Calendar.getInstance(java.util.TimeZone.getTimeZone("GMT")); calStart.set(2017,9,1,0,0,0); calStart.set(Calendar.MILLISECOND, 0); calStart.set(Calendar.HOUR_OF_DAY, 8); shift.setStartTime(calStart.getTimeInMillis()); Calendar calEnd = Calendar.getInstance(java.util.TimeZone.getTimeZone("GMT")); calEnd.set(2017,9,1,0,0,0); calStart.set(Calendar.MILLISECOND, 0); calEnd.set(Calendar.HOUR_OF_DAY, 17); shift.setFinishTime(calEnd.getTimeInMillis()); shift.setMealBreak(3600000L); //1 hour in milliseconds } else if (rate1.getTimesheetFields().equals("HOURS")) { shift.setHours(8 * 60 * 60 * 1000L); } else if (rate1.getTimesheetFields().equals("DECIMAL")) { shift.setDecimal(new BigDecimal(1)); } else if (rate1.getTimesheetFields().equals("DAY")) { shift.setDecimal(new BigDecimal(1)); } Shift[] shifts = new Shift[1]; shifts[0] = shift; timesheetSubmission.setShifts(shifts); IntimeServiceV2_0Stub.UpdateTimesheet updateTimesheetRequest=new IntimeServiceV2_0Stub.UpdateTimesheet(); updateTimesheetRequest.setToken(ticket); updateTimesheetRequest.setTimesheet(timesheetSubmission); UpdateTimesheetResponse updateTimesheetResponse=stub.updateTimesheet(updateTimesheetRequest); Long timesheetId=updateTimesheetResponse.get_return(); System.out.println("Update Timesheet returned:"+timesheetId); } catch (Exception e) { System.out.println("Exception occurred: " + e); } |
---|
Submit a Timesheet
try { IntimeServiceV2_0Stub.SubmitTimesheet submitTimesheetRequest=new IntimeServiceV2_0Stub.SubmitTimesheet(); submitTimesheetRequest.setToken(ticket); submitTimesheetRequest.setTimesheetId(<timesheet_id>); SubmitTimesheetResponse submitTimesheetResponse=stub.submitTimesheet(submitTimesheetRequest); System.out.println("Submit Timesheet returned: "+submitTimesheetResponse.get_return()); } catch (Exception e) { System.out.println("Exception occurred: " + e); } |
---|
...
Field | Constant | Comment | Notes |
---|---|---|---|
Client | |||
invoice period | 0 | Weekly | |
1 | Two-Weekly | ||
2 | Four-Weekly | ||
3 | Calendar Monthly | ||
4 | 4-4-5 | ||
Worker | |||
workerType | paye | For PAYE Workers | |
ltd | For Ltd Company Workers | ||
external-contractor | For Non Ltd Company Workers | ||
cis | For CIS Workers | ||
umb | For Workers operating through an Umbrella | You must specify the umbrella against the worker, otherwise the worker will appear as LTD. | |
cisBusinessType | SoleTrader | ||
Company | |||
Trust | |||
Partnership | |||
cisPercentage | 0 | ||
20 | |||
30 | |||
paymentFrequency | weekly | ||
monthly | |||
<InPay Payroll Name> | If InPay connected, for PAYE workers, use the InPay Payroll Name | ||
timesheetsOnInvoices | 0 | Timesheets On Invoices | |
1 | Timesheets Not On Invoices | ||
paperOnInvoices | -1 | Agency Default | |
0 | No Attachments | ||
1 | Attach Paper Timesheets | ||
2 | Attach Expense Group Paper | ||
4 | Attach Expense Receipts Paper | ||
<sum of the above> | Attach the appropriate paper | For example, 5 to attach timesheets and receipts | |
gender | M | ||
F | |||
U | Unkown | ||
LTD invoice period | 0 | Weekly | |
1 | Two-Weekly | ||
2 | Four-Weekly | ||
3 | Calendar Monthly | ||
4 | 4-4-5 | ||
Payment Method | bacs | ||
cheque | |||
cash | |||
chaps | |||
ach | |||
international | |||
building society | |||
Placement | |||
layout | standard | See Maintaining Placements | |
calendar | |||
timesheetDateCalculator | weekly | See Maintaining Placements. You can see all possible values for this in the ui. | |
monthly | |||
<many more> | See UI for all options. | ||
Rates | |||
period | 60 | For hourly rates entered in hours format (hours only or start, break, finish). | |
1440 | For fixed rates of a specified duration entered in decimal format (decimal or tickbox) | ||
periodDuration | <any integer> | The duration in minutes for the fixed rate (e.g. 60 for hours, 480 for a day). | |
timePattern | default | Will use the selected default time pattern | |
<any string> | The string should match the name of a time pattern in the system | ||
timesheetFields | START_FINISH_BREAK | Enter start, break, finish | Only when period above is 60 |
HOURS | Enter hours only | Only when period above is 60 | |
DECIMAL | Enter time as a decimal | Only when period above is 1440 | |
DAY | Tickbox only (equivalent to entering decimals as 1.00) | Only when period above is 1440 |