This approach can be simpler because developers are likely more familiar with business codes as they directly relate to the business domain.
This reduces the need for additional database lookups to translate codes to IDs, which can result in faster performance due to caching.
createAccountingEntryUsingCodes
Info
Depending on the structure of the accounting data to be imported, you can explore the capabilities of this object, which allows the creation of Accounting Entries by using business codes, or you can also use createAccountingEntryUsingIds utilizing internal Sage Active IDs.
HTTP | Operation | Type | Object | DTO Why-DTOs? |
---|---|---|---|---|
Mutation | createAccountingEntryUsingCodes |
AccountingEntryCreateUsingCodesGLDtoInput |
Description
Advantages
- Direct use of journal codes, third-party codes, and account codes, eliminating the need for Sage Active IDs.
- Automatic validation of the existence of journal codes, third-party codes, and account codes.
- Automatic detection of the third-party type (Client, Supplier, Employee) based on the sub-account class.
- Optimized performance through the utilization of an internal cache for fetching journal, third-party, and account IDs, thereby reducing the number of queries required.
- Simplified model definition with streamlined lines that eliminate the need to manage accountingEntryThirdParty and accountingEntryInvoice sub-resources.
- Automatic assignment of the description and document number from the header to the lines if not defined in the line.
- Automatic creation of tax registers if the consistency of the transaction amounts allows it.
- Automatic summation of debit or credit from multiple lines of the same third party in the entry, merging them into a single entry line.
- Preservation of all business controls managed by Sage Active to ensure the integrity of the added entries.
To see examples of mutations that include the adding of accounting entries :
download the Postman collection: Quick start / 5. Test your first query in Postman
Would you like to see an example of how to add an entry?
This example pertains to a sales invoice.
To convert it into a purchase invoice, simply use a purchase journal and a supplier code.
graphQL Mutation
mutation ($values:AccountingEntryCreateUsingCodesGLDtoInput!) {
createAccountingEntryUsingCodes (input: $values) {
id
number
}
}
graphQL Variables
{
"values": {
"description": "Facture FA0022",
"date": "2023-01-01",
"documentDate": "2022-12-16",
"documentNumber": "FA0022",
"journalTypeCode": "VTE",
"accountingEntryLines": [
{
"thirdCode": "BAGUES",
"description": "Facture FA0022 régularisation",
"creditAmount": 0,
"debitAmount": 158.25
"subAccountCode": "411000000"
},
{
"creditAmount": 150,
"debitAmount": 0,
"subAccountCode": "701005000"
},
{
"creditAmount": 8.25,
"debitAmount": 0,
"subAccountCode": "445710500"
}
]
}
}
Example of Response
{
"data": {
"createAccountingEntryUsingCodes": {
"id": "e451aff7-004d-4e72-a6fb-4ea25e9d9c64",
"number": 785
}
}
}
Tax registers
Automatic creation of tax registers
The creation of tax registers for purchase and sales invoices is now automatic.
Registers are created if the prerequisites are met; otherwise, priority is given to the creation of the accounting entry without creating the registers, rather than allowing the Sage Active business controller to reject the entry for non-compliance with the registers.
The conditions are:
- Tax codes for revenue or expense accounts must be defined.
- The VAT accounts defined in the tax codes of these accounts must be those present in the entry.
- The VAT amount and the associated taxable base for the VAT account and the expense or revenue account must be consistent with the VAT rate of the tax code.
- Other management rules not respected or not yet accounted for by Sage Active.
Header
Key | Value |
---|---|
Authorization |
Bearer Current access Token How to find? |
X-TenantId |
Current tenant id How to find? |
X-OrganizationId |
Current organization Id How to find? |
x-api-key |
Primary or secondary subscription key of your app How to find? |
createAccountingEntryUsingCodes
Fields | Type | Description |
---|---|---|
date | Datetime |
Date of the accounting entry |
journalTypeCode |
String | An existing journal code |
documentDate | Datetime |
Date of the accounting document |
documentNumber | String | Document number or reference of the entry |
description | String | Description |
accountingEntryLines[] |
Array | List of all entry lines |
Info
- documentDate: An optional date field indicating the date of the document associated with the accounting entry.
If not provided, the document date will be automatically set to match the accounting entry date. - documentNumber: The reference number of the document. Mandatory in legislation DE.
For purchases or sales, it can be filled with the invoice number. - description: A value used as a template for lines from the interface, which assigns a default value to the lines.
This value is optional
This value is optional
This value is mandatory even if descriptions are given for each line.
- accountingEntryLines: A list of lines in the accounting entry.
The accounting entry must be balanced, meaning the total of the lines with a debit must be equal to the total of the lines with a credit.
Attempting to add an unbalanced entry will result in an error.
createAccountingEntryUsingCodes/accountingEntryLines
Fields | Type | Description |
---|---|---|
subAccountCode |
String | code of a general account |
thirdCode | String | code of a third |
description | String | Description |
debitAmount |
Decimal | Amount debit |
creditAmount |
Decimal | Amount credit |
Info
- subAccountCode: An existing general account, which is required on each of the entry lines.
- thirdCode: An existing third-party code, which is necessary on one of the lines if the entry pertains to a third party, such as a purchase invoice, sales invoice, or any other accounting entry that involves a third party.
Based on the class of the subAccountCode, the type of third party (Customer, Supplier, Employee) will be automatically detected. -
description: The description of the line. If not specified, it will be assigned the value from the description field of the entry header.
- creditAmount, debitAmount: The accounting entry must be balanced, meaning the total of the lines with a debit must equal the total of the lines with a credit.
Attempting to add an unbalanced entry will result in an error.
For the PURCHASE_INVOICE
or SALES_INVOICE
journals, if several lines contain the same third party, these lines are merged into one, with the sum of the debit or credit of the lines.
This allows compliance with Sage Active while, for instance, permitting the addition of entries from an import file containing invoices where the due dates are split over several lines.