Correct xml data type for Payroll hours - xero-api

I'm trying to integrate the Payroll API (USA) but running into challenges posting a Timesheet.
I'm using a JSON to xml parser which is giving me an output like this:
<?xml version="1.0"?>
<Timesheet>
<EmployeeID>9e246df3-8775-43ee-bc7e-47f5f5896964</EmployeeID>
<EndDate>2017-10-16T00:00:00Z</EndDate>
<Hours>43.2000</Hours>
<StartDate>2017-10-10T00:00:00Z</StartDate>
<Status>Draft</Status>
</Timesheet>
I have no experience with xml APIs but that looks the same as the example code provided. However on the API end the hours I get returned are 0:
"Status":"DRAFT","Hours":0,
etc...
The Timesheet on the user console end also has 0 hours.
Is there something else I need to be considering here?
Thanks

Answer:
I had misinterpreted the API, the "Hours" for a period is the hours calculated by Xero, based on the quantity of pay items provided.
Hopefully this clarifies in case anyone else has same confusion.

Related

Extract incident details from Service Now in Excel

I am trying to extract ticket details from Service Now. Is there a way to extract the details without ODBC ? I have also tried the solution mentioned in [1]: https://community.servicenow.com/docs/DOC-3844, but I am receiving an error 9 -subscript out of range.
Is there a better way to extract details efficiently? I tried asking this in the service now forum but I thought I might get other opinions from here.
It's been a while since this question is asked. Hopefully following is still useful.
I am extracting change data (not incident) , but the process still should be same. You will need to gather incident table and column information. Then there are couple of ways to approach the problem.
1) If the data you are extracting has fixed parameters , such as fixed period or fixed column or group etc., then you can create a report within servicenow and then use REST/SOAP API to get the data in text/csv format. You can use different python modules to convert from csv to xls or xlsx depending on you need. I used openpyXL ,csv , xlsreader ,xlswriter etc.
See here for a example
ServiceNow - How to use SOAP to download reports
2) If the data has dynmaic parameters where you need to change columns, dates or filter etc, you can still use soap / REST API but form query within python scripts instead of having static report. This way you can change it based on your requirement on the fly.
Here is an example query for DB. you can use example for above. Just switch url with following.
table_name = 'u_change_table_name' #SN DB holding change/INCIDENT info
table_limit = 800
table_query = 'active=true&sysparm_display_value=true&planned_start_date=today'
date_query = 'chg_start_date>=javascript:gs.daysAgoStart(1)^active=true^chg_type=normal'
table_fields = 'chg_number,chg_start_date,chg_duration,chg_end_date' #Actual column names from DB and not from SN report.
url= (
'https://yourcompany.service-now.com/api/now/table/' +table_name +\
'?sysparm_query=' + date_query + '&sysparm_fields=' \
+ table_fields + '&sysparm_limit=' + str(table_limit)
)

Scribe Jobs: how to get the current date and compare it?

Honesty I'm very new in terms of Scribe Jobs, but I have been trying to develop a Job that get the current date and compare it against one field from the source (CRM input Date).
This is the code in the formula editor of the Pre-Operation Step Control:
IF(S146 =TODAY( ), GOTOSTEP ( ),FAILROW( ))
I'm trying to allow the migration only for records inserted today, the rest will just generate error.
Can somebody help me?
Try this:
if( DATEDIFF ("d", GETCURRENTUTCTIME, S146) < 1 )
Here's a great place to look for more information:
http://help.scribesoft.com/scribeonline/en/sol/formulas/datefunctions.htm

MuleSoft: Sum line items and group by ID

I am new to integration and MuleSoft so I need your help. I have a flat file with different invoice line items per salesID, like this:
SalesOrderID OrderQty UnitPrice
43659 70 2024.994
43659 70 2024.994
43660 1 419.4589
43660 1 874.794
43661 1 809.76
I want to insert total invoice amount and quantity in another CSV file using Mule, something like this:
SalesOrderID OrderQty UnitPrice
43659 140 4049.988
43660 2 1294.4589
43661 1 809.76
I know how to do this in informatica,but im trying to figure out a way to do this in MuleSoft. How can I sum up all the line items and group them by SalesOrderID? Any help/clue will be really appreciated.
Thanks.
There are a number of ways to do this, let me explain my personal favourite assuming you are using Mule community edition.
Use the superb library: SuperCSV, it will allow you not only to parse the data (including those dot numbers) but also validate it and give back an exact report on why the file is broken in case it is.
This could be done in a transformer that transform the inbound stream and return either a map of maps (or even better a iterator that handles the whole thing but this is more difficult) or a custom exception with the error report.
Given that this requirement is one that faces Mule developers even today, it's useful to see a solution based on the Mule 4.x runtime and Dataweave 2.x.
If the data came from a file or is otherwise a monolithic stream of text, use the splitBy() function to get an array of text lines.
payload splitBy '\n'
remove the first line as the headers should not be calculated
payload[1 to -1] // this is my favorite way to do it
Now use the reduce() function to iterate over each of the lines in turn, updating the accumulator each time to account for quantity and price.
Hopefully that helps

Yahoo Weather API 3 days Forecast with humidity value

