Table: Ledger_Entry
Columns
Name | Type | Constraints | Description
ledger_entry_KEY | int | NOT NULL | Assigned by COMMON_dp_Allocate_Unique_Identifiers. Database assigned primary key for this table
row_version | timestamp | NOT NULL |
update__staff_KEY | int | NOT NULL |
update_date | datetime | NOT NULL |
bank_account_KEY | int |  | A bank account is required for all types except Invoices and Service Charges which must not specify a bank account.
control_date | smalldatetime | NOT NULL | Date used to group Ledger Entries together.
ledger_entry_type_KEY | int | NOT NULL | The type of this Ledger Entry.
client_KEY | int | NOT NULL | Key to a Client row
entry_date | smalldatetime | NOT NULL | Date of this item (check date, invoice date, receipt date).
reference | nvarchar (30) | NOT NULL | User defined reference for this entry.
amount | decimal (17, 2) | NOT NULL | The total amount of this item.
comments | nvarchar (-1) | NOT NULL | Comments about this item that can be included on reports.
internal_comments | nvarchar (-1) | NOT NULL | Comments about this item that are internal to the firm.
approved_date | smalldatetime |  | Date this item was approved.
approved__staff_KEY | int |  | Key of the Staff who approved this item.
posted_date | smalldatetime |  | Date this item was posted.
posted__staff_KEY | int |  | Key of the Staff who posted this item.
entry_number | int | NOT NULL | Each entry will be assigned a number that is unique by Ledger Entry Type that the user can select.
create_date | datetime | NOT NULL |

Primary key
Name | Columns | Description
PK_Ledger_Entry$ledger_entry_KEY | ledger_entry_KEY | CLUSTERED
Unique constraints
Name | Columns | Description
UK_Ledger_Entry__ledger_entry_type_KEY__entry_number | ledger_entry_type_KEY, entry_number |
Indexes
Name | Columns | Description
IX_Ledger_Entry$approved__staff_KEY$approved_date | approved__staff_KEY, approved_date |
IX_Ledger_Entry$bank_account_KEY | bank_account_KEY |
IX_Ledger_Entry$client_KEY$entry_date | client_KEY, entry_date |
IX_Ledger_Entry$control_date@ledger_entry_type_KEY | control_date, ledger_entry_type_KEY |
IX_Ledger_Entry$entry_date@posted__staff_KEY | entry_date, posted__staff_KEY |
IX_Ledger_Entry$entry_number | entry_number |
IX_Ledger_Entry$ledger_entry_KEY$entry_date$posted__staff_KEY$amount$client_KEY | ledger_entry_KEY, entry_date, posted__staff_KEY, amount, client_KEY |
IX_Ledger_Entry$ledger_entry_KEY$entry_date$posted_date | ledger_entry_KEY, entry_date, posted_date |
IX_Ledger_Entry$ledger_entry_type_KEY$client_KEY$entry_date | ledger_entry_type_KEY, client_KEY, entry_date | Speeds up retrieving last service charge date by client_KEY enough to not have to cache it on Client record.
IX_Ledger_Entry$posted__staff_KEY$posted_date | posted__staff_KEY, posted_date |
IX_Ledger_Entry$reference | reference |

Foreign keys
Name | Columns | Referenced table | Description
FK_Ledger_Entry__Bank_Account__bank_account_KEY | bank_account_KEY | Bank_Account |
FK_Ledger_Entry__Client__client_KEY | client_KEY | Client |
FK_Ledger_Entry__Ledger_Entry_Type__ledger_entry_type_KEY | ledger_entry_type_KEY | Ledger_Entry_Type |
FK_Ledger_Entry__Staff__approved__staff_KEY | approved__staff_KEY | Staff |
FK_Ledger_Entry__Staff__posted__staff_KEY | posted__staff_KEY | Staff |

Incoming foreign keys
Name | Columns | Referencing table | Description
FK_Invoice__Ledger_Entry__invoice_KEY | invoice_KEY | Invoice |
FK_Invoice__Ledger_Entry__ledger_entry_KEY | ledger_entry_KEY | Invoice |
FK_Ledger_Entry_Application__Ledger_Entry__from__ledger_entry_KEY | from__ledger_entry_KEY | Ledger_Entry_Application |
FK_Ledger_Entry_Application__Ledger_Entry__to__ledger_entry_KEY | to__ledger_entry_KEY | Ledger_Entry_Application |
FK_Ledger_Entry_Service_Charge__Ledger_Entry__past_due__ledger_entry_KEY | past_due__ledger_entry_KEY | Ledger_Entry_Service_Charge |
FK_Ledger_Entry_Service_Charge__Ledger_Entry__service_charge__ledger_entry_KEY | service_charge__ledger_entry_KEY | Ledger_Entry_Service_Charge |
FK_Ledger_Entry_Submittal__Ledger_Entry__ledger_entry_KEY | ledger_entry_KEY | Ledger_Entry_Submittal | on delete cascade;
FK_Online_Payment__Ledger_Entry__ledger_entry_KEY | ledger_entry_KEY | Online_Payment | on delete cascade;
FK_Billing_Decision_Collection__Ledger_Entry__collection_source__ledger_entry_KEY | collection_source__ledger_entry_KEY | Billing_Decision_Collection | on delete cascade;
FK_Billing_Decision_Tax_Collection__Ledger_Entry__collection_source__ledger_entry_KEY | collection_source__ledger_entry_KEY | Billing_Decision_Tax_Collection | on delete cascade;