-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathAccountSuccinctly_CreateTables.sql
35 lines (34 loc) · 1.12 KB
/
AccountSuccinctly_CreateTables.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
Code: Accounting Succinctly from SyncFusion
Purpose: Generate data tables
*/
IF Object_id('Journals') is not null
DROP TABLE [dbo].Journals
GO
IF Object_id('Chart_of_Accounts') is not null
DROP TABLE [dbo].Chart_of_Accounts
GO
CREATE TABLE [dbo].Chart_of_Accounts
(
ID INT IDENTITY(1,1),
AccountNum VARCHAR(12) UNIQUE NOT NULL,
Descrip VARCHAR(48),
AcctType CHAR(1) CHECK (AcctType in ('A','L','O','R','E')),
Balance MONEY,
CONSTRAINT PK_Chart_of_Accounts PRIMARY KEY (ID)
)
CREATE TABLE [dbo].Journals
(
ID INT IDENTITY(1,1), -- Unique key per line item
AccountID INT,
JrnlType CHAR(2), -- GJ, AR, AP, SJ, PJ, etc
TransNum INT, -- Key to group entries together.
DC CHAR(1) CHECK (DC in ('D','C')),
Posted CHAR(1) DEFAULT 'N',
TransDate DATETIME DEFAULT GetDate(),
PostDate DATETIME,
Amount MONEY NOT NULL,
CONSTRAINT PK_Journals PRIMARY KEY (ID),
CONSTRAINT FK_Chart FOREIGN KEY (AccountID) REFERENCES Chart_of_Accounts(ID)
)
GO