Foundations
Working with Journals
In this tutorial, we will learn how to add additional journals to handle a multi-journal ledger system.
Journals are a fundamental tool in accounting, used to record transactions. In this tutorial, we will cover how to create a new journal, modify an existing one, query a journal, and lock a journal to prevent posting.
Every ledger in Twisp starts with a default journal, but you can create as many additional journals as needed to suit your particular accounting structure.
- Create a new journal using the
createJournal
mutation - Update an existing journal using the
updateJournal
mutation - Query a journal with the
journal
query - Delete (lock) a journal using the
deleteJournal
mutation
Getting started
The easiest way to interact with the Twisp GraphQL API is to login to the Twisp Console and use the GraphiQL tool.
If you prefer to use your own GraphQL client, you can send authenticated requests to the Twisp API endpoint.
To seed your setup with some example accounts, sets, and tran codes, you can use the Example Setup.
Create a new journal
You can create a new journal using the createJournal
mutation.
Create a journal
mutation CreateJournal($journalGLId: UUID!) {
createJournal(
input: {
journalId: $journalGLId
name: "GL"
description: "General Ledger"
status: ACTIVE
}
) {
journalId
name
description
status
}
}
This will return the ID, name, description, and status of the newly created journal. Customize the input to suit your needs.
Modify an existing journal
To modify an existing journal, you can use the updateJournal
mutation. Let's update the description of the newly created journal:
Update a journal
mutation UpdateJournal($journalGLId: UUID!) {
updateJournal(
id: $journalGLId
input: { description: "_The_ ledger. The only one." }
) {
journalId
description
history(first: 2) {
nodes {
version
description
}
}
}
}
The response includes the UUID and the updated description of the journal, as well as the history of the changes made to the journal.
Query a journal
To query a journal, you can use the journal
query and provide the ID to fetch.
Read a journal
query GetJournal($journalGLId: UUID!) {
journal(id: $journalGLId) {
name
description
status
version
}
}
This will return the name, description, status, and version of the journal.
Lock a journal to prevent posting
Like other resources in Twisp, "deleting" a journal does not actually remove it from the database, but instead prevents it from being used by setting its status to LOCKED
.
To lock a journal to prevent posting, you can use the deleteJournal
mutation. Let's lock our General Ledger journal:
Lock journal
mutation DeleteJournal($journalGLId: UUID!) {
deleteJournal(id: $journalGLId) {
journalId
status
}
}
Conclusion
Journals are a fundamental component of accounting, used to store collections of transactions. In this tutorial, we covered how to create a new journal, modify an existing one, query a journal, and lock a journal. These basic operations can be used to manage journals effectively and efficiently in your multi-journal accounting workflow.