Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

No Format
    "Details": [
        {
            "$type": "Winbooks.TORM.OM.Logistics.DocumentDetail, Winbooks.TORM.OM",
            "$isShowId": true,
            "Id": "ca7e5867-0a84-4235-8c4e-a8a300c86587",
            ...
            "Quantity": 2,
            "NextTotalQuantity": 2,
            ...
            "DocumentHeader": {...},
            "Row": {...},
            "NextDetails": [
                {
                    "$type": "Winbooks.TORM.OM.Logistics.DocumentDetailLink, Winbooks.TORM.OM",
                    "TotalLevel": 1,
                    "Version": 1,
                    "Modified": "/Date(1521025795000)/",
                    "ModifiedBy": "7507ea76-474b-4ccc-80d3-a35b0090b2b6",
                    "Created": "/Date(1521025795000)/",
                    "CreatedBy": "7507ea76-474b-4ccc-80d3-a35b0090b2b6",
                    "Folder_Id": "3a6a9ea1-ce6e-45e7-889a-d8e325a43b70",
                    "ParentDocumentDetail_Id": "ca7e5867-0a84-4235-8c4e-a8a300c86587",
                    "DocumentDetail_Id": "69e65278-b099-4d34-9926-a8a300c87a19",
                    "Type": 0,
                    "Quantity": 2,
                    "Id": "0cead30b-9e49-43b1-aacc-a8a300c87a1c",
                    "ResultState": 0,
                    "ActionState": 0,
                    "CachedCollection": {},
                    "IsBinding": false,
                    "IsSpecifiedId": false,
                    "IsDirty": false,
                    "UpdatedEntities": {},
                    "Custom": {},
                    "UpdatedProperties": [],
                    "UpdatedValues": [],
                    "FolderCode": "JF_TEST_RESTAPI"
                }
            ],
            "StockTransaction": [{...}],
            "FolderCode": "JF_TEST_RESTAPI",
            "Type_UpdatedValues": "[]"
        },
		{...}
   ]

Posting a new Document

First, we have to retrieve the Id of the address. This can be done by 2 ways.

Info
If we manage the contact person in the document, we should also retrieve the Id of the contact.

Load the third BEBOP

GET {{url}}/app/Third/BEBOP/Folder/{{folder}}?MaxLevel=2

The property DefaultAddress.Id give you this Id (56e918d4-0cc0-42db-a040-a89b00aa382d).

This request generates several SQL queries to fetch all the sub-entities (MaxLevel=2 to get the DefaultAddress), and we don't need most of the sub-entities.

Make a query

It's really more efficient to use queries and especially queries with projection to get just what we need. This can be done with the /ExecuteCriteria suffixe.

POST {{url}}/app/Addresss/Folder/{{folder}}/ExecuteCriteria

The body of the request contains the criteria corresponding to this query in .NET:

Code Block
languagec#
ICriteria criteria = new AddressDAO().CreateCriteria()
   .CreateAlias("third", typeof(Third), Third.Names.Id, Address.Names.Third_Id)
   .Add(Condition.Eq("third." + Third.Names.Code, "BEBOP"))
   .Add(Condition.Eq(Address.Names.IsInvoicingDefault, true))
   .SetProjection(Projections.Property(Address.Names.Id));
Newtonsoft.Json.Linq.JArray addressid = _folder.GetFilterAll(criteria.JsonCriteriaSerialize(), "Address");

Body for the ExecuteCriteria in JSON: 

No Format
{
   "EntityType": "Winbooks.TORM.OM.Address, Winbooks.TORM.OM",
   "DAOType": "Winbooks.TORM.DAL.AddressDAO, Winbooks.TORM.DAL",
   "IsCustomization": false,
   "Alias": "this",
   "Association": {
      "third": {
         "AliasName": "third",
         "Type": "Winbooks.TORM.OM.Third, Winbooks.TORM.OM",
         "JoinType": 1,
         "LeftProperty": "Id",
         "RightProperty": "Third_Id"
      }
   },
   "Conditions": [
      {
         "Operator": 0,
         "PropertyName": "third.Code",
         "OtherPropertyName": "",
         "Values": ["BEBOP"],
         "ValueTypes": ["System.String, mscorlib"]
      },
      {
         "Operator": 0,
         "PropertyName": "IsInvoicingDefault",
         "OtherPropertyName": "",
         "Values": [true],
         "ValueTypes": ["System.Boolean, mscorlib"]
      }
   ],
   "Havings": [],
   "ProjectionsList": [
      {
         "PropertyName": "Id",
         "Operator": 22
      }
   ],
   "Orders": [],
   "Params": {},
   "FirstResult": -1,
   "MaxResult": -1,
   "ResultState": 0,
   "TimeOutSeconds": 0
}

The answer is the id of the default address for invoicing.

No Format
[
"56e918d4-0cc0-42db-a040-a89b00aa382d"
]

Post the DocumentHeader (using the friendly code properties)

POST {{url}}/app/DocumentHeader/Folder/{{folder}}

The body of the request contains the document to post like this:

