You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Post a sale transaction


GLTransHeader

BookPeriodJournalDocNumberBookDateDueDate

March 2017

VERK715/03/201715/03/2017

GLTrans

LineOrderCentralAccountTypeGLAccountVatAmountVatBaseAmountTurnOverAmountVatTaxAmount...
0CUSTOMER400000
121010001000210
1
70000021-1000



2V0345100021-2101000




Important remark

Pay attention to the signs and when the following fields are filled: Vat, VatBaseAmount, TurnOverAmount, VatTaxAmount and the CurrencyXxx.
You should compare what you get through your POST with what you get when you encode via Wow.
You can view that in the Tools / Support / Explorer form / GLTransactionHeader and GLTransaction.
You can also view some of these fields in the TAB List of the encoding form.



Getting BookPeriod 3/2017

url: https://stg-api.winbooksonweb.be/app/BookPeriods/Folder/JF_TEST_RESTAPI/ExecuteCriteria (POST)

Body
{
    "EntityType": "Winbooks.TORM.OM.Accounting.BookPeriod, Winbooks.TORM.OM",
    "Conditions": [
        {
            "Operator": 0,
            "PropertyName": "RelatedYear",
            "OtherPropertyName": "",
            "Values": [2017]
        },
        {
            "Operator": 0,
            "PropertyName": "RelatedMonth",
            "OtherPropertyName": "",
            "Values": [3]
        },
        {
            "Operator": 21,
            "PropertyName": "",
            "OtherPropertyName": "",
            "Values": [
                {
                    "Operator": 0,
                    "PropertyName": "Number",
                    "OtherPropertyName": "",
                    "Values": [0]
                }
            ]
        }
    ],
    "Orders": [
        {
            "PropertyName": "Number",
            "Alias": null,
            "Projections": null,
            "Ascending": true
        }
    ],
    "FirstResult": 0,
    "MaxResult": 1
}



Getting Journal VERK for bookyear 71070394-f7aa-4f07-aecb-a74d006cd568


url: https://stg-api.winbooksonweb.be/app/Journals/Folder/JF_TEST_RESTAPI/ExecuteCriteria (POST)

{
    "EntityType": "Winbooks.TORM.OM.Accounting.Journal, Winbooks.TORM.OM",
    "Conditions": [
        {
            "Operator": 0,
            "PropertyName": "BookYear_Id",
            "OtherPropertyName": "",
            "Values": [
                "71070394-f7aa-4f07-aecb-a74d006cd568"
            ]
        },
        {
            "Operator": 0,
            "PropertyName": "Code",
            "OtherPropertyName": "",
            "Values": [
                "VERKP"
            ]
        }
    ],
    "FirstResult": 0,
    "MaxResult": 1
}

-> 126dc006-149c-4561-b369-a85d0118361f

Getting the Vat 21

GET {{url}}/app/Vat/21/Folder/{{folder}}

Getting Vat 21
-> d939ccde-90ec-45bb-97fe-a74d006cd718


Getting account 400000

url: https://stg-api.winbooksonweb.be/app/GLAccounts/Folder/JF_TEST_RESTAPI/ExecuteCriteria (POST)

{
    "EntityType": "Winbooks.TORM.OM.Accounting.GLAccount, Winbooks.TORM.OM",
    "Association": {
        "gLAccountBookYear": {
            "AliasName": "gLAccountBookYear",
            "Type": "Winbooks.TORM.OM.Accounting.GLAccount_BookYear, Winbooks.TORM.OM",
            "JoinType": 1,
            "LeftProperty": "GLAccount_Id",
            "RightProperty": "Id"
        }
    },
    "Conditions": [
        {
            "Operator": 0,
            "PropertyName": "gLAccountBookYear.BookYear_Id",
            "OtherPropertyName": "",
            "Values": [
                "71070394-f7aa-4f07-aecb-a74d006cd568"
            ]
        },
        {
            "Operator": 0,
            "PropertyName": "Code",
            "OtherPropertyName": "",
            "Values": [
                "400000"
            ]
        }
    ],
    "FirstResult": 0,
    "MaxResult": 1
}

-> 023a99d0-f1e5-45c8-b902-a74d006cd5a8


Getting VAT account for CentralAccountType.Id = cd7a050f-4876-4124-b6d0-a74d006cd582

url: https://stg-api.winbooksonweb.be/app/GLAccount_CentralAccountTypes/Folder/JF_TEST_RESTAPI/ExecuteCriteria (POST)

{
    "EntityType": "Winbooks.TORM.OM.Accounting.GLAccount_CentralAccountType, Winbooks.TORM.OM",
    "Conditions": [
        {
            "Operator": 0,
            "PropertyName": "CentralAccountType_Id",
            "OtherPropertyName": "",
            "Values": [
                "cd7a050f-4876-4124-b6d0-a74d006cd582"
            ]
        }
    ],
    "FirstResult": 0,
    "MaxResult": 1
}

-> 78e3f0f9-aacb-433b-b993-a74d006cd5a9


Getting the Currency Id for code EUR ...

url: https://stg-api.winbooksonweb.be/app/Currencys/Folder/JF_TEST_RESTAPI/ExecuteCriteria (POST)

{
    "EntityType": "Winbooks.TORM.OM.Currency, Winbooks.TORM.OM",
    "Conditions": [
        {
            "Operator": 0,
            "PropertyName": "Code",
            "OtherPropertyName": "",
            "Values": [
                "EUR"
            ]
        }
    ],
    "FirstResult": -1,
    "MaxResult": 1
}

 -> 8d70e1d6-57cf-4bc1-8402-a74d006cd472



*************************************************************************************
* Here, as we just need the Id, we use a projection which is more efficient
* We could do so for some other entities
*************************************************************************************
Getting the Customer Id for code BEBOP ...

url: https://stg-api.winbooksonweb.be/app/Customers/Folder/JF_TEST_RESTAPI/ExecuteCriteria (POST)

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

 -> f5e92880-31c0-43af-9348-a85d0117d78b


Getting the GLAccount Id for code 700000 ...

url: https://stg-api.winbooksonweb.be/app/GLAccounts/Folder/JF_TEST_RESTAPI/ExecuteCriteria (POST)

{
    "EntityType": "Winbooks.TORM.OM.Accounting.GLAccount, Winbooks.TORM.OM",
    "Conditions": [
        {
            "Operator": 0,
            "PropertyName": "Code",
            "OtherPropertyName": "",
            "Values": [
                "700000"
            ]
        }
    ],
    "ProjectionsList": [
        {
            "PropertyName": "Id",
            "Operator": 22
        }
    ],
    "FirstResult": -1,
    "MaxResult": 1
}

 -> c61c5554-0803-4286-9315-a74d006cd5aa


Getting the GLTransHeader with the highest DocNumber in the journal
url: https://stg-api.winbooksonweb.be/app/GLTransHeaders/Folder/JF_TEST_RESTAPI/ExecuteCriteria (POST)

{
    "EntityType": "Winbooks.TORM.OM.Accounting.GLTransHeader, Winbooks.TORM.OM",
    "Conditions": [
        {
            "Operator": 0,
            "PropertyName": "Journal_Id",
            "OtherPropertyName": "",
            "Values": [
                "126dc006-149c-4561-b369-a85d0118361f"
            ]
        }
    ],
    "Orders": [
        {
            "PropertyName": "DocNumber",
            "Alias": null,
            "Projections": null,
            "Ascending": false
        }
    ],
    "FirstResult": 0,
    "MaxResult": 1
}

-> DocNumber = 6

POSTING the invoice


Creating GLTransHeader + 2 level VERKP  7 in Mar 2017

url: https://stg-api.winbooksonweb.be/app/GLTransHeader/Folder/JF_TEST_RESTAPI (POST)
{
    "$type": "Winbooks.TORM.OM.Accounting.GLTransHeader, Winbooks.TORM.OM",
    "TotalLevel": 2,
    "BookPeriod_Id": "911157a0-a894-42a4-8339-a74d006cd568",
    "Journal_Id": "126dc006-149c-4561-b369-a85d0118361f",
    "DocNumber": 9,
    "BookDate": "\/Date(1489536000000)\/",
    "DueDate": "\/Date(1492214400000)\/",
    "GLTransactions": [
        {
            "$type": "Winbooks.TORM.OM.Accounting.GLTrans, Winbooks.TORM.OM",
            "TotalLevel": 1,
            "BookPeriod_Id": "911157a0-a894-42a4-8339-a74d006cd568",
            "Currency_Id": "8d70e1d6-57cf-4bc1-8402-a74d006cd472",
            "GLAccount_Id": "023a99d0-f1e5-45c8-b902-a74d006cd5a8",
            "CentralAccountType_Id": "a58991c8-625f-435d-9402-a74d006cd580",
            "Customer_Id": "f5e92880-31c0-43af-9348-a85d0117d78b",
            "LineOrder": 0,
            "ValueDate": "\/Date(1489536000000)\/",
            "Amount": 1210.0,
            "VatBaseAmount": 1000.0,
            "TurnOverAmount": 1000.0,
            "VatTaxAmount": 210.0,
            "IsVatAllocation": false,
            "OldestMatchedDate": "\/Date(1489536000000)\/",
            "CurrencyAmount": 1210.0,
            "CurrencyRate": 1.0,
            "CurrencyVatBaseAmount": 1000.0,
            "CurrencyVatTaxAmount": 210.0,
            "CommentBooking": "Customer Bla bla bla 17/05/2018 17:23:40"
        },
        {
            "$type": "Winbooks.TORM.OM.Accounting.GLTrans, Winbooks.TORM.OM",
            "TotalLevel": 1,
            "BookPeriod_Id": "911157a0-a894-42a4-8339-a74d006cd568",
            "Currency_Id": "8d70e1d6-57cf-4bc1-8402-a74d006cd472",
            "GLAccount_Id": "c61c5554-0803-4286-9315-a74d006cd5aa",
            "Vat_Id": "d939ccde-90ec-45bb-97fe-a74d006cd718",
            "Customer_Id": "f5e92880-31c0-43af-9348-a85d0117d78b",
            "LineOrder": 1,
            "ValueDate": "\/Date(1489536000000)\/",
            "Amount": -1000.0,
            "IsVatAllocation": false,
            "OldestMatchedDate": "\/Date(1489536000000)\/",
            "CurrencyAmount": -1000.0,
            "CurrencyRate": 1.0,
            "CommentBooking": "Turnover Bla bla bla 17/05/2018 17:23:40"
        },
        {
            "$type": "Winbooks.TORM.OM.Accounting.GLTrans, Winbooks.TORM.OM",
            "TotalLevel": 1,
            "Version": 0,
            "BookPeriod_Id": "911157a0-a894-42a4-8339-a74d006cd568",
            "Currency_Id": "8d70e1d6-57cf-4bc1-8402-a74d006cd472",
            "GLAccount_Id": "78e3f0f9-aacb-433b-b993-a74d006cd5a9",
            "CentralAccountType_Id": "cd7a050f-4876-4124-b6d0-a74d006cd582",
            "Vat_Id": "d939ccde-90ec-45bb-97fe-a74d006cd718",
            "Customer_Id": "f5e92880-31c0-43af-9348-a85d0117d78b",
            "LineOrder": 2,
            "ValueDate": "\/Date(1489536000000)\/",
            "Amount": -210.0,
            "VatBaseAmount": 1000.0,
            "IsVatAllocation":true,
            "OldestMatchedDate": "\/Date(1489536000000)\/",
            "CurrencyAmount": -210.0,
            "CurrencyRate": 1.0,
            "CurrencyVatBaseAmount": 1000.0,
            "CommentBooking": "Vat Bla bla bla 17/05/2018 17:23:40"
        }
    ]
}


Getting the GLTransHeader just posted

url: https://stg-api.winbooksonweb.be/app/GLTransHeaders/Folder/JF_TEST_RESTAPI/ExecuteCriteria (POST)
{
    "EntityType": "Winbooks.TORM.OM.Accounting.GLTransHeader, Winbooks.TORM.OM",
    "Association": {
        "jnl": {
            "AliasName": "jnl",
            "Type": "Winbooks.TORM.OM.Accounting.Journal, Winbooks.TORM.OM",
            "JoinType": 1,
            "LeftProperty": "Id",
            "RightProperty": "Journal_Id"
        }
    },
    "Conditions": [
        {
            "Operator": 0,
            "PropertyName": "jnl.Code",
            "OtherPropertyName": "",
            "Values": [
                "VERKP"
            ]
        },
        {
            "Operator": 0,
            "PropertyName": "DocNumber",
            "OtherPropertyName": "",
            "Values": [
                7
            ]
        }
    ],
    "FirstResult": -1,
    "MaxResult": -1
}


Get the history of a general account

With the .NET Winbooks.Apis.Services.dll


        private static string GetGLTransactions()
        {
            string glAccountCode = "604000";
            DateTime dateFrom = new DateTime(2018, 1, 1);

            Tools.Log(string.Format("Getting transactions of {0} from {1} ...", glAccountCode, dateFrom));

            Guid glAccount_Id = GetId(new GLAccountDAO().CreateCriteria(), "GLAccount", glAccountCode);

            ICriteria criteria = new GLTransDAO().CreateCriteria()
            .CreateAlias("header", typeof(GLTransHeader), GLTransHeader.Names.Id, GLTrans.Names.GLTransHeader_Id)
            .CreateAlias("header", "jnl", typeof(Journal), Journal.Names.Id, GLTransHeader.Names.Journal_Id)
            .CreateAlias("header", "period", typeof(BookPeriod), BookPeriod.Names.Id, GLTransHeader.Names.BookPeriod_Id)
            .CreateAlias("period", "year", typeof(BookYear), BookYear.Names.Id, BookPeriod.Names.BookYear_Id)
            .CreateAlias(JoinType.LeftOuterJoin, "sup", typeof(Supplier), Supplier.Names.Id, GLTrans.Names.Supplier_Id)
            .Add(Condition.Eq(GLTrans.Names.GLAccount_Id, glAccount_Id))
            .Add(Condition.Ge("header." + GLTransHeader.Names.BookDate, dateFrom))
            .SetProjection(Projections.Property("header." + GLTransHeader.Names.BookDate),
                           Projections.Property("year." + BookYear.Names.Name),
                           Projections.Property("period." + BookPeriod.Names.Name),
                           Projections.Property("jnl." + Journal.Names.Code),
                           Projections.Property("header." + GLTransHeader.Names.DocNumber),
                           Projections.Property("sup." + Supplier.Names.Code),
                           Projections.Property(GLTrans.Names.Amount),
                           Projections.Property(GLTrans.Names.CommentBooking),
                           Projections.Property(GLTrans.Names.CommentExternal))
            .Order("header."+GLTransHeader.Names.BookDate)
            ;

            Newtonsoft.Json.Linq.JArray transs = _folder.GetFilterAll(criteria.JsonCriteriaSerialize(), "GLTrans");

            if (transs != null)
            {
                foreach (Newtonsoft.Json.Linq.JToken trans in transs)
                    Tools.Log(trans[0].ToString() + " " +
                        trans[1].ToString() + " " +
                        trans[2].ToString() + " " +
                        trans[3].ToString() + " " +
                        trans[4].ToString() + " " +
                        trans[5].ToString() + " " +
                        trans[6].ToString() + " " +
                        trans[7].ToString() + " " +
                        trans[8].ToString()
                        );
            }
            else
                Tools.Log("  no transaction");

            Tools.Log("  Done");

            return "OK";
        }


