---
title: "Examples using the Rest API with accounting transactions"
canonical: "https://help.winbooks.be/space/DEV/3211374/Examples%20using%20the%20Rest%20API%20with%20accounting%20transactions"
format: markdown
---
# Post a sale transaction


GLTransHeader

| **BookPeriod** | **Journal** | **DocNumber** | **BookDate** | **DueDate** |
| --- | --- | --- | --- | --- |
| **March 2017** | **VERK** | **7** | **15/03/2017** | **15/03/2017** |

GLTrans

| **LineOrder** | **CentralAccountType** | **GLAccount** | **Vat** | **Amount** | **VatBaseAmount** | **TurnOverAmount** | **VatTaxAmount** | **...** |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 0 | CUSTOMER | 400000 |  | 1210 | 1000 | 1000 | 210 |  |
| 1 |  | 700000 | 21 | -1000 |  |  |  |  |
| 2 | V03 | 451000 | 21 | -210 | 1000 |  |  |  |



> ℹ️ **Important remark**
> ℹ️ 
> ℹ️ <span style="color: #ff0000">**Pay attention to the signs and when the following fields are filled: Vat, VatBaseAmount, TurnOverAmount, VatTaxAmount and the CurrencyXxx.**</span>  
> ℹ️ <span style="color: #ff0000">**You can download an example of booking for sale, purchase and their credit notes **</span><span style="color: #ff0000">**.**</span>
> ℹ️ 
> ℹ️ **<span style="color: #ff0000">You should compare what you get through your POST with what you get when you encode via Wow.</span>**  
> ℹ️ **<span style="color: #ff0000">You can view that in the Tools / Support / Explorer form / GLTransactionHeader and GLTransaction.</span>**  
> ℹ️ **<span style="color: #ff0000">You can also view some of these fields in the TAB List of the encoding form.</span>**

> ℹ️ **About performances**
> ℹ️ 
> ℹ️ **<span style="color: #339966">If you book a batch of invoices, before to book the batch, you should get the Id of the recurring objects which are often the same for all invoices:</span>**
> ℹ️ 
> ℹ️ - **<span style="color: #339966">BookPeriod</span>**
> ℹ️ - **<span style="color: #339966">Journal</span>**
> ℹ️ - **<span style="color: #339966">CentralAccountType for Customers or Suppliers</span>**
> ℹ️ - **<span style="color: #339966">GLAccounts if they are often the same, or make a cache in your application to find the Id of a GLAccount.Code that you already got</span>**
> ℹ️ - **<span style="color: #339966">Vat for most used VAT code (0, 6, 21, ...)</span>**
> ℹ️ - **<span style="color: #339966">Currency</span>**
> ℹ️ - **<span style="color: #339966">Customer Id for the walking customer</span>**
> ℹ️ 
> ℹ️ **<span style="color: #339966">Doing like that, you will have a quicker posting of your invoices and you will load less the infrastructure of WinBooks on Web</span>**



## Getting BookPeriod 3/2017

<details>
<summary>C# code</summary>

```csharp
        BookPeriod bookPeriod = GetEntity.GetBookPeriod(_folder, 2017, 3);


        public static BookPeriod GetBookPeriod(EntitiesServices folder, int relatedYear, int relatedMonth)
        {
            var periodCriteria = new BookPeriodDAO().CreateCriteria()
                .Add(Condition.Eq(BookPeriod.Names.RelatedYear, relatedYear))
                .Add(Condition.Eq(BookPeriod.Names.RelatedMonth, relatedMonth))
                .Add(Condition.NotEq(BookPeriod.Names.Number, 0))                    // to avoid opening period
                .Order(BookPeriod.Names.Number, true)                                // to avoid the closing period
                .SetFirstResult(0).SetMaxResults(1);

            BookPeriod bookPeriod = folder.GetFilter<BookPeriod>(periodCriteria);
            return bookPeriod;
        }
```
</details>


**<span style="color: #ff9900">POST</span>**<span style="color: #ff9900"> </span><span style="color: #ff8f4e">{{url}}</span>/app/BookPeriods/Folder/<span style="color: #ff8f4e">{{folder}}</span>/ExecuteCriteria

<details>
<summary>Body</summary>

```
{
    "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
}
```
</details>


<details>
<summary>Result</summary>

