Create Message

The Create Message initializes a new Ledger.

Business Rules

  • The ledger must not already exist.
  • At least one currency must be defined.
  • The first currency in currrencies will be used as the ledger's default.
  • If no domain is specified, a default domain will be created.
  • For initial account balances, the sum of debits must equal the sum of credits.
  • A name must be specified in at least one language.
  • The language of the first name will be used as the ledger default. If no language is provided, the Laravel system language will be used.
  • If the code of an account defined in accounts is the same as one in the template, then it will overwrite the template definition.
  • If transDate is not provided then the current date is used.
  • Transactions can only be posted after the opening date.

Create Message Properties

Property Type Description
accounts Account[] A list of ledger accounts.
balances Balance[] A list of balances for the opening transaction.
currencies Currency[] A list of currencies supported by the ledger.
domains Domain[] A list of ledger domains (organizational units).
journals SubJournal[] A list of sub-journals that can receive Journal Entries.
names Name[] Name of the ledger, multilingual.
rules stdClass Ledger attribute settings. See below.
sections array Section definitions.
template string A Chart of Accounts template to use.
templatePath string The path to the CoA template (read only).
transDate string The opening balance date.

Property Requirements

At least one currency and one name are required. If account balances are provided with no opening date, then the current date is used. Transactions cannot be posted earlier than the date of the opening balances.

A list of available templates can be obtained with the Artisan ledger:templates command.

Ledger rules

The rules property is a stdClass object that defines the characteristics of the ledger. This object is used to populate a LedgerRules object. In JSON notation the contents of the object are:

{
  "rules": {
    "account": {
      "codeFormat": "optional regular expression, eg \/[0-9]{4}\/",
      "postToCategory": false
    },
    "batch": {
      "allowReports": true,
      "limit": 0
    },
    "domain": {
      "default": "default domain identifier (defaults to the first domain)"
    },
    "entry": {
      "reviewed": false
    },
    "language": {
      "default": "language_code (defaults to App::getLocale()"
    },
    "openDate": "Opening date for the ledger (defaults to the date of an opening transaction)",
    "pageSize": 100
  }
}

account->codeFormat This is a regular expression that specifies the acceptable pattern for ledger account codes.

account->postToCategory If set then transactions can be posted directly to category accounts. This normally not a recommended practice, so the default value is false.

batch->allowReports If set false, then report requests in a batch will generate an error.

batch->limit Limits the number of sub-requests in a batch. The default (0) is no limit.

domain->default Sets the default domain code. If not specified, the first defined domain is used. If no domains are defined, a default is automatically created.

entry->reviewed Sets the default state of the reviewed flag for journal entries. Set to true if transactions do not need to be reviewed.

language->default Sets the default language code (examples: en, en-US, Fr-CA). If not specified, the application's current locale is used.

pageSize Specifies the maximum number of rows to return in an API query. JSON API users cannot override this limit.

Applications can define additional rule properties as needed. However, to avoid conflict with future features it is recommended that any properties added by the application begin with an underscore.