No Format
{
    "$type": "Winbooks.TORM.OM.Logistics.DocumentHeader, Winbooks.TORM.OM",
    "TotalLevel": 4,
    "CurrencyRate": 1,
    "Number": 2018004,
    "Date": "/Date(1521028391000)/",
    "DueDate": "/Date(1521590400000)/",
    "IsVatIncluded": false,
    "IsInitial": true,
    "TotalBase": 500,
    "TotalVat": 102.38,
    "TotalToPay": 602.38,
    "TotalQuantity": 3,
    "ComputingMethod": 1,
    "Addressing": {
        "$type": "Winbooks.TORM.OM.Logistics.DocumentAddressing, Winbooks.TORM.OM",
        "TotalLevel": 1,
        "DeliveringAddress_Id": "56e918d4-0cc0-42db-a040-a89b00aa382d",
        "InvoicingAddress_Id": "56e918d4-0cc0-42db-a040-a89b00aa382d",
        "PostingAddress_Id": "56e918d4-0cc0-42db-a040-a89b00aa382d",
        },    
	"Details": [
        {
            "$type": "Winbooks.TORM.OM.Logistics.DocumentDetail, Winbooks.TORM.OM",
    		"TotalLevel": 3,
            "RowNumber": 1000,
            "Quantity": 2,
            "Amount": 200,
            "Row": {
                "$type": "Winbooks.TORM.OM.Logistics.DocumentRow, Winbooks.TORM.OM",
				"TotalLevel": 2,
                "Name": "Wheel",
                "UnitPrice": 100,
                "DiscountRate": 0,
                "Comment": "",
                "VatCode": "21",
                "ItemCode": "WHEEL"
                }
        },
        {
            "$type": "Winbooks.TORM.OM.Logistics.DocumentDetail, Winbooks.TORM.OM",
    		"TotalLevel": 3,
            "RowNumber": 2000,
            "Quantity": 1,
            "Amount": 300,
            "Row": {
                "$type": "Winbooks.TORM.OM.Logistics.DocumentRow, Winbooks.TORM.OM",
				"TotalLevel": 2,
                "Name": "Frame",
                "UnitPrice": 300,
                "DiscountRate": 0,
                "Comment": "",
                "VatCode": "21",
                "ItemCode": "FRAME"
                }
        }
    ],
    "JournalLogCode": "ORDER",
    "CustomerCode": "BEBOP",
    "CurrencyCode": "EUR",
    "PayCodeCode": "7"
}

At the last level (Row), we have to specify "TotalLevel":2 because we use friendly code property (VatCode and ItemCode).

If you use the Id's (which is more efficient), at the last level, you should specify "TotalLevel":1.

The answer give the reference to the created DocumentHeader.

No Format
{
    "Href": "https://stg-api.winbooksonweb.be/app/DocumentHeader/6caa4a57-4db0-464a-834d-a8aa00ae41a4/Folder/JF_TEST_RESTAPI"
}

Post the DocumentHeader (using the Id's)

It is more efficient to specify the Id's of the related entities, especially when we post several documents using the same journal or customer or items or vat or currency.

First, we have to retrieve the Id's:

...

Or really more efficiently via the ExecuteCriteria:

...

{ "EntityType": "Winbooks.TORM.OM.Accounting.VatAccount, Winbooks.TORM.OM",
"Conditions": [ {"Operator": 0, "PropertyName": "Code", "Values": ["21"] } ],
"ProjectionsList": [ {"PropertyName": "Id", "Operator": 22} ],
"MaxResult": 1 }

...

{ "EntityType": "Winbooks.TORM.OM.Logistics.Item, Winbooks.TORM.OM",
"Conditions": [ {"Operator": 0, "PropertyName": "Code", "Values": ["WHEEL"] } ],
"ProjectionsList": [ {"PropertyName": "Id", "Operator": 22} ],
"MaxResult": 1 }

...

{ "EntityType": "Winbooks.TORM.OM.Logistics.JournalLog, Winbooks.TORM.OM",
"Conditions": [ {"Operator": 0, "PropertyName": "Code", "Values": ["ORDER"] } ],
"ProjectionsList": [ {"PropertyName": "Id", "Operator": 22} ],
"MaxResult": 1 }

...

{ "EntityType": "Winbooks.TORM.OM.Customer, Winbooks.TORM.OM",
"Conditions": [ {"Operator": 0, "PropertyName": "Code", "Values": ["BEBOP"] } ],
"ProjectionsList": [ {"PropertyName": "Id", "Operator": 22} ],
"MaxResult": 1 }

...

{ "EntityType": "Winbooks.TORM.OM.Currency, Winbooks.TORM.OM",
"Conditions": [ {"Operator": 0, "PropertyName": "Code", "Values": ["EUR"] } ],
"ProjectionsList": [ {"PropertyName": "Id", "Operator": 22} ],
"MaxResult": 1 }

...

{ "EntityType": "Winbooks.TORM.OM.Accounting.PayCode, Winbooks.TORM.OM",
"Conditions": [ {"Operator": 0, "PropertyName": "Code", "Values": ["7"] } ],
"ProjectionsList": [ {"PropertyName": "Id", "Operator": 22} ],
"MaxResult": 1 }

POST {{url}}/app/DocumentHeader/Folder/{{folder}}

The body of the request contains the document to post like this:

...

Children Display