```
[
    {
        "$type": "Winbooks.TORM.OM.Accounting.BookPeriod, Winbooks.TORM.OM",
        "TotalLevel": 1,
        "IsEnded": false,
        "Version": 1,
        "Modified": null,
        "ModifiedBy": "00000000-0000-0000-0000-000000000000",
        "Created": "/Date(1491453375000)/",
        "CreatedBy": "7507ea76-474b-4ccc-80d3-a35b0090b2b6",
        "Folder_Id": "3a6a9ea1-ce6e-45e7-889a-d8e325a43b70",
        "BookYear_Id": "71070394-f7aa-4f07-aecb-a74d006cd568",
        "IType": "P",
        "Number": 4,
        "Name": "Avr 2017",
        "Begin": "/Date(1491004800000)/",
        "End": "/Date(1493510400000)/",
        "IsClosed": false,
        "IsSalesClosed": false,
        "IsPurchaseClosed": false,
        "IsCashbookClosed": false,
        "IsMiscellaneousOperationClosed": false,
        "IsCashbookCostAccountingClosed": false,
        "IsMiscellaneousOperationCostAccountingClosed": false,
        "IsPurchaseCostAccountingClosed": false,
        "IsSalesCostAccountingClosed": false,
        "IsCostAccountingClosed": false,
        "Archived": false,
        "RelatedMonth": 4,
        "RelatedYear": 2017,
        "IsVatDone": false,
        "LocalizedProperties": [
            "Name"
        ],
        "LocalizedColumns": [
            "Name"
        ],
        "ChildPeriod_Types": "Winbooks.TORM.OM.Accounting.BookYear, Winbooks.TORM.OM",
        "Id": "302eda6b-c8f9-40cb-aeaa-a74d006cd568",
        "ResultState": 0,
        "ActionState": 0,
        "CachedCollection": {},
        "IsBinding": false,
        "IsSpecifiedId": false,
        "IsDirty": false,
        "UpdatedEntities": {},
        "Localized": {},
        "Custom": {},
        "UpdatedProperties": [],
        "UpdatedValues": [],
        "FolderCode": "JF_TEST_RESTAPI"
    }
]
```
</details>



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


<details>
<summary>C# code</summary>

```
        Journal journal = GetEntity.GetJournal(_folder, "VERKP", bookPeriod);

        public static Journal GetJournal(EntitiesServices folder, string journalCode, BookPeriod bookPeriod)
        {
            var journalCriteria = new JournalDAO().CreateCriteria()
                .Add(Condition.Eq(Journal.Names.BookYear_Id, bookPeriod.BookYear_Id))
                .Add(Condition.Eq(Journal.Names.Code, journalCode))
                .SetFirstResult(0).SetMaxResults(1);

            Journal journal = folder.GetFilter<Journal>(journalCriteria);
            return journal;
        }
```
</details>


**<span style="color: #ff9900">POST </span>**<span style="color: #ff8f4e">**{{url}}**</span>/app/Journals/Folder/<span style="color: #ff8f4e">{{folder}}</span>/ExecuteCriteria

<details>
<summary>Body</summary>

```
{
    "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
}
```
</details>


<details>
<summary>Result</summary>

```
[
    {
        "$type": "Winbooks.TORM.OM.Accounting.Journal, Winbooks.TORM.OM",
        "TotalLevel": 1,
        "Version": 2,
        "Modified": "/Date(1514995935000)/",
        "ModifiedBy": "7507ea76-474b-4ccc-80d3-a35b0090b2b6",
        "Created": "/Date(1514995213000)/",
        "CreatedBy": "7507ea76-474b-4ccc-80d3-a35b0090b2b6",
        "Folder_Id": "3a6a9ea1-ce6e-45e7-889a-d8e325a43b70",
        "BookYear_Id": "71070394-f7aa-4f07-aecb-a74d006cd568",
        "Currency_Id": "00000000-0000-0000-0000-000000000000",
        "GLAccount_Id": "00000000-0000-0000-0000-000000000000",
        "JournalLog_Id": "00000000-0000-0000-0000-000000000000",
        "BankAccount_Id": "00000000-0000-0000-0000-000000000000",
        "Code": "VERKP",
        "Name": "Verkopen",
        "Type": 2,
        "SubType": 0,
        "IsLocked": false,
        "IsWbcReserved": false,
        "ExportFromPeriod": 0,
        "ExportToPeriod": 0,
        "VatJournal": false,
        "ExtractEncoding": false,
        "AllowedSigns": 0,
        "BusinessAccount": "",
        "CodaNumberPosition": 0,
        "IsIntrastat": false,
        "BatchBooking": null,
        "LocalizedProperties": [
            "Name"
        ],
        "LocalizedColumns": [
            "Name"
        ],
        "Id": "126dc006-149c-4561-b369-a85d0118361f",
        "ResultState": 0,
        "ActionState": 0,
        "CachedCollection": {},
        "IsBinding": false,
        "IsSpecifiedId": false,
        "IsDirty": false,
        "UpdatedEntities": {},
        "Localized": {},
        "Custom": {},
        "UpdatedProperties": [],
        "UpdatedValues": [],
        "FolderCode": "JF_TEST_RESTAPI",
        "CurrencyCode": "",
        "GLAccountCode": "",
        "JournalLogCode": ""
    }
]
```
</details>

## Getting the Vat 21

<details>
<summary>C# code</summary>

```csharp
folder.GetByCode<Vat>("21");
```
</details>




**<span style="color: #339966">GET</span>**<span style="color: #339966"> </span><span style="color: #ff8f4e">{{url}}</span><span style="color: #505050">/app/Vat/21/Folder/</span><span style="color: #ff8f4e">{{folder}}</span>

<details>
<summary>Result</summary>

```
{
    "$type": "Winbooks.TORM.OM.Accounting.VatAccount, Winbooks.TORM.OM",
    "TotalLevel": 1,
    "Version": 2,
    "Modified": null,
    "ModifiedBy": "00000000-0000-0000-0000-000000000000",
    "Created": "/Date(1491453376000)/",
    "CreatedBy": "7507ea76-474b-4ccc-80d3-a35b0090b2b6",
    "Folder_Id": "3a6a9ea1-ce6e-45e7-889a-d8e325a43b70",
    "Parent_Id": "08ed287c-ec3b-4d17-babc-a74d006cd718",
    "Vat_Id": "00000000-0000-0000-0000-000000000000",
    "CentralAccountType_Id": "cd7a050f-4876-4124-b6d0-a74d006cd582",
    "CentralAccountType2_Id": "00000000-0000-0000-0000-000000000000",
    "CentralAccountType3_Id": "cd7a050f-4876-4124-b6d0-a74d006cd582",
    "CentralAccountType4_Id": "00000000-0000-0000-0000-000000000000",
    "IType": "V",
    "ParentIndex": null,
    "Code": "21",
    "Rate": 21,
    "DeductibilityRate": null,
    "TreeLevel": "",
    "ValidFrom": "/Date(820454400000)/",
    "ValidTo": "/Date(3453235200000)/",
    "TaxType": 1,
    "DeductionType": 0,
    "IsInTurnOver": true,
    "IntracomStatus": 0,
    "IsIntrastat": false,
    "BaseInvoiceField": "+03            ",
    "TaxInvoiceField": "+54            ",
    "BaseCreditNoteField": "+49            ",
    "TaxCreditNoteField": "+64            ",
    "GLAccountValidPrefix": "7*",
    "Description": "Ventes 21%",
    "TreeLibDesc": "21%   (   21   )",
    "BaseCompute": 1,
    "TaxCompute": 1,
    "InputType": 2,
    "Community": 1,
    "IsHidden": false,
    "IsLocked": false,
    "IsCustomized": false,
    "IsInAnnualVatList": true,
    "IsVatInCashBookOrPrincipalJournal": true,
    "IsInvertedBehavior": false,
    "IsVatConsistency": true,
    "IdentificationCode": "211400",
    "Note": "Toute vente de biens et/ou services pour lesquels le tarif réduit n'est pas d'application.",
    "IsMoss": false,
    "LocalizedProperties": [
        "Code",
        "Note",
        "TreeLibDesc",
        "Description"
    ],
    "LocalizedColumns": [
        "Code",
        "bigstring0",
        "string1",
        "largestring0"
    ],
    "CodeLocalized": "21",
    "NoteLocalized": "Toute vente de biens et/ou services pour lesquels le tarif réduit n'est pas d'application.",
    "TreeLibDescLocalized": "21%   (   21   )",
    "DescriptionLocalized": "Ventes 21%",
    "Parent_Types": "Winbooks.TORM.OM.Accounting.VatGroup, Winbooks.TORM.OM",
    "Id": "d939ccde-90ec-45bb-97fe-a74d006cd718",
    "ResultState": 0,
    "ActionState": 0,
    "CachedCollection": {},
    "IsBinding": false,
    "IsSpecifiedId": false,
    "IsDirty": false,
    "UpdatedEntities": {},
    "Localized": {},
    "Custom": {},
    "UpdatedProperties": [],
    "UpdatedValues": [],
    "ParentCode": "",
    "childVatCode": "",
    "CentralAccountTypeCode": "V03",
    "CentralAccountType2Code": "",
    "CentralAccountType3Code": "V03",
    "CentralAccountType4Code": "",
    "LinkedVatCode": "",
    "CentralAccountTypeInvoice1Code": "V03",
    "CentralAccountTypeInvoice2Code": "",
    "CentralAccountTypeCreditNote1Code": "V03",
    "CentralAccountTypeCreditNote2Code": ""
}
```
</details>