I am building a web app, which uses Yahoo Weather API to provide weather information, based on a ZIP code, provided by the users.
I know that in order to obtain this data for certain number of days I have to add it as a parameter in my request, like so:
http://weather.yahooapis.com/forecastrss?p=33035&u=c&d=3
Which gives this result:
<channel>
....
<yweather:location city="Homestead" region="FL" country="US"/>
<yweather:units temperature="C" distance="km" pressure="mb" speed="km/h"/>
<yweather:wind chill="19" direction="90" speed="11.27"/>
<yweather:atmosphere humidity="78" visibility="16.09" pressure="1021" rising="1"/>
<yweather:astronomy sunrise="7:12 am" sunset="7:36 pm"/>
...
<item>
...
<yweather:forecast day="Wed" date="2 Apr 2014" low="19" high="28" text="Mostly Sunny" code="34"/>
<yweather:forecast day="Thu" date="3 Apr 2014" low="21" high="29" text="Partly Cloudy" code="30"/>
<yweather:forecast day="Fri" date="4 Apr 2014" low="20" high="28" text="Partly Cloudy" code="30"/>
<guid isPermaLink="false">USFL0208_2014_04_04_7_00_EDT</guid>
</item>
</channel>
However I need to be able to get the humidity level for EVERY day in the forecast and not just the current one. I've tried to find solution here and also read the Yahoo API documentation, but it's really a short one.
I've also tried http://www.myweather2.com/ and http://developer.worldweatheronline.com/, but they have the same issue with humidity - it's shown only for the current day and stripped from the whole forecast.
I'll keep trying with other free Weather APIs, but if you can help here I'd be very grateful.
I've spent some time researching for better APIs than the Yahoo! Weather API and I found something, that works for me, so I've decided to share the info, in case anyone else bump into this some day.
Version 2 of the Forecast API looks like a nice solution, because it provides detailed information, more specifically the humidity index for each day in the forecast, which was what I was looking for in the first place.
There are also number of libraries for this API (languages include PHP, Node.js, Python, Perl and others).
It works with longitude & latitude as in this example
https://api.forecast.io/forecast/APIKEY/LATITUDE,LONGITUDE,TIME
and of course one needs to register for an API key.
The TIME parameter is optional, the temperature uses Fahrenheit metrics by default, but this can be changed with additional ?units=ca parameter.
One disadvantage is that you get only a 1,000 free calls per day, which probably won't be suitable for big applications.
If you know a better answer to the original question, I'll be very happy to hear it. Until then I'll use this solution, without going into much details:
// The default result from a Forecast API call is in JSON,
// so decode it to an object for easier access
$fcObj = json_decode($jsonResult);
if(!empty($fcObj->daily->data[0]->humidity)) {
// get humidity value in %
$humidty = $fcObj->daily->data[0]->humidity * 100;
}

yahoo yql - include zip code in results

I've been trying out the Yahoo YQL local search, here's my the initial query:
select * from local.search where zip='94085' and query='pizza'
It does retrieve a result like this:
<Result id="21332021" xmlns="urn:yahoo:lcl">
<Title>Pizza Depot</Title>
<Address>919 E Duane Ave</Address>
<City>Sunnyvale</City>
<State>CA</State>
<Phone>(408) 245-7760</Phone>
<Latitude>37.389001</Latitude>
<Longitude>-122.003952</Longitude>
<Rating>
<AverageRating>3.5</AverageRating>
<TotalRatings>6</TotalRatings>
<TotalReviews>6</TotalReviews>
<LastReviewDate>1307988793</LastReviewDate>
<LastReviewIntro> Weve been coming to this Pizza Depot every week after softball games for years. The owner is very friendly and always does whatevers necessary to please the customer. Hes even stayed open late just for us after a game that didnt end until 9:45. Sometimes it gets a little busy at night, but isnt that a sign of a good pizza place? If it was always empty, then there might be something to complain about. Our group leaves satisfied week after week...</LastReviewIntro>
</Rating>
<Distance>0.75</Distance>
<Url>http://local.yahoo.com/info-21332021-pizza-depot-sunnyvale</Url>
<ClickUrl>http://local.yahoo.com/info-21332021-pizza-depot-sunnyvale</ClickUrl>
<MapUrl>http://local.yahoo.com/info-21332021-pizza-depot-sunnyvale?viewtype=map</MapUrl>
<BusinessUrl>http://www.pizzadepot-sunnyvale.com/</BusinessUrl>
<BusinessClickUrl>http://www.pizzadepot-sunnyvale.com/</BusinessClickUrl>
<Categories>
<Category id="96926236">Restaurants</Category>
<Category id="96926243">Pizza</Category>
</Categories>
</Result>
But there's no zip code. Can anyone help me include that one? Using these doesn't work either:
select zip, * from local.search where zip='94085' and query='pizza'
select zip from local.search where zip='94085' and query='pizza'
TIA
Though not an optimal solution, since the ZIP code is not an included field in the results, it would be possible to find the ZIP code by running an additional query for each of your results. In the following query, change the text to be the desired latitude and longitude.
SELECT postal FROM geo.placefinder WHERE text="37.389001, -122.003952" AND gflags="R"
To add insult to injury, YQL does not currently support table joins...at least not in the typical sense, so it's not possible to incorporate the above query into your current query.
For reference:
geo.placefinder parameters:
http://developer.yahoo.com/boss/geo/docs/control-parameters.html
Joining:
http://developer.yahoo.com/yql/guide/joins.html