With the HTTP request / JSON

Get the Id of the general account

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

The body of the request:


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


The result is:

[
"1349f47e-00f9-48af-bcd4-a74d006cd5a9"
]

Get the transaction of the general account after a specific date

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

The body of the request:

{
   "EntityType": "Winbooks.TORM.OM.Accounting.GLTrans, Winbooks.TORM.OM",
   "Alias": "this",
   "Association": {
      "header": {
         "AliasName": "header",
         "Type": "Winbooks.TORM.OM.Accounting.GLTransHeader, Winbooks.TORM.OM",
         "JoinType": 1,
         "LeftProperty": "Id",
         "RightProperty": "GLTransHeader_Id"
      },
      "jnl": {
         "OwnerAlias": "header",
         "AliasName": "jnl",
         "Type": "Winbooks.TORM.OM.Accounting.Journal, Winbooks.TORM.OM",
         "JoinType": 1,
         "LeftProperty": "Id",
         "RightProperty": "Journal_Id"
      },
      "period": {
         "OwnerAlias": "header",
         "AliasName": "period",
         "Type": "Winbooks.TORM.OM.Accounting.BookPeriod, Winbooks.TORM.OM",
         "JoinType": 1,
         "LeftProperty": "Id",
         "RightProperty": "BookPeriod_Id"
      },
      "year": {
         "OwnerAlias": "period",
         "AliasName": "year",
         "Type": "Winbooks.TORM.OM.Accounting.BookYear, Winbooks.TORM.OM",
         "JoinType": 1,
         "LeftProperty": "Id",
         "RightProperty": "BookYear_Id"
      },
      "sup": {
         "AliasName": "sup",
         "Type": "Winbooks.TORM.OM.Supplier, Winbooks.TORM.OM",
         "JoinType": 2,
         "LeftProperty": "Id",
         "RightProperty": "Supplier_Id"
      }
   },
   "Conditions": [
      {
         "Operator": 0,
         "PropertyName": "GLAccount_Id",
         "OtherPropertyName": "",
         "Values": [
            "1349f47e-00f9-48af-bcd4-a74d006cd5a9"
         ],
      },
      {
         "Operator": 3,
         "PropertyName": "header.BookDate",
         "OtherPropertyName": "",
         "Values": [
            "2018-01-01T00:00:00"
         ],
      }
   ],
   "ProjectionsList": [
      {
         "PropertyName": "header.BookDate",
         "Operator": 22
      },
      {
         "PropertyName": "year.Name",
         "Operator": 22
      },
      {
         "PropertyName": "period.Name",
         "Operator": 22
      },
      {
         "PropertyName": "jnl.Code",
         "Operator": 22
      },
      {
         "PropertyName": "header.DocNumber",
         "Operator": 22
      },
      {
         "PropertyName": "sup.Code",
         "Operator": 22
      },
      {
         "PropertyName": "Amount",
         "Operator": 22
      },
      {
         "PropertyName": "CommentBooking",
         "Operator": 22
      },
      {
         "PropertyName": "CommentExternal",
         "Operator": 22
      }
   ],
   "Orders": [
      {
         "PropertyName": "header.BookDate",
         "Alias": null,
         "Projections": null,
         "Ascending": true
      }
   ]
}

The result:

[
    [
        "/Date(1520982000000+0100)/",
        "Exercice 2018",
        "Mar 2018",
        "SINV",
        1,
        "EDDYMERCKX",
        140,
        "Wheel",
        null
    ],
    [
        "/Date(1520982000000+0100)/",
        "Exercice 2018",
        "Mar 2018",
        "SINV",
        1,
        "EDDYMERCKX",
        200,
        "Frame",
        null
    ]
]


  • No labels