Financial Ledger API
Author© : CBT Limited, London, UK
Version#: 4.0.00 beta
Released: 27th September 2012
Version#: 4.0.00 beta
Released: 27th September 2012
Purpose
The Razor Cloud has a financial accounting ledger which is described here. Accounts are entered and viewed in the Report page of the Razor Cloud© console or in a linked third party accounting application.REST Examples
The information is returned in a simple format, the structure of which is obvious by inspecting the element names.To change the response format from XML to JSON replace
rest with json in the URL. For example:
src="http://razor-cloud.com/xml/rest/account/list?pos=8508a7e6ce43e091 returns XML src="http://razor-cloud.com/xml/json/account/list?pos=8508a7e6ce43e091 returns JSONThe XML may be parsed and used by a client application, or may be converted into different formats using XSL style sheets.
Ledger Accounts in XML
Click to display a list of account names and IDs in XML using this REST URL.src="http://razor-cloud.com/xml/rest/account/list?pos=8508a7e6ce43e091
Ledger Accounts in JSON
Click to display a list of account names and IDs in JSON using this REST URL.src="http://razor-cloud.com/xml/json/account/list?pos=8508a7e6ce43e091
Ledger Currencies
Click to display an XML list of ledger currency names and codes using this REST URL.src="http://razor-cloud.com/xml/rest/account/currencies?pos=8508a7e6ce43e091
Account Subsidiary Ledgers
Click to display an XML list of account names (name) with their subsidiary ledgers (id) using this REST URL.src="http://razor-cloud.com/xml/rest/account/subledger?pos=8508a7e6ce43e091
XSL Style Sheet Examples
The same REST URL can return very different results by appending a suitable style sheet URL to the request. Sample XSL style sheets (having the extension *.xsl) may be accessed atsrc="http://razor-cloud.com/xsl/*.xsl.
Ledger Style Sheet
Click to display the XSL style sheet to transform an XML list to a HTML table using this REST URL.src="http://razor-cloud.com/xsl/name_list.xsl
Ledger XML Rendered by Name XSL
Click to display an XML list of ledger accounts using this REST URL, transformed into HTML by XSL.
src="http://razor-cloud.com/xml/rest/account/list?pos=8508a7e6ce43e091&xsl=src="http://razor-cloud.com/xsl/name_list.xsl
Ledger XML Rendered by ID XSL
Click to display an XML list of ledger accounts using this REST URL, transformed into HTML by another XSL.
src="http://razor-cloud.com/xml/rest/account/list?pos=8508a7e6ce43e091&xsl=src="http://razor-cloud.com/xsl/id_list.xsl
Code Examples
C# Example
The following code snippet shows how to get data from an XML document in C#. Similar libraries and tools to inspect and parse XML documents are available in most modern environments.
System.Xml.XmlDocument xmlAccounts = new System.Xml.XmlDocument();
System.Net.WebRequest req = System.Net.WebRequest.Create("http://www.razor-cloud.com/xml/rest/account/list?pos=8508a7e6ce");
System.Net.WebResponse resp = req.GetResponse();
System.IO.StreamReader textReader = new System.IO.StreamReader(resp.GetResponseStream());
System.Xml.XmlTextReader xmlReader = new System.Xml.XmlTextReader(textReader);
xmlAccounts.Load(xmlReader);
foreach (System.Xml.XmlNode xmlAccount in xmlAccounts.SelectNodes("account")) {
if (xmlAccount.SelectSingleNode("account") == null) continue; // skip invalid accounts
Response.Write("Account ID = " + xmlAccount.SelectSingleNode("id").InnerText + "<br />");
Response.Write("Account Name = " + xmlAccount.SelectSingleNode("name").InnerText + "<br />");
}
REST pos={pos_code}
Requests are submitted to the Razor Cloud web services using REST URLs with parameters.Note that the URL must be on one line and the parameters must be strictly in sequence.
The mandatory point of sale code
pos_code and optional
style_sheet style sheet query parameters are appended to the URL.
To change the response format from XML to JSON replace rest with json in the URL.
URL Syntax
To list the accounts of the ledger use this URL:
src="http://razor-cloud.com/xml/rest/account/list?pos={pos_code}
To get the currency names and codes used by the ledger use this URL:
src="http://razor-cloud.com/xml/rest/account/currencies?pos={pos_code}
To get the subsidiary ledger of each account, if any, use this URL:
src="http://razor-cloud.com/xml/rest/account/subledger?pos={pos_code}
To get the activity subsidiary accounts, if any, use this URL:
src="http://razor-cloud.com/xml/rest/account/activity?pos={pos_code}
To get the asset subsidiary accounts, if any, use this URL:
src="http://razor-cloud.com/xml/rest/account/asset?pos={pos_code}
To get the bank and cash subsidiary accounts, if any, use this URL:
src="http://razor-cloud.com/xml/rest/account/finance?pos={pos_code}
To get the subsidiary accounts of employee, payable, receivable and other party subsidiary ledgers, if any, use this URL:
src="http://razor-cloud.com/xml/rest/account/party?pos={pos_code}
Parameters
The REST URLs have one or more of the following parameters:| Parameter | Default | Accepts | Description |
|---|---|---|---|
| pos | null | String |
The point of sale code to identify the client to the Razor Cloud.
Select the Company tab in the Razor Cloud console to see the pos_code in the POS Code field.
|
| xsl | null | String |
The optional URL of a style sheet to translate the XML result into HTML or other format.
Sample style sheets can be accessed at src="http://razor-cloud.com/xsl/ and edited to suit specific requirements. |
Results
The REST URLs return one or more of the following objects, or an error message:| Object | Field | Type | Description |
|---|---|---|---|
| account | id | String | ID of the ledger account. |
| name | String | Name of the ledger account. | |
| type | String | Type or subsidiary ledger of the ledger account. | |