Dyota's blog

Dynamics Finance and Operations: General Ledger ERD

This was generated by Claude Sonnet 4. The prompt was:

do your best to write me a dbml script that describes the relationships of dynamics F&O tables around ledgerjournalaccount

// Dynamics 365 F&O - LedgerJournalAccount and Related Tables
// Core journal entry processing tables and relationships

Table LedgerJournalTable {
  JournalNum varchar [primary key, note: 'Journal number - unique identifier']
  JournalType int [note: 'Journal type enum']
  JournalName varchar [note: 'Journal name reference']
  Name varchar [note: 'Journal description']
  PostedBy varchar [note: 'User who posted']
  Posted int [note: 'Posted status']
  DataAreaId varchar [note: 'Company/Legal entity']
  CreatedDateTime datetime
  ModifiedDateTime datetime
  
  Note: 'Header table for journal entries'
}

Table LedgerJournalAccount {
  JournalNum varchar [note: 'Links to LedgerJournalTable']
  LineNum decimal [note: 'Line number within journal']
  AccountType int [note: 'Account type enum (Ledger, Customer, Vendor, etc.)']
  LedgerDimension bigint [note: 'Main account + financial dimensions']
  OffsetAccountType int [note: 'Offset account type']
  OffsetLedgerDimension bigint [note: 'Offset account dimensions']
  AmountCurDebit decimal [note: 'Debit amount in currency']
  AmountCurCredit decimal [note: 'Credit amount in currency']
  CurrencyCode varchar [note: 'Transaction currency']
  ExchRate decimal [note: 'Exchange rate']
  AmountMSTDebit decimal [note: 'Debit amount in accounting currency']
  AmountMSTCredit decimal [note: 'Credit amount in accounting currency']
  Txt varchar [note: 'Transaction text/description']
  TransDate date [note: 'Transaction date']
  Voucher varchar [note: 'Voucher number']
  PostingProfile varchar [note: 'Posting profile']
  DataAreaId varchar [note: 'Company/Legal entity']
  RecId bigint [primary key, note: 'Record ID']
  
  Note: 'Journal line details - core transaction data'
}

Table DimensionAttributeValueCombination {
  RecId bigint [primary key, note: 'Dimension combination ID']
  DisplayValue varchar [note: 'Full account display string']
  MainAccount bigint [note: 'Link to MainAccount']
  DataAreaId varchar
  
  Note: 'Stores account + dimension combinations'
}

Table MainAccount {
  RecId bigint [primary key]
  MainAccountId varchar [note: 'Main account number']
  Name varchar [note: 'Account name']
  Type int [note: 'Account type (Asset, Liability, etc.)']
  DebitCredit int [note: 'Normal balance (Debit/Credit)']
  DataAreaId varchar
  
  Note: 'Chart of accounts main account master'
}

Table DimensionAttribute {
  RecId bigint [primary key]
  Name varchar [note: 'Dimension name (Department, CostCenter, etc.)']
  BackingEntityType varchar [note: 'Backing entity type']
  Type int [note: 'Dimension type']
  
  Note: 'Financial dimension definitions'
}

Table DimensionAttributeValue {
  RecId bigint [primary key]
  DimensionAttribute bigint [note: 'Links to DimensionAttribute']
  Value varchar [note: 'Dimension value code']
  DisplayValue varchar [note: 'Dimension value display name']
  DataAreaId varchar
  
  Note: 'Individual dimension values'
}

Table LedgerJournalName {
  JournalName varchar [primary key]
  Description varchar [note: 'Journal name description']
  JournalType int [note: 'Journal type']
  VoucherSeries varchar [note: 'Number sequence for vouchers']
  DataAreaId varchar
  
  Note: 'Journal name setup and configuration'
}

Table GeneralJournalEntry {
  RecId bigint [primary key]
  JournalNum varchar [note: 'Source journal number']
  Voucher varchar [note: 'Voucher number']
  AccountingDate date [note: 'Accounting date']
  SubledgerJournal bigint [note: 'Subledger journal reference']
  DataAreaId varchar
  
  Note: 'Posted general journal entries'
}

Table GeneralJournalAccountEntry {
  RecId bigint [primary key]
  GeneralJournalEntry bigint [note: 'Links to GeneralJournalEntry']
  LedgerDimension bigint [note: 'Account dimension combination']
  PostingType int [note: 'Posting type']
  TransactionCurrencyAmount decimal [note: 'Amount in transaction currency']
  AccountingCurrencyAmount decimal [note: 'Amount in accounting currency']
  DataAreaId varchar
  
  Note: 'Individual account entries in posted transactions'
}

Table CustTable {
  AccountNum varchar [primary key]
  Name varchar [note: 'Customer name']
  DataAreaId varchar
  
  Note: 'Customer master data'
}

Table VendTable {
  AccountNum varchar [primary key]
  Name varchar [note: 'Vendor name']
  DataAreaId varchar
  
  Note: 'Vendor master data'
}

Table LedgerParameters {
  Key_ int [primary key]
  AccountingCurrency varchar [note: 'Base accounting currency']
  DataAreaId varchar
  
  Note: 'Ledger parameters and setup'
}

// Primary relationships
Ref: LedgerJournalAccount.JournalNum > LedgerJournalTable.JournalNum
Ref: LedgerJournalAccount.LedgerDimension > DimensionAttributeValueCombination.RecId
Ref: LedgerJournalAccount.OffsetLedgerDimension > DimensionAttributeValueCombination.RecId
Ref: LedgerJournalTable.JournalName > LedgerJournalName.JournalName

// Dimension relationships
Ref: DimensionAttributeValueCombination.MainAccount > MainAccount.RecId
Ref: DimensionAttributeValue.DimensionAttribute > DimensionAttribute.RecId

// Posted transaction relationships
Ref: GeneralJournalEntry.JournalNum > LedgerJournalTable.JournalNum
Ref: GeneralJournalAccountEntry.GeneralJournalEntry > GeneralJournalEntry.RecId
Ref: GeneralJournalAccountEntry.LedgerDimension > DimensionAttributeValueCombination.RecId

// Master data relationships (conditional based on AccountType)
// Note: These are conditional relationships based on AccountType field
// Ref: LedgerJournalAccount.AccountNum > CustTable.AccountNum [note: 'When AccountType = Customer']
// Ref: LedgerJournalAccount.AccountNum > VendTable.AccountNum [note: 'When AccountType = Vendor']

// Table Groups for organization
TableGroup "Journal Entry Core" {
  LedgerJournalTable
  LedgerJournalAccount
  LedgerJournalName
}

TableGroup "Chart of Accounts" {
  MainAccount
  DimensionAttributeValueCombination
  DimensionAttribute
  DimensionAttributeValue
}

TableGroup "Posted Transactions" {
  GeneralJournalEntry
  GeneralJournalAccountEntry
}

TableGroup "Master Data" {
  CustTable
  VendTable
  LedgerParameters
}