AOTG API: Get List of AR Invoice

From AutoCount Resource Center

Get List of AR Invoice

Get the list of AR Invoice in a specific date range.

API Method

Http Method: POST
Method: /api/public/v1/ARInvoice/GetARInvoiceList
Content-Type: application/json
Parameters: FromDateTime, ToDateTime
Document date range.

API Request Flow

  1. Submit GetARInvoiceList request to retrieve a range of AR Invoice in account book.
  2. Check the successful request status, if the data is completed (ready).
  3. Retrieve the data with Result method.


Code Snippets

  • Add header of "SOTC_AUTH", and assign value of AccessToken.


<?php

$request = new HttpRequest();
$request->setUrl('http://aotg.cloud:8080/api/public/v1/ARInvoice/GetARInvoiceList');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'cache-control' => 'no-cache',
  'SOTC_AUTH' => 'SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d',
  'Content-Type' => 'application/json'
));

$request->setBody('{
  "FromDateTime": "2019-02-01T01:45:08.269Z",
  "ToDateTime": "2019-02-28T01:45:08.269Z"
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

var client = new RestClient("http://aotg.cloud:8080/api/public/v1/ARInvoice/GetARInvoiceList");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("SOTC_AUTH", "SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("undefined", "{\r\n  \"FromDateTime\": \"2019-02-01T01:45:08.269Z\",\r\n  \"ToDateTime\": \"2019-02-28T01:45:08.269Z\"\r\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_PORT => "8080",
  CURLOPT_URL => "http://aotg.cloud:8080/api/public/v1/ARInvoice/GetARInvoiceList",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\r\n  \"FromDateTime\": \"2019-02-01T01:45:08.269Z\",\r\n  \"ToDateTime\": \"2019-02-28T01:45:08.269Z\"\r\n}",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "SOTC_AUTH: SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d",
    "cache-control: no-cache"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

import requests

url = "http://aotg.cloud:8080/api/public/v1/ARInvoice/GetARInvoiceList"

payload = "{\r\n  \"FromDateTime\": \"2019-02-01T01:45:08.269Z\",\r\n  \"ToDateTime\": \"2019-02-28T01:45:08.269Z\"\r\n}"
headers = {
    'Content-Type': "application/json",
    'SOTC_AUTH': "SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d",
    'cache-control': "no-cache",
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)


Reponse

Response Successful HTTP Request

200 OK

Response Successful Body

Id can be used for checking the status of result. Id and Name are required to retrieve result (data).

{
    "Id": "f5175ac-8d11-4593-96ce-ccd36085d0d1",
    "Name": "GetARInvoiceList",
    "StartTimestamp": "2019-03-04T03:21:02.3896767Z",
    "EndTimestamp": "2019-03-04T03:21:02.3896767Z"
}


Check Status before get data (result)

Code Snippets

<?php

$request = new HttpRequest();
$request->setUrl('http://aotg.cloud:8080/api/public/v1/Result/f5175ac-8d11-4593-96ce-ccd36085d0d1');
$request->setMethod(HTTP_METH_GET);

$request->setHeaders(array(
  'cache-control' => 'no-cache',
  'SOTC_AUTH' => 'SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

var client = new RestClient("http://aotg.cloud:8080/api/public/v1/Result/f5175ac-8d11-4593-96ce-ccd36085d0d1");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("SOTC_AUTH", "SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d");
IRestResponse response = client.Execute(request);

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_PORT => "8080",
  CURLOPT_URL => "http://aotg.cloud:8080/api/public/v1/Result/f5175ac-8d11-4593-96ce-ccd36085d0d1",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => array(
    "SOTC_AUTH: SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d",
    "cache-control: no-cache"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

import requests

url = "http://aotg.cloud:8080/api/public/v1/Result/f5175ac-8d11-4593-96ce-ccd36085d0d1"

payload = ""
headers = {
    'SOTC_AUTH': "SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d",
    'cache-control': "no-cache",
    }

response = requests.request("GET", url, data=payload, headers=headers)

print(response.text)


Response Status

4 possible responses from process status.

InQueue status
  • InQueue status Indicates that the requests to AOTG Server is waiting to be processed.
  • Usually this happen when many requests are called to AOTG Web API in within a second.
    Make sure the request in the loop has pause time,
    or use 'batch' method to process multiple records in single request if applicable.
"RequestId": "f5175ac-8d11-4593-96ce-ccd36085d0d1",
"Status": "InQueue"
Processing status
  • Processing status indicates that the request is not complete.
"RequestId": "f5175ac-8d11-4593-96ce-ccd36085d0d1",
"Status": "Processing"
Completed status
  • Completed status Indicates that the request has been performed and succeeded.
"RequestId": "f5175ac-8d11-4593-96ce-ccd36085d0d1",
"Status": "Completed"
Failed status
  • Failed status indicates that the request has been performed but has error.
"RequestId": "f5175ac-8d11-4593-96ce-ccd36085d0d1",
"Status": "Failed"



Get data (result)

Code Snippets

<?php

$request = new HttpRequest();
$request->setUrl('http://aotg.cloud:8080/api/public/v1/Result/GetARInvoiceList/f5175ac-8d11-4593-96ce-ccd36085d0d1/result');
$request->setMethod(HTTP_METH_GET);

$request->setHeaders(array(
  'cache-control' => 'no-cache',
  'SOTC_AUTH' => 'SAMs1a36d2-a139-e911-b8b3-000aa03t3d'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

var client = new RestClient("http://aotg.cloud:8080/api/public/v1/Result/GetARInvoiceList/f5175ac-8d11-4593-96ce-ccd36085d0d1/result");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("SOTC_AUTH", "SAMs1a36d2-a139-e911-b8b3-000aa03t3d");
IRestResponse response = client.Execute(request);

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_PORT => "8080",
  CURLOPT_URL => "http://aotg.cloud:8080/api/public/v1/Result/GetARInvoiceList/f5175ac-8d11-4593-96ce-ccd36085d0d1/result",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => array(
    "SOTC_AUTH: SAMs1a36d2-a139-e911-b8b3-000aa03t3d",
    "cache-control: no-cache"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

import requests

url = "http://aotg.cloud:8080/api/public/v1/Result/GetARInvoiceList/f5175ac-8d11-4593-96ce-ccd36085d0d1/result"

payload = ""
headers = {
    'SOTC_AUTH': "SAMs1a36d2-a139-e911-b8b3-000aa03t3d",
    'cache-control': "no-cache"
    }

response = requests.request("GET", url, data=payload, headers=headers)

print(response.text)

Response Successful HTTP Request

200 OK

Response Successful Body

{
    "RequestId": "f5175ac-8d11-4593-96ce-ccd36085d0d1",
    "RequestName": "GetARInvoiceList",
    "HostName": "---",
    "IPAddress": "---",
    "RequestTypeName": "ARInvoice",
    "ResultJson": "[{\"DebtorCode\":\"300-D001\",\"CompanyName\":\"DEF CUSTOMER\",\"Description\":\"INVOICE\",\"DocDate\":\"2019-02-11T00:00:00\",\"JournalType\":null,\"DueDate\":\"2019-02-11T00:00:00\",\"DocNo\":\"I-000036\",\"LocalAmount\":300.00,\"TaxableAmount\":0.0,\"OutstandingAmount\":300.00,\"CurrencyCode\":\"MYR\",\"Agent\":\"TOM\",\"SourceType\":\"IV\",\"SourceKey\":\"1213\",\"CurrencyRate\":0.0,\"Id\":\"1219\",\"RefNo2\":null,\"CreditTerm\":null,\"InclusiveTax\":false,\"Note\":null,\"Total\":0.0,\"Amount\":300.00,\"TaxAmount\":0.00,\"DetailsLine\":[]},{\"DebtorCode\":\"300-A001\",\"CompanyName\":\"ABC CUSTOMER\",\"Description\":\"CASH SALE\",\"DocDate\":\"2019-02-11T00:00:00\",\"JournalType\":null,\"DueDate\":\"2019-02-11T00:00:00\",\"DocNo\":\"CS-000002\",\"LocalAmount\":100.00,\"TaxableAmount\":0.0,\"OutstandingAmount\":100.00,\"CurrencyCode\":\"MYR\",\"Agent\":\"\",\"SourceType\":\"CS\",\"SourceKey\":\"1222\",\"CurrencyRate\":0.0,\"Id\":\"1230\",\"RefNo2\":null,\"CreditTerm\":null,\"InclusiveTax\":false,\"Note\":null,\"Total\":0.0,\"Amount\":100.00,\"TaxAmount\":0.00,\"DetailsLine\":[]},{\"DebtorCode\":\"300-C002\",\"CompanyName\":\"CALIFORNIA SB\",\"Description\":\"SALES\",\"DocDate\":\"2019-02-04T00:00:00\",\"JournalType\":null,\"DueDate\":\"2019-02-04T00:00:00\",\"DocNo\":\"I-000042\",\"LocalAmount\":402.00,\"TaxableAmount\":0.0,\"OutstandingAmount\":402.00,\"CurrencyCode\":\"MYR\",\"Agent\":\"\",\"SourceType\":\"\",\"SourceKey\":\"\",\"CurrencyRate\":0.0,\"Id\":\"1299\",\"RefNo2\":null,\"CreditTerm\":null,\"InclusiveTax\":false,\"Note\":null,\"Total\":0.0,\"Amount\":402.00,\"TaxAmount\":0.00,\"DetailsLine\":[]}]",
    "RequestParamJson": null,
    "ResultStream": null,
    "ResultTypeName": "System.Collections.Generic.List`1[PSW.SOTC.Accounting.Provider.Models.ARInvoiceEntity]",
    "Status": "Completed",
    "Version": "1.2.19051.12002",
    "AccountBookInfo": "Plug-In 1.9 Test;1.0.9.77",
    "AccountBookDBInfo": "1.0.9.77",
    "Timestamp": "2019-03-04T04:58:15.0678413Z",
    "ResultedTimestamp": "2019-03-04T04:58:15.1308412Z",
    "ProcessingInterval": 0.26281319999999997,
    "InQueueInterval": -0.0898255,
    "ResultFileURL": null
}

[
  {
    "DebtorCode": "300-D001",
    "CompanyName": "DEF CUSTOMER",
    "Description": "INVOICE",
    "DocDate": "2019-02-11T00:00:00",
    "JournalType": null,
    "DueDate": "2019-02-11T00:00:00",
    "DocNo": "I-000036",
    "LocalAmount": 300,
    "TaxableAmount": 0,
    "OutstandingAmount": 300,
    "CurrencyCode": "MYR",
    "Agent": "TOM",
    "SourceType": "IV",
    "SourceKey": "1213",
    "CurrencyRate": 0,
    "Id": "1219",
    "RefNo2": null,
    "CreditTerm": null,
    "InclusiveTax": false,
    "Note": null,
    "Total": 0,
    "Amount": 300,
    "TaxAmount": 0,
    "DetailsLine": []
  },
  {
    "DebtorCode": "300-A001",
    "CompanyName": "ABC CUSTOMER",
    "Description": "CASH SALE",
    "DocDate": "2019-02-11T00:00:00",
    "JournalType": null,
    "DueDate": "2019-02-11T00:00:00",
    "DocNo": "CS-000002",
    "LocalAmount": 100,
    "TaxableAmount": 0,
    "OutstandingAmount": 100,
    "CurrencyCode": "MYR",
    "Agent": "",
    "SourceType": "CS",
    "SourceKey": "1222",
    "CurrencyRate": 0,
    "Id": "1230",
    "RefNo2": null,
    "CreditTerm": null,
    "InclusiveTax": false,
    "Note": null,
    "Total": 0,
    "Amount": 100,
    "TaxAmount": 0,
    "DetailsLine": []
  },
  {
    "DebtorCode": "300-C002",
    "CompanyName": "CALIFORNIA SB",
    "Description": "SALES",
    "DocDate": "2019-02-04T00:00:00",
    "JournalType": null,
    "DueDate": "2019-02-04T00:00:00",
    "DocNo": "I-000042",
    "LocalAmount": 402,
    "TaxableAmount": 0,
    "OutstandingAmount": 402,
    "CurrencyCode": "MYR",
    "Agent": "",
    "SourceType": "",
    "SourceKey": "",
    "CurrencyRate": 0,
    "Id": "1299",
    "RefNo2": null,
    "CreditTerm": null,
    "InclusiveTax": false,
    "Note": null,
    "Total": 0,
    "Amount": 402,
    "TaxAmount": 0,
    "DetailsLine": []
  }
]


See Also AOTG API


Go to menu

Go to top
Resources For AutoCount Software Developers