...
Create or update a Timesheet
Submit 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(20518); 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(20518); 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()); } } } } catch (Exception e) { System.out.println("Exception occurred: " + e); } |
---|
Get a Single Sign-on token
...