The Journal Template-Batch-Line Pattern

In the Financial systems, Journals are used for accounting. Microsoft Dynamics NAV has an Architectural Pattern called Journal Template-Batch-Line that ensures data integrity, and acts as a datacontract for each transaction.

Technical description

Journals are the datacontracts, employed to create entries that are used for the accounting purposes. They can be used either manually via the user interface, or automated via processes, such as documents or batch programs.

Each Journal has a Journal Line table that has a Journal Template Code, and a Journal Batch Code. The Template can be used to influence the functional user interface, and the reports are being used in the process. The Batch allows different users to use the Journal at the same time without interfering with each other, or temporarily keep data in a Journal until it is ready to be posted.

The following diagram explains how to implement the Journal Template-Batch-Line Pattern:

Technical description

The Journal Line table contains information that needs to be carried over to the entry table that is created by it, as well as all the references to other data that are required for implementing the Journal-Template-Batch-Line Pattern. The creation of the entry tables is done using the Posting Pattern, which we will discuss later in this chapter. A Journal also has a predefined number of management Codeunits that help in the behavior of the template, the batch selection, and the selection of the posting process.

Note

The Entry Table pattern is discussed later in this chapter.

The previous diagram shows the basic components of a Journal.

Let's step through the tables one-by-one.

The Journal Template table

The Primary Key of a Journal Template table is called Name. It is of the type Code, and has a length of 10 characters. Other fields in a Journal template table are Description, the Reason and Source Code, and one or more references to Posting processes or testing reports.

The Optional fields in a Journal Template table are fields that act as predefined values for the journals, such as No., Series, and the Bal. Account No. The Journal Template table has two list page objects. One is editable to be used for Application Administrators. Another one is non-editable, and helps the users to select the template that they want to use.

The Journal Batch table

The Primary Key of the Journal Batch table contains a reference to the Journal Template table, and a field called Name of type Code with the length of 10 characters. Together, these fields are the Primary Key, and are numbered 1 and 2.

Other fields in this table are similar to the Journal Template table. These fields overrule the template. For example, if the template has Reason Code "SALES" and the batch has Reason Code "INVENTORY", then the batch gets priority. So, the reason code "INVENTORY" is used. If there is a functional requirement, the Journal batch can also contain a Boolean called Recurring, indicating that the Journal Lines act as a template, and will be periodically repeated.

Journal batch has an an editable list page that allows users to select a batch, and create their own batches.

The Journal Line table

The Journal line table is the actual posting data-contract that contains the data to be processed. The Primary Key has three fields:

Field ID

Name

Type

Description

1

The Journal Template Name

Code 10

It references to the Journal Template table

2

The Line No.

Integer

This is a unique value determined by AutoSplitKey

51

The Journal Batch Name

Code 10

This references to the Journal Batch table

Other than these fields, the Journal Line table contains all the fields that are required to create the entry records.

Recurring Journals

Journals that are recurring contain two other fields that are used for the date calculation, which are the following:

  • Recurring Method |Option |, F Fixed, V Variable, B Balance, RF Reversing Fixed, RV Reversing Variable, RB Reversing Balance
  • Recurring Frequency, DateFormula

Note

An explanation of the use of recurring journals and its methods is available at http://www.archerpoint.com/blog/Posts/microsoft-dynamics-nav-2009-r2-creating-recurring-general-journals.

Pages

Journals have at least one journal page, but some journals in Microsoft Dynamics NAV have multiple pages, showing different columns for different usages. For example, the General Journal has a Bank Journal, a Payment Journal, and a Cash Receipt Journal, all based on the same tables.

Codeunits

Each journal has a set of Codeunits that are required as a minimum:

Name

Description

JnlManagement

This is the Helper object that contains the functions to select templates, manage working with batches, and other functions specific to a journal.

Jnl.-B.Post+Print

This Codeunit can be called with a Journal Batch table as a parameter. All the lines in the journal that are related to the batch are posted and printed.

Jnl.-B.Post

This Codeunit can be called with a Journal Batch table as a parameter. All the lines in the journal related to the batch are posted.

Jnl.-Post+Print

This Codeunit can be called from a Journal Line table. All the lines in the selection are posted and printed.

Jnl.-Post

This Codeunit can be called from a Journal Line. All the lines in the selection are posted.

Jnl.-Post Batch

This Codeunit can be called from a Journal Line table. All the lines within the same Journal Batch are posted.

Jnl.-Check Line

This Codeunit is called automatically before posting the lines, and it contains the business logic to test the journal lines for valid values.

Jnl.-Post Line

This is the actual routine that moves the data from the Journal to one or more Entry tables. This also creates a Registry table.

Implementations

Journals are used in Microsoft Dynamics NAV for, among others, the General Ledger, Inventory, Intrastat, Resources, Jobs, Cost Accounting, Fixed Assets, Insurance, and Warehouse. Examples of pages, based on the same journal tables, are the Payment Journal, the Phys. Inventory Journal, and the Production Journal.

Hierarchy

The Job Journal, the Resource Journal, the Journal Item, and the General Journal in Microsoft Dynamics NAV have a hierarchy. The following diagram illustrates this:

Hierarchy

When a Job Journal Line is posted, the Item consumption, or the Resource Consumption can be posted using the required journal, which then might trigger the General Journal again, if this has implications for the financial backend. This posting can be executed asynchronously for performance reasons.

Note

The hierarchy is described in Chapter 1, Introduction to Microsoft Dynamics NAV, in Microsoft Dynamics NAV 2013 Application Design, published by Packt Publishing.

Journals as contracts

When journals are used in hierarchy, or in any way nested in posting routines, there is a standard pattern for populating the values. This pattern is described in the section Posting in the later part of this chapter.

Examples

The following journals exist in Microsoft Dynamics NAV:

Table IDs

Description

232, 80, 81

The General Journal

233, 82, 83

The Item Journal (Inventory)

236, 206, 207

The Resource Journal

237, 209, 210

The Job Journal

1100, 1101, 1102

The Cost Journal (Cost Accounting)

5619, 5620, 5621

The Fixed Asset Journal

5622, 5623, 5624

The Fixed Asset Reclassify Journal

5633, 5634, 5635

The Insurance Journal

7309, 7310, 7311

The Warehouse Journal

261, 262, 263

The Intrastat Jnl. Line

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset