Create Exact Online companies en mass - exact-online

To simulate an accountancy environment, I need to create at least 100 of Exact Online companies (divisions, administraties, dossiers). This can be achieved using a manual action, repeated 100 times. And repeated across 7 countries. In totaal 700 times approximately one minute.
Is there a way to create these numbers of companies automatically through either the REST or XML API?
The documentation on REST API does not list POST possibilities; the XML API does not describe anything about what upload/download features are applicable.

Exact Online support explained me that there is a way, used by portals of large accountants.
The Administrations topic on XML supports to some extent the creation of companies. It does not matter into which company you upload the XML for a new Exact Online company, it gets added as an independent company.
Code sample to create 100 companies, having a human number 501..600:
insert into UploadXMLTopics
( topic
, payload
, division_code
, orig_system_reference
, orig_system_group
)
select 'Administrations'
, '<?xml version="1.0" encoding="utf-8"?>
<eExact xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="eExact-XML.xsd">
<Administrations>
<Administration number="' || 500+id || '">
<Name>Leeg ' || id || '</Name>
<AddressLine1>Harm Buiterplein ' || id || '</AddressLine1>
<Postcode>2501 TH</Postcode>
<City>Den Haag</City>
<State code="ZH" />
<Country code="NL" />
<Currency code="EUR" />
<Phone>0351448695</Phone>
<Fax>0351448690</Fax>
<Email>info#leeg' || id || '.nl</Email>
<HomePage>www.leeg.nl</HomePage>
<ChamberOfCommerce>12411369</ChamberOfCommerce>
<COCEstablishmentNumber>99</COCEstablishmentNumber>
<ActivitySector code="A" />
<ActivitySubSector code="01" />
<SBICode code="014" />
<CompanySize code="G" />
<BusinessType code="51" />
<StartDate>2015-05-13</StartDate>
<BlockingStatus>0</BlockingStatus>
</Administration>
</Administrations>
</eExact>'
, sdn.code
, 'Create-admin-' || id
, 'Create-admin'
from exactonlinexml..calendar clr
join ( select min(code) code from exactonlinerest..systemdivisions ) sdn
where clr.id between 1 and 100

Related

Adding Html tag into the title of the Tree query in Oracle APEX

I have a requirement to make few text in the title of my tree query in Oracle APEX to bold by adding b tag. But when i do that, the tag is displayed at the front end. My query is as mentioned below. I do not want to see the b tag, rather i want the text enclosed by b tag to be bold. Please help.
SELECT
CASE
WHEN CONNECT_BY_ISLEAF = 1 THEN 0
WHEN level = 1 THEN 1
ELSE -1
END
AS status,
level,
CASE
WHEN level = 1 THEN questions
ELSE '<b>' -- Comes in the front end which i do not want
|| flow_condition
|| '</b>'
|| ' - '
|| questions
END
AS title,
NULL AS icon,
question_id AS value,
NULL AS tooltip,
--null as link
apex_page.get_url(
p_page => 401,
p_items => 'P401_QUESTION_ID',
p_values => question_id,
p_clear_cache => 401
) AS link
FROM
(
SELECT
mmq.*,
mmm.flow_condition
FROM
msd_mc_questions mmq
LEFT OUTER JOIN msd_mc_par_chld_mapping mmm ON (
mmq.parent_id = mmm.parent_question_id
AND
mmq.question_id = mmm.child_question_id
)
)
START WITH
parent_id IS NULL
CONNECT BY
PRIOR question_id = parent_id
ORDER SIBLINGS BY questions
Struggled with this for hours but then found a solution via jQuery. Create a dynamic action that on page load and executes javascript. Find all items with class .a-TreeView-label (assuming that's the class name at runtime that you get as well - check to be sure) and loop over them and for each one, replace its text with itself. This forces it to re-render as HTML. My code in the javascript task:
$(".a-TreeView-label").each(function(index){
$(this).replaceWith($(this).text());
});
On the item attribute "Escape special characters" change to "No"

R: Web scraping JSON, extracting information from nest

I am trying to use tidyJSON to extract information from JSON, but I am open to any R package that can achieve my ends. I took a look at the documentation and vignittes and found the complex example was helpful. However, the information I want is nested inside of a non-key-value pair and I am not sure how to access it. I am interested in getting appid, name, developer, etc., but this information is within 570 and 730:
{"570":{"appid":570,"name":"Dota 2","developer":"Valve","publisher":"Valve","score_rank":71,"owners":102151578,"owners_variance":259003,"players_forever":102151578,"players_forever_variance":259003,"players_2weeks":9436299,"players_2weeks_variance":89979,"average_forever":11727,"average_2weeks":1229,"median_forever":277,"median_2weeks":662,"ccu":811259,"price":"0","tags":{"Free to Play":22678,"MOBA":7808,"Strategy":7415,"Multiplayer":6757,"Team-Based":4848,"Action":4602,"e-sports":4089,"Online Co-Op":3669,"Competitive":3553,"PvP":2655,"RTS":2267,"Difficult":2129,"RPG":2114,"Fantasy":2044,"Tower Defense":2024,"Co-op":1898,"Character Customization":1514,"Replay Value":1487,"Action RPG":1397,"Simulation":1024}},
"730":{"appid":730,"name":"Counter-Strike: Global Offensive","developer":"Valve","publisher":"Valve","score_rank":78,"owners":29225079,"owners_variance":154335,"players_forever":28552354,"players_forever_variance":152685,"players_2weeks":9102348,"players_2weeks_variance":88410,"average_forever":17648,"average_2weeks":791,"median_forever":5030,"median_2weeks":358,"ccu":543626,"price":"1499","tags":{"FPS":17082,"Multiplayer":13744,"Shooter":12833,"Action":10881,"Team-Based":10369,"Competitive":9664,"Tactical":8529,"First-Person":7329,"e-sports":6716,"PvP":6383,"Online Co-Op":5714,"Military":4621,"Co-op":4435,"Strategy":4424,"War":4361,"Realistic":3196,"Trading":3191,"Difficult":3158,"Fast-Paced":3100,"Moddable":2496}}
There are many thousands of such entries. Is there a way to skip the "top-level" and look within the nest?
The JSON information is from http://steamspy.com/api.php?request=top100in2weeks
This might be what you need:
library(jsonlite)
data = fromJSON("http://steamspy.com/api.php?request=top100in2weeks")
appid = lapply(data, function(x){x$appid})
name = lapply(data, function(x){x$name})
df = data.frame(appid = unlist(appid),
name = unlist(name),
stringsAsFactors = F)
Result:
> head(df)
appid name
570 570 Dota 2
730 730 Counter-Strike: Global Offensive
578080 578080 PLAYERUNKNOWN'S BATTLEGROUNDS
440 440 Team Fortress 2
271590 271590 Grand Theft Auto V
433850 433850 H1Z1: King of the Kill
I'll let you add the rest of the information
Edit: Adding arrays to a dataframe
Adding the tags information for each game in the data frame is possible. And the times tagged as well. For each game you must store an array of tag names in a column and the tag quantities in another.
After the definition of df add the following lines:
for(k in 1:nrow(d)){
d$tags[k] = list(names(data[[k]]$tags))
d$tagsQ[k] = list(unlist(data[[k]]$tags))
}
This will give you:
> d["570",]
appid name
570 570 Dota 2
tags
570 Free to Play, MOBA, Strategy, Multiplayer, Team-Based, Action, e-sports, Online Co-Op, Competitive, PvP, RTS, Difficult, RPG, Fantasy, Tower Defense, Co-op, Character Customization, Replay Value, Action RPG, Simulation
tagsQ
570 22686, 7810, 7420, 6759, 4850, 4603, 4092, 3672, 3555, 2657, 2267, 2130, 2116, 2045, 2024, 1898, 1514, 1487, 1397, 1023
In this situation, columns tags and tagsQ contain lists. To obtain the second tag and quantity for appid 570 do:
> df["570","tags"][[1]][2]
[1] "MOBA"
> d["570","tagsQ"][[1]][2]
MOBA
7810

Find node id by name in Umbraco Razor

I have a site with structure like Home -> News -> Year -> Month -> Day -> Article and need a query to find the id of the Day folder where the name of the folder matches a specified Year, Month and Day.
For example for 12th May 2003 it would be something like:
#something().where("Year.name = 2003").where("Month.name = May").where("Day.name = 12")
Depending on your preference, you can construct a query using either the dynamic DynamicPublishedContent or the strongly-typed IPublishedContent API.
The query will be different depending on where it's used, so assuming you want to run this query and display the results in the "News" page, you need something like the following:
var year = CurrentPage.Years.Where("Name == #1", "2013").First();
var month = year.Months.Where("Name == #1", "May").First();
var day = month.Days.Where("Name == #1", "12").First();
var dayId = day.Id;
Alternatively, you can try the strongly typed version:
var day = Model.Content
.Descendants("Year").First(y => y.Name == "2013")
.Descendants("Month").First(m => m.Name == "May")
.Descendants("Day").First(d => d.Name == "12").Id;
I've used First() for brevity but in reality you might want to check if the page exists before getting its descendants. Also, you might want to have a look at the documentation and come up with a query that's better suited to your scenario.

MySQL query to extract multiple Lat/Long coordinates and plot on Google map

I have the following MySQL query below. I'm trying to pull out the four sets of coordinates, then plot them on my custom Google v3 API page. (I also need it to "connect" the dots with blue lines as well)
Here is what the original "printable_text" column data looks like:
Grids : T04SR08W09NW
BestFit: 38.204326/-89.995942 38.204330/-89.993452
: 38.203490/-89.993451 38.203486/-89.995941
PreMark: NO Directional Boring: NO Depth>7Ft: NO
Here is my current MySQL query:
SELECT ticket
, SUBSTR(printable_text
, LOCATE('BestFit: ',printable_text)+9
, LOCATE('PreMark:', printable_text) - LOCATE('BestFit: '
, printable_text) - 9) AS coord
, REPLACE((SUBSTR(printable_text
, LOCATE('BestFit: ',printable_text)+9
, LOCATE('PreMark:', printable_text) - LOCATE('BestFit: '
, printable_text) - 9)),'/',',') AS coord
FROM tickets
WHERE ticket = 'A3041073'
Here is what I have extracted so far:
38.204326/-89.995942 38.204330/-89.993452 : 38.203490/-89.993451 38.203486/-89.995941
38.204326,-89.995942 38.204330,-89.993452 : 38.203490,-89.993451 38.203486,-89.995941
I'm guessing I need to get rid of the "/", "spaces", "colons", and feed the four coordinates to my Google API for plotting and connecting..?

MySQL - Perl: How to get array of zip codes within submitted "x" miles of submitted "zipcode" in Perl example

I have found many calculations here and some php examples and most are just over my head.
I found this example:
SELECT b.zip_code, b.state,
(3956 * (2 * ASIN(SQRT(
POWER(SIN(((a.lat-b.lat)*0.017453293)/2),2) +
COS(a.lat*0.017453293) *
COS(b.lat*0.017453293) *
POWER(SIN(((a.lng-b.lng)*0.017453293)/2),2))))) AS distance
FROM zips a, zips b
WHERE
a.zip_code = '90210' ## I would use the users submitted value
GROUP BY distance
having distance <= 5; ## I would use the users submitted value
But, I am having trouble understanding how to implement the query with my database.
It looks like that query has all I need.
However, I cannot even find/understand what b.zip_code actually is! (whats the b. and zips a, zips b?)
I also do not need the state in the query.
My mySQL db structure is like this:
ZIP | LAT | LONG
33416 | 26.6654 | -80.0929
I wrote this in attempt to return some kind of results (not based on above query) but, it only kicks out one zip code.
## Just for a test BUT, in reality I desire to SELECT a zip code WHERE ZIP = the users submitted zip code
## not by a submitted lat lon. I left off the $connect var, assume it's there.
my $set1 = (26.6654 - 0.20);
my $set2 = (26.6654 + 0.20);
my $set3 = (-80.0929 - 0.143);
my $set4 = (-80.0929 + 0.143);
my $test123 = $connect->prepare(qq{SELECT `ZIP` FROM `POSTAL`
WHERE `LAT` >= ? AND `LAT` <= ?
AND `LONG` >= ? AND `LONG` <= ?}) or die "$DBI::errstr";
$test123->execute("$set1","$set2","$set3","$set4") or die "$DBI::errstr";
my $cntr;
while(#zip = $test123->fetchrow_array()) {
print qq~$zip[$cntr]~;
push(#zips,$zip[$cntr]);
$cntr++;
}
As you can see, I am quite the novice so, I need some hand holding here with verbose explanation.
So, in Perl, how can I push zip codes into an array from a USER SUBMITTED ZIP CODE and user submitted DISTANCE in miles. Can be a square instead of a circle, not really that critical of a feature. Faster is better.
I'll tackle the small but crucial part of the question:
However, I cannot even find/understand what b.zip_code actually is! (whats the "b." and "zips a, zips b"?)
Basically, the query joins two tables. BUT, both tables being joined are in fact the same table - "zips" (in other words, it joins "zips" table to itself"). Of course, since the rest of the query needs to understand when you are referring to the first copy of the "zips" table and when to the second copy of the "zips" table, you are giving a table alias to each copy - to wit, "a" and "b"'.
So, "b.xxx" means "column xxx from table zips, from the SECOND instance of that table being joined".
I don't see what's wrong with your first query. You have latitude and longitude in your database (if I'm understanding, you're comparing a single entry to all others). You don't need to submit or return the state that's just part of the example. Make the first query work like this:
my $query = "SELECT b.zip_code,
(3956 * (2 * ASIN(SQRT(
POWER(SIN(((a.lat-b.lat)*0.017453293)/2),2) +
COS(a.lat*0.017453293) *
COS(b.lat*0.017453293) *
POWER(SIN(((a.lng-b.lng)*0.017453293)/2),2))))) AS distance
FROM zips a, zips b WHERE
a.zip_code = ?
GROUP BY distance having distance <= ?";
my $sth = $dbh->prepare($query);
$sth->execute( $user_submitted_zip, $user_submitted_distance );
while( my ($zip, $distance) = $sth->fetchrow() ) ) {
# do something
}
This won't be that fast, but if you have a small record set ( less than 30k rows ) it should be fine. If you really want to go faster you should look into a search engine such as Sphinx which will do this for you.
fetchrow_array returns a list of list references, essentially a two-dimensional array, where each row represents a different result from the database query and each column represents a field from the query (in your case, there is only one field, or column, per row).
Calling while ($test123->fetchrow_array()) will cause an infinite loop as your program executes the query over and over again. If the query returns results, then the while condition will be satisfied and the loop will repeat. The usual idiom would be to say something more like for my $row ($test123->fetchrow_array()) { ..., which will only execute the query once and then iterate over the results.
Each result is a list reference, and the zip code you are interested in is in the first (and only) column, so you could accumulate the results in an array like this:
my #zips = (); # for final results
for my $row ($test123->fetchrow_array()) {
push #zips, $row->[0];
}
or even more concisely with Perl's map statement:
my #zips = map { $_->[0] } $test123->fetchrow_array()
which does the same thing.