## Getting account 400000

<details>
<summary>C# code</summary>

```csharp
folder.GetByCode<GLAccount>("400000");
```
</details>


**<span style="color: #339966">GET </span>**<span style="color: #ff8f4e">{{url}}</span><span style="color: #505050">/app/GLAccount/400000/Folder/</span><span style="color: #ff8f4e">{{folder}}</span>


<details>
<summary>Result</summary>

```
{
    "$type": "Winbooks.TORM.OM.Accounting.GLAccount, Winbooks.TORM.OM",
    "TotalLevel": 1,
    "Version": 1,
    "Modified": null,
    "ModifiedBy": "00000000-0000-0000-0000-000000000000",
    "Created": "/Date(1491453375000)/",
    "CreatedBy": "7507ea76-474b-4ccc-80d3-a35b0090b2b6",
    "Folder_Id": "3a6a9ea1-ce6e-45e7-889a-d8e325a43b70",
    "Title_Id": "00000000-0000-0000-0000-000000000000",
    "GLCategory_Id": "00000000-0000-0000-0000-000000000000",
    "Vat_Id": "00000000-0000-0000-0000-000000000000",
    "CentralAccountType_Id": "a58991c8-625f-435d-9402-a74d006cd580",
    "Currency_Id": "00000000-0000-0000-0000-000000000000",
    "GLAccount_Id": "00000000-0000-0000-0000-000000000000",
    "GLAccount2_Id": "00000000-0000-0000-0000-000000000000",
    "GLAccount3_Id": "00000000-0000-0000-0000-000000000000",
    "GLAccount4_Id": "00000000-0000-0000-0000-000000000000",
    "Name": "Clients",
    "Code": "400000",
    "Type": 0,
    "Side": 0,
    "IsToMatch": false,
    "IsLocked": false,
    "IsPrintSum": false,
    "IsTitle": false,
    "IsResultAccount": false,
    "IsDisallowedExpense": false,
    "IsHidden": false,
    "MemoType": 0,
    "Memo": "",
    "DeductibilityRate_Id": "00000000-0000-0000-0000-000000000000",
    "LocalizedProperties": [
        "Name"
    ],
    "LocalizedColumns": [
        "Name"
    ],
    "Id": "023a99d0-f1e5-45c8-b902-a74d006cd5a8",
    "ResultState": 0,
    "ActionState": 0,
    "CachedCollection": {},
    "IsBinding": false,
    "IsSpecifiedId": false,
    "IsDirty": false,
    "UpdatedEntities": {},
    "Localized": {},
    "Custom": {},
    "UpdatedProperties": [],
    "UpdatedValues": [],
    "FolderCode": "JF_TEST_RESTAPI",
    "CategoryCode": "",
    "VatCode": "",
    "DefaultCentralAccountTypeCode": "CUSTOMER",
    "CurrencyCode": "",
    "GLAccountInternalBalanceDBCode": "",
    "GLAccountInternalBalanceCDCode": "",
    "GLAccountOfficialBalanceDBCode": "",
    "GLAccountOfficialBalanceCDCode": ""
}
```
</details>

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

<details>
<summary>C# code</summary>

```csharp
            var criteria = new GLAccount_CentralAccountTypeDAO().CreateCriteria()
                .Add(Condition.Eq(GLAccount_CentralAccountType.Names.CentralAccountType_Id, id))
                .SetFirstResult(0).SetMaxResults(1);

            GLAccount_CentralAccountType glAccCentType = folder.GetFilter<GLAccount_CentralAccountType>(criteria);
            if (glAccCentType == null)
                return null;
            if (glAccCentType.GLAccount_Id == System.Guid.Empty)
                return null;
            GLAccount glAccount = folder.GetById<GLAccount>(glAccCentType.GLAccount_Id);
```
</details>


