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 can download an example of booking for sale, purchase and their credit notes here.

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.

About performances

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:

  • BookPeriod
  • Journal
  • CentralAccountType for Customers or Suppliers
  • 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
  • Vat for most used VAT code (0, 6, 21, ...)
  • Currency
  • Customer Id for the walking customer

Doing like that, you will have a quicker posting of your invoices and you will load less the infrastructure of WinBooks on Web



Getting BookPeriod 3/2017

C# code
        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;
        }


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

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
}


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



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


C# code
        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;
        }


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

Body
{
    "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
}

Result
[
    {
        "$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": ""
    }
]

Getting the Vat 21

C# code
folder.GetByCode<Vat>("21");




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

Result
{
    "$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": ""
}

Getting account 400000

C# code
folder.GetByCode<GLAccount>("400000");


GET {{url}}/app/GLAccount/400000/Folder/{{folder}}


Result
{
    "$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": ""
}


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

C# code
            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);


POST {{url}}/app/GLAccount_CentralAccountTypes/Folder/JF_TEST_RESTAPI/ExecuteCriteria

Body
{
    "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
}

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


Getting the currency EUR

C# code
folder.GetByCode<Currency>("EUR");


GET {{url}}/app/Currency/EUR/Folder/{{folder}}

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


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


C# code
        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;
        }



POST {{url}}/app/Customers/Folder/{{folder}}/ExecuteCriteria
Body
{
    "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
}
Result
[
    "f5e92880-31c0-43af-9348-a85d0117d78b"
]

Getting account 700000


C# code
folder.GetByCode<GLAccount>("700000");


GET {{url}}/app/GLAccount/700000/Folder/{{folder}}

Result
{
    "$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": ""
}


Getting the GLTransHeader with the highest DocNumber in the journal


C# code
...


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

Body
{
    "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
}


Result
[
    {
        "$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": ""
    }
]


POSTING the invoice


Creating GLTransHeader + 2 level VERKP 9 in Mar 2017


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

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


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


Getting the GLTransHeader just posted


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

Body
{
    "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
}

_________________________________________________________________

Get the history of a general account

With the .NET Winbooks.Apis.Services.dll


C# code
        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

Body
{
	"EntityType":"Winbooks.TORM.OM.Accounting.GLAccount, Winbooks.TORM.OM",
	"Conditions":
		[
			{"Operator":0,
			"PropertyName":"Code",
			"OtherPropertyName":"",
			"Values":["604000"],
			}
		],
	"ProjectionsList":
		[
			{"PropertyName":"Id",
			"Operator":22}
		],
	"MaxResult":1,
}
Result
[
"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:

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


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