Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
A view, v_Jiwa_SalesOrder_List is provided with a corresponding query class v_Jiwa_SalesOrder_ListQuery to facilitate retrieving a filtered, paginated list of sales orders. The data returned includes data from several tables to bring together customer, sales order, delivery information from one query.
Which fields are returned can be limited with the Fields property - so only the required fields are returned.
With the Include property set to "Total" the response will include the total count of records matching the query - this is useful for pagination. The Skip and Take properties can be added specify the starting record number to return and the number of records to return.
Retrieve first 25 sales orders from the NSW/Main warehouse, ordered by InvoiceNo.
ServiceStack Client C#
var client = new ServiceStack.JsonServiceClient("https://api.jiwa.com.au");
var authResponse = client.Get(new ServiceStack.Authenticate() { UserName = "admin", Password = "password" });
var salesOrderListRequest = new JiwaFinancials.Jiwa.JiwaServiceModel.Tables.v_Jiwa_SalesOrder_ListQuery() { PhysicalWarehouseDescription = "New South Wales", LogicalWarehouseDescription = "Main", Fields = "InvoiceID,InvoiceNo,InvoiceInitDate,DebtorID,DebtorAccountNo,DebtorName",OrderBy = "InvoiceNo", Include = "Total", Take = 25 };
ServiceStack.QueryResponse<JiwaFinancials.Jiwa.JiwaServiceModel.Tables.v_Jiwa_SalesOrder_List> salesOrderListResponse = client.Get(salesOrderListRequest);
C#
using (var webClient = new System.Net.WebClient())
{
// Authenticate
webClient.QueryString.Add("username", "Admin");
webClient.QueryString.Add("password", "password");
string responsebody = webClient.DownloadString("https://api.jiwa.com.au/auth");
// Above returns something like this: {"SessionId":"0hKBFAnutUk8Mw6YY6DN","UserName":"api","DisplayName":"","ResponseStatus":{}}
// Deserialise response into a dynamic - below requires the Newtonsoft.Json nuget package
var authResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(responsebody);
var sessionId = authResponse.SessionId;
webClient.Headers.Add(System.Net.HttpRequestHeader.Cookie, string.Format("ss-id={0}", sessionId));
responsebody = webClient.DownloadString("https://api.jiwa.com.au/Queries/SalesOrderList?PhysicalWarehouseDescription=New South Wales&LogicalWarehouseDescription=Main&Fields=InvoiceID,InvoiceNo,InvoiceInitDate,DebtorID,AccountNo,DebtorName&OrderBy=InvoiceNo&Include=Total&Take=25");
}
Note the &format=json in the above URL this overrides the content type returned. For browsers the default content type is HTML - if a content type override is omitted, then a HTML razor view of the data will be returned instead of json. xml and csv are also valid overrides for the content type to be returned.
With the above example, simply setting the Skip property of the request DTO to 25 will have the effect of retrieving the next 25 records. Because we include in the request Include=Total, the response will contain a property, Total, which is the count of the total number of records matching the query.
Using SO_MainQuery
An alternative to using the v_Jiwa_SalesOrder_ListQuery is to simply use the SO_MainQuery.
All tables have a corresponding Query class. For example, the table SO_Main has a class SO_MainQuery. The SO_MainQuery class is the DTO used for query operations against the SO_Main table. By setting various properties of an instance of this class, a filtered, ordered set of results can be obtained.
Retrieve first 25 sales orders, ordered by InvoiceNo.
ServiceStack Client C#
var client = new ServiceStack.JsonServiceClient("https://api.jiwa.com.au");
var authResponse = client.Get(new ServiceStack.Authenticate() { UserName = "admin", Password = "password" });
var salesOrderListRequest = new JiwaFinancials.Jiwa.JiwaServiceModel.Tables.SO_MainQuery() { Fields = "InvoiceID, InvoiceNo, InvoiceInitDate, DebtorID", OrderBy = "InvoiceNo", Take = 25, Include = "Total" };
ServiceStack.QueryResponse<JiwaFinancials.Jiwa.JiwaServiceModel.Tables.SO_Main> salesOrderListResponse = client.Get(salesOrderListRequest);
C#
using (var webClient = new System.Net.WebClient())
{
// Authenticate
webClient.QueryString.Add("username", "Admin");
webClient.QueryString.Add("password", "password");
string responsebody = webClient.DownloadString("https://api.jiwa.com.au/auth");
// Above returns something like this: {"SessionId":"0hKBFAnutUk8Mw6YY6DN","UserName":"api","DisplayName":"","ResponseStatus":{}}
// Deserialise response into a dynamic - below requires the Newtonsoft.Json nuget package
var authResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(responsebody);
var sessionId = authResponse.SessionId;
webClient.Headers.Add(System.Net.HttpRequestHeader.Cookie, string.Format("ss-id={0}", sessionId));
responsebody = webClient.DownloadString("https://api.jiwa.com.au/Queries/SO_Main?Fields=InvoiceID,InvoiceNo,InvoiceInitDate,DebtorID&OrderBy=InvoiceNo&Take=25&Include=Total");
}
Note: The &format=json in the above URL this overrides the content type returned. For browsers the default content type is HTML - if a content type override is omitted, then a HTML razor view of the data will be returned instead of json. xml and csv are also valid overrides for the content type to be returned.
Read a Sales Order
Create a new Sales Order
Update an existing Sales Order
Custom Fields
List all custom fields for sales orders
Get All Custom Field Values for a Single Sales Order
Get a Single Custom Field Value for a Sales Order and Custom Field
Update a Single Custom Field Value for a Sales Order and Custom Field
Sales Order History (Snapshot)
Retrieve a list of sales order histories
Retrieve a sales order history
Update a sales order history
Note that to update some fields of the sales order history, you need to not use the SalesOrderHistorysPATCHRequest on /SalesOrders/{InvoiceID}/Historys/{InvoiceHistoryID} but instead use the SalesOrderPATCHRequest - this will pass the values through to the current snaphot number of the sales order. See Update An Existing Sales Order.
Custom Fields
List all custom fields for sales order historys
Get All Custom Field Values for a Single Sales Order History
Get a Single Custom Field Value for a Sales Order history and Custom Field
Update a Single Custom Field Value for a Sales Order history and Custom Field
Lines
Read all lines for a sales order
Read a sales order line
Add a line to a sales order
Inventory Item
Comment Line
Update a sales order line
Delete a sales order line
Custom Fields
List all custom fields for sales order lines
Get All Custom Field Values for a Single Sales Order Line
Get a Single Custom Field Value for a Sales Order line and Custom Field
Update a Single Custom Field Value for a Sales Order line and Custom Field
Notes
Documents
Processing a Sales Order
To process a sales order, a specific route must be called, this then performs the business logic for posting journals and debtor transactions.