**<span style="color: #ff9900">POST</span>**<span style="color: #ff9900"> </span><span style="color: #ff8f4e">{{url}}</span>/app/GLAccount_CentralAccountTypes/Folder/JF_TEST_RESTAPI/ExecuteCriteria

<details>
<summary>Body</summary>

```
{
    "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
}
```
</details>


<details>
<summary>Result</summary>

```
[
    {
        "$type": "Winbooks.TORM.OM.Accounting.GLAccount_CentralAccountType, Winbooks.TORM.OM",
        "TotalLevel": 1,
        "Version": 1,
        "GLAccount_Id": "78e3f0f9-aacb-433b-b993-a74d006cd5a9",
        "CentralAccountType_Id": "cd7a050f-4876-4124-b6d0-a74d006cd582",
        "Id": "b0eec357-2546-421f-8f9f-a74d006cd5a9",
        "ResultState": 0,
        "ActionState": 0,
        "CachedCollection": {},
        "IsBinding": false,
        "IsSpecifiedId": false,
        "IsDirty": false,
        "UpdatedEntities": {},
        "Custom": {},
        "UpdatedProperties": [],
        "UpdatedValues": [],
        "GLAccountCode": "451000",
        "CentralAccountTypeCode": "V03"
    }
]
```
</details>


## Getting the currency EUR

<details>
<summary>C# code</summary>

```csharp
folder.GetByCode<Currency>("EUR");
```
</details>


<span style="color: #339966">GET </span><span style="color: #ff8f4e">{{url}}</span><span style="color: #505050">/app/Currency/EUR/Folder/</span><span style="color: #ff8f4e">{{folder}}</span>

<details>
<summary>Result</summary>

```
{
    "$type": "Winbooks.TORM.OM.Currency, Winbooks.TORM.OM",
    "TotalLevel": 1,
    "Code": "EUR",
    "CodeISO": "EUR",
    "Version": 1,
    "Modified": null,
    "ModifiedBy": "00000000-0000-0000-0000-000000000000",
    "Created": "/Date(1491453374000)/",
    "CreatedBy": "7507ea76-474b-4ccc-80d3-a35b0090b2b6",
    "Folder_Id": "3a6a9ea1-ce6e-45e7-889a-d8e325a43b70",
    "Name": "Euro",
    "NumberOfDecimals": 2,
    "Rate": null,
    "RateDate": null,
    "IsRateInverse": false,
    "IsLinkedToTransaction": false,
    "Id": "8d70e1d6-57cf-4bc1-8402-a74d006cd472",
    "ResultState": 0,
    "ActionState": 0,
    "CachedCollection": {},
    "IsBinding": false,
    "IsSpecifiedId": false,
    "IsDirty": false,
    "UpdatedEntities": {},
    "Custom": {},
    "UpdatedProperties": [],
    "UpdatedValues": [],
    "FolderCode": "JF_TEST_RESTAPI"
}
```
</details>


## Getting the Customer Id for code BEBOP ...

> ℹ️ Here, as we just need the Id, we use a projection which is more efficient  
> ℹ️ We could do so for some other entities


<details>
<summary>C# code</summary>

```csharp
        Guid customer_Id = GetId(new CustomerDAO().CreateCriteria(), "Customer", "BEBOP");


        private static Guid GetId(ICriteria criteria, string type, string code)
        {
            criteria.Add(Condition.Eq("Code", code))
                .SetProjection(Projections.Property("Id"))
                .SetMaxResults(1);
            Newtonsoft.Json.Linq.JArray id = _folder.GetFilterAll(criteria.JsonCriteriaSerialize(), type);
            Guid guid = id == null ? Guid.Empty : Guid.Parse(id[0].ToString());

            return guid;
        }
```
</details>



<span style="color: #ff9900">**POST**</span>** **<span style="color: #ff8f4e">{{url}}</span>/app/Customers/Folder/<span style="color: #ff8f4e">{{folder}}</span>/ExecuteCriteria

<details>
<summary>Body</summary>

```
{
    "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
}
```
</details>

<details>
<summary>Result</summary>

```
[
    "f5e92880-31c0-43af-9348-a85d0117d78b"
]
```
</details>

## Getting account 700000


<details>
<summary>C# code</summary>

```csharp
folder.GetByCode<GLAccount>("700000");
```
</details>


