Page History
...
POST {{url}}/app/Customer/TEST/Folder/{{folder}}
The body of the request until for version <= 2.4 of WinBooks on Web will be like this:
Code Block |
---|
{ "$type": "Winbooks.TORM.OM.Customer, Winbooks.TORM.OM", "TotalLevel": 4, "Code": "TEST", "VatApplicable": 1, "IsLocked": false, "IsHidden": false, "MemoType": 0, "Third": { "$type": "Winbooks.TORM.OM.Third, Winbooks.TORM.OM", "TotalLevel": 3, "Code": "TEST", "Name": "The Test Company", "VatNumber": "0000000196", "WebSite": "www.test.be", "Addresses": [ { "$type": "Winbooks.TORM.OM.Address, Winbooks.TORM.OM", "TotalLevel": 2, "Index": 0, "Address1": "Vuchtlaan 78", "Address2": "", "Town": "Antwerpen", "Zip": "2000", "Name": "", "Number": "", "Box": "", "PhoneNo": "+3233215476", "FaxNo": "", "MemoType": 0, "Memo": "", "IsDelivering": true, "IsDeliveringDefault": true, "IsPosting": true, "IsPostingDefault": true, "IsInvoicing": true, "IsInvoicingDefault": true, "CountryCode": "BE" } ], "CivilityCode": "NV", "VatCountryCode": "BE", "LanguageCode": "en", "CurrencyCode": "EUR" }, "VatCode": "21", "CategoryCode": "EU", "GLAccountDefaultCode": "700000", "GLAccountCentralCode": "400000", "PayCodeCode": "30" } |
The body from for version >= 2.5 of WinBooks On Web looks like this:
...
To post the customer, the body will be this one ( for version <= 2.4):
Code Block |
---|
{ "$type": "Winbooks.TORM.OM.Customer, Winbooks.TORM.OM", "TotalLevel": 3, "Vat_Id": "d939ccde-90ec-45bb-97fe-a74d006cd718", "CustomerCategory_Id": "c3613c92-d081-4a94-a245-a8b3005d2391", "GLAccount_Id": "c61c5554-0803-4286-9315-a74d006cd5aa", "GLAccount2_Id": "023a99d0-f1e5-45c8-b902-a74d006cd5a8", "PayCode_Id": "bee3ad14-c3b0-4284-80e7-a74d006cd9a8", "Code": "TEST2", "VatApplicable": 1, "IsLocked": false, "IsHidden": false, "MemoType": 0, "Third": { "$type": "Winbooks.TORM.OM.Third, Winbooks.TORM.OM", "TotalLevel": 2, "ThirdCivility_Id": "9bc5b8f4-3682-46c6-ac84-a74d006cd9ad", "VatCountry_Id": "4bb898f0-21ba-4ea9-9c35-a74d006cd473", "Language_Id": "4b2d0fa7-ecf7-4883-9e04-a89d00bcd216", "Currency_Id": "8d70e1d6-57cf-4bc1-8402-a74d006cd472", "Code": "TEST2", "Name": "The Test Company 2", "VatNumber": "0000000295", "WebSite": "www.test2.be", "Addresses": [ { "$type": "Winbooks.TORM.OM.Address, Winbooks.TORM.OM", "TotalLevel": 1, "Country_Id": "4bb898f0-21ba-4ea9-9c35-a74d006cd473", "Index": 0, "Address1": "Vuchtlaan 79", "Address2": "", "Town": "Antwerpen", "Zip": "2000", "Name": "", "Number": "", "Box": "", "PhoneNo": "+3233215476", "FaxNo": "", "MemoType": 0, "Memo": "", "IsDelivering": true, "IsDeliveringDefault": true, "IsPosting": true, "IsPostingDefault": true, "IsInvoicing": true, "IsInvoicingDefault": true } ] } } |
And this one for the version >= 2.5:
Code Block |
---|
{ "$type": "Winbooks.TORM.OM.Customer, Winbooks.TORM.OM", "TotalLevel": 4, "Code": "WB5", "Vat_Id": "1d625e47-4871-450b-91c8-9f9400b4ca36", "GLAccount_Id": "5633a32d-c312-4e19-9e6b-9f9400b4c691", "GLAccount2_Id": "d2647e20-8267-4703-90c0-9f9400b4c67a", "PayCode_Id": "f6a39f52-a79d-4758-933a-9f9400b4d059", "VatApplicable": 1, "Code": "WB5", "Third": { "$type": "Winbooks.TORM.OM.Third, Winbooks.TORM.OM", "TotalLevel": 3, "Code": "WB5", "ThirdCivility_Id": "5f4964b8-00f2-464f-a01d-9f9400b4d0ce", "VatCountry_Id": "8f8a337e-b483-4c30-b6ed-9f9400b4c553", "Language_Id": "5dc36906-5d31-4ff9-b20c-9f9400b4c5df", "Currency_Id": "2b790e84-f9f5-4ff6-b775-9f9400b4c54e", "Name": "Customer WB5", "VatNumber": "0000000394", "Code": "WB5", "Addresses": [ { "$type": "Winbooks.TORM.OM.Third_Address, Winbooks.TORM.OM", "TotalLevel": 2, "IsDelivering": true, "IsDeliveringDefault": true, "IsPosting": true, "IsPostingDefault": true, "IsInvoicing": true, "IsInvoicingDefault": true, "Index": 0, "Address": { "$type": "Winbooks.TORM.OM.Address, Winbooks.TORM.OM", "TotalLevel": 1, "Country_Id": "8f8a337e-b483-4c30-b6ed-9f9400b4c553", "Address1": "330 Lemonierlaan (WB5)", "Town": "Antwerpen", "Zip": "2000", "PhoneNo": "+3223456789" } } ] } } |
...
You can update the Customer and the Third by the same way you create them but you have to remove the address else it will create a new address. The address has to be updated separately.
POST PUT {{url}}/app/Customer/TEST2/Folder/{{folder}}
...
Update the Address
Find the Address Id
First, we have to retrieve the Id of the Address of the Third TEST2.
For version <= 2.4 of WinBooks on Web
This is the .NET query to do that (with the Winbooks.Apis.Service.dll):
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)); NewtonsoftNewtonsoft.Json.Linq.JArray addressid = _folder.GetFilterAll(criteria.JsonCriteriaSerialize(), "Address");
if (addressid == null)
Tools.Log(" no address for BEBOP");
else
Tools.Log(" address_id = " + addressid[0].ToString());
The corresponding http request is this one:
POST {{url}}/app/Addresss/Folder/{{folder}}/ExecuteCriteria
with the following JSON body:
Code Block |
---|
{
"EntityType": "Winbooks.TORM.OM.Address, Winbooks.TORM.OM",
"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" ], } ], "ProjectionsList": [ { "PropertyName": "Id", "Operator": 22 } ], } |
For version >= 2.5 of WinBooks on Web
This is the .NET query to do that (with the Winbooks.Apis.Service.dll):
ICriteria criteria = new Third_AddressDAO().CreateCriteria()
.CreateAlias("address", typeof(Address), Address.Names.Id, Third_Address.Names.Address_Id)
.CreateAlias("third", typeof(Third), Third.Names.Id, Third_Address.Names.Third_Id)
.Add(Condition.Eq("third." + Third.Names.Code, "BEBOP"))
.Add(Condition.Eq(Third_Address.Names.IsInvoicingDefault, true))
.SetProjection(Projections.Property("address." + Address.Names.Id));
Newtonsoft.Json.Linq.JArray addressid = _folder.GetFilterAll(criteria.JsonCriteriaSerialize(), "Third_Address");
if (addressid == null)
Tools.Log(" no address for BEBOP");
else
Tools.Log(" address_id = " + addressid[0].ToString());
The corresponding http request is this one:
POST {{url}}/app/Third_Addresss/Folder/{{folder}}/ExecuteCriteria
with the following JSON body:
Code Block |
---|
{ "EntityType": "Winbooks.TORM.OM.Third_Address, Winbooks.TORM.OM", "IsCustomization": false, "Alias": "this", "Association": { "address": { "AliasName": "address", "Type": "Winbooks.TORM.OM.Address, Winbooks.TORM.OM", "JoinType": 1, "LeftProperty": "Id", "RightProperty": "Address_Id" }, "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" ] }, { "Operator": 0, "PropertyName": "IsInvoicingDefault", "OtherPropertyName": "", "Values": [ true ] } ], "Havings": [], "ProjectionsList": [ { "PropertyName": "address.Id", "Operator": 22 } ], "Orders": [], "Params": {}, "FirstResult": -1, "MaxResult": -1, "ResultState": 0, "TimeOutSeconds": 0 } |
The result is an array of Id's:
[ "adb4d306-63c9-4d5d-a31a-a8b3008e9946" ]
...