-- IQX database structure split by table
-- Source: IQXDatabaseStructure - with comments.sql
-- Table: "pears"."IQacDocumentTemplate"
-- Table comment: Templates for Financial Documents. By the default the system uses two templates with IDs 'SalesInvoice' and 'Receipt' and Class 'Invoice' and 'Payment' respectively.
-- Statement count: 13
CREATE TABLE "pears"."IQacDocumentTemplate" (
"DocumentTemplateID" CHAR(12) NOT NULL
,"Name" CHAR(50) NOT NULL
,"DocumentClass" CHAR(30) NOT NULL
,"ControlLedgerID" CHAR(12) NULL
,"PaymentLedgerID" CHAR(12) NULL
,"PaymentAccountCode" CHAR(12) NULL
,"VATNominalCode" CHAR(12) NULL
,"ReportFile" CHAR(100) NULL
,"DaysToPay" SMALLINT NULL
,"Sign" SMALLINT NOT NULL DEFAULT 1
,"AutoNumberType" CHAR(12) NULL
,"AutoNumberNext" INTEGER NULL
,"AutoNumberPrefix" CHAR(12) NULL
,"DocumentType" CHAR(30) NULL
,"Defunct" SMALLINT NULL
,PRIMARY KEY ("DocumentTemplateID" ASC)
)
GO
COMMENT ON COLUMN "pears"."IQacDocumentTemplate"."DocumentClass" IS
'Name of the Java class'
GO
COMMENT ON COLUMN "pears"."IQacDocumentTemplate"."Sign" IS
'-1 for e.g. Credit Notes'
GO
COMMENT ON COLUMN "pears"."IQacDocumentTemplate"."AutoNumberType" IS
'StartDoc, SaveDoc, PrintDoc, LinkTemplate, None'
GO
COMMENT ON COLUMN "pears"."IQacDocumentTemplate"."DocumentType" IS
'Optional descriptive term e.g. Credit Note'
GO
COMMENT ON TABLE "pears"."IQacDocumentTemplate" IS
'Templates for Financial Documents. By the default the system uses two templates with IDs ''SalesInvoice'' and ''Receipt'' and Class ''Invoice'' and ''Payment'' respectively.'
GO
ALTER TABLE "pears"."IQacDocumentTemplate"
ADD FOREIGN KEY "IQacNominal" ("VATNominalCode" ASC)
REFERENCES "pears"."IQacNominal" ("NominalCode")
GO
ALTER TABLE "pears"."IQacDocumentTemplate"
ADD FOREIGN KEY "ConLedger" ("ControlLedgerID" ASC)
REFERENCES "pears"."IQacLedger" ("LedgerID")
GO
ALTER TABLE "pears"."IQacDocumentTemplate"
ADD FOREIGN KEY "PayLedger" ("PaymentLedgerID" ASC)
REFERENCES "pears"."IQacLedger" ("LedgerID")
GO
ALTER TABLE "pears"."IQacDocumentTemplate"
ADD FOREIGN KEY "PayAccount" ("PaymentLedgerID" ASC,"PaymentAccountCode" ASC)
REFERENCES "pears"."IQacAccount" ("LedgerID","AccountCode")
GO
CREATE UNIQUE INDEX "IQacDoc_Name" ON "pears"."IQacDocumentTemplate"
( "Name" )
GO
CREATE TRIGGER "WPK_iqacdocumenttemplate_INVOICEFORMATS" after INSERT,DELETE,UPDATE ORDER 1 ON
"pears"."iqacdocumenttemplate"
FOR each statement
BEGIN
CALL "WPKTrackChange"('P','INVOICEFORMATS')
END
GO
COMMENT TO PRESERVE FORMAT ON TRIGGER "pears"."IQacDocumentTemplate"."WPK_iqacdocumenttemplate_INVOICEFORMATS" IS
{CREATE TRIGGER WPK_iqacdocumenttemplate_INVOICEFORMATS
after INSERT,DELETE,UPDATE ORDER 1 ON
iqacdocumenttemplate
FOR each statement
BEGIN
CALL WPKTrackChange('P','INVOICEFORMATS')
END
}
GO