<span style="color: #339966">**GET **</span><span style="color: #ff8f4e">{{url}}</span><span style="color: #505050">/app/GLAccount/700000/Folder/</span><span style="color: #ff8f4e">{{folder}}</span>

<details>
<summary>Result</summary>

```
{
    "$type": "Winbooks.TORM.OM.Accounting.GLAccount, Winbooks.TORM.OM",
    "TotalLevel": 1,
    "Version": 1,
    "Modified": null,
    "ModifiedBy": "00000000-0000-0000-0000-000000000000",
    "Created": "/Date(1491453375000)/",
    "CreatedBy": "7507ea76-474b-4ccc-80d3-a35b0090b2b6",
    "Folder_Id": "3a6a9ea1-ce6e-45e7-889a-d8e325a43b70",
    "Title_Id": "00000000-0000-0000-0000-000000000000",
    "GLCategory_Id": "00000000-0000-0000-0000-000000000000",
    "Vat_Id": "00000000-0000-0000-0000-000000000000",
    "CentralAccountType_Id": "00000000-0000-0000-0000-000000000000",
    "Currency_Id": "00000000-0000-0000-0000-000000000000",
    "GLAccount_Id": "00000000-0000-0000-0000-000000000000",
    "GLAccount2_Id": "00000000-0000-0000-0000-000000000000",
    "GLAccount3_Id": "00000000-0000-0000-0000-000000000000",
    "GLAccount4_Id": "00000000-0000-0000-0000-000000000000",
    "Name": "Ventes Et Prestations Services",
    "Code": "700000",
    "Type": 0,
    "Side": 0,
    "IsToMatch": false,
    "IsLocked": false,
    "IsPrintSum": false,
    "IsTitle": false,
    "IsResultAccount": true,
    "IsDisallowedExpense": false,
    "IsHidden": false,
    "MemoType": 0,
    "Memo": "",
    "DeductibilityRate_Id": "00000000-0000-0000-0000-000000000000",
    "LocalizedProperties": [
        "Name"
    ],
    "LocalizedColumns": [
        "Name"
    ],
    "Id": "c61c5554-0803-4286-9315-a74d006cd5aa",
    "ResultState": 0,
    "ActionState": 0,
    "CachedCollection": {},
    "IsBinding": false,
    "IsSpecifiedId": false,
    "IsDirty": false,
    "UpdatedEntities": {},
    "Localized": {},
    "Custom": {},
    "UpdatedProperties": [],
    "UpdatedValues": [],
    "FolderCode": "JF_TEST_RESTAPI",
    "CategoryCode": "",
    "VatCode": "",
    "DefaultCentralAccountTypeCode": "",
    "CurrencyCode": "",
    "GLAccountInternalBalanceDBCode": "",
    "GLAccountInternalBalanceCDCode": "",
    "GLAccountOfficialBalanceDBCode": "",
    "GLAccountOfficialBalanceCDCode": ""
}
```
</details>

##   
Getting the GLTransHeader with the highest DocNumber in the journal


<details>
<summary>C# code</summary>

```csharp
...
```
</details>


**<span style="color: #ff9900">POST</span>** <span style="color: #ff8f4e">{{url}}</span>/app/GLTransHeaders/Folder/<span style="color: #ff8f4e">{{folder}}</span>/ExecuteCriteria

<details>
<summary>Body</summary>

```
{
    "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
}
```
</details>


<details>
<summary>Result</summary>

```
[
    {
        "$type": "Winbooks.TORM.OM.Accounting.GLTransHeader, Winbooks.TORM.OM",
        "TotalLevel": 1,
        "Version": 1,
        "Modified": null,
        "ModifiedBy": "00000000-0000-0000-0000-000000000000",
        "Created": "/Date(1526557170000)/",
        "CreatedBy": "7507ea76-474b-4ccc-80d3-a35b0090b2b6",
        "Folder_Id": "3a6a9ea1-ce6e-45e7-889a-d8e325a43b70",
        "BookPeriod_Id": "911157a0-a894-42a4-8339-a74d006cd568",
        "Journal_Id": "126dc006-149c-4561-b369-a85d0118361f",
        "DocNumber": 9,
        "BookDate": "/Date(1489536000000)/",
        "DueDate": "/Date(1492214400000)/",
        "ReminderLevel": null,
        "ReminderDate": null,
        "PaymentStatus": null,
        "IsLocked": false,
        "IsImported": false,
        "IsTemp": false,
        "IsChecked": false,
        "IsDoc": false,
        "CommentPayment": "",
        "Reference": "",
        "MemoType": 0,
        "Memo": "",
        "JournalCurrencyRate": null,
        "ConditionalDiscountRate": null,
        "ConditionalDiscountAmount": null,
        "ConditionalDiscountAmount2": null,
        "ConditionalDiscountCurrencyAmount": null,
        "ConditionalDiscountDueDate": null,
        "PayCode_Id": "00000000-0000-0000-0000-000000000000",
        "VatStatus": 0,
        "IsVatCompletelyDeclared": false,
        "Id": "5573174a-1bec-4850-8b9a-a8e300e11546",
        "ResultState": 0,
        "ActionState": 0,
        "CachedCollection": {},
        "IsBinding": false,
        "IsSpecifiedId": false,
        "IsDirty": false,
        "UpdatedEntities": {},
        "Custom": {},
        "UpdatedProperties": [],
        "UpdatedValues": [],
        "FolderCode": "JF_TEST_RESTAPI",
        "JournalCode": "VERKP",
        "PayCodeCode": ""
    }
]
```
</details>

##   
POSTING the invoice


Creating GLTransHeader + 2 level VERKP 9 in Mar 2017


<span style="color: #ff9900">**POST**</span>** **<span style="color: #ff8f4e">**{{url}}**</span>/app/GLTransHeader/Folder/<span style="color: #ff8f4e">{{folder}}</span>

<details>
<summary>Body</summary>

```
{
    "$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"
        }
    ]
}


```
</details>


<details>
<summary>Result</summary>

```
{
    "Href": "http://stg-api.winbooksonweb.be/app/GLTransHeader/54a56121-73fd-4238-9d31-a8ee00989856/Folder/JF_TEST_RESTAPI"
}
```
</details>


## Getting the GLTransHeader just posted


**<span style="color: #ff8f4e">POST</span>**<span style="color: #ff8f4e"> {{url}}</span>/app/GLTransHeaders/Folder/<span style="color: #ff8f4e">{{folder}}</span>/ExecuteCriteria

<details>
<summary>Body</summary>

```
{
    "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": [
                9
            ]
        }
    ],
    "FirstResult": -1,
    "MaxResult": -1
}

```
</details>

# _________________________________________________________________

# Get the history of a general account

## With the .NET Winbooks.Apis.Services.dll


<details>
<summary>C# code</summary>

```csharp
        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";
        }



```
</details>

## With the HTTP request / JSON

### Get the Id of the general account

**<span style="color: #ff6600">[POST ](https://stg-api.winbooksonweb.be/app/GLAccounts/Folder/JF_TEST_RESTAPI)</span>**<span style="color: #ff8f4e">[{{url}}](https://stg-api.winbooksonweb.be/app/GLAccounts/Folder/JF_TEST_RESTAPI)</span>[/app/GLAccounts/Folder/](https://stg-api.winbooksonweb.be/app/GLAccounts/Folder/JF_TEST_RESTAPI)<span style="color: #ff8f4e">[{{folder}}](https://stg-api.winbooksonweb.be/app/GLAccounts/Folder/JF_TEST_RESTAPI)</span>/ExecuteCriteria

<details>
<summary>Body</summary>

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

<details>
<summary>Result</summary>

```
[
"1349f47e-00f9-48af-bcd4-a74d006cd5a9"
]
```
</details>


Get the transaction of the general account after a specific date

**<span style="color: #ff6600">[POST ](https://stg-api.winbooksonweb.be/app/GLAccounts/Folder/JF_TEST_RESTAPI)</span>**<span style="color: #ff8f4e">[{{url}}](https://stg-api.winbooksonweb.be/app/GLAccounts/Folder/JF_TEST_RESTAPI)</span>/app/GLTranss/Folder/<span style="color: #ff8f4e">[{{folder}}](https://stg-api.winbooksonweb.be/app/GLAccounts/Folder/JF_TEST_RESTAPI)</span><span style="color: #000000">[/ExecuteCriteria](https://stg-api.winbooksonweb.be/app/GLAccounts/Folder/JF_TEST_RESTAPI)</span>

The body of the request:

<details>
<summary>Body</summary>

```
{
   "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
      }
   ]
}
```
</details>


<details>
<summary>Result</summary>

```
[
    [
        "/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
    ]
]
```
</details>