MYOB Exo Business Debtors
List of entities
Entity details
Entity: CAMPAIGN_WAVE
CommentThis table contains details of all campaign waves setup in EXO Business CRM.
Primary key columnsSEQNO

Attributes:
Column namePrimary keyData typeNot NULLComment
SEQNOYesINTEGERYesA unique ID number for the campaign wave.
WAVE_NONoINTEGERNoAn ID number that uniquely identifies the campaign wave within the campaign.
CAMPAIGN_SEQNONoINTEGERYesThe ID number of the campaign that the campaign wave is part of.
DESCRIPTNoVARCHAR(50)NoA short written description of the campaign wave.
STARTDATENoDATETIMENoThe start date for the period that the campaign wave runs over.
ENDDATENoDATETIMENoThe end date for the period that the campaign wave runs over.
COMMUNICATION_METHODNoINTEGERNoThis field specifies the Communication Method selected for the campaign wave. Will be one of:
0 = no Communication Method selected
1 = Mailshot Process
2 = Bulk Activity Creation
3 = Execute SQL
4 = Social Media Post
5 = Export List
6 = Execute External Program
TRACKER_KEYNoVARCHAR(150)NoFor campaign waves with the "Mailshot Process" Communication Method, this field contains any text entered into the Tracker ID field.
OPT_IN_URLNoVARCHAR(150)NoFor campaign waves with the "Mailshot Process" Communication Method, this field contains any text entered into the Opt in URL field.
OPT_OUT_URLNoVARCHAR(150)NoFor campaign waves with the "Mailshot Process" Communication Method, this field contains any text entered into the Opt out URL field.
LANDING_SITENoVARCHAR(150)NoFor campaign waves with the "Mailshot Process" Communication Method, this field contains any text entered into the Landing site field.
PROCESSEDNoCHAR(1)NoThis field is set to 'Y' if the campaign wave's Processed flag is ticked.
COMPLETENoCHAR(1)NoThis field is set to 'Y' if the campaign wave's Complete flag is ticked.
DOC_BATCH_HDR_SEQNONoINTEGERNoFor campaign waves with the "Mailshot Process " Communication Method that include email attachments, this field contains the ID number of the documentation batch in the DOC_BATCH_HDR table that relates to the attachments.
SOCIAL_MEDIA_TEXTNoVARCHAR(500)NoFor campaign waves with the "Social Media Post" Communication Method, this field contains the text that is posted to the social media network(s).
FACEBOOK_POST_IDNoVARCHAR(100)NoFor campaign waves with the "Social Media Post" Communication Method, this field contains the ID number of the Facebook post.
TWITTER_POST_IDNoVARCHAR(100)NoFor campaign waves with the "Social Media Post" Communication Method, this field contains the ID number of the Twitter post.
LINKEDIN_POST_DATENoDATETIMENoFor campaign waves with the "Social Media Post" Communication Method, this field contains the date of the LinkedIn post.
SETTINGSNoVARCHAR(4096)NoThis field is used by campaign waves where the Communication Method is "Execute SQL" or "Execute External Program".

Relationships:
NameRelationship typeParentChildCardinality
CAMPAIGN_CAMPAIGN_WAVENon IdentifyingCAMPAIGNCAMPAIGN_WAVEZero Or More
CAMPAIGN_WAVE_CAMPAIGN_WAVE_AUDITNon IdentifyingCAMPAIGN_WAVECAMPAIGN_WAVE_AUDITZero Or More
CAMPAIGN_WAVE_CAMPAIGN_WAVE_CONTACT_LISTSNon IdentifyingCAMPAIGN_WAVECAMPAIGN_WAVE_CONTACT_LISTSZero Or More
CAMPAIGN_WAVE_CONTACTSNon IdentifyingCAMPAIGN_WAVECONTACTSZero Or More
CAMPAIGN_WAVE_DR_PRICESNon IdentifyingCAMPAIGN_WAVEDR_PRICESZero Or More
CAMPAIGN_WAVE_DR_PRICE_POLICYNon IdentifyingCAMPAIGN_WAVEDR_PRICE_POLICYZero Or More
CAMPAIGN_WAVE_DR_TRANSNon IdentifyingCAMPAIGN_WAVEDR_TRANSZero Or More
CAMPAIGN_WAVE_JOBCOST_HDRNon IdentifyingCAMPAIGN_WAVEJOBCOST_HDRZero Or More
CAMPAIGN_WAVE_OPPORTUNITYNon IdentifyingCAMPAIGN_WAVEOPPORTUNITYZero Or More
CAMPAIGN_WAVE_SALESORD_HDRNon IdentifyingCAMPAIGN_WAVESALESORD_HDRZero Or More
CAMPAIGN_WAVE_TASKSNon IdentifyingCAMPAIGN_WAVETASKSZero Or More

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (CAMPAIGN_SEQNO)
Not NullColumn ConstraintNOT NULL (SEQNO)
CAMPAIGN_CAMPAIGN_WAVEForeign KeyTable ConstraintFOREIGN KEY (CAMPAIGN_SEQNO) REFERENCES CAMPAIGN(SEQNO)
DF__CAMPAIGN___COMMU__4C97D86FDefaultColumn ConstraintCOMMUNICATION_METHOD DEFAULT 0
DF__CAMPAIGN___COMPL__4E8020E1DefaultColumn ConstraintCOMPLETE DEFAULT N
DF__CAMPAIGN___DOC_B__4F74451ADefaultColumn ConstraintDOC_BATCH_HDR_SEQNO DEFAULT 0
DF__CAMPAIGN___ENDDA__4BA3B436DefaultColumn ConstraintENDDATE DEFAULT getdate()
DF__CAMPAIGN___PROCE__4D8BFCA8DefaultColumn ConstraintPROCESSED DEFAULT N
DF__CAMPAIGN___START__4AAF8FFDDefaultColumn ConstraintSTARTDATE DEFAULT getdate()
PK__CAMPAIGN__C8320F98708B2022Primary KeyTable ConstraintPRIMARY KEY (SEQNO)

Triggers:
Trigger nameCode
CAMPAIGN_WAVE_PROCESSEDCREATE TRIGGER [dbo].[CAMPAIGN_WAVE_PROCESSED]
ON [dbo].[CAMPAIGN_WAVE]
FOR UPDATE
AS
BEGIN
DECLARE @FLATLIST AS VARCHAR(500),
@CAMPAIGN_SEQNO INT,
@WAVENO INT,
@CAMPAIGN_WAVE_SEQNO INT,
@SALESNO INT,
@TRANSDATE DATETIME,
@DESCRIPT VARCHAR(50),
@SUBJECT VARCHAR(100),
@NOTE VARCHAR(255),
@COMM_MESSAGE VARCHAR(255),
@PROCESSED CHAR(1),
@COMPLETE CHAR(1),
@CAMPAIGN_WAVE_TYPE VARCHAR(100),
@INTERACTIONS INT,
@WAS_PROCESSED CHAR(1),
@COMMUNICATION_METHOD CHAR(1),
@OLD_SOCIAL_MEDIA_TEXT VARCHAR(500),
@OLD_FACEBOOK_POST_ID VARCHAR(100),
@OLD_LINKEDIN_POST_DATE DATETIME,
@OLD_TWITTER_POST_ID VARCHAR(100),
@FACEBOOK_POST_ID VARCHAR(100),
@TWITTER_POST_ID VARCHAR(100),
@LINKEDIN_POST_DATE DATETIME

SET @FLATLIST ='' /*FLATLIST builds a comma separated list of the CONTACT_LIST.names used in this Campaign Wave*/
SET @WAS_PROCESSED = (SELECT PROCESSED from DELETED)
SET @SALESNO = [dbo].FN_GET_STAFF_NO()

SELECT
@OLD_SOCIAL_MEDIA_TEXT = ISNULL(SOCIAL_MEDIA_TEXT, ''),
@OLD_FACEBOOK_POST_ID = ISNULL(FACEBOOK_POST_ID, ''),
@OLD_LINKEDIN_POST_DATE = ISNULL(LINKEDIN_POST_DATE, 0),
@OLD_TWITTER_POST_ID = ISNULL(TWITTER_POST_ID, ''),
@WAS_PROCESSED = PROCESSED
FROM DELETED

SELECT
@CAMPAIGN_WAVE_SEQNO = SEQNO,
@CAMPAIGN_SEQNO = CAMPAIGN_SEQNO,
@WAVENO = WAVE_NO,
@DESCRIPT = DESCRIPT,
@TRANSDATE = GETDATE(),
@PROCESSED = PROCESSED,
@COMPLETE = COMPLETE,
@COMMUNICATION_METHOD = COMMUNICATION_METHOD,
@OLD_SOCIAL_MEDIA_TEXT = SOCIAL_MEDIA_TEXT,
@FACEBOOK_POST_ID = FACEBOOK_POST_ID,
@LINKEDIN_POST_DATE = LINKEDIN_POST_DATE,
@TWITTER_POST_ID = TWITTER_POST_ID
FROM INSERTED

IF @COMMUNICATION_METHOD <> '4' AND @PROCESSED = 'Y' AND @WAS_PROCESSED <> 'Y'
BEGIN
-- Get interaction count
IF @COMMUNICATION_METHOD = '2' /*BULK TASK INSERT*/
SELECT @INTERACTIONS=ISNULL(COUNT(*), 0)
FROM TASKS WITH (NOLOCK)
WHERE CAMPAIGN_WAVE_SEQNO = @CAMPAIGN_WAVE_SEQNO
ELSE
SELECT @INTERACTIONS=ISNULL(COUNT(*), 0)
FROM CAMPAIGN_WAVE_AUDIT CWA WITH (NOLOCK)
WHERE CWA.CAMPAIGN_WAVE_SEQNO = @CAMPAIGN_WAVE_SEQNO

SELECT @FLATLIST = ISNULL(@FLATLIST, '') + ', ' + TITLE
FROM CONTACT_LIST CL
WHERE CL.SEQNO IN (SELECT CONTACT_LIST_SEQNO
FROM CAMPAIGN_WAVE_CONTACT_LISTS WITH (NOLOCK)
WHERE CAMPAIGN_WAVE_SEQNO = @CAMPAIGN_WAVE_SEQNO)
SELECT @COMM_MESSAGE =
CASE
WHEN @COMMUNICATION_METHOD = '1' THEN 'Mailshot Processed' -- Mailshot
WHEN @COMMUNICATION_METHOD = '2' THEN 'Bulk Activity Processed' -- Bulk Activity Creation
WHEN @COMMUNICATION_METHOD = '3' THEN 'Execute SQL Processed' -- Execute SQL
WHEN @COMMUNICATION_METHOD = '5' THEN 'Export List Processed' -- Export List
WHEN @COMMUNICATION_METHOD = '6' THEN 'Executed External Program' -- Execute External Program
ELSE ''
END

SET @NOTE = 'List(s) Used : ' + SUBSTRING(@FLATLIST, 3, LEN(@FLATLIST))+ ' '+CAST(@INTERACTIONS AS VARCHAR(100))+' Interactions'

SET @SUBJECT='Wave '+ LTRIM(STR(@WAVENO, 2)) + ' ' + @COMM_MESSAGE + '-' + @DESCRIPT
INSERT INTO CAMPAIGN_HIST (CAMPAIGN_SEQNO, SALESNO, TRANSDATE, SUBJECT, NOTE)
VALUES (@CAMPAIGN_SEQNO, @SALESNO, @TRANSDATE, @SUBJECT, @NOTE)
END /*IF PROCESSED*/
ELSE IF @COMMUNICATION_METHOD = '4' -- Social Media Post
BEGIN
SELECT @COMM_MESSAGE =
CASE
WHEN @OLD_FACEBOOK_POST_ID <> @FACEBOOK_POST_ID THEN 'Facebook wall post'
WHEN @OLD_LINKEDIN_POST_DATE <> @LINKEDIN_POST_DATE THEN 'LinkedIn activity'
WHEN @OLD_TWITTER_POST_ID <> @TWITTER_POST_ID THEN 'Twitter status update'
ELSE ''
END

IF @COMM_MESSAGE <> ''
BEGIN
SET @SUBJECT='Wave '+ LTRIM(STR(@WAVENO, 2)) + ' ' + @COMM_MESSAGE --+ '-' + @DESCRIPT
SET @NOTE = @OLD_SOCIAL_MEDIA_TEXT
INSERT INTO CAMPAIGN_HIST (CAMPAIGN_SEQNO, SALESNO, TRANSDATE, SUBJECT, NOTE)
VALUES (@CAMPAIGN_SEQNO, @SALESNO, @TRANSDATE, @SUBJECT, @NOTE)
END
END
END


Entity: CONTACTS
CommentThis table contains information about Contacts.
Primary key columnsSEQNO

Attributes:
Column namePrimary keyData typeNot NULLComment
SEQNOYesINTEGERYesA unique identifier for the Contact record.
SALUTATIONNoVARCHAR(4)NoThe Contact's preferred salutation, e.g. Mr, Mrs.
FIRSTNAMENoVARCHAR(30)NoThe Contact's first name.
LASTNAMENoVARCHAR(30)NoThe Contact's last/family name.
TITLENoVARCHAR(30)NoThe Contact's job title.
MOBILENoVARCHAR(30)NoThe Contact's mobile phone number.
DIRECTPHONENoVARCHAR(30)NoThe Contact's direct telephone number.
DIRECTFAXNoVARCHAR(30)NoThe Contact's fax number.
HOMEPHONENoVARCHAR(30)NoThe Contact's home phone number.
EMAILNoVARCHAR(60)NoThe Contact's email address.
NOTESNoVARCHAR(4096)NoAll notes entered for the Contact on the Notes tab.
ADDRESS1NoVARCHAR(30)NoPostal address line 1.
ADDRESS2NoVARCHAR(30)NoPostal address line 2.
ADDRESS3NoVARCHAR(30)NoPostal address line 3.
ADDRESS4NoVARCHAR(30)NoPostal address line 4.
ADDRESS5NoVARCHAR(30)NoPostal address line 5. This line is only available on the Contacts window if the Additional Postal Address Row profile setting is enabled.
POST_CODENoVARCHAR(12)NoThe Contact's post code.
DELADDR1NoVARCHAR(30)NoDelivery address line 1.
DELADDR2NoVARCHAR(30)NoDelivery address line 2.
DELADDR3NoVARCHAR(30)NoDelivery address line 3.
DELADDR4NoVARCHAR(30)NoDelivery address line 4.
DELADDR5NoVARCHAR(30)NoDelivery address line 5.
DELADDR6NoVARCHAR(30)NoDelivery address line 6.
ISACTIVENoCHAR(1)NoWhether the Contact is active (Y) or inactive (N).
ADVERTSOURCENoINTEGERNoThe Contact's Advertising Source - corresponds to the SEQNO of the type in the ADVERT_TYPES table.
SALESNONoINTEGERNoThe STAFFNO of staff member who is set as the Sales person for the Contact.
FULLNAMENoASNoThe Contact's full name, formed by joining the FIRSTNAME and LASTNAME fields.
COMPANY_ACCNONoINTEGERNoIf the Contact is associated with a company (Debtor, Creditor or Non Account) the company's ID number is recorded here.
COMPANY_ACCTYPENoINTEGERNoIf the Contact is associated with a company (Debtor, Creditor or Non Account) the type of company account is recorded here:
1 = Debtor account
2 = Creditor account
3 = Non Account
MSN_IDNoVARCHAR(45)NoThe Contact's MSN ID number.
YAHOO_IDNoVARCHAR(45)NoThe Contact's Yahoo! ID number.
SKYPE_IDNoVARCHAR(45)NoThe Contact's Skype ID number.
LAST_UPDATEDNoDATETIMENoThe date and time when the Contact record was last updated.
SUB1NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 1 is ticked on the Marketing tab.
SUB2NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 2 is ticked on the Marketing tab.
SUB3NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 3 is ticked on the Marketing tab.
SUB4NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 4 is ticked on the Marketing tab.
SUB5NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 5 is ticked on the Marketing tab.
SUB6NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 6 is ticked on the Marketing tab.
SUB7NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 7 is ticked on the Marketing tab.
SUB8NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 8 is ticked on the Marketing tab.
SUB9NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 9 is ticked on the Marketing tab.
SUB10NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 10 is ticked on the Marketing tab.
SUB11NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 11 is ticked on the Marketing tab.
SUB12NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 12 is ticked on the Marketing tab.
SUB13NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 13 is ticked on the Marketing tab.
SUB14NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 14 is ticked on the Marketing tab.
SUB15NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 15 is ticked on the Marketing tab.
SUB16NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 16 is ticked on the Marketing tab.
SUB17NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 17 is ticked on the Marketing tab.
SUB18NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 18 is ticked on the Marketing tab.
SUB19NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 19 is ticked on the Marketing tab.
SUB20NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 20 is ticked on the Marketing tab.
SUB21NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 21 is ticked on the Marketing tab.
SUB22NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 22 is ticked on the Marketing tab.
SUB23NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 23 is ticked on the Marketing tab.
SUB24NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 24 is ticked on the Marketing tab.
SUB25NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 25 is ticked on the Marketing tab.
SUB26NoCHAR(1)NoThis field is set to 'Y' if Marketing Class number 26 is ticked on the Marketing tab.
SYNC_CONTACTSNoCHAR(1)YesThis field is set to 'Y' if the Contact is set to sync with Microsoft Outlook.
LINKEDINNoVARCHAR(20)NoThe Contact's LinkedIn account ID.
TWITTERNoVARCHAR(500)NoThe Contact's Twitter username.
FACEBOOKNoVARCHAR(500)NoThe Contact's Facebook username or ID number.
OPTOUT_EMARKETINGNoCHAR(1)NoThis field is set to 'Y' if the Contact's Opt-Out eMarketing flag is ticked. Contacts who have opted out of eMarketing will not be included in campaign waves for campaigns whose Campaign Type is set to "Marketing" (EXO Business CRM).
CAMPAIGN_WAVE_SEQNONoINTEGERNoIf the Contact is included in a campaign wave (EXO Business CRM), the wave's ID number is stored here.
LATITUDENoFLOAT(53)NoThe Contact's latitude.
LONGITUDENoFLOAT(53)NoThe Contact's longitude.
GEOCODE_STATUSNoINTEGERNoResult of the geocode lookup. Will be one of:
Null or -1 - lookup not yet attempted
0 - lookup successful
>0 - lookup failed

Relationships:
NameRelationship typeParentChildCardinality
ADVERT_TYPES_CONTACTSNon IdentifyingADVERT_TYPESCONTACTSZero Or More
CAMPAIGN_WAVE_CONTACTSNon IdentifyingCAMPAIGN_WAVECONTACTSZero Or More
CONTACTS_CAMPAIGN_WAVE_AUDITNon IdentifyingCONTACTSCAMPAIGN_WAVE_AUDITZero Or More
CONTACTS_CONTACT_LIST_ITEMNon IdentifyingCONTACTSCONTACT_LIST_ITEMZero Or More
CONTACTS_CR_CONTACTSNon IdentifyingCONTACTSCR_CONTACTSZero Or More
CONTACTS_CR_CONT_HISTNon IdentifyingCONTACTSCR_CONT_HISTZero Or More
CONTACTS_CR_TRANSNon IdentifyingCONTACTSCR_TRANSZero Or More
CONTACTS_DR_CONTACTSNon IdentifyingCONTACTSDR_CONTACTSZero Or More
CONTACTS_TASKSNon IdentifyingCONTACTSTASKSZero Or More
STAFF_CONTACTSNon IdentifyingSTAFFCONTACTSZero Or More

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (SYNC_CONTACTS)
Not NullColumn ConstraintNOT NULL (SEQNO)
ADVERT_TYPES_CONTACTSForeign KeyTable ConstraintFOREIGN KEY (ADVERTSOURCE) REFERENCES ADVERT_TYPES(SEQNO)
CAMPAIGN_WAVE_CONTACTSForeign KeyTable ConstraintFOREIGN KEY (CAMPAIGN_WAVE_SEQNO) REFERENCES CAMPAIGN_WAVE(SEQNO)
DF__CONTACTS__ADVERT__08C105B8DefaultColumn ConstraintADVERTSOURCE DEFAULT 0
DF__CONTACTS__CAMPAI__5AE5F7C6DefaultColumn ConstraintCAMPAIGN_WAVE_SEQNO DEFAULT -1
DF__CONTACTS__ISACTI__74BA0D0BDefaultColumn ConstraintISACTIVE DEFAULT Y
DF__CONTACTS__LAST_U__6C3AA0FADefaultColumn ConstraintLAST_UPDATED DEFAULT getdate()
DF__CONTACTS__OPTOUT__5250B1C5DefaultColumn ConstraintOPTOUT_EMARKETING DEFAULT N
DF__CONTACTS__SALESN__09B529F1DefaultColumn ConstraintSALESNO DEFAULT 0
DF__CONTACTS__SUB10__348057BCDefaultColumn ConstraintSUB10 DEFAULT N
DF__CONTACTS__SUB11__3668A02EDefaultColumn ConstraintSUB11 DEFAULT N
DF__CONTACTS__SUB12__3850E8A0DefaultColumn ConstraintSUB12 DEFAULT N
DF__CONTACTS__SUB13__3A393112DefaultColumn ConstraintSUB13 DEFAULT N
DF__CONTACTS__SUB14__3C217984DefaultColumn ConstraintSUB14 DEFAULT N
DF__CONTACTS__SUB15__3E09C1F6DefaultColumn ConstraintSUB15 DEFAULT N
DF__CONTACTS__SUB16__3FF20A68DefaultColumn ConstraintSUB16 DEFAULT N
DF__CONTACTS__SUB17__41DA52DADefaultColumn ConstraintSUB17 DEFAULT N
DF__CONTACTS__SUB18__43C29B4CDefaultColumn ConstraintSUB18 DEFAULT N
DF__CONTACTS__SUB19__45AAE3BEDefaultColumn ConstraintSUB19 DEFAULT N
DF__CONTACTS__SUB1__2355CBBADefaultColumn ConstraintSUB1 DEFAULT N
DF__CONTACTS__SUB20__47932C30DefaultColumn ConstraintSUB20 DEFAULT N
DF__CONTACTS__SUB21__497B74A2DefaultColumn ConstraintSUB21 DEFAULT N
DF__CONTACTS__SUB22__4B63BD14DefaultColumn ConstraintSUB22 DEFAULT N
DF__CONTACTS__SUB23__4D4C0586DefaultColumn ConstraintSUB23 DEFAULT N
DF__CONTACTS__SUB24__4F344DF8DefaultColumn ConstraintSUB24 DEFAULT N
DF__CONTACTS__SUB25__511C966ADefaultColumn ConstraintSUB25 DEFAULT N
DF__CONTACTS__SUB26__5304DEDCDefaultColumn ConstraintSUB26 DEFAULT N
DF__CONTACTS__SUB2__253E142CDefaultColumn ConstraintSUB2 DEFAULT N
DF__CONTACTS__SUB3__27265C9EDefaultColumn ConstraintSUB3 DEFAULT N
DF__CONTACTS__SUB4__290EA510DefaultColumn ConstraintSUB4 DEFAULT N
DF__CONTACTS__SUB5__2AF6ED82DefaultColumn ConstraintSUB5 DEFAULT N
DF__CONTACTS__SUB6__2CDF35F4DefaultColumn ConstraintSUB6 DEFAULT N
DF__CONTACTS__SUB7__2EC77E66DefaultColumn ConstraintSUB7 DEFAULT N
DF__CONTACTS__SUB8__30AFC6D8DefaultColumn ConstraintSUB8 DEFAULT N
DF__CONTACTS__SUB9__32980F4ADefaultColumn ConstraintSUB9 DEFAULT N
DF__CONTACTS__SYNC_C__657894D2DefaultColumn ConstraintSYNC_CONTACTS DEFAULT Y
PK__CONTACTS__73C5E8D2Primary KeyTable ConstraintPRIMARY KEY (SEQNO)
STAFF_CONTACTSForeign KeyTable ConstraintFOREIGN KEY (SALESNO) REFERENCES STAFF(STAFFNO)



Entity: CURRENCIES
CommentThis table contains details of all currencies used in the EXO Business system.
Primary key columnsCURRENCYNO

Attributes:
Column namePrimary keyData typeNot NULLComment
CURRENCYNOYesINTEGERYesA unique ID code for the currency.
CURRCODENoVARCHAR(3)NoThe three-letter currency code, e.g. AUD, NZD.
CURRNAMENoVARCHAR(30)NoThe descriptive name for the currency.
BUYRATENoFLOAT(53)NoThe buy rate (for purchases).
SELLRATENoFLOAT(53)NoThe sell rate (for sales).
CURRSYMBOLNoVARCHAR(5)NoThe symbol for the currency, e.g. $, £.
AVERAGE_RATENoFLOAT(53)NoThis field relates to the Intercompany module.
CLOSING_RATENoFLOAT(53)NoThis field relates to the Intercompany module.
RE_MOVEMENTSNoFLOAT(53)NoThis field relates to the Intercompany module.
ALERTPCNoINTEGERYesThe % Change Alert for the currency - when editing currencies, the user will be alerted if the currency is changed by a percentage greater than this.

Relationships:
NameRelationship typeParentChildCardinality
CURRENCIES_CR_ALLOCATIONSNon IdentifyingCURRENCIESCR_ALLOCATIONSZero Or More
CURRENCIES_CR_INVLINESNon IdentifyingCURRENCIESCR_INVLINESZero Or More
CURRENCIES_CR_TRANSNon IdentifyingCURRENCIESCR_TRANSZero Or More
CURRENCIES_DR_ALLOCATIONSNon IdentifyingCURRENCIESDR_ALLOCATIONSZero Or More
CURRENCIES_DR_INVLINESNon IdentifyingCURRENCIESDR_INVLINESZero Or More
CURRENCIES_DR_TRANSNon IdentifyingCURRENCIESDR_TRANSZero Or More
CURRENCIES_GLACCSNon IdentifyingCURRENCIESGLACCSZero Or More
CURRENCIES_JOBCOST_LINESNon IdentifyingCURRENCIESJOBCOST_LINESZero Or More
CURRENCIES_JOB_CONTRACT_BILLINGSNon IdentifyingCURRENCIESJOB_CONTRACT_BILLINGSZero Or More
CURRENCIES_JOB_TRANSACTIONSNon IdentifyingCURRENCIESJOB_TRANSACTIONSZero Or More
CURRENCIES_OPPORTUNITY_QUOTENon IdentifyingCURRENCIESOPPORTUNITY_QUOTEZero Or More

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (ALERTPC)
Not NullColumn ConstraintNOT NULL (CURRENCYNO)
DF__CURRENCIE__ALERT__25BE0270DefaultColumn ConstraintALERTPC DEFAULT 5
DF__CURRENCIE__AVERA__17642ACADefaultColumn ConstraintAVERAGE_RATE DEFAULT 0
DF__CURRENCIE__BUYRA__2CFD9AD7DefaultColumn ConstraintBUYRATE DEFAULT 0
DF__CURRENCIE__CLOSI__18584F03DefaultColumn ConstraintCLOSING_RATE DEFAULT 0
DF__CURRENCIE__RE_MO__2B6B2377DefaultColumn ConstraintRE_MOVEMENTS DEFAULT 0
DF__CURRENCIE__SELLR__2DF1BF10DefaultColumn ConstraintSELLRATE DEFAULT 0
PK__CURRENCIE__CURRE__2C09769EPrimary KeyTable ConstraintPRIMARY KEY (CURRENCYNO)

Triggers:
Trigger nameCode
CURRENCY_RATE_CHANGECREATE TRIGGER [dbo].[CURRENCY_RATE_CHANGE] ON [dbo].[CURRENCIES]
FOR INSERT, UPDATE AS
BEGIN
  DECLARE @DR_PERIOD INT
  DECLARE @CR_PERIOD INT
  DECLARE @STK_PERIOD INT
  DECLARE @GL_PERIOD INT

  SELECT @DR_PERIOD=SEQNO FROM PERIOD_STATUS WHERE AGE=0 AND LEDGER ='D'
  SELECT @CR_PERIOD=SEQNO FROM PERIOD_STATUS WHERE AGE=0 AND LEDGER ='C'
  SELECT @STK_PERIOD=SEQNO FROM PERIOD_STATUS WHERE AGE=0 AND LEDGER ='S'
  SELECT @GL_PERIOD=SEQNO FROM PERIOD_STATUS WHERE AGE=0 AND LEDGER ='G'

  SET NOCOUNT ON
  INSERT INTO CURRENCY_RATECHANGES
  (CURRENCYNO, CURRCODE, NEWBUYRATE, NEWSELLRATE, DR_PERIOD, CR_PERIOD, STK_PERIOD, GL_PERIOD )
  SELECT INSERTED.CURRENCYNO, INSERTED.CURRCODE,
         INSERTED.BUYRATE, INSERTED.SELLRATE, @DR_PERIOD, @CR_PERIOD, @STK_PERIOD, @GL_PERIOD
  FROM INSERTED
  SET NOCOUNT OFF
END


Entity: DR_ACCGROUP2S
CommentThis table stores the Secondary Groups for Debtors (a grouping on top of the primary grouping - see DR_ACCGROUPS).
Primary key columnsACCGROUP

Attributes:
Column namePrimary keyData typeNot NULLComment
ACCGROUPYesINTEGERYesA unique ID for the Secondary Debtor Group.
GROUPNAMENoVARCHAR(30)NoThe name of the group.
REPORTCODENoVARCHAR(15)NoA report code for the group.

Relationships:
NameRelationship typeParentChildCardinality
DR_ACCGROUP2S_DR_ACCSNon IdentifyingDR_ACCGROUP2SDR_ACCSZero Or More
FK_CRM_BUDGET_EXCLUDED_ACCGROUP2S_DR_ACCGROUP2SNon IdentifyingDR_ACCGROUP2SCRM_BUDGET_EXCLUDED_ACCGROUP2SZero Or More
FK_CRM_BUDGET_LINE_DR_ACCGROUP2SNon IdentifyingDR_ACCGROUP2SCRM_BUDGET_LINEZero Or More

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (ACCGROUP)
PK__DR_ACCGROUP2S__46B27FE2Primary KeyTable ConstraintPRIMARY KEY (ACCGROUP)



Entity: DR_ACCGROUPS
CommentThis table stores the Primary Groups for Debtors (the finer level of grouping - compare DR_ACCGROUP2S).
Primary key columnsACCGROUP

Attributes:
Column namePrimary keyData typeNot NULLComment
ACCGROUPYesINTEGERYesA unique ID for the Primary Debtor Group.
GROUPNAMENoVARCHAR(30)NoThe name of the group.
REPORTCODENoVARCHAR(15)NoA report code for the group.

Relationships:
NameRelationship typeParentChildCardinality
DR_ACCGROUPS_DR_ACCSNon IdentifyingDR_ACCGROUPSDR_ACCSOne Or More
DR_ACCGROUPS_DR_PRICESNon IdentifyingDR_ACCGROUPSDR_PRICESOne Or More
DR_ACCGROUPS_DR_PRICE_POLICY_ACCNon IdentifyingDR_ACCGROUPSDR_PRICE_POLICY_ACCOne Or More
FK_CRM_BUDGET_EXCLUDED_ACCGROUPS_DR_ACCGROUPSNon IdentifyingDR_ACCGROUPSCRM_BUDGET_EXCLUDED_ACCGROUPSZero Or More
FK_CRM_BUDGET_LINE_DR_ACCGROUPSNon IdentifyingDR_ACCGROUPSCRM_BUDGET_LINEZero Or More

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (ACCGROUP)
PK__DR_ACCGROUPS__758D6A5CPrimary KeyTable ConstraintPRIMARY KEY (ACCGROUP)



Entity: DR_ACCS
CommentThis table contains information about Debtor accounts.
Primary key columnsACCNO

Attributes:
Column namePrimary keyData typeNot NULLComment
ACCNOYesINTEGERYesThe unique ID number for the Debtor account.
NAMENoVARCHAR(60)NoThe Debtor's name.
ADDRESS1NoVARCHAR(30)NoPostal address line 1.
ADDRESS2NoVARCHAR(30)NoPostal address line 2.
ADDRESS3NoVARCHAR(30)NoPostal address line 3.
ADDRESS4NoVARCHAR(30)NoPostal address line 4
ADDRESS5NoVARCHAR(30)NoPostal address line 5. This line is only available on the Debtor Account Details screen if the Additional Postal Address Row profile setting is enabled.
DELADDR1NoVARCHAR(30)NoDelivery address line 1.
DELADDR2NoVARCHAR(30)NoDelivery address line 2.
DELADDR3NoVARCHAR(30)NoDelivery address line 3.
DELADDR4NoVARCHAR(30)NoDelivery address line 4.
DELADDR5NoVARCHAR(30)NoDelivery address line 5.
DELADDR6NoVARCHAR(30)NoDelivery address line 6.
PHONENoVARCHAR(30)NoThe Debtor's phone number.
FAXNoVARCHAR(30)NoThe Debtor's fax number.
EMAILNoVARCHAR(60)NoThe Debtor's email address.
CREDLIMITNoFLOAT(53)NoThe credit limit for the Debtor account.
ACCGROUPNoINTEGERNoThe Debtor's primary Debtor Account Group.
SALESNONoINTEGERNoID number of the salesperson assigned to the Debtor account.
LASTMONTHNoFLOAT(53)NoTurnover for last month.
LASTYEARNoFLOAT(53)NoTurnover for last year.
AGEDBAL0NoFLOAT(53)NoAged Balance for the current month.
AGEDBAL1NoFLOAT(53)NoAged Balance for the previous month.
AGEDBAL2NoFLOAT(53)NoAged Balance for two months back.
AGEDBAL3NoFLOAT(53)NoAged Balance for three months back.
CREDITSTATUSNoINTEGERNoCredit terms for the Debtor.
DISCOUNTLEVELNoINTEGERNoThe Debtor's discount level - this is only populated via EXO APIs.
OPENITEMNoCHAR(1)NoContains "Y" if this is not a balance brought forward account.
INVOICETYPENoINTEGERNoThis field only applies to Australian databases where M-Powered Invoices are enabled. If set to 1, search results on the Transactions tab of the Debtor Account Details window will only include accounts with the M-Powered invoice type.
NOTESNoVARCHAR(4096)NoAll notes entered for the Debtor on the Notes tab.
MONTHVALNoFLOAT(53)NoTurnover for the current month.
YEARVALNoFLOAT(53)NoTurnover for the current year.
STARTDATENoDATETIMENoThe date that the Debtor account was created on.
SORTCODENoVARCHAR(12)NoBanks National Clearing Code or Routing Number used by some banks. Expose as an Extra Field to use.
BANKNoVARCHAR(20)NoThe Bank detail from the last update of a payment header. Populated via right-clicking on a payment on the Transactions tab and selecting Edit Ref Field. This option is only available if the profile setting "Permitted level of access to debtor transaction editing" (EDITDRTRANS) is set to allow transaction editing.
BANK_ACCOUNTNoVARCHAR(40)NoThe Debtor's bank account number, used for Direct Debit payments.
BANK_ACC_NAMENoVARCHAR(40)NoThe Debtor's bank account name, used for Direct Debit payments.
BSBNONoVARCHAR(40)NoThe Debtor's Bank State Branch number (Australian databases only).
D_DEBIT_FAXNoCHAR(1)NoIf set to 'Y', Direct Debit payment advice will be sent to the Debtor by fax.
D_DEBIT_PRINTNoCHAR(1)NoIf set to 'Y', printed Direct Debit payment advice will be sent to the Debtor.
D_DEBIT_EMAILNoCHAR(1)NoIf set to 'Y', Direct Debit payment advice will be sent to the Debtor by email.
PAY_TYPENoINTEGERNoThe default payment method.
BRANCHNoVARCHAR(30)NoThe Branch detail from the last update of a payment header. Populated via right-clicking on a payment on the Transactions tab and selecting Edit Ref Field. This option is only available if the profile setting "Permitted level of access to debtor transaction editing" (EDITDRTRANS) is set to allow transaction editing.
DRAWERNoVARCHAR(30)NoThe Drawer detail from the last update of a payment header. Populated via right-clicking on a payment on the Transactions tab and selecting Edit Ref Field. This option is only available if the profile setting "Permitted level of access to debtor transaction editing" (EDITDRTRANS) is set to allow transaction editing.
TAXSTATUSNoINTEGERNoThe Override GST rate for the Debtor.
PRICENONoINTEGERNoThe Base price for the Debtor.
AUTOBILLCODENoVARCHAR(23)NoThe Bill of Materials (Order Template) used by the Debtor.
ALPHACODENoVARCHAR(15)NoA non-unique alphanumeric ID code for the Debtor. Can be used for sorting accounts alphabetically, e.g. give "The Warehouse" the code "WARE" to sort under W instead of T. Sometimes used as an alternate account reference.
HEAD_ACCNONoINTEGERYesThe ACCNO of the Debtor's head office account. If no head office, this is set to -1.
PASS_WORDNoVARCHAR(30)NoUsed for integrated web shops.
CURRENCYNONoINTEGERYesThe currency of the Debtor account.
ALERTNoVARCHAR(60)NoPop-up alert text to display when dealing with the Debtor.
STATEMENTNoCHAR(1)NoHow statements will be sent to the Debtor. P = print, E = email, B = both, N = none.
INVFILENONoINTEGERNoThe number that is used in the name of the invoice template that will be used for this Debtor, e.g. 1 for Invoice1.clf.
PROMPTPAY_PCNoFLOAT(53)NoPrompt payment discount percentage.
PROMPTPAY_AMTNoFLOAT(53)NoPrompt payment discount amount.
ISACTIVENoCHAR(1)NoWhether the account is active (Y) or inactive (N).
BAD_CHEQUENoCHAR(1)NoIf 'Y', cheques are not accepted from the Debtor. Set by the "Do Not Accept Cheque" flag on the Details 2 tab.
BRANCHNONoINTEGERNoBranch number - only used by specific sites.
LAST_UPDATEDNoDATETIMENoTime and date stamp when the Debtor's account details were last updated.
TAXREGNoVARCHAR(30)NoGST/ABN number of the Debtor.
STOPCREDITNoCHAR(1)NoIf 'Y', the Debtor is on Stop Credit, and no further transactions will take place.
POST_CODENoVARCHAR(12)NoThe Debtor's postal code.
GLCONTROLACCNoINTEGERNoNot currently used.
GLCONTROLSUBACCNoINTEGERNoNot currently used.
PRIOR_AGEDBAL0NoFLOAT(53)NoPrior Aged Balance for the current month.
PRIOR_AGEDBAL1NoFLOAT(53)NoPrior Aged Balance for the previous month.
PRIOR_AGEDBAL2NoFLOAT(53)NoPrior Aged Balance for two months back.
PRIOR_AGEDBAL3NoFLOAT(53)NoPrior Aged Balance for three months back.
BALANCENoASNoCurrent balance.
PRIOR_BALANCENoASNoBalance as at the prior period.
ACCGROUP2NoINTEGERNoThe Debtor's secondary Debtor Account Group.
FREIGHT_FREENoCHAR(1)YesUsed to suppress the freight prompt on Invoices or Sales Orders for this Debtor account. Can be superseded by the FREIGHT_FREE settings in price rules.
COURIER_DEPOT_SEQNONoINTEGERNoRelated to the courier add-on module. Not currently supported.
KEEPTRANSACTIONSNoCHAR(1)YesIf 'N', all branch transactions are transferred to head office account.
NEED_ORDERNONoCHAR(1)YesIf set to 'Y', order numbers are checked against past order numbers to prevent duplication. Only applies when the profile setting "Validate Debtor Order Numbers" (VALIDATE_DR_ORDERNO) is enabled.
PRICEGROUPNoINTEGERNoPrice Group for the Debtor. New accounts get this from profile setting "Default debtor price group for new debtors" (DEFDRPRICEGROUP).
ALLOW_RESTRICTED_STOCKNoCHAR(1)YesIf 'Y', it is possible to sell stock items that have been flagged as restricted goods to this Debtor. If the profile setting "Use customised customer stock restrictions logic" (CUSTOM_STOCK_RESTRICTION) is enabled, a custom function (FN_RESTRICTED_ITEM) is used instead of this field.
PRIVATE_ACCNoCHAR(1)YesIf 'Y', the debtor account is classed as private. It can only be accessed by users who have the profile setting "Allow access to private debtor accounts" (ALLOW_ACCESS_TO_PRIVATE_DR_ACC) enabled.
ISTEMPLATENoCHAR(1)YesIf 'Y', this Debtor account can be used as a template for Non Accounts and new POS accounts.
WEBSITENoVARCHAR(50)NoURL of the Debtor's website.
AVE_DAYS_TO_PAYNoINTEGERYesAverage Debtor days, calculated by the Stored Procedure DR_CR_ALLOCATION_AVE_DAYS_SP every time you access the Analysis tab.
INVOICE_TYPENoVARCHAR(20)NoThe type of invoice to send to the Debtor: DEFAULT, STANDARD or M-POWERED. Only applies to Australian databases.
STATEMENT_CONTACT_SEQNONoINTEGERNoWhen sending statements via email, the email will be sent to this address. If this field is blank, the email address of the Debtor account's default contact is used. If the account does not have a default Contact, the Debtor's email address (EMAIL) is used.
LINKEDINNoVARCHAR(20)NoThe Debtor's LinkedIn account ID.
TWITTERNoVARCHAR(500)NoThe Debtor's Twitter username.
FACEBOOKNoVARCHAR(500)NoThe Debtor's Facebook account ID or username.
LATITUDENoFLOAT(53)NoThe Debtor's latitude.
LONGITUDENoFLOAT(53)NoThe Debtor's longitude.
GEOCODE_STATUSNoINTEGERNoResult of the geocode lookup. Will be one of:
Null or -1 - lookup not yet attempted
0 - lookup successful
>0 - lookup failed

Relationships:
NameRelationship typeParentChildCardinality
DR_ACCGROUP2S_DR_ACCSNon IdentifyingDR_ACCGROUP2SDR_ACCSZero Or More
DR_ACCGROUPS_DR_ACCSNon IdentifyingDR_ACCGROUPSDR_ACCSOne Or More
DR_ACCS_DR_ADDRESSESNon IdentifyingDR_ACCSDR_ADDRESSESOne Or More
DR_ACCS_DR_CONTACTSNon IdentifyingDR_ACCSDR_CONTACTSZero Or More
DR_ACCS_DR_CONT_HISTNon IdentifyingDR_ACCSDR_CONT_HISTZero Or More
DR_ACCS_DR_PRICESNon IdentifyingDR_ACCSDR_PRICESOne Or More
DR_ACCS_DR_PRICE_POLICY_ACCNon IdentifyingDR_ACCSDR_PRICE_POLICY_ACCOne Or More
DR_ACCS_DR_TRANSNon IdentifyingDR_ACCSDR_TRANSZero Or More
DR_ACCS_JOBCOST_HDRNon IdentifyingDR_ACCSJOBCOST_HDRZero Or More
DR_PRICEGROUPS_DR_ACCSNon IdentifyingDR_PRICEGROUPSDR_ACCSOne Or More
FK_CRM_BUDGET_EXCLUDED_DR_ACCS_DR_ACCSNon IdentifyingDR_ACCSCRM_BUDGET_EXCLUDED_DR_ACCSZero Or More
FK_CRM_BUDGET_LINE_DR_ACCSNon IdentifyingDR_ACCSCRM_BUDGET_LINEZero Or More
STAFF_DR_ACCSNon IdentifyingSTAFFDR_ACCSOne Or More

Indexes:
NameIndex columnsIndex type
DR_ACCS_NAMENAME ASC
DR_ACCS_PAY_TYPEPAY_TYPE ASC
DR_ACCS_TAXSTATUSTAXSTATUS ASC

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (AVE_DAYS_TO_PAY)
Not NullColumn ConstraintNOT NULL (ACCNO)
Not NullColumn ConstraintNOT NULL (ISTEMPLATE)
Not NullColumn ConstraintNOT NULL (PRIVATE_ACC)
Not NullColumn ConstraintNOT NULL (ALLOW_RESTRICTED_STOCK)
Not NullColumn ConstraintNOT NULL (NEED_ORDERNO)
Not NullColumn ConstraintNOT NULL (KEEPTRANSACTIONS)
Not NullColumn ConstraintNOT NULL (FREIGHT_FREE)
Not NullColumn ConstraintNOT NULL (CURRENCYNO)
Not NullColumn ConstraintNOT NULL (HEAD_ACCNO)
DF_DR_ACCS_CURRENCYNODefaultColumn ConstraintCURRENCYNO DEFAULT 0
DF_DR_ACCS_HEAD_ACCNODefaultColumn ConstraintHEAD_ACCNO DEFAULT -1
DF__DR_ACCS__ACCGROU__4E9398CCDefaultColumn ConstraintACCGROUP2 DEFAULT 0
DF__DR_ACCS__ACCGROU__7A521F79DefaultColumn ConstraintACCGROUP DEFAULT 0
DF__DR_ACCS__AGEDBAL__000AF8CFDefaultColumn ConstraintAGEDBAL2 DEFAULT 0
DF__DR_ACCS__AGEDBAL__00FF1D08DefaultColumn ConstraintAGEDBAL3 DEFAULT 0
DF__DR_ACCS__AGEDBAL__7E22B05DDefaultColumn ConstraintAGEDBAL0 DEFAULT 0
DF__DR_ACCS__AGEDBAL__7F16D496DefaultColumn ConstraintAGEDBAL1 DEFAULT 0
DF__DR_ACCS__ALLOW_R__78BFA819DefaultColumn ConstraintALLOW_RESTRICTED_STOCK DEFAULT Y
DF__DR_ACCS__AVE_DAY__6BE59B3FDefaultColumn ConstraintAVE_DAYS_TO_PAY DEFAULT -1
DF__DR_ACCS__BAD_CHE__48EFCE0FDefaultColumn ConstraintBAD_CHEQUE DEFAULT N
DF__DR_ACCS__BRANCHN__5EDF0F2EDefaultColumn ConstraintBRANCHNO DEFAULT 0
DF__DR_ACCS__CREDITS__02E7657ADefaultColumn ConstraintCREDITSTATUS DEFAULT 0
DF__DR_ACCS__CREDLIM__795DFB40DefaultColumn ConstraintCREDLIMIT DEFAULT 0
DF__DR_ACCS__DISCOUN__03DB89B3DefaultColumn ConstraintDISCOUNTLEVEL DEFAULT 0
DF__DR_ACCS__D_DEBIT__4F7CD00DDefaultColumn ConstraintD_DEBIT_FAX DEFAULT N
DF__DR_ACCS__D_DEBIT__5070F446DefaultColumn ConstraintD_DEBIT_PRINT DEFAULT N
DF__DR_ACCS__D_DEBIT__5165187FDefaultColumn ConstraintD_DEBIT_EMAIL DEFAULT N
DF__DR_ACCS__FREIGHT__0C90CB45DefaultColumn ConstraintFREIGHT_FREE DEFAULT N
DF__DR_ACCS__GEOCODE__44628521DefaultColumn ConstraintGEOCODE_STATUS DEFAULT NULL
DF__DR_ACCS__GLCONTR__379037E3DefaultColumn ConstraintGLCONTROLACC DEFAULT 0
DF__DR_ACCS__GLCONTR__38845C1CDefaultColumn ConstraintGLCONTROLSUBACC DEFAULT 0
DF__DR_ACCS__INVFILE__18C19800DefaultColumn ConstraintINVFILENO DEFAULT 0
DF__DR_ACCS__INVOICE__06B7F65EDefaultColumn ConstraintINVOICETYPE DEFAULT 0
DF__DR_ACCS__INVOICE__77E15DD0DefaultColumn ConstraintINVOICE_TYPE DEFAULT DEFAULT
DF__DR_ACCS__ISACTIV__25A691D2DefaultColumn ConstraintISACTIVE DEFAULT Y
DF__DR_ACCS__ISTEMPL__5ECACBECDefaultColumn ConstraintISTEMPLATE DEFAULT N
DF__DR_ACCS__KEEPTRA__7EB7AD3ADefaultColumn ConstraintKEEPTRANSACTIONS DEFAULT Y
DF__DR_ACCS__LASTMON__7C3A67EBDefaultColumn ConstraintLASTMONTH DEFAULT 0
DF__DR_ACCS__LASTYEA__7D2E8C24DefaultColumn ConstraintLASTYEAR DEFAULT 0
DF__DR_ACCS__MONTHVA__07AC1A97DefaultColumn ConstraintMONTHVAL DEFAULT 0
DF__DR_ACCS__NEED_OR__4050666DDefaultColumn ConstraintNEED_ORDERNO DEFAULT N
DF__DR_ACCS__OPENITE__04CFADECDefaultColumn ConstraintOPENITEM DEFAULT Y
DF__DR_ACCS__PAY_TYP__52593CB8DefaultColumn ConstraintPAY_TYPE DEFAULT 0
DF__DR_ACCS__PRICEGR__190C7C1ADefaultColumn ConstraintPRICEGROUP DEFAULT 0
DF__DR_ACCS__PRICENO__0D64F3EDDefaultColumn ConstraintPRICENO DEFAULT 1
DF__DR_ACCS__PRIOR_A__000AF8CFDefaultColumn ConstraintPRIOR_AGEDBAL3 DEFAULT 0
DF__DR_ACCS__PRIOR_A__7D2E8C24DefaultColumn ConstraintPRIOR_AGEDBAL0 DEFAULT 0
DF__DR_ACCS__PRIOR_A__7E22B05DDefaultColumn ConstraintPRIOR_AGEDBAL1 DEFAULT 0
DF__DR_ACCS__PRIOR_A__7F16D496DefaultColumn ConstraintPRIOR_AGEDBAL2 DEFAULT 0
DF__DR_ACCS__PRIVATE__0FA30D71DefaultColumn ConstraintPRIVATE_ACC DEFAULT N
DF__DR_ACCS__PROMPTP__3CFEF876DefaultColumn ConstraintPROMPTPAY_PC DEFAULT 0
DF__DR_ACCS__PROMPTP__3DF31CAFDefaultColumn ConstraintPROMPTPAY_AMT DEFAULT 0
DF__DR_ACCS__SALESNO__7B4643B2DefaultColumn ConstraintSALESNO DEFAULT 0
DF__DR_ACCS__STARTDA__09946309DefaultColumn ConstraintSTARTDATE DEFAULT getdate()
DF__DR_ACCS__STATEME__01DE32A8DefaultColumn ConstraintSTATEMENT DEFAULT Y
DF__DR_ACCS__STATEME__5FF4C5A6DefaultColumn ConstraintSTATEMENT_CONTACT_SEQNO DEFAULT -1
DF__DR_ACCS__STOPCRE__0CA5D9DEDefaultColumn ConstraintSTOPCREDIT DEFAULT N
DF__DR_ACCS__TAXSTAT__0C70CFB4DefaultColumn ConstraintTAXSTATUS DEFAULT 0
DF__DR_ACCS__YEARVAL__08A03ED0DefaultColumn ConstraintYEARVAL DEFAULT 0
DR_ACCGROUP2S_DR_ACCSForeign KeyTable ConstraintFOREIGN KEY (ACCGROUP2) REFERENCES DR_ACCGROUP2S(ACCGROUP)
DR_ACCGROUPS_DR_ACCSForeign KeyTable ConstraintFOREIGN KEY (ACCGROUP) REFERENCES DR_ACCGROUPS(ACCGROUP)
DR_PRICEGROUPS_DR_ACCSForeign KeyTable ConstraintFOREIGN KEY (PRICEGROUP) REFERENCES DR_PRICEGROUPS(GROUPNO)
PK_DR_ACCSPrimary KeyTable ConstraintPRIMARY KEY (ACCNO)
STAFF_DR_ACCSForeign KeyTable ConstraintFOREIGN KEY (SALESNO) REFERENCES STAFF(STAFFNO)



Entity: DR_ADDRESSES
CommentThis table stores the additional delivery addresses for a Debtor account. These are used in places like Sales Orders, where the user can select a delivery address for the order.
Primary key columnsSEQNO

Attributes:
Column namePrimary keyData typeNot NULLComment
SEQNOYesINTEGERYesA unique ID number for the record.
ACCNONoINTEGERNoThe account number of the Debtor record that the address applies to.
DELADDR1NoVARCHAR(30)NoDelivery address line 1.
DELADDR2NoVARCHAR(30)NoDelivery address line 2.
DELADDR3NoVARCHAR(30)NoDelivery address line 3.
DELADDR4NoVARCHAR(30)NoDelivery address line 4.
DELADDR5NoVARCHAR(30)NoDelivery address line 5.
DELADDR6NoVARCHAR(30)NoDelivery address line 6.
COURIER_DEPOT_SEQNONoINTEGERNoThis field is no longer used - it relates to the old couriers module.

Relationships:
NameRelationship typeParentChildCardinality
DR_ACCS_DR_ADDRESSESNon IdentifyingDR_ACCSDR_ADDRESSESOne Or More

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (SEQNO)
DR_ACCS_DR_ADDRESSESForeign KeyTable ConstraintFOREIGN KEY (ACCNO) REFERENCES DR_ACCS(ACCNO)
PK__DR_ADDRESSES__489AC854Primary KeyTable ConstraintPRIMARY KEY (SEQNO)



Entity: DR_ALLOCATIONS
CommentThis table stores details of Debtor allocations.
Primary key columnsSEQNO, ALLOCNO

Attributes:
Column namePrimary keyData typeNot NULLComment
SEQNOYesINTEGERYesA unique ID number for the allocation.
ALLOCNOYesINTEGERYesA unique ID number for the allocation set.
TRANS_SEQNONoINTEGERNoThis field is a link back to the original transaction line in DR_TRANS table (DR_TRANS.seqno).
AMOUNTNoFLOAT(53)NoThe amount allocated.
CURRENCYNoINTEGERNoThe ID number of the currency in which the transaction took place.
TAKENUPNoCHAR(1)NoThis field is a flag that specify whether or not the allocation has been a part of realised gain/losses.
ALLOCTIMENoDATETIMENoThe date and time of the allocation.
PERIOD_SEQNONoINTEGERYesThe period in which the allocation took place.
AGE_STAMPNoINTEGERNoThis is a historical field that has been superseded by the AGE calculated field.
AGENoASNoThe allocation's age. This is calculated based on PERIOD_SEQNO.
EXCHRATENoFLOAT(53)YesThe exchange rate used for conversion at the time of the allocation.

Relationships:
NameRelationship typeParentChildCardinality
CURRENCIES_DR_ALLOCATIONSNon IdentifyingCURRENCIESDR_ALLOCATIONSZero Or More
DR_TRANS_DR_ALLOCATIONSNon IdentifyingDR_TRANSDR_ALLOCATIONSZero Or More
PERIOD_STATUS_DR_ALLOCATIONSNon IdentifyingPERIOD_STATUSDR_ALLOCATIONSZero Or More

Indexes:
NameIndex columnsIndex type
DR_ALLOCATIONS_PERIOD_SEQNO_INDEXPERIOD_SEQNO ASC
DR_ALLOCATIONS_TRANS_SEQNO_INDEXTRANS_SEQNO ASC

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (EXCHRATE)
Not NullColumn ConstraintNOT NULL (SEQNO)
Not NullColumn ConstraintNOT NULL (ALLOCNO)
Not NullColumn ConstraintNOT NULL (PERIOD_SEQNO)
CURRENCIES_DR_ALLOCATIONSForeign KeyTable ConstraintFOREIGN KEY (CURRENCY) REFERENCES CURRENCIES(CURRENCYNO)
DF__DR_ALLOCA__AGE_S__48D1692CDefaultColumn ConstraintAGE_STAMP DEFAULT -1
DF__DR_ALLOCA__ALLOC__02284B6BDefaultColumn ConstraintALLOCTIME DEFAULT getdate()
DF__DR_ALLOCA__AMOUN__5CF6C6BCDefaultColumn ConstraintAMOUNT DEFAULT 0
DF__DR_ALLOCA__CURRE__5DEAEAF5DefaultColumn ConstraintCURRENCY DEFAULT 0
DF__DR_ALLOCA__EXCHR__7DE51B40DefaultColumn ConstraintEXCHRATE DEFAULT 1
DF__DR_ALLOCA__PERIO__47DD44F3DefaultColumn ConstraintPERIOD_SEQNO DEFAULT 0
DF__DR_ALLOCA__TAKEN__5EDF0F2EDefaultColumn ConstraintTAKENUP DEFAULT N
DR_TRANS_DR_ALLOCATIONSForeign KeyTable ConstraintFOREIGN KEY (TRANS_SEQNO) REFERENCES DR_TRANS(SEQNO)
PERIOD_STATUS_DR_ALLOCATIONSForeign KeyTable ConstraintFOREIGN KEY (SEQNO) REFERENCES PERIOD_STATUS(PERIOD_SEQNO)
PK__DR_ALLOCATIONS__5C02A283Primary KeyTable ConstraintPRIMARY KEY (SEQNO, ALLOCNO)

Triggers:
Trigger nameCode
update_draccbal_onallocCREATE TRIGGER [dbo].[update_draccbal_onalloc] on [dbo].[DR_ALLOCATIONS]
FOR INSERT
AS
declare @accno integer,
@age integer,
@trans_seqno integer,
@amount float,
@exchrate float
begin

  SET NOCOUNT ON
select @trans_seqno=trans_seqno, @amount=amount from inserted

select @accno=accno, @age=age, @exchrate=exchrate from dr_trans where seqno=@trans_seqno

IF (@age=0) begin
        UPDATE dr_accs
        SET agedbal0=agedbal0-@amount
        WHERE ACCNO=@ACCNO
end
ELSE IF (@age=1) begin
        UPDATE dr_accs
        SET agedbal1=agedbal1-@amount
        WHERE ACCNO=@ACCNO
end
ELSE IF (@age=2) begin
        UPDATE dr_accs
        SET agedbal2=agedbal2-@amount
        WHERE ACCNO=@ACCNO
end
ELSE BEGIN UPDATE dr_accs
        SET agedbal3=agedbal3-@amount
        WHERE ACCNO=@ACCNO
END
 UPDATE [dbo].[DR_ALLOCATIONS]
 SET EXCHRATE=@exchrate
 WHERE TRANS_SEQNO=@trans_seqno
  SET NOCOUNT OFF
end
UPDATE_DRACCBAL_ONUNALLOCCREATE TRIGGER [dbo].[UPDATE_DRACCBAL_ONUNALLOC] on [dbo].[DR_ALLOCATIONS]
FOR DELETE
AS
declare @accno integer,
@age integer,
@trans_seqno integer,
@amount float
begin

  SET NOCOUNT ON
select @trans_seqno=trans_seqno, @amount=amount from deleted

select @accno=accno, @age=age from DR_trans where seqno=@trans_seqno

IF (@age=0) begin
        UPDATE DR_ACCS
        SET agedbal0=agedbal0+@amount
        WHERE ACCNO=@ACCNO
end
ELSE IF (@age=1) begin
        UPDATE DR_ACCS
        SET agedbal1=agedbal1+@amount
        WHERE ACCNO=@ACCNO
end
ELSE IF (@age=2) begin
        UPDATE DR_ACCS
        SET agedbal2=agedbal2+@amount
        WHERE ACCNO=@ACCNO
end
ELSE BEGIN UPDATE DR_ACCS
        SET agedbal3=agedbal3+@amount
        WHERE ACCNO=@ACCNO
END

UPDATE DR_TRANS
SET ALLOCATEDBAL=ALLOCATEDBAL-@amount, ALLOCATED=0
WHERE SEQNO=@TRANS_SEQNO

  SET NOCOUNT OFF
end
UPDATE_DRACC_PRIORBAL_ONALLOCCREATE TRIGGER [dbo].[UPDATE_DRACC_PRIORBAL_ONALLOC] ON [dbo].[DR_ALLOCATIONS]
FOR INSERT AS
  DECLARE @ACCNO INTEGER,
  @TRANS_AGE INTEGER,
  @ALLOC_AGE INTEGER,
  @TRANS_SEQNO INTEGER,
  @TRANS_AMOUNT FLOAT,
  @AMOUNT FLOAT
BEGIN

  SET NOCOUNT ON

  SELECT @TRANS_SEQNO=TRANS_SEQNO, @AMOUNT=AMOUNT, @ALLOC_AGE=AGE FROM INSERTED

  SELECT @ACCNO=ACCNO, @TRANS_AMOUNT=AMOUNT, @TRANS_AGE=AGE FROM DR_TRANS WHERE SEQNO=@TRANS_SEQNO

  IF (@ALLOC_AGE>0)
  BEGIN
    IF (@TRANS_AGE=1)
    BEGIN
      UPDATE DR_ACCS SET PRIOR_AGEDBAL0=PRIOR_AGEDBAL0-@AMOUNT WHERE ACCNO=@ACCNO
    END
    ELSE
    IF (@TRANS_AGE=2)
    BEGIN
      UPDATE DR_ACCS SET PRIOR_AGEDBAL1=PRIOR_AGEDBAL1-@AMOUNT WHERE ACCNO=@ACCNO
    END
    ELSE
    IF (@TRANS_AGE=3)
    BEGIN
     UPDATE DR_ACCS SET PRIOR_AGEDBAL2=PRIOR_AGEDBAL2-@AMOUNT WHERE ACCNO=@ACCNO
    END
    ELSE
    BEGIN
      UPDATE DR_ACCS SET PRIOR_AGEDBAL3=PRIOR_AGEDBAL3-@AMOUNT WHERE ACCNO=@ACCNO
    END

    IF (@ALLOC_AGE > 0)
    BEGIN
     IF @ALLOC_AGE >= 1
     BEGIN
      IF (@TRANS_AGE>=2)
      BEGIN
        UPDATE DR_TRANS
SET ALLOCAGE=@ALLOC_AGE, PREV_PERIOD_OPEN=@TRANS_AMOUNT-ISNULL((SELECT SUM(AMOUNT) FROM [dbo].[DR_ALLOCATIONS]
WHERE TRANS_SEQNO=@TRANS_SEQNO AND AGE>=2), 0), PREV_PERIOD_CLOSE=@TRANS_AMOUNT-ISNULL((SELECT SUM(AMOUNT)
FROM [dbo].[DR_ALLOCATIONS] WHERE TRANS_SEQNO=@TRANS_SEQNO AND AGE>=1), 0) WHERE SEQNO=@TRANS_SEQNO
      END

      IF (@TRANS_AGE=1)
      BEGIN
        UPDATE DR_TRANS
SET ALLOCAGE=@ALLOC_AGE, PREV_PERIOD_OPEN=0, PREV_PERIOD_CLOSE=@TRANS_AMOUNT-ISNULL((SELECT SUM(AMOUNT)
FROM [dbo].[DR_ALLOCATIONS] WHERE TRANS_SEQNO=@TRANS_SEQNO AND AGE>=1), 0) WHERE SEQNO=@TRANS_SEQNO
      END
     END

     IF (@TRANS_AMOUNT-ISNULL((SELECT SUM(AMOUNT) FROM [dbo].[DR_ALLOCATIONS] WHERE TRANS_SEQNO=@TRANS_SEQNO AND AGE>=1), 0))=0
       BEGIN
         UPDATE DR_TRANS SET ALLOCATED=2 WHERE SEQNO=@TRANS_SEQNO
       END
    END
  END
  SET NOCOUNT OFF
END
UPDATE_DRACC_PRIORBAL_ONUNALLOCCREATE TRIGGER [dbo].[UPDATE_DRACC_PRIORBAL_ONUNALLOC] ON [dbo].[DR_ALLOCATIONS]
FOR DELETE AS
  DECLARE @ACCNO INTEGER,
  @TRANS_AGE INTEGER,
  @ALLOC_AGE INTEGER,
  @TRANS_SEQNO INTEGER,
  @TRANS_AMOUNT FLOAT,
  @AMOUNT FLOAT
BEGIN

  SET NOCOUNT ON

  SELECT @TRANS_SEQNO=TRANS_SEQNO, @AMOUNT=AMOUNT, @ALLOC_AGE=AGE FROM DELETED

  SELECT @ACCNO=ACCNO, @TRANS_AMOUNT=AMOUNT, @TRANS_AGE=AGE FROM DR_TRANS WHERE SEQNO=@TRANS_SEQNO

  IF (@ALLOC_AGE>0)
  BEGIN
    IF (@TRANS_AGE=1)
    BEGIN
      UPDATE DR_ACCS SET PRIOR_AGEDBAL0=PRIOR_AGEDBAL0+@AMOUNT WHERE ACCNO=@ACCNO
    END
    ELSE
    IF (@TRANS_AGE=2)
    BEGIN
      UPDATE DR_ACCS SET PRIOR_AGEDBAL1=PRIOR_AGEDBAL1+@AMOUNT WHERE ACCNO=@ACCNO
    END
    ELSE
    IF (@TRANS_AGE=3)
    BEGIN
     UPDATE DR_ACCS SET PRIOR_AGEDBAL2=PRIOR_AGEDBAL2+@AMOUNT WHERE ACCNO=@ACCNO
    END
    ELSE
    BEGIN
      UPDATE DR_ACCS SET PRIOR_AGEDBAL3=PRIOR_AGEDBAL3+@AMOUNT WHERE ACCNO=@ACCNO
    END

    IF (@ALLOC_AGE > 0)
    BEGIN
     IF @ALLOC_AGE >= 1
     BEGIN
      IF (@TRANS_AGE>=2)
      BEGIN
        UPDATE DR_TRANS
SET ALLOCAGE=@ALLOC_AGE, PREV_PERIOD_OPEN=@TRANS_AMOUNT+ISNULL((SELECT SUM(AMOUNT) FROM [dbo].[DR_ALLOCATIONS]
WHERE TRANS_SEQNO=@TRANS_SEQNO AND AGE>=2), 0), PREV_PERIOD_CLOSE=@TRANS_AMOUNT+ISNULL((SELECT SUM(AMOUNT)
FROM [dbo].[DR_ALLOCATIONS] WHERE TRANS_SEQNO=@TRANS_SEQNO AND AGE>=1), 0) WHERE SEQNO=@TRANS_SEQNO
      END

      IF (@TRANS_AGE=1)
      BEGIN
        UPDATE DR_TRANS
SET ALLOCAGE=@ALLOC_AGE, PREV_PERIOD_OPEN=0, PREV_PERIOD_CLOSE=@TRANS_AMOUNT+ISNULL((SELECT SUM(AMOUNT)
FROM [dbo].[DR_ALLOCATIONS] WHERE TRANS_SEQNO=@TRANS_SEQNO AND AGE>=1), 0) WHERE SEQNO=@TRANS_SEQNO
      END
     END

     UPDATE DR_TRANS SET ALLOCATED=0 WHERE SEQNO=@TRANS_SEQNO
    END
  END
  SET NOCOUNT OFF
END


Entity: DR_CONTACTS
CommentThis table contains details of Contact records that are associated with Debtor accounts. Contact details are taken from the relevant entry in the CONTACTS table.
Primary key columnsSEQNO

Attributes:
Column namePrimary keyData typeNot NULLComment
SEQNOYesINTEGERYesA unique identifier for the Debtor Contact. The identifier for the Contact record is specified by the CONTACT_SEQNO field.
ACCNONoINTEGERNoThe account number of the Debtor account that the Contact is associated with.
DEFCONTACTNoCHAR(1)NoThis field is set to 'Y' if the Contact is set as the default Contact for the Debtor account.
SALUTATIONNoVARCHAR(4)NoTaken from the associated record in the CONTACTS table.
FIRSTNAMENoVARCHAR(30)NoTaken from the associated record in the CONTACTS table.
LASTNAMENoVARCHAR(30)NoTaken from the associated record in the CONTACTS table.
TITLENoVARCHAR(30)NoTaken from the associated record in the CONTACTS table.
MOBILENoVARCHAR(30)NoTaken from the associated record in the CONTACTS table.
DIRECTPHONENoVARCHAR(30)NoTaken from the associated record in the CONTACTS table.
DIRECTFAXNoVARCHAR(30)NoTaken from the associated record in the CONTACTS table.
EMAILNoVARCHAR(60)NoTaken from the associated record in the CONTACTS table.
HOMEPHONENoVARCHAR(30)NoTaken from the associated record in the CONTACTS table.
NOTESNoVARCHAR(4096)NoTaken from the associated record in the CONTACTS table.
ADDRESS1NoVARCHAR(30)NoTaken from the associated record in the CONTACTS table.
ADDRESS2NoVARCHAR(30)NoTaken from the associated record in the CONTACTS table.
ADDRESS3NoVARCHAR(30)NoTaken from the associated record in the CONTACTS table.
DELADDR1NoVARCHAR(30)NoTaken from the associated record in the CONTACTS table.
DELADDR2NoVARCHAR(30)NoTaken from the associated record in the CONTACTS table.
DELADDR3NoVARCHAR(30)NoTaken from the associated record in the CONTACTS table.
DELADDR4NoVARCHAR(30)NoTaken from the associated record in the CONTACTS table.
ISACTIVENoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB1NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB2NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB3NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB4NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
ADVERTSOURCENoINTEGERNoTaken from the associated record in the CONTACTS table.
SALESNONoINTEGERNoTaken from the associated record in the CONTACTS table.
POST_CODENoVARCHAR(12)NoTaken from the associated record in the CONTACTS table.
SUB5NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB6NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB7NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB8NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB9NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB10NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB11NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB12NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB13NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB14NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB15NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB16NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB17NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB18NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB19NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB20NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
ADDRESS4NoVARCHAR(30)NoTaken from the associated record in the CONTACTS table.
DELADDR5NoVARCHAR(30)NoTaken from the associated record in the CONTACTS table.
DELADDR6NoVARCHAR(30)NoTaken from the associated record in the CONTACTS table.
CONTACT_SEQNONoINTEGERNoThe ID number of the Contact record in the CONTACTS table.
SUB21NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB22NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB23NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB24NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB25NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
SUB26NoCHAR(1)NoTaken from the associated record in the CONTACTS table.
DEFACCOUNTNoCHAR(1)YesThis field is set to 'Y' if the Debtor account is the default company for the Contact, i.e. if it is the company specified in the Company field on the Details tab of the Contacts window.
ADDRESS5NoVARCHAR(30)NoTaken from the associated record in the CONTACTS table.

Relationships:
NameRelationship typeParentChildCardinality
CONTACTS_DR_CONTACTSNon IdentifyingCONTACTSDR_CONTACTSZero Or More
DR_ACCS_DR_CONTACTSNon IdentifyingDR_ACCSDR_CONTACTSZero Or More
DR_CONTACTS_DR_CONT_HISTNon IdentifyingDR_CONTACTSDR_CONT_HISTOne Or More

Indexes:
NameIndex columnsIndex type
DRCONTACT_SEQNO_IDXCONTACT_SEQNO ASC
DR_DEFCONTACT_INDEXACCNO ASC, DEFCONTACT ASC

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (DEFACCOUNT)
Not NullColumn ConstraintNOT NULL (SEQNO)
CONTACTS_DR_CONTACTSForeign KeyTable ConstraintFOREIGN KEY (CONTACT_SEQNO) REFERENCES CONTACTS(SEQNO)
DF__DR_CONTACT__SUB1__7795AE5FDefaultColumn ConstraintSUB1 DEFAULT N
DF__DR_CONTACT__SUB2__7889D298DefaultColumn ConstraintSUB2 DEFAULT N
DF__DR_CONTACT__SUB3__797DF6D1DefaultColumn ConstraintSUB3 DEFAULT N
DF__DR_CONTACT__SUB4__7A721B0ADefaultColumn ConstraintSUB4 DEFAULT N
DF__DR_CONTACT__SUB5__131DCD43DefaultColumn ConstraintSUB5 DEFAULT N
DF__DR_CONTACT__SUB6__1411F17CDefaultColumn ConstraintSUB6 DEFAULT N
DF__DR_CONTACT__SUB7__150615B5DefaultColumn ConstraintSUB7 DEFAULT N
DF__DR_CONTACT__SUB8__15FA39EEDefaultColumn ConstraintSUB8 DEFAULT N
DF__DR_CONTACT__SUB9__16EE5E27DefaultColumn ConstraintSUB9 DEFAULT N
DF__DR_CONTAC__ADVER__7B663F43DefaultColumn ConstraintADVERTSOURCE DEFAULT 0
DF__DR_CONTAC__CONTA__6FF557EEDefaultColumn ConstraintCONTACT_SEQNO DEFAULT 0
DF__DR_CONTAC__DEFAC__4204700CDefaultColumn ConstraintDEFACCOUNT DEFAULT N
DF__DR_CONTAC__DEFCO__4CAB505ADefaultColumn ConstraintDEFCONTACT DEFAULT N
DF__DR_CONTAC__ISACT__76A18A26DefaultColumn ConstraintISACTIVE DEFAULT Y
DF__DR_CONTAC__SALES__7B313519DefaultColumn ConstraintSALESNO DEFAULT 0
DF__DR_CONTAC__SUB10__17E28260DefaultColumn ConstraintSUB10 DEFAULT N
DF__DR_CONTAC__SUB11__18D6A699DefaultColumn ConstraintSUB11 DEFAULT N
DF__DR_CONTAC__SUB12__19CACAD2DefaultColumn ConstraintSUB12 DEFAULT N
DF__DR_CONTAC__SUB13__1ABEEF0BDefaultColumn ConstraintSUB13 DEFAULT N
DF__DR_CONTAC__SUB14__1BB31344DefaultColumn ConstraintSUB14 DEFAULT N
DF__DR_CONTAC__SUB15__1CA7377DDefaultColumn ConstraintSUB15 DEFAULT N
DF__DR_CONTAC__SUB16__1D9B5BB6DefaultColumn ConstraintSUB16 DEFAULT N
DF__DR_CONTAC__SUB17__1E8F7FEFDefaultColumn ConstraintSUB17 DEFAULT N
DF__DR_CONTAC__SUB18__1F83A428DefaultColumn ConstraintSUB18 DEFAULT N
DF__DR_CONTAC__SUB19__2077C861DefaultColumn ConstraintSUB19 DEFAULT N
DF__DR_CONTAC__SUB20__216BEC9ADefaultColumn ConstraintSUB20 DEFAULT N
DF__DR_CONTAC__SUB21__546D390ADefaultColumn ConstraintSUB21 DEFAULT Y
DF__DR_CONTAC__SUB22__55615D43DefaultColumn ConstraintSUB22 DEFAULT Y
DF__DR_CONTAC__SUB23__5655817CDefaultColumn ConstraintSUB23 DEFAULT Y
DF__DR_CONTAC__SUB24__5749A5B5DefaultColumn ConstraintSUB24 DEFAULT Y
DF__DR_CONTAC__SUB25__583DC9EEDefaultColumn ConstraintSUB25 DEFAULT Y
DF__DR_CONTAC__SUB26__5931EE27DefaultColumn ConstraintSUB26 DEFAULT Y
DR_ACCS_DR_CONTACTSForeign KeyTable ConstraintFOREIGN KEY (ACCNO) REFERENCES DR_ACCS(ACCNO)
PK__DR_CONTAC__SEQNO__4BB72C21Primary KeyTable ConstraintPRIMARY KEY (SEQNO)

Triggers:
Trigger nameCode
UPDATE_DR_DEFCONTACTCREATE TRIGGER [dbo].[UPDATE_DR_DEFCONTACT] ON [dbo].[DR_CONTACTS] FOR UPDATE AS
DECLARE
  @NEW_DEFCONTACT CHAR,
  @SEQNO INTEGER,
  @ACCNO INTEGER
BEGIN
  SET NOCOUNT ON
  SELECT @NEW_DEFCONTACT=DEFCONTACT, @SEQNO=SEQNO, @ACCNO=ACCNO FROM INSERTED
  IF (@NEW_DEFCONTACT = 'Y')
    EXECUTE UPDATE_DEFAULT_CONTACT 1, @SEQNO, @ACCNO
  SET NOCOUNT OFF
END
UPDATE_DR_DEFCONTACT2CREATE TRIGGER [dbo].[UPDATE_DR_DEFCONTACT2] ON [dbo].[DR_CONTACTS] FOR INSERT AS
DECLARE
  @NEW_DEFCONTACT CHAR,
  @SEQNO INTEGER,
  @ACCNO INTEGER
BEGIN
  SET NOCOUNT ON
  SELECT @NEW_DEFCONTACT=DEFCONTACT, @SEQNO=SEQNO, @ACCNO=ACCNO FROM INSERTED
  IF (@NEW_DEFCONTACT = 'Y')
    EXECUTE UPDATE_DEFAULT_CONTACT 1, @SEQNO, @ACCNO
  SET NOCOUNT OFF
END


Entity: DR_CONT_HIST
CommentThis table contains information about the History Notes attached to Debtor accounts.
Primary key columnsSEQNO

Attributes:
Column namePrimary keyData typeNot NULLComment
SEQNOYesINTEGERYesA unique identifier for the record.
CONTACT_SEQNONoINTEGERNoThe ID number of the associated Contact record.
POSTTIMENoDATETIMENoThe actual date and time that the record was posted.
TRANSDATENoDATETIMENoThe transaction date against the History Note.
COMTYPENoINTEGERNoThis field is used by the Serviceable Units add-on module - it is not set from the Debtors UI.
SALESNONoINTEGERNoThe ID of the staff member selected on the History Note.
NOTENoVARCHAR(4096)NoThe main body of the History Note.
SUBJECTNoVARCHAR(80)NoThe subject line of the History Note.
ACCNONoINTEGERNoThe ID number of the Debtor account that the History Note is attached to.
ACTIONSTATUSNoINTEGERNoThis field is used by the Serviceable Units add-on module - it is not set from the Debtors UI.
ACTIONDUEDATENoDATETIMENoThis field is used by the Serviceable Units add-on module - it is not set from the Debtors UI.
JOBNONoINTEGERYesThis is a legacy field that is no longer used.
EVENT_SEQNONoINTEGERNoIf the History Note was created as a result of event logging, this field contains the ID number of the reason event from the REASONS table.
OUTLOOK_LINKNoVARCHAR(40)NoIf the History Note was emailed, this field contains a link to the email in MS Outlook.

Relationships:
NameRelationship typeParentChildCardinality
DR_ACCS_DR_CONT_HISTNon IdentifyingDR_ACCSDR_CONT_HISTZero Or More
DR_CONTACTS_DR_CONT_HISTNon IdentifyingDR_CONTACTSDR_CONT_HISTOne Or More
REASONS_DR_CONT_HISTNon IdentifyingREASONSDR_CONT_HISTZero Or More
STAFF_DR_CONT_HISTNon IdentifyingSTAFFDR_CONT_HISTOne Or More

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (JOBNO)
Not NullColumn ConstraintNOT NULL (SEQNO)
DF__DR_CONT_H__ACCNO__31A25463DefaultColumn ConstraintACCNO DEFAULT -1
DF__DR_CONT_H__ACTIO__5728DECDDefaultColumn ConstraintACTIONSTATUS DEFAULT 0
DF__DR_CONT_H__ACTIO__581D0306DefaultColumn ConstraintACTIONDUEDATE DEFAULT getdate()
DF__DR_CONT_H__COMTY__04EFA97DDefaultColumn ConstraintCOMTYPE DEFAULT 0
DF__DR_CONT_H__EVENT__28E3BC87DefaultColumn ConstraintEVENT_SEQNO DEFAULT -1
DF__DR_CONT_H__JOBNO__096A45D7DefaultColumn ConstraintJOBNO DEFAULT 0
DF__DR_CONT_H__POSTT__0307610BDefaultColumn ConstraintPOSTTIME DEFAULT getdate()
DF__DR_CONT_H__SALES__05E3CDB6DefaultColumn ConstraintSALESNO DEFAULT 0
DF__DR_CONT_H__TRANS__03FB8544DefaultColumn ConstraintTRANSDATE DEFAULT getdate()
DR_ACCS_DR_CONT_HISTForeign KeyTable ConstraintFOREIGN KEY (ACCNO) REFERENCES DR_ACCS(ACCNO)
DR_CONTACTS_DR_CONT_HISTForeign KeyTable ConstraintFOREIGN KEY (CONTACT_SEQNO) REFERENCES DR_CONTACTS(CONTACT_SEQNO)
PK__DR_CONT_H__SEQNO__02133CD2Primary KeyTable ConstraintPRIMARY KEY (SEQNO)
REASONS_DR_CONT_HISTForeign KeyTable ConstraintFOREIGN KEY (EVENT_SEQNO) REFERENCES REASONS(SEQNO)
STAFF_DR_CONT_HISTForeign KeyTable ConstraintFOREIGN KEY (SALESNO) REFERENCES STAFF(STAFFNO)



Entity: DR_INVLINES
CommentThis table contains line information for all Debtor transactions.
Primary key columns

Attributes:
Column namePrimary keyData typeNot NULLComment
SEQNONoINTEGERYesA unique transaction ID.
ACCNONoINTEGERNoThe account number of the Debtor that the transaction belongs to.
INVNONoVARCHAR(20)NoThe invoice number.
HDR_SEQNONoINTEGERNoThe SEQNO of the record in the DR_TRANS table that this record related to.
STOCKCODENoVARCHAR(23)NoCode of the Stock item on this line.
DESCRIPTIONNoVARCHAR(40)NoDescription of the Stock item on this line.
QUANTITYNoFLOAT(53)NoThe quantity for this line.
UNITPRICENoFLOAT(53)NoThe unit price of the Stock item on this line.
DISCOUNTNoFLOAT(53)NoThe percentage discount for the Stock item on this line.
ANALYSISNoINTEGERNoGL code for the Stock line. Can be overridden. The visibility of this column onscreen is controlled by the profile "Enable display and override of GL code from stock item".
LOCATIONNoINTEGERNoThe location that the Stock item will be moved out of. Generally, lines inherit the location from the invoice header.
UNITPRICE_INCTAXNoFLOAT(53)NoThe unit price of the Stock item on this line, inclusive of tax.
CUSTOMFIELDNoVARCHAR(30)No
UPDATE_STOCKNoCHAR(1)NoIf this field is set to 'Y', stock movements are created via the trigger DR_INVLINES_POST. The field is then set to 'T'.
UNITCOSTNoFLOAT(53)NoThe unit cost of the Stock item on this line.
JOBCODENoVARCHAR(15)NoIf the line originates from a job, the job's code is recorded in this field.
CURRENCYNONoINTEGERNoThe currency number for the line.
EXCHRATENoFLOAT(53)NoThe exchange rate for the line at the time of the transaction.
ORDERQTYNoFLOAT(53)NoThe Order Qty from the Sales Order.
BKORDQTYNoFLOAT(53)NoBack Order Qty from the Sales Order.
BATCHCODENoVARCHAR(20)NoThe batch code on the line. The "Enable stock batch codes" Company-level profile setting must be enabled to be able to use batch codes.
HIDDENNoCHAR(1)No
SUBCODENoINTEGERNoThe GL subaccount code on the line.
BRANCHNONoINTEGERNoThe branch number. Lines generally inherit the branch specified on the invoice header.
TAXRATENoFLOAT(53)NoThe percentage tax rate on the line at the time of the transaction.
TAXRATE_NONoINTEGERNoThe ID number of the tax rate used by the transaction.
LINETOTAL_TAXNoFLOAT(53)NoThe tax total for the line.
LINETAX_OVERRIDDENNoCHAR(1)NoContains 'Y' if the tax on the line has been manually modified.
LINE_SOURCENoINTEGERNoThe source SEQNO of the line, if it originated from a Sales Order or job.
JOBNONoINTEGERNoIf the line originates from a job, the job's ID number is recorded in this field.
SERIALNONoVARCHAR(50)No
TRANSDATENoDATETIMENoThe date of the transaction.
LINETOTALNoASNoA computed field containing the total value for the line, excluding tax.
LINETOTAL_INCTAXNoASNoA computed field containing the total value for the line, including tax.
NUNITPRNoASNoA computed field containing the unit price, taking into account the discount on the line.
LISTPRICENoFLOAT(53)NoThe original unit price for the Stock item on this line.
FREIGHT_FREENoCHAR(1)Yes'Y' or 'N' depending on whether the line is freight free. This comes from the price policy for the line.
CONTRACT_HDRNoINTEGERYes
DRINVLINEIDNoINTEGERNoA unique ID for the invoice line, which should be used to link to other tables. Every time an invoice is edited, the lines are essentially removed and reinserted again, which changes the SEQNO. However, the DRINVLINEID field retains its value. Hence, any relationships built on this field are still valid in such a scenario.
NARRATIVE_SEQNONoINTEGERNoThe SEQNO for the narrative on this line.
PRICE_OVERRIDDENNoCHAR(1)YesContains 'Y' if the price on the line has been manually modified.
KITCODENoVARCHAR(23)NoThe Bill of Materials code, if the line is part of a BOM.
LINETYPENoINTEGERYesThis field indicates the type of line. Will be one of:
0 = Normal stockline
1 = BOM header line
2 = BOM component line
4 = Narrative line
KITSEQNONoINTEGERNoA Bill of Materials SEQNO used to group BOM lines together.
LINKED_STOCKCODENoVARCHAR(23)NoThe physical stock unit.
LINKED_QTYNoFLOAT(53)NoThe physical stock unit quantity.
HIDDEN_COSTNoFLOAT(53)NoThis field applies to Bills of Materials. For kits that use pricing by components, this field stores the header-level cost. For builds that use individual stocklines, this fields stores the lines' real costs.
HIDDEN_SELLNoFLOAT(53)NoThis field applies to Bills of Materials. For kits that use pricing by components, this field stores header-level sell prices For builds that use individual stocklines, this fields stores the lines' real prices.
BOMTYPENoCHAR(1)NoThe type of Bill of Materials that the line relates to: N = Normal stock item B = Build K = Kit L = Lookup
SHOWLINENoCHAR(1)NoThis field applies to Bills of Materials, and is used by Clarity to determine if the line can be printed.
LINKEDSTATUSNoCHAR(1)NoWill be one of: S = Stocked L = Lookup N = Not applicable
BOMPRICINGNoCHAR(1)NoHow Bills of Materials are priced. Will be one of: C = Pricing by Component T = Pricing by total
CREDITQTYNoINTEGERYesContains the sum of quantities which have been a part of credit notes against the transaction.
CODETYPENoCHAR(1)YesThe type of code on the line. Will be one of: G - GL code S - Stock code
JOB_CONTRACT_BILLINGS_SEQNONoINTEGERYesIf the invoice is related to a Progress Billing invoice in EXO Job Costing, the ID number of that invoice is recorded here (from JOB_CONTRACT_BILLINGS).
COST_LINENONoINTEGERYesThis field is the link used when allocating cost lines to DR_INVLINES.

Relationships:
NameRelationship typeParentChildCardinality
CURRENCIES_DR_INVLINESNon IdentifyingCURRENCIESDR_INVLINESZero Or More
DR_INVLINES_DR_INVLINES_SERIALSNon IdentifyingDR_INVLINESDR_INVLINES_SERIALSZero Or More
DR_INVLINES_JOB_TRANSACTIONSIdentifyingDR_INVLINESJOB_TRANSACTIONSZero Or More
DR_INVLINES_SALESORD_HDRNon IdentifyingDR_INVLINESSALESORD_HDRZero Or More
DR_TRANS_DR_INVLINES_ACCNONon IdentifyingDR_TRANSDR_INVLINESZero Or More
DR_TRANS_DR_INVLINES_SEQNONon IdentifyingDR_TRANSDR_INVLINESZero Or More
NARRATIVES_DR_INVLINESNon IdentifyingNARRATIVESDR_INVLINESZero Or More
STOCK_ITEMS_DR_INVLINESNon IdentifyingSTOCK_ITEMSDR_INVLINESZero Or More
TAX_RATES_DR_INVLINESNon IdentifyingTAX_RATESDR_INVLINESZero Or More

Indexes:
NameIndex columnsIndex type
DR_INVLINES_ANALYSISANALYSIS ASC
DR_INVLINES_HDRSEQHDR_SEQNO ASC
DR_INVLINES_LINE_SOURCELINE_SOURCE ASC
DR_INVLINES_STOCKCODESTOCKCODE ASC

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (COST_LINENO)
Not NullColumn ConstraintNOT NULL (SEQNO)
Not NullColumn ConstraintNOT NULL (JOB_CONTRACT_BILLINGS_SEQNO)
Not NullColumn ConstraintNOT NULL (CODETYPE)
Not NullColumn ConstraintNOT NULL (CREDITQTY)
Not NullColumn ConstraintNOT NULL (LINETYPE)
Not NullColumn ConstraintNOT NULL (PRICE_OVERRIDDEN)
Not NullColumn ConstraintNOT NULL (CONTRACT_HDR)
Not NullColumn ConstraintNOT NULL (FREIGHT_FREE)
CURRENCIES_DR_INVLINESForeign KeyTable ConstraintFOREIGN KEY (CURRENCYNO) REFERENCES CURRENCIES(CURRENCYNO)
DF__DR_INVLIN__ACCNO__1229A90ADefaultColumn ConstraintACCNO DEFAULT 0
DF__DR_INVLIN__ANALY__1ABEEF0BDefaultColumn ConstraintANALYSIS DEFAULT 0
DF__DR_INVLIN__BKORD__6A06A917DefaultColumn ConstraintBKORDQTY DEFAULT 0
DF__DR_INVLIN__BOMPR__4CC12A4ADefaultColumn ConstraintBOMPRICING DEFAULT N
DF__DR_INVLIN__BOMTY__49E4BD9FDefaultColumn ConstraintBOMTYPE DEFAULT N
DF__DR_INVLIN__BRANC__34E8D562DefaultColumn ConstraintBRANCHNO DEFAULT 0
DF__DR_INVLIN__CODET__7D45FCC2DefaultColumn ConstraintCODETYPE DEFAULT S
DF__DR_INVLIN__CONTR__485B9C89DefaultColumn ConstraintCONTRACT_HDR DEFAULT 0
DF__DR_INVLIN__COST___02FED618DefaultColumn ConstraintCOST_LINENO DEFAULT -1
DF__DR_INVLIN__CREDI__76D75FA7DefaultColumn ConstraintCREDITQTY DEFAULT 0
DF__DR_INVLIN__CURRE__36870511DefaultColumn ConstraintCURRENCYNO DEFAULT 0
DF__DR_INVLIN__DISCO__18D6A699DefaultColumn ConstraintDISCOUNT DEFAULT 0
DF__DR_INVLIN__DRINV__0FE2393CDefaultColumn ConstraintDRINVLINEID DEFAULT 0
DF__DR_INVLIN__EXCHR__377B294ADefaultColumn ConstraintEXCHRATE DEFAULT 1
DF__DR_INVLIN__FREIG__0D84EF7EDefaultColumn ConstraintFREIGHT_FREE DEFAULT N
DF__DR_INVLIN__HDR_S__1411F17CDefaultColumn ConstraintHDR_SEQNO DEFAULT 0
DF__DR_INVLIN__HIDDE__0CDBAF5FDefaultColumn ConstraintHIDDEN_COST DEFAULT 0
DF__DR_INVLIN__HIDDE__0DCFD398DefaultColumn ConstraintHIDDEN_SELL DEFAULT 0
DF__DR_INVLIN__JOBNO__6A1BB7B0DefaultColumn ConstraintJOBNO DEFAULT 0
DF__DR_INVLIN__JOB_C__020AB1DFDefaultColumn ConstraintJOB_CONTRACT_BILLINGS_SEQNO DEFAULT -1
DF__DR_INVLIN__KITSE__0BE78B26DefaultColumn ConstraintKITSEQNO DEFAULT -1
DF__DR_INVLIN__LINET__0E4EF685DefaultColumn ConstraintLINETYPE DEFAULT -1
DF__DR_INVLIN__LINET__1BE81D6EDefaultColumn ConstraintLINETOTAL_TAX DEFAULT 0
DF__DR_INVLIN__LINKE__4BCD0611DefaultColumn ConstraintLINKEDSTATUS DEFAULT N
DF__DR_INVLIN__LISTP__59063A47DefaultColumn ConstraintLISTPRICE DEFAULT 0
DF__DR_INVLIN__LOCAT__1BB31344DefaultColumn ConstraintLOCATION DEFAULT 1
DF__DR_INVLIN__ORDER__691284DEDefaultColumn ConstraintORDERQTY DEFAULT 0
DF__DR_INVLIN__PRICE__6641052BDefaultColumn ConstraintPRICE_OVERRIDDEN DEFAULT N
DF__DR_INVLIN__QUANT__16EE5E27DefaultColumn ConstraintQUANTITY DEFAULT 0
DF__DR_INVLIN__SHOWL__4AD8E1D8DefaultColumn ConstraintSHOWLINE DEFAULT Y
DF__DR_INVLIN__SUBCO__33F4B129DefaultColumn ConstraintSUBCODE DEFAULT 0
DF__DR_INVLIN__TRANS__6B0FDBE9DefaultColumn ConstraintTRANSDATE DEFAULT getdate()
DF__DR_INVLIN__UNITC__6B2FD77ADefaultColumn ConstraintUNITCOST DEFAULT 0
DF__DR_INVLIN__UNITP__17E28260DefaultColumn ConstraintUNITPRICE DEFAULT 0
DF__DR_INVLIN__UNITP__1CA7377DDefaultColumn ConstraintUNITPRICE_INCTAX DEFAULT 0
DF__DR_INVLIN__UPDAT__21F5FC7FDefaultColumn ConstraintUPDATE_STOCK DEFAULT Y
DR_TRANS_DR_INVLINES_ACCNOForeign KeyTable ConstraintFOREIGN KEY (ACCNO) REFERENCES DR_TRANS(ACCNO)
DR_TRANS_DR_INVLINES_SEQNOForeign KeyTable ConstraintFOREIGN KEY (HDR_SEQNO) REFERENCES DR_TRANS(SEQNO)
NARRATIVES_DR_INVLINESForeign KeyTable ConstraintFOREIGN KEY (SEQNO) REFERENCES NARRATIVES(SEQNO)
STOCK_ITEMS_DR_INVLINESForeign KeyTable ConstraintFOREIGN KEY (STOCKCODE) REFERENCES STOCK_ITEMS(STOCKCODE)
TAX_RATES_DR_INVLINESForeign KeyTable ConstraintFOREIGN KEY (TAXRATE_NO) REFERENCES TAX_RATES(SEQNO)

Triggers:
Trigger nameCode
DRINVLINESIDCREATE TRIGGER [dbo].[DRINVLINESID] ON [dbo].[DR_INVLINES] FOR INSERT AS
BEGIN
  SET NOCOUNT ON
  UPDATE [dbo].[DR_INVLINES] SET DRINVLINEID = INSERTED.SEQNO
  FROM [dbo].[DR_INVLINES]
  INNER JOIN INSERTED ON ([dbo].[DR_INVLINES].SEQNO = INSERTED.SEQNO)
  WHERE INSERTED.DRINVLINEID IS NULL OR INSERTED.DRINVLINEID = 0
  SET NOCOUNT OFF
END
DR_INVLINES_POSTCREATE TRIGGER [dbo].[DR_INVLINES_POST]
ON [dbo].[DR_INVLINES]
FOR INSERT
AS
BEGIN
/* Exonet created trigger from DBUpdate */
  SET NOCOUNT ON
  DECLARE @ASTOCKTRANSCODE VARCHAR(23),
  @AREF2 VARCHAR(30), @ATRANSTYPE INT, @AGLPOSTED CHAR(1), @APOSTTOGL CHAR(1), @APOSTLOOKUPTOGL CHAR(1),
  @ISBOMBUILD CHAR(1), @ISBOMKITHDR CHAR(1), @ISBOMLINKED CHAR(1), @AQUANTITY DOUBLE PRECISION,
  @AUNITPRICE DOUBLE PRECISION, @AUNITCOST DOUBLE PRECISION,
  @UNITPRICE DOUBLE PRECISION, @UNITCOST DOUBLE PRECISION, @HIDDEN_COST DOUBLE PRECISION,
  @HIDDEN_SELL DOUBLE PRECISION, @QUANTITY DOUBLE PRECISION, @KITCODE VARCHAR(23), @KITSEQNO INT,
  @STOCKCODE VARCHAR(23), @JOBNO INT, @LINKED_STOCKCODE VARCHAR(23),
  @SEQNO INT, @HDR_SEQNO INT, @BATCHCODE VARCHAR(20), @INVNO VARCHAR(20), @ACCNO INT, @LOCATION INT,
  @TRANSDATE DATETIME, @LINKEDSTATUS CHAR(1), @DISCOUNT DOUBLE PRECISION, @EXCHRATE DOUBLE PRECISION, @BOMTYPE CHAR(1),
  @LINETYPE INT, @UPDATE_STOCK CHAR(1), @SESSION_ID INT
   , @AGE INT
   , @PERIOD_SEQNO INT
IF ISNULL((SELECT TOP 1 SESSION_ID FROM DR_TRANS D JOIN INSERTED I ON D.SEQNO = I.HDR_SEQNO), -1) = -1
  BEGIN
  EXECUTE GEN_ID 'DR_TRANS', 'SESSION_ID', 'Y', @ID=@SESSION_ID OUTPUT
  UPDATE D
  SET SESSION_ID = @SESSION_ID
  FROM DR_TRANS D
  JOIN INSERTED I ON D.SEQNO = I.HDR_SEQNO
  END
ELSE
  BEGIN
  SELECT @SESSION_ID = (SELECT TOP 1 SESSION_ID FROM DR_TRANS D JOIN INSERTED I ON D.SEQNO = I.HDR_SEQNO)
  END
      SET @AGE = 0
SELECT @PERIOD_SEQNO = SEQNO FROM PERIOD_STATUS WHERE LEDGER='S' AND AGE = @AGE
  DECLARE INSERTED_INVCURSOR CURSOR LOCAL FOR
    SELECT UNITPRICE, UNITCOST, HIDDEN_COST, HIDDEN_SELL, QUANTITY, KITCODE, KITSEQNO, STOCKCODE,
    JOBNO, LINKED_STOCKCODE, SEQNO, HDR_SEQNO, BATCHCODE, INVNO, ACCNO, LOCATION, TRANSDATE, LINKEDSTATUS,
    DISCOUNT, EXCHRATE, BOMTYPE, LINETYPE, UPDATE_STOCK
    FROM INSERTED
  OPEN INSERTED_INVCURSOR
  FETCH NEXT FROM INSERTED_INVCURSOR
  INTO @UNITPRICE, @UNITCOST, @HIDDEN_COST, @HIDDEN_SELL, @QUANTITY, @KITCODE, @KITSEQNO, @STOCKCODE,
    @JOBNO, @LINKED_STOCKCODE, @SEQNO, @HDR_SEQNO, @BATCHCODE, @INVNO, @ACCNO, @LOCATION, @TRANSDATE, @LINKEDSTATUS,
    @DISCOUNT, @EXCHRATE, @BOMTYPE, @LINETYPE, @UPDATE_STOCK
  WHILE @@FETCH_STATUS = 0
  BEGIN
    SET @ISBOMKITHDR = 'N'
    IF ((@BOMTYPE = 'K') AND (@LINETYPE = 1))
      SET @ISBOMKITHDR = 'Y'
    IF ((@STOCKCODE IS NOT NULL) AND (@STOCKCODE<>'') AND (@UPDATE_STOCK='Y') AND (@ISBOMKITHDR = 'N'))
    BEGIN
      /* PREPARE TO INSERT STOCK TRANSACTION FOR NON-KIT HEADER LINES */
      SET @ISBOMBUILD = 'N'
      SET @ISBOMLINKED = 'N'
      IF (@BOMTYPE = 'B')
        SET @ISBOMBUILD = 'Y'
      IF (@BOMTYPE = 'L')
        SET @ISBOMLINKED = 'Y'
      SET @ATRANSTYPE = 0
      SET @AGLPOSTED = 'N'
      SET @APOSTTOGL = 'Y'
      SET @APOSTLOOKUPTOGL = 'N'
      SET @AUNITPRICE = @UNITPRICE
      SET @AUNITCOST = @UNITCOST
      SET @AREF2 = 'INVOICE'
      SET @AQUANTITY = - @QUANTITY
      /* FIND STOCKCODE TO POST TO STOCKTRANS */
      SET @ASTOCKTRANSCODE = @LINKED_STOCKCODE
      IF (((@ASTOCKTRANSCODE <> '') AND ((@LINETYPE = 2) OR (@LINETYPE = 0))) OR (@ISBOMLINKED = 'Y'))
        SET @ASTOCKTRANSCODE = @STOCKCODE
      IF (@ASTOCKTRANSCODE = '')
        SET @ASTOCKTRANSCODE = @STOCKCODE
      /* FIND LOCAL CURRENCY DISCOUNTED UNIT PRICE EXCL TAX TO USE FOR STOCK_TRANS */
      SET @AUNITPRICE = @AUNITPRICE * (1 - @DISCOUNT / 100)
      IF (@EXCHRATE <> 0)
        SET @AUNITPRICE = @AUNITPRICE / @EXCHRATE
      IF ((@ISBOMBUILD ='Y') AND (@LINETYPE = 2))
      BEGIN
         /* CONSUME COMPONENTS FOR BOM BUILD COMPONENTS */
        SET @AUNITPRICE = @HIDDEN_SELL
        SET @AUNITCOST = @HIDDEN_COST
        SET @AREF2 = 'SALES ORD BOM'
        SET @ATRANSTYPE = 3
        SET @AGLPOSTED = 'Y'
        SET @APOSTTOGL = 'N'
        SET @AUNITPRICE = @AUNITCOST
        IF (@LINKEDSTATUS = 'L')
          SET @APOSTLOOKUPTOGL = 'Y'
      END
      ELSE IF ((@ISBOMBUILD='Y') AND (@LINETYPE = 1))
      BEGIN
        /* CREATE NEW BOM BUILD HEADER OUTPUT ITEM */
        SET @ATRANSTYPE = 1
        SET @AGLPOSTED = 'Y'
        SET @APOSTTOGL = 'N'
        SET @AQUANTITY = @QUANTITY
        SET @AUNITPRICE = @AUNITCOST
      END
      INSERT INTO STOCK_TRANS
      (TRANSTYPE, STOCKCODE, ACCNO, REF1, REF2, QUANTITY, UNITPRICE, LOCATION, FROM_LEDGER, FROM_HDR, BATCHCODE,
      JOBNO, LINE_SEQNO, TRANSDATE, PLU, KITCODE, KITSEQNO, POST_TO_GL, UNITCOST, GLPOSTED, POST_LOOKUP_TO_GL, SESSION_ID
     , PERIOD_SEQNO
      ) VALUES (@ATRANSTYPE, @ASTOCKTRANSCODE, @ACCNO, @INVNO, @AREF2, @AQUANTITY,
      @AUNITPRICE, @LOCATION, 'd', @HDR_SEQNO, @BATCHCODE, @JOBNO, @SEQNO, @TRANSDATE,
      @STOCKCODE, @KITCODE, @KITSEQNO, @APOSTTOGL, @AUNITCOST, @AGLPOSTED, @APOSTLOOKUPTOGL, @SESSION_ID
 , @PERIOD_SEQNO
 )
      /* SET UPDATE_STOCK FIELD ON DR_INVLINE TO MARK LINE AS TRIGGERED */
      UPDATE [dbo].[DR_INVLINES]
      SET UPDATE_STOCK='T'
      WHERE SEQNO = @SEQNO
      /* INSERT 2nd TRANSACTION FOR THE SALE OF THE CREATED BOM BUILD HEADER OUTPUT ITEM */
      IF ((@ISBOMBUILD='Y') AND (@LINETYPE = 1))
      BEGIN
        SET @ATRANSTYPE = 0
        SET @AGLPOSTED = 'N'
        SET @APOSTTOGL = 'Y'
        SET @AQUANTITY = -@QUANTITY
        SET @AUNITPRICE = @UNITPRICE
        INSERT INTO STOCK_TRANS
        (TRANSTYPE, STOCKCODE, ACCNO, REF1, REF2, QUANTITY, UNITPRICE, LOCATION, FROM_LEDGER, FROM_HDR, BATCHCODE,
        JOBNO, LINE_SEQNO, TRANSDATE, PLU, KITCODE, KITSEQNO, POST_TO_GL, UNITCOST, GLPOSTED, POST_LOOKUP_TO_GL, SESSION_ID
        , PERIOD_SEQNO
        ) VALUES (@ATRANSTYPE, @ASTOCKTRANSCODE, @ACCNO, @INVNO, @AREF2, @AQUANTITY,
        @AUNITPRICE, @LOCATION, 'd', @HDR_SEQNO, @BATCHCODE, @JOBNO, @SEQNO, @TRANSDATE,
        @STOCKCODE, @KITCODE, @KITSEQNO, @APOSTTOGL, @AUNITCOST, @AGLPOSTED, @APOSTLOOKUPTOGL, @SESSION_ID
 , @PERIOD_SEQNO
)
      END
    END
    ELSE IF ((@STOCKCODE IS NOT NULL) AND (@STOCKCODE<>'') AND (@UPDATE_STOCK='Y') AND (@ISBOMKITHDR = 'Y'))
    BEGIN
      /* SET UPDATE_STOCK FIELD FOR KIT HEADER DR_INVLINE TO MARK LINE AS TRIGGERED */
      UPDATE [dbo].[DR_INVLINES]
      SET UPDATE_STOCK='T'
      WHERE SEQNO = @SEQNO
    END
    FETCH NEXT FROM INSERTED_INVCURSOR
    INTO @UNITPRICE, @UNITCOST, @HIDDEN_COST, @HIDDEN_SELL, @QUANTITY, @KITCODE, @KITSEQNO, @STOCKCODE,
      @JOBNO, @LINKED_STOCKCODE, @SEQNO, @HDR_SEQNO, @BATCHCODE, @INVNO, @ACCNO, @LOCATION, @TRANSDATE, @LINKEDSTATUS,
      @DISCOUNT, @EXCHRATE, @BOMTYPE, @LINETYPE, @UPDATE_STOCK
  END
  CLOSE INSERTED_INVCURSOR
  DEALLOCATE INSERTED_INVCURSOR
  SET NOCOUNT OFF
END
DR_INVLINES_SET_UNITCOSTCREATE TRIGGER [dbo].[DR_INVLINES_SET_UNITCOST]
ON [dbo].[DR_INVLINES]
FOR INSERT
AS
  DECLARE @STOCKCOSTMETHOD INTEGER
BEGIN
  SET NOCOUNT ON
  EXECUTE GET_PROFILE_VALUE_INT 'STOCKCOSTMETHOD', @STOCKCOSTMETHOD OUTPUT
  UPDATE [dbo].[DR_INVLINES]
  SET UNITCOST = (SELECT (CASE @STOCKCOSTMETHOD WHEN 1 THEN LATESTCOST
                  WHEN 2 THEN STDCOST ELSE AVECOST END)
                  FROM STOCK_ITEMS
                  WHERE STOCK_ITEMS.STOCKCODE = INSERTED.STOCKCODE)
  FROM [dbo].[DR_INVLINES] JOIN INSERTED ON ([dbo].[DR_INVLINES].SEQNO = INSERTED.SEQNO)
  WHERE INSERTED.STOCKCODE IS NOT NULL
  AND (INSERTED.STOCKCODE <> '')
  AND (INSERTED.BOMTYPE <> 'K') AND (INSERTED.BOMTYPE <> 'B')
  SET NOCOUNT OFF
END


Entity: DR_INVLINES_SERIALS
CommentThis table contains details of serial numbers on Debtor Invoice lines.
Primary key columnsSEQNO

Attributes:
Column namePrimary keyData typeNot NULLComment
SEQNOYesINTEGERYesA unique ID number for the line.
SERIALNONoVARCHAR(50)NoThe serial number.
INVLINEIDNoINTEGERNoThe associated Debtors Invoice line - links to DR_INVLINES.DRINVLINEID.
POSTTIMENoDATETIMENo

Relationships:
NameRelationship typeParentChildCardinality
DR_INVLINES_DR_INVLINES_SERIALSNon IdentifyingDR_INVLINESDR_INVLINES_SERIALSZero Or More

Indexes:
NameIndex columnsIndex type
DR_INVLINES_SERIALS_INDEXSERIALNO ASC, INVLINEID ASCUNIQUE

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (SEQNO)
DF__DR_INVLIN__POSTT__548247A3DefaultColumn ConstraintPOSTTIME DEFAULT getdate()
DR_INVLINES_DR_INVLINES_SERIALSForeign KeyTable ConstraintFOREIGN KEY (INVLINEID) REFERENCES DR_INVLINES(DRINVLINEID)
PK__DR_INVLINES_SERI__538E236APrimary KeyTable ConstraintPRIMARY KEY (SEQNO)



Entity: DR_PRICEGROUPS
CommentThis table stores details of all Debtor Price Policy Groups. These are set up in the EXO Business Configurator at Admin > Debtors > Debtor Price Policy Groups.
Primary key columnsGROUPNO

Attributes:
Column namePrimary keyData typeNot NULLComment
GROUPNOYesINTEGERYesA unique identifier for the Debtor Price Policy Group.
GROUPNAMENoVARCHAR(30)YesThe Debtor Price Policy Group's name.
REPORTCODENoVARCHAR(15)NoA reporting code for the Debtor Price Policy Group.

Relationships:
NameRelationship typeParentChildCardinality
DR_PRICEGROUPS_DR_ACCSNon IdentifyingDR_PRICEGROUPSDR_ACCSOne Or More

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (GROUPNAME)
Not NullColumn ConstraintNOT NULL (GROUPNO)
PK__DR_PRICEGROUPS__181857E1Primary KeyTable ConstraintPRIMARY KEY (GROUPNO)



Entity: DR_PRICES
CommentThis table contains information on Debtor price rules.
Primary key columnsSEQNO

Attributes:
Column namePrimary keyData typeNot NULLComment
SEQNOYesINTEGERYesA unique ID number for the price record.
ACCNONoINTEGERNoThe Debtor account that the price rule is defined for. Has the value -1 if the price rule belongs to a generic price policy.
STOCKCODENoVARCHAR(23)NoIf the price rule is defined for an individual Stock item, this field stores the item's stockcode.
PRICENoFLOAT(53)NoThe substitute price to be applied to the stockcode/group.
STARTDATENoDATETIMENoDate from which the price rule is active.
STOPDATENoDATETIMENoDate to which the price rule remains active.
MINQTYNoFLOAT(53)NoMinimum quantity for the price rule to apply.
ACCGROUPNoINTEGERNoThe Debtors Account Group that the price rule belongs to.
STOCKPRICEGROUPNoINTEGERNoIf the price rule is defined against a price group rather than an individual product, this field stores the Stock price group.
DISCOUNTNoFLOAT(53)NoThe percentage discount to be applied, as per a price rule.
FREIGHT_FREENoCHAR(1)Yes
POLICY_HDRNoINTEGERNoThe Debtor price policy that the price rule belongs to.
SELL_PRICE_BANDNONoINTEGERYesSwitch to this base sell price band (generally set if no discount/substitute price is applied).
MASTER_JOBNONoINTEGERNoID number of the master job that this price rule applies to, if relevant.
JOBNONoINTEGERNoID number of the job that this price rule applies to, if relevant.
CAMPAIGN_WAVE_SEQNONoINTEGERNoID number of the campaign wave that this price rule applies to, if relevant.

Relationships:
NameRelationship typeParentChildCardinality
CAMPAIGN_WAVE_DR_PRICESNon IdentifyingCAMPAIGN_WAVEDR_PRICESZero Or More
DR_ACCGROUPS_DR_PRICESNon IdentifyingDR_ACCGROUPSDR_PRICESOne Or More
DR_ACCS_DR_PRICESNon IdentifyingDR_ACCSDR_PRICESOne Or More
DR_PRICE_POLICY_DR_PRICESNon IdentifyingDR_PRICE_POLICYDR_PRICESOne Or More
STOCK_ITEMS_DR_PRICESNon IdentifyingSTOCK_ITEMSDR_PRICESZero Or More

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (SELL_PRICE_BANDNO)
Not NullColumn ConstraintNOT NULL (SEQNO)
Not NullColumn ConstraintNOT NULL (FREIGHT_FREE)
CAMPAIGN_WAVE_DR_PRICESForeign KeyTable ConstraintFOREIGN KEY (CAMPAIGN_WAVE_SEQNO) REFERENCES CAMPAIGN_WAVE(SEQNO)
DF__DR_PRICES__ACCGR__0ABD916CDefaultColumn ConstraintACCGROUP DEFAULT -1
DF__DR_PRICES__ACCNO__51FA155CDefaultColumn ConstraintACCNO DEFAULT 0
DF__DR_PRICES__CAMPA__58098B1BDefaultColumn ConstraintCAMPAIGN_WAVE_SEQNO DEFAULT -1
DF__DR_PRICES__FREIG__18AC8967DefaultColumn ConstraintFREIGHT_FREE DEFAULT N
DF__DR_PRICES__JOBNO__13D39108DefaultColumn ConstraintJOBNO DEFAULT 0
DF__DR_PRICES__MASTE__12DF6CCFDefaultColumn ConstraintMASTER_JOBNO DEFAULT 0
DF__DR_PRICES__MINQT__2A6B46EFDefaultColumn ConstraintMINQTY DEFAULT 0
DF__DR_PRICES__PRICE__52EE3995DefaultColumn ConstraintPRICE DEFAULT 0
DF__DR_PRICES__SELL___08F60FE2DefaultColumn ConstraintSELL_PRICE_BANDNO DEFAULT -1
DF__DR_PRICES__START__53E25DCEDefaultColumn ConstraintSTARTDATE DEFAULT getdate()
DF__DR_PRICES__STOCK__68336F3EDefaultColumn ConstraintSTOCKPRICEGROUP DEFAULT -1
DF__DR_PRICES__STOPD__54D68207DefaultColumn ConstraintSTOPDATE DEFAULT getdate()
DR_ACCGROUPS_DR_PRICESForeign KeyTable ConstraintFOREIGN KEY (ACCGROUP) REFERENCES DR_ACCGROUPS(ACCGROUP)
DR_ACCS_DR_PRICESForeign KeyTable ConstraintFOREIGN KEY (ACCNO) REFERENCES DR_ACCS(ACCNO)
DR_PRICE_POLICY_DR_PRICESForeign KeyTable ConstraintFOREIGN KEY (POLICY_HDR) REFERENCES DR_PRICE_POLICY(POLICY_HDR)
PK__DR_PRICES__SEQNO__5105F123Primary KeyTable ConstraintPRIMARY KEY (SEQNO)
STOCK_ITEMS_DR_PRICESForeign KeyTable ConstraintFOREIGN KEY (STOCKCODE) REFERENCES STOCK_ITEMS(STOCKCODE)



Entity: DR_PRICE_POLICY
CommentThis table contains information on Debtor price policies.
Primary key columnsPOLICY_HDR

Attributes:
Column namePrimary keyData typeNot NULLComment
POLICY_HDRYesINTEGERYesA unique ID number for the policy record.
CUSTOMER_REFNoVARCHAR(30)NoReference field for the customer's reference.
POLICY_REFNoVARCHAR(30)NoReference field for the policy
START_DATENoDATETIMEYesDate from which the policy becomes active.
END_DATENoDATETIMEYesDate to which the price rule remains active.
PRICE_MODENoCHAR(1)Yes
IS_ACTIVENoCHAR(1)YesThis field contains 'Y' if the policy is active.
NOTESNoVARCHAR(4096)NoAny notes that have been recorded for the policy.
FREIGHT_FREENoCHAR(1)Yes
FIXEDNoCHAR(1)YesThis field contains 'Y' if the policy is fixed
CAMPAIGN_WAVE_SEQNONoINTEGERNoThe ID number of the campaign wave that the policy relates to, if relevant.

Relationships:
NameRelationship typeParentChildCardinality
CAMPAIGN_WAVE_DR_PRICE_POLICYNon IdentifyingCAMPAIGN_WAVEDR_PRICE_POLICYZero Or More
DR_PRICE_POLICY_DR_PRICESNon IdentifyingDR_PRICE_POLICYDR_PRICESOne Or More
DR_PRICE_POLICY_DR_PRICE_POLICY_ACCNon IdentifyingDR_PRICE_POLICYDR_PRICE_POLICY_ACCOne Or More

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (FIXED)
Not NullColumn ConstraintNOT NULL (POLICY_HDR)
Not NullColumn ConstraintNOT NULL (START_DATE)
Not NullColumn ConstraintNOT NULL (FREIGHT_FREE)
Not NullColumn ConstraintNOT NULL (END_DATE)
Not NullColumn ConstraintNOT NULL (IS_ACTIVE)
Not NullColumn ConstraintNOT NULL (PRICE_MODE)
CAMPAIGN_WAVE_DR_PRICE_POLICYForeign KeyTable ConstraintFOREIGN KEY (CAMPAIGN_WAVE_SEQNO) REFERENCES CAMPAIGN_WAVE(SEQNO)
DF__DR_PRICE___CAMPA__58FDAF54DefaultColumn ConstraintCAMPAIGN_WAVE_SEQNO DEFAULT -1
DF__DR_PRICE___END_D__33C07256DefaultColumn ConstraintEND_DATE DEFAULT getdate()
DF__DR_PRICE___FIXED__3791033ADefaultColumn ConstraintFIXED DEFAULT N
DF__DR_PRICE___FREIG__369CDF01DefaultColumn ConstraintFREIGHT_FREE DEFAULT Y
DF__DR_PRICE___IS_AC__35A8BAC8DefaultColumn ConstraintIS_ACTIVE DEFAULT Y
DF__DR_PRICE___PRICE__34B4968FDefaultColumn ConstraintPRICE_MODE DEFAULT Y
DF__DR_PRICE___START__32CC4E1DDefaultColumn ConstraintSTART_DATE DEFAULT getdate()
PK__DR_PRICE_POLICY__31D829E4Primary KeyTable ConstraintPRIMARY KEY (POLICY_HDR)

Triggers:
Trigger nameCode
AFTER_POLICY_DELETECREATE TRIGGER [dbo].[AFTER_POLICY_DELETE] ON [dbo].[DR_PRICE_POLICY]
FOR DELETE
AS
SET NOCOUNT ON
  DELETE FROM DR_PRICES WHERE POLICY_HDR IN (SELECT POLICY_HDR FROM DELETED)
  DELETE FROM DR_PRICE_POLICY_ACC WHERE POLICY_HDR IN (SELECT POLICY_HDR FROM DELETED)
SET NOCOUNT OFF
AFTER_POLICY_INSERTCREATE TRIGGER [dbo].[AFTER_POLICY_INSERT] ON [dbo].[DR_PRICE_POLICY]
FOR INSERT
AS
SET NOCOUNT ON
UPDATE [dbo].[DR_PRICE_POLICY] SET POLICY_REF = 'Policy '+CAST(POLICY_HDR AS VARCHAR) WHERE
POLICY_REF IS NULL AND POLICY_HDR IN (SELECT POLICY_HDR FROM INSERTED)
SET NOCOUNT OFF


Entity: DR_PRICE_POLICY_ACC
CommentThis table defines the members of Debtor price policies.
Primary key columnsSEQNO

Attributes:
Column namePrimary keyData typeNot NULLComment
SEQNOYesINTEGERYesA unique ID number for the record.
POLICY_HDRNoINTEGERYesThe Debtor price policy that the account/account group belongs to.
ACCNONoINTEGERNoThe relevant Debtor account.
ACCGROUPNoINTEGERNoThe relevant Debtor account group.

Relationships:
NameRelationship typeParentChildCardinality
DR_ACCGROUPS_DR_PRICE_POLICY_ACCNon IdentifyingDR_ACCGROUPSDR_PRICE_POLICY_ACCOne Or More
DR_ACCS_DR_PRICE_POLICY_ACCNon IdentifyingDR_ACCSDR_PRICE_POLICY_ACCOne Or More
DR_PRICE_POLICY_DR_PRICE_POLICY_ACCNon IdentifyingDR_PRICE_POLICYDR_PRICE_POLICY_ACCOne Or More

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (POLICY_HDR)
Not NullColumn ConstraintNOT NULL (SEQNO)
DR_ACCGROUPS_DR_PRICE_POLICY_ACCForeign KeyTable ConstraintFOREIGN KEY (ACCGROUP) REFERENCES DR_ACCGROUPS(ACCGROUP)
DR_ACCS_DR_PRICE_POLICY_ACCForeign KeyTable ConstraintFOREIGN KEY (ACCNO) REFERENCES DR_ACCS(ACCNO)
DR_PRICE_POLICY_DR_PRICE_POLICY_ACCForeign KeyTable ConstraintFOREIGN KEY (POLICY_HDR) REFERENCES DR_PRICE_POLICY(POLICY_HDR)
PK__DR_PRICE_POLICY___3A6D6FE5Primary KeyTable ConstraintPRIMARY KEY (SEQNO)



Entity: DR_TRANS
CommentThis table contains header information for all Debtor transactions.
Primary key columnsSEQNO

Attributes:
Column namePrimary keyData typeNot NULLComment
SEQNOYesINTEGERYesA unique transaction ID.
POSTTIMENoDATETIMENoThe actual date/time the transaction was posted at.
TRANSDATENoDATETIMENoThe date/time mentioned in the transaction itself.
ACCNONoINTEGERNoThe ID number of the Debtor account against which the transaction was generated. If the transaction is against a branch account, this field is set to the head account's ACCNO.
TRANSTYPENoINTEGERNo1 = Postive amount is Invoice, Negative amount is Credit; 4 = Negative amount is Payment, Positive amount is Refund
INVNONoVARCHAR(20)NoThe invoice number. For credit notes, the invoice number is prefixed with CR.
REF1NoVARCHAR(20)NoFor invoices, this field contains whatever was entered into the Reference field. If the invoice is for an asset created from Job Costing, this field holds the stockcode for the asset. For payments, this field contains the payment type, e.g. CASH, CHEQUE.
REF2NoVARCHAR(20)NoFor payments, this filed contains the payment reference/cheque number. For invoices, when coming from Sales Order, this field contains the customer orderno Extra Field value.
REF3NoVARCHAR(30)NoFor payments, this field contains the payment bank and branch. For invoices, this field contains the text 'Invoice'.
NAMENoVARCHAR(70)NoThe name of the Debtor account against which the transaction was generated.
SALESNONoINTEGERNoThe ID number of the salesperson.
SUBTOTALNoFLOAT(53)NoThe tax-exclusive amount, in the currency of the Debtor account.
TAXTOTALNoFLOAT(53)NoThe tax total in the currency of the Debtor account.
TAXINCNoCHAR(1)NoY = tax inclusive, N = tax exclusive.
ANALYSISNoVARCHAR(12)NoFor payments, this field holds the payment type.
ALLOCATEDBALNoFLOAT(53)NoThe amount that has been allocated.
ALLOCATEDNoCHAR(1)No0 = Unallocated or partially allocated. 1 = Allocated in the current period. 2 = Allocated in any prior period.
ALLOCAGENoINTEGERNoThe age in which the transaction was allocated.
GLPOSTEDNoCHAR(1)NoY = the transaction has been posted to GL. N = the transaction has not been posted to GL.
GLCODENoINTEGERNoFor payments, this field contains the GL code of the bank account.
DUEDATENoDATETIMENoThe payment due date.
BRANCH_ACCNONoINTEGERNoOnly used in head account/branch account scenarios. This field contains the account number of the branch account.
DELIVADDR1NoVARCHAR(30)NoDelivery address line 1.
DELIVADDR2NoVARCHAR(30)NoDelivery address line 2.
DELIVADDR3NoVARCHAR(30)NoDelivery address line 3.
DELIVADDR4NoVARCHAR(30)NoDelivery address line 4.
CONTACT_SEQNONoINTEGERNoThe SEQNO of the Contact assigned to this transaction.
CURRENCYNONoINTEGERNoThe ID of the currency being used for the transaction.
EXCHRATENoFLOAT(53)NoThe exchange rate being used for the transaction, as determined by the currency in use.
BATCHNONoINTEGERNoIf the transaction was a part of a Debtors receipt batch, the batch number is stored here.
SHIFTNONoINTEGERNoThe shift number for EXO Business POS.
GLSUBCODENoINTEGERNoFor payments, this field contains the GL subcode of the bank account.
BRANCHNONoINTEGERNoThe branch ID number.
ORD_REFNoVARCHAR(20)NoFor invoices generated from Sales Orders, this field holds the order's reference field value.
DISPATCH_INFONoVARCHAR(70)NoThe dispatch method. The profile setting "Prompt for dispatch information for debtor invoices and sales orders" must be enabled for users to be able to enter a dispatch method.
SO_SEQNONoINTEGERNoFor invoices generated from Sales Orders, this field holds the SEQNO of the Sales Order.
TAXRATENoFLOAT(53)NoThe tax rate used by the transaction, e.g. 12.5 = 12.5%.
TAXRATE_NONoINTEGERNoThe ID number of the tax rate used by the transaction.
DELIVADDR5NoVARCHAR(30)NoDelivery address line 5.
DELIVADDR6NoVARCHAR(30)NoDelivery address line 6.
PREV_PERIOD_OPENNoFLOAT(53)NoBalance as at the start of the previous period.
TERMINAL_IDNoVARCHAR(30)NoThe terminal ID for a shift in EXO Business POS.
DEPOSIT_STATUSNoINTEGERNoThis value is set to 1 if the payment is a deposit.
AMOUNTNoASNoThe amount of the transaction, including tax, in the currency of the Debtor account.
UNREALISED_GAINS_GL_BATCHNoINTEGERYesThe batch number for the unrealised gains journal that the transaction is a part of. Reset to zero when the journal is reversed.
TAXRETCODENoVARCHAR(15)NoThe tax return code for the GST return that this transaction applies to.
WEEK_NONoINTEGERNoThe week number. Populated by the SET_DR_TRANS_WEEK_NO trigger - week dates must be set up first.
DDNONoINTEGERNoDirect debit number.
RELEASEDAMTNoFLOAT(53)YesThis field is populated by the Direct Debits functionality.
SALES_ACCNONoINTEGERNoIf the transaction is against a branch account, this field holds the account number for the branch account and the ACCNO field holds the account number of the head account. In all other cases, this field and the ACCNO field always have same number.
FREIGHT_FREENoCHAR(1)YesSet to 'Y' if this transaction is freight free. This is determined by a combination of the FREIGHT_FREE properties on Debtor accounts and Price Policies.
CONTRACT_HDRNoINTEGERYesThis field links to price policies to indicate that a price rule was used belonging to this price contract, e.g. it could be a promotion.
BANKACCNONoVARCHAR(20)No
BANKACCNAMENoVARCHAR(20)No
GLBATCHNONoINTEGERNoThe batch number for the journals that have sourced from this transaction.
JOBNONoINTEGERYesWhere Job Costing is in use, this field contains the ID number of the job associated with the transaction.
NARRATIVE_SEQNONoINTEGERNoID number of the narrative attached to the transaction.
TOAGEDBALNoINTEGERNoOnly applicable in case of balance brought forward accounts payments and adjustments. Used in the trigger POST_DR_TRANS to refresh the aged balances on the account. 0 = current 1 = 1 months 2 = 2 months 3 = 3 months 4 = from oldest
EFTCAIDNoVARCHAR(15)NoOnly applies to EFTPOS transactions. The CAID (entered in EXO Business Config) is stamped to every payment transaction in EXO Business when that transaction is processed via EFTPOS. The CAID is used when a settlement is performed to compute settlement totals and produce a settlement report.
EFTSTANNoINTEGERNoFor EFTPOS payment transactions, the journal number (often know as a STAN) is stamped to each transaction in EXO Business and directly correlates to the journal entry in the EFTPOS software.
PAY_STATUSNoINTEGERNoThis value is set by the Toggle Query Status right-click menu option on the Allocations screen.
PHYS_BRANCHNoINTEGERNoID of the Physical branch.
PHYS_STAFFNoINTEGERNoThe staff ID of the person logged in.
SESSION_IDNoINTEGERNoID number of the session.
PREV_PERIOD_CLOSENoFLOAT(53)NoThe balance as at the end of the previous period.
EFTAUTHNoVARCHAR(30)NoOnly applies to EFTPOS transactions. The authorisation code for EFTPOS integration.
GATEWAYNONoINTEGERNoOnly applies to EFTPOS transactions. The gateway number for EFTPOS integration.
SOURCEINV_SEQNONoINTEGERYesFor credit notes, this field stores the SEQNO of the source invoice transaction.
TXIDNoVARBINARY(256)NoA unique transaction ID number, populated by the trigger TRG_TXID_DR_TRANS. Used to separate native transactions inserted by EXO Business from other transactions.
PTNONoINTEGERNoThe payment number.
CUSTORDERNONoVARCHAR(20)NoFor invoices generated from Sales Orders, this field holds the value of the Extra Field customer Order number.
PERIOD_SEQNONoINTEGERYesID number of the period that the transaction is in.
AGE_STAMPNoINTEGERNoThis is a historical field that has been superseded by the AGE calculated field.
AGENoASNoThe transaction's age. This is calculated based on PERIOD_SEQNO.
TAXROUNDINGNoFLOAT(53)YesThe tax rounding amount, where the tax on the header doesn't match the sum of the tax on the lines. Where the tax rate is consistent across all lines of an invoice and none of the lines have been overridden, tax is calculated based on the subtotal. If any line on the invoice has a varied tax rate,  or any line is recorded as TAX_OVERRIDDEN='Y' then the tax total on the invoice is the sum of the tax on each line. The difference between the sum of the rounded tax on the lines and the application of the tax rate to the subtotal is recorded in this field.
OPPORTUNITY_SEQNONoINTEGERNoIf the transaction is associated with an Opportunity (EXO Business CRM), the Opportunity's ID number is stored here.
CAMPAIGN_WAVE_SEQNONoINTEGERNoIf the transaction is associated with a campaign wave (EXO Business CRM), the wave's ID number is stored here.
JOB_CONTRACT_BILLINGS_SEQNONoINTEGERYesIf the invoice is related to a Progress Billing invoice in EXO Job Costing, the ID number of that invoice is recorded here (from JOB_CONTRACT_BILLINGS).

Relationships:
NameRelationship typeParentChildCardinality
CAMPAIGN_WAVE_DR_TRANSNon IdentifyingCAMPAIGN_WAVEDR_TRANSZero Or More
CURRENCIES_DR_TRANSNon IdentifyingCURRENCIESDR_TRANSZero Or More
DR_ACCS_DR_TRANSNon IdentifyingDR_ACCSDR_TRANSZero Or More
DR_TRANS_DR_ALLOCATIONSNon IdentifyingDR_TRANSDR_ALLOCATIONSZero Or More
DR_TRANS_DR_INVLINES_ACCNONon IdentifyingDR_TRANSDR_INVLINESZero Or More
DR_TRANS_DR_INVLINES_SEQNONon IdentifyingDR_TRANSDR_INVLINESZero Or More
DR_TRANS_JOB_TRANSACTIONSNon IdentifyingDR_TRANSJOB_TRANSACTIONSZero Or More
GLACCS_DR_TRANSNon IdentifyingGLACCSDR_TRANSZero Or More
NARRATIVES_DR_TRANSNon IdentifyingNARRATIVESDR_TRANSZero Or More
OPPORTUNITY_DR_TRANSNon IdentifyingOPPORTUNITYDR_TRANSZero Or More
PAYMENT_TYPES_DR_TRANSNon IdentifyingPAYMENT_TYPESDR_TRANSZero Or More
PERIOD_STATUS_DR_TRANSNon IdentifyingPERIOD_STATUSDR_TRANSZero Or More
STAFF_DR_TRANSNon IdentifyingSTAFFDR_TRANSZero Or More
TAX_RATES_DR_TRANSNon IdentifyingTAX_RATESDR_TRANSZero Or More

Indexes:
NameIndex columnsIndex type
DR_TRANS_ACCNOACCNO ASC
DR_TRANS_ALLOCATEDALLOCATED ASC
DR_TRANS_GLBATCHNOGLBATCHNO ASC
DR_TRANS_INVNOINVNO ASC
DR_TRANS_OPPORTUNITYOPPORTUNITY_SEQNO ASC
DR_TRANS_PERIODSEQNO_INDEXPERIOD_SEQNO ASC
DR_TRANS_PERIOD_SEQNOPERIOD_SEQNO ASC
DR_TRANS_TRANSDATETRANSDATE ASC
DR_TRANS_TRANSTYPETRANSTYPE ASC

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (JOB_CONTRACT_BILLINGS_SEQNO)
Not NullColumn ConstraintNOT NULL (SEQNO)
Not NullColumn ConstraintNOT NULL (TAXROUNDING)
Not NullColumn ConstraintNOT NULL (PERIOD_SEQNO)
Not NullColumn ConstraintNOT NULL (SOURCEINV_SEQNO)
Not NullColumn ConstraintNOT NULL (JOBNO)
Not NullColumn ConstraintNOT NULL (CONTRACT_HDR)
Not NullColumn ConstraintNOT NULL (FREIGHT_FREE)
Not NullColumn ConstraintNOT NULL (RELEASEDAMT)
Not NullColumn ConstraintNOT NULL (UNREALISED_GAINS_GL_BATCH)
CAMPAIGN_WAVE_DR_TRANSForeign KeyTable ConstraintFOREIGN KEY (CAMPAIGN_WAVE_SEQNO) REFERENCES CAMPAIGN_WAVE(SEQNO)
CURRENCIES_DR_TRANSForeign KeyTable ConstraintFOREIGN KEY (CURRENCYNO) REFERENCES CURRENCIES(CURRENCYNO)
DF__DR_TRANS__ACCNO__2354350CDefaultColumn ConstraintACCNO DEFAULT 0
DF__DR_TRANS__AGE_ST__43188FD6DefaultColumn ConstraintAGE_STAMP DEFAULT -1
DF__DR_TRANS__ALLOCA__2FBA0BF1DefaultColumn ConstraintALLOCATEDBAL DEFAULT 0
DF__DR_TRANS__ALLOCA__30AE302ADefaultColumn ConstraintALLOCATED DEFAULT 0
DF__DR_TRANS__ALLOCA__31A25463DefaultColumn ConstraintALLOCAGE DEFAULT 0
DF__DR_TRANS__BRANCH__3118447EDefaultColumn ConstraintBRANCHNO DEFAULT 0
DF__DR_TRANS__CAMPAI__562142A9DefaultColumn ConstraintCAMPAIGN_WAVE_SEQNO DEFAULT -1
DF__DR_TRANS__CONTRA__494FC0C2DefaultColumn ConstraintCONTRACT_HDR DEFAULT 0
DF__DR_TRANS__CURREN__32B6742DDefaultColumn ConstraintCURRENCYNO DEFAULT 0
DF__DR_TRANS__DDNO__5DCAEF64DefaultColumn ConstraintDDNO DEFAULT -1
DF__DR_TRANS__DEPOSI__4F67C174DefaultColumn ConstraintDEPOSIT_STATUS DEFAULT 0
DF__DR_TRANS__EXCHRA__33AA9866DefaultColumn ConstraintEXCHRATE DEFAULT 1
DF__DR_TRANS__FREIGH__0E7913B7DefaultColumn ConstraintFREIGHT_FREE DEFAULT N
DF__DR_TRANS__GATEWA__6C59D134DefaultColumn ConstraintGATEWAYNO DEFAULT -1
DF__DR_TRANS__GLPOST__3296789CDefaultColumn ConstraintGLPOSTED DEFAULT N
DF__DR_TRANS__GLSUBC__30242045DefaultColumn ConstraintGLSUBCODE DEFAULT 0
DF__DR_TRANS__JOBNO__4ED38FEEDefaultColumn ConstraintJOBNO DEFAULT -1
DF__DR_TRANS__JOB_CO__01168DA6DefaultColumn ConstraintJOB_CONTRACT_BILLINGS_SEQNO DEFAULT -1
DF__DR_TRANS__OPPORT__75AEFC9BDefaultColumn ConstraintOPPORTUNITY_SEQNO DEFAULT -1
DF__DR_TRANS__PAY_ST__7D6461A5DefaultColumn ConstraintPAY_STATUS DEFAULT 0
DF__DR_TRANS__PERIOD__42246B9DDefaultColumn ConstraintPERIOD_SEQNO DEFAULT 0
DF__DR_TRANS__PHYS_B__2E079900DefaultColumn ConstraintPHYS_BRANCH DEFAULT 0
DF__DR_TRANS__PHYS_S__2EFBBD39DefaultColumn ConstraintPHYS_STAFF DEFAULT 0
DF__DR_TRANS__POSTTI__216BEC9ADefaultColumn ConstraintPOSTTIME DEFAULT getdate()
DF__DR_TRANS__PREV_P__2A363CC5DefaultColumn ConstraintPREV_PERIOD_OPEN DEFAULT 0
DF__DR_TRANS__PREV_P__491094F7DefaultColumn ConstraintPREV_PERIOD_CLOSE DEFAULT 0
DF__DR_TRANS__PTNO__3652C63EDefaultColumn ConstraintPTNO DEFAULT -1
DF__DR_TRANS__RELEAS__5EBF139DDefaultColumn ConstraintRELEASEDAMT DEFAULT 0
DF__DR_TRANS__SALESN__2A01329BDefaultColumn ConstraintSALESNO DEFAULT 0
DF__DR_TRANS__SESSIO__2FEFE172DefaultColumn ConstraintSESSION_ID DEFAULT -1
DF__DR_TRANS__SOURCE__75E33B6EDefaultColumn ConstraintSOURCEINV_SEQNO DEFAULT -1
DF__DR_TRANS__SO_SEQ__0D99FE17DefaultColumn ConstraintSO_SEQNO DEFAULT 0
DF__DR_TRANS__SUBTOT__2AF556D4DefaultColumn ConstraintSUBTOTAL DEFAULT 0
DF__DR_TRANS__TAXINC__2DD1C37FDefaultColumn ConstraintTAXINC DEFAULT N
DF__DR_TRANS__TAXRAT__18178C8ADefaultColumn ConstraintTAXRATE DEFAULT 0
DF__DR_TRANS__TAXRAT__190BB0C3DefaultColumn ConstraintTAXRATE_NO DEFAULT 0
DF__DR_TRANS__TAXROU__5A70F67ADefaultColumn ConstraintTAXROUNDING DEFAULT 0
DF__DR_TRANS__TAXTOT__2BE97B0DDefaultColumn ConstraintTAXTOTAL DEFAULT 0
DF__DR_TRANS__TRANSD__226010D3DefaultColumn ConstraintTRANSDATE DEFAULT getdate()
DF__DR_TRANS__TRANST__24485945DefaultColumn ConstraintTRANSTYPE DEFAULT 0
DF__DR_TRANS__UNREAL__1C722D53DefaultColumn ConstraintUNREALISED_GAINS_GL_BATCH DEFAULT 0
DF__DR_TRANS__WEEK_N__5CD6CB2BDefaultColumn ConstraintWEEK_NO DEFAULT 0
DR_ACCS_DR_TRANSForeign KeyTable ConstraintFOREIGN KEY (ACCNO) REFERENCES DR_ACCS(ACCNO)
GLACCS_DR_TRANSForeign KeyTable ConstraintFOREIGN KEY (GLCODE) REFERENCES GLACCS(ACCNO)
NARRATIVES_DR_TRANSForeign KeyTable ConstraintFOREIGN KEY (NARRATIVE_SEQNO) REFERENCES NARRATIVES(SEQNO)
OPPORTUNITY_DR_TRANSForeign KeyTable ConstraintFOREIGN KEY (OPPORTUNITY_SEQNO) REFERENCES OPPORTUNITY(SEQNO)
PAYMENT_TYPES_DR_TRANSForeign KeyTable ConstraintFOREIGN KEY (PTNO) REFERENCES PAYMENT_TYPES(PTNO)
PERIOD_STATUS_DR_TRANSForeign KeyTable ConstraintFOREIGN KEY (PERIOD_SEQNO) REFERENCES PERIOD_STATUS(SEQNO)
PK__DR_TRANS__2077C861Primary KeyTable ConstraintPRIMARY KEY (SEQNO)
STAFF_DR_TRANSForeign KeyTable ConstraintFOREIGN KEY (SALESNO) REFERENCES STAFF(STAFFNO)
TAX_RATES_DR_TRANSForeign KeyTable ConstraintFOREIGN KEY (TAXRATE_NO) REFERENCES TAX_RATES(SEQNO)

Triggers:
Trigger nameCode
POST_DR_TRANSCREATE TRIGGER [dbo].[POST_DR_TRANS]
ON [dbo].[DR_TRANS]
FOR INSERT
AS
BEGIN
/* Exonet created trigger from DBUpdate version [6.155] */
  SET NOCOUNT ON
  DECLARE @ACCNO INTEGER, @BRANCH_ACCNO INTEGER, @SUBTOTAL FLOAT, @TAXTOTAL FLOAT,
    @AGE INTEGER, @TRANSTYPE INTEGER, @TOAGEDBAL INTEGER, @PERIODSTHISYEAR INTEGER, @PERIODSINYEAR INTEGER,
    @MONTHVAL FLOAT, @LASTMONTH FLOAT, @YEARVAL FLOAT, @LASTYEAR FLOAT,
    @AMOUNT FLOAT, @AGEDBAL0 FLOAT, @AGEDBAL1 FLOAT, @AGEDBAL2 FLOAT, @AGEDBAL3 FLOAT,
    @PRIOR_AGEDBAL0 FLOAT, @PRIOR_AGEDBAL1 FLOAT, @PRIOR_AGEDBAL2 FLOAT, @PRIOR_AGEDBAL3 FLOAT,
    @TURNOVER_ACCNO INTEGER, @OPENITEM CHAR(1)

  SELECT @PERIODSTHISYEAR = PERIODSTHISYEAR FROM GL_CONTROL
  SELECT @PERIODSINYEAR = COUNT(SEQNO) FROM PERIODS_DEFN WHERE SEQNO > 0

  DECLARE INSERTED_CURSOR CURSOR LOCAL
  FOR SELECT ACCNO, BRANCH_ACCNO, SUBTOTAL, TAXTOTAL, AGE, TRANSTYPE, TOAGEDBAL
  FROM INSERTED

  OPEN INSERTED_CURSOR

  FETCH NEXT FROM INSERTED_CURSOR
  INTO @ACCNO, @BRANCH_ACCNO, @SUBTOTAL, @TAXTOTAL, @AGE, @TRANSTYPE, @TOAGEDBAL

  WHILE @@FETCH_STATUS = 0
  BEGIN
    SELECT @OPENITEM = OPENITEM FROM DR_ACCS WHERE ACCNO = @ACCNO

    SET @MONTHVAL = 0
    SET @LASTMONTH = 0
    SET @YEARVAL = 0
    SET @LASTYEAR = 0
    SET @AGEDBAL0 = 0
    SET @AGEDBAL1 = 0
    SET @AGEDBAL2 = 0
    SET @AGEDBAL3 = 0
    SET @PRIOR_AGEDBAL0 = 0
    SET @PRIOR_AGEDBAL1 = 0
    SET @PRIOR_AGEDBAL2 = 0
    SET @PRIOR_AGEDBAL3 = 0

    /* Set Turnover variables */
    IF (@TRANSTYPE = 1)
    BEGIN
      IF (@AGE = 0)
        SET @MONTHVAL = @SUBTOTAL
      ELSE IF (@AGE = 1)
        SET @LASTMONTH = @SUBTOTAL

      IF ((@AGE+1) <= @PERIODSTHISYEAR)
        SET @YEARVAL = @SUBTOTAL
      ELSE IF ((@AGE+1) <= (@PERIODSTHISYEAR+@PERIODSINYEAR))
        SET @LASTYEAR = @SUBTOTAL
    END

    /* Set Aged Balance variables */
    SET @AMOUNT = @SUBTOTAL + @TAXTOTAL
    IF ((NOT (@OPENITEM = 'Y')) AND (@TOAGEDBAL IS NOT NULL)) /* set according to Age selected */
      EXECUTE DR_ACCS_BALFWD_BAL_DELTAS @ACCNO, @TOAGEDBAL, @AMOUNT,
        @AGEDBAL0 OUTPUT, @AGEDBAL1 OUTPUT, @AGEDBAL2 OUTPUT, @AGEDBAL3 OUTPUT,
        @PRIOR_AGEDBAL0 OUTPUT, @PRIOR_AGEDBAL1 OUTPUT, @PRIOR_AGEDBAL2 OUTPUT
    ELSE /* set as usual */
    BEGIN
      IF (@AGE = 0)
        SET @AGEDBAL0 = @AMOUNT
      ELSE IF (@AGE = 1)
      BEGIN
        SET @AGEDBAL1 = @AMOUNT
        SET @PRIOR_AGEDBAL0 = @AGEDBAL1
      END
      ELSE IF (@AGE = 2)
      BEGIN
        SET @AGEDBAL2 = @AMOUNT
        SET @PRIOR_AGEDBAL1 = @AGEDBAL2
      END
      ELSE
      BEGIN
        SET @AGEDBAL3 = @AMOUNT
        IF (@AGE = 3)
          SET @PRIOR_AGEDBAL2 = @AGEDBAL3
        ELSE
          SET @PRIOR_AGEDBAL3 = @AGEDBAL3
      END
    END

    /* Determine which A/c to set Turnover field values in */
    IF (@BRANCH_ACCNO > 0) /* If there is a Branch A/c */
      SET @TURNOVER_ACCNO = @BRANCH_ACCNO
    ELSE
      SET @TURNOVER_ACCNO = @ACCNO

    /* Set Turnover field values */
    UPDATE DR_ACCS SET
      MONTHVAL = MONTHVAL + @MONTHVAL,
      LASTMONTH = LASTMONTH + @LASTMONTH,
      YEARVAL = YEARVAL + @YEARVAL,
      LASTYEAR = LASTYEAR + @LASTYEAR
    WHERE
      ACCNO = @TURNOVER_ACCNO

    /* Set Aged Balance field values */
    UPDATE DR_ACCS SET
      AGEDBAL0 = AGEDBAL0 + @AGEDBAL0,
      AGEDBAL1 = AGEDBAL1 + @AGEDBAL1,
      AGEDBAL2 = AGEDBAL2 + @AGEDBAL2,
      AGEDBAL3 = AGEDBAL3 + @AGEDBAL3,
      PRIOR_AGEDBAL0 = PRIOR_AGEDBAL0 + @PRIOR_AGEDBAL0,
      PRIOR_AGEDBAL1 = PRIOR_AGEDBAL1 + @PRIOR_AGEDBAL1,
      PRIOR_AGEDBAL2 = PRIOR_AGEDBAL2 + @PRIOR_AGEDBAL2,
      PRIOR_AGEDBAL3 = PRIOR_AGEDBAL3 + @PRIOR_AGEDBAL3
    WHERE
      ACCNO = @ACCNO

    FETCH NEXT FROM INSERTED_CURSOR
    INTO @ACCNO, @BRANCH_ACCNO, @SUBTOTAL, @TAXTOTAL, @AGE, @TRANSTYPE, @TOAGEDBAL
  END
  CLOSE INSERTED_CURSOR
  DEALLOCATE INSERTED_CURSOR
  SET NOCOUNT OFF
END
SET_DR_TRANS_PREV_PERIOD_OPENCREATE TRIGGER [dbo].[SET_DR_TRANS_PREV_PERIOD_OPEN]
ON [dbo].[DR_TRANS]
FOR INSERT
AS
  DECLARE @NEW_SEQNO INTEGER,
         @NEW_AGE INTEGER,
         @NEW_AMOUNT FLOAT
BEGIN
  SET NOCOUNT ON
  SELECT @NEW_SEQNO=SEQNO, @NEW_AGE=AGE, @NEW_AMOUNT=AMOUNT FROM INSERTED

  IF (@NEW_AGE > 0)
  BEGIN
   IF (@NEW_AGE>=2)
     UPDATE [dbo].[DR_TRANS] SET ALLOCAGE=@NEW_AGE,
       PREV_PERIOD_OPEN = @NEW_AMOUNT - ISNULL((SELECT SUM(AMOUNT) FROM DR_ALLOCATIONS WHERE TRANS_SEQNO=@NEW_SEQNO AND AGE>=2), 0),
       PREV_PERIOD_CLOSE = @NEW_AMOUNT - ISNULL((SELECT SUM(AMOUNT) FROM DR_ALLOCATIONS WHERE TRANS_SEQNO=@NEW_SEQNO AND AGE>=1), 0)
         WHERE SEQNO = @NEW_SEQNO
   ELSE
   IF (@NEW_AGE=1)
     UPDATE [dbo].[DR_TRANS] SET ALLOCAGE=@NEW_AGE,
       PREV_PERIOD_OPEN=0,
       PREV_PERIOD_CLOSE = @NEW_AMOUNT - ISNULL((SELECT SUM(AMOUNT) FROM DR_ALLOCATIONS WHERE TRANS_SEQNO=@NEW_SEQNO AND AGE>=1), 0)
         WHERE SEQNO = @NEW_SEQNO
  END
  SET NOCOUNT OFF
END
SET_DR_TRANS_WEEK_NO/****** Object: Trigger [dbo].[SET_DR_TRANS_WEEK_NO] Script Date: 18/12/2001 12:51:35 ******/



CREATE TRIGGER SET_DR_TRANS_WEEK_NO
ON dbo.[dbo].[DR_TRANS]
FOR INSERT
AS
  DECLARE @NEW_WEEK_NO INTEGER,
          @NEW_SEQNO INTEGER,
          @TODAYS_DATE DATETIME,
          @CURRENT_WEEK_NO INTEGER
BEGIN
  SET NOCOUNT ON
  SELECT @NEW_WEEK_NO=WEEK_NO, @NEW_SEQNO=SEQNO
    FROM INSERTED

  IF ((@NEW_WEEK_NO IS NULL) OR (@NEW_WEEK_NO=0))
  BEGIN
    SELECT @TODAYS_DATE=GETDATE()
    SELECT @CURRENT_WEEK_NO=MAX(WEEK_NO) FROM WEEK_DATES
      WHERE @TODAYS_DATE>=START_DATE
      AND @TODAYS_DATE<(END_DATE+1)
    UPDATE [dbo].[DR_TRANS] SET WEEK_NO=@CURRENT_WEEK_NO WHERE SEQNO=@NEW_SEQNO
  END
  SET NOCOUNT OFF
END


Entity: GLACCS
CommentThis table contains details of all General Ledger accounts.
Primary key columnsACCNO

Attributes:
Column namePrimary keyData typeNot NULLComment
ACCNOYesINTEGERYesThe unique GL account number.
NAMENoVARCHAR(40)NoThe account name.
DRCRNoCHAR(1)NoThis field is set to 'C' for Credit accounts or 'D' for Debit accounts.
SECTIONNoINTEGERNoThis field is set to 0 for Profit and loss accounts or 1 for Balance sheet accounts.
OPENINGBALNoFLOAT(53)NoThe account's opening balance.
BALANCENoFLOAT(53)NoThe account's balance.
USESUBCODESNoCHAR(1)NoNot used.
REPORTCODENoVARCHAR(15)NoThe report code used by the GL account.
TAXSTATUSNoINTEGERNoThe Override GST rate specified for the GL account. A value of -1 corresponds to the AUTO SELECT RATE option.
CURRENCYNONoINTEGERNoThe ID number of the currency that the GL account is in.
ISACTIVENoCHAR(1)NoThis field contains 'Y' if the GL account is active.
ACCGROUPNoINTEGERNoThe GL account's Account Group.
ALLOWJOURNALNoCHAR(1)NoThis field is set to 'Y' if the GL account allows journals.
LAST_UPDATEDNoDATETIMENoThe date and time when the GL account was last updated.
BALSHEETACCTOTNoASNoThe balance sheet total for the account.
BALANCE_SHEET_TYPENoINTEGERYesFor balance sheet accounts, this field indicates the balance sheet type. Will be one of:
-1 = Not a balance sheet account
0 = Asset
1 = Liability
2 = Equity
NOTESNoVARCHAR(4096)NoAny notes on the GL account.
EXCLUDE_FROM_REVALNoCHAR(1)NoIf this field is set to 'Y', the account is excluded from revaluation.
PRIVATE_ACCNoCHAR(1)YesThis field is set to 'Y' if the GL account is a private account.
CREATED_DATENoDATETIMENoThe date and time that the GL account was created.

Relationships:
NameRelationship typeParentChildCardinality
CURRENCIES_GLACCSNon IdentifyingCURRENCIESGLACCSZero Or More
GLACCS_CR_TRANSNon IdentifyingGLACCSCR_TRANSZero Or More
GLACCS_DR_TRANSNon IdentifyingGLACCSDR_TRANSZero Or More
GLACCS_JOBCOST_HDRNon IdentifyingGLACCSJOBCOST_HDRZero Or More
GLACCS_JOBCOST_HDR_SALESNon IdentifyingGLACCSJOBCOST_HDRZero Or More
GLACCS_JOBCOST_LINESNon IdentifyingGLACCSJOBCOST_LINESZero Or More
GLACCS_JOB_CONTRACT_BILLINGSNon IdentifyingGLACCSJOB_CONTRACT_BILLINGSZero Or More
GLACCS_JOB_CONTRACT_BILLINGS_SUBNon IdentifyingGLACCSJOB_CONTRACT_BILLINGSZero Or More
GLACCS_JOB_TRANSACTIONSNon IdentifyingGLACCSJOB_TRANSACTIONSZero Or More
GLACCS_OPPORTUNITY_QUOTENon IdentifyingGLACCSOPPORTUNITY_QUOTEZero Or More
GLACCS_STOCK_GROUPSNon IdentifyingGLACCSSTOCK_GROUPSZero Or More
GLACCS_STOCK_GROUPS_COSNon IdentifyingGLACCSSTOCK_GROUPSZero Or More
GLACCS_STOCK_GROUPS_PNon IdentifyingGLACCSSTOCK_GROUPSZero Or More
GLACCS_STOCK_ITEMSNon IdentifyingGLACCSSTOCK_ITEMSZero Or More
GLACCS_STOCK_ITEMS_COSNon IdentifyingGLACCSSTOCK_ITEMSZero Or More
GLACCS_STOCK_TRANSNon IdentifyingGLACCSSTOCK_TRANSZero Or More
GL_ACCS_STOCKITEMS_PONon IdentifyingGLACCSSTOCK_ITEMSZero Or More

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (PRIVATE_ACC)
Not NullColumn ConstraintNOT NULL (ACCNO)
Not NullColumn ConstraintNOT NULL (BALANCE_SHEET_TYPE)
CURRENCIES_GLACCSForeign KeyTable ConstraintFOREIGN KEY (CURRENCYNO) REFERENCES CURRENCIES(CURRENCYNO)
DF__GLACCS__ACCGROUP__613C58ECDefaultColumn ConstraintACCGROUP DEFAULT 0
DF__GLACCS__ALLOWJOU__2882FE7DDefaultColumn ConstraintALLOWJOURNAL DEFAULT Y
DF__GLACCS__BALANCE__3E082B48DefaultColumn ConstraintBALANCE DEFAULT 0
DF__GLACCS__BALANCE___40113AA2DefaultColumn ConstraintBALANCE_SHEET_TYPE DEFAULT -1
DF__GLACCS__CURRENCY__3A228BCBDefaultColumn ConstraintCURRENCYNO DEFAULT 0
DF__GLACCS__DRCR__3B2BBE9DDefaultColumn ConstraintDRCR DEFAULT D
DF__GLACCS__EXCLUDE___23CA01AFDefaultColumn ConstraintEXCLUDE_FROM_REVAL DEFAULT N
DF__GLACCS__ISACTIVE__58A712EBDefaultColumn ConstraintISACTIVE DEFAULT Y
DF__GLACCS__OPENINGB__3D14070FDefaultColumn ConstraintOPENINGBAL DEFAULT 0
DF__GLACCS__PRIVATE___13697CB4DefaultColumn ConstraintPRIVATE_ACC DEFAULT N
DF__GLACCS__SECTION__3C1FE2D6DefaultColumn ConstraintSECTION DEFAULT 0
DF__GLACCS__TAXSTATU__51700577DefaultColumn ConstraintTAXSTATUS DEFAULT 0
DF__GLACCS__USESUBCO__3FF073BADefaultColumn ConstraintUSESUBCODES DEFAULT N
PK__GLACCS__3A379A64Primary KeyTable ConstraintPRIMARY KEY (ACCNO)



Entity: NARRATIVES
CommentThis table contains the narratives attached to transactions.
Primary key columnsSEQNO

Attributes:
Column namePrimary keyData typeNot NULLComment
SEQNOYesINTEGERYesA unique ID number for the narrative.
NARRATIVENoVARCHAR(4096)NoThe text of the narrative.

Relationships:
NameRelationship typeParentChildCardinality
NARRATIVES_CR_INVLINESNon IdentifyingNARRATIVESCR_INVLINESZero Or More
NARRATIVES_CR_TRANSIdentifyingNARRATIVESCR_TRANSZero Or More
NARRATIVES_DR_INVLINESNon IdentifyingNARRATIVESDR_INVLINESZero Or More
NARRATIVES_DR_TRANSNon IdentifyingNARRATIVESDR_TRANSZero Or More
NARRATIVES_JOBCOST_LINESNon IdentifyingNARRATIVESJOBCOST_LINESZero Or More
NARRATIVES_JOB_CONTRACT_BILLINGSNon IdentifyingNARRATIVESJOB_CONTRACT_BILLINGSZero Or More
NARRATIVES_JOB_TRANSACTIONSNon IdentifyingNARRATIVESJOB_TRANSACTIONSZero Or More
NARRATIVES_OPPORTUNITY_QUOTENon IdentifyingNARRATIVESOPPORTUNITY_QUOTEZero Or More
NARRATIVES_PURCHORD_HDRNon IdentifyingNARRATIVESPURCHORD_HDRZero Or More
NARRATIVES_SALESORD_HDRNon IdentifyingNARRATIVESSALESORD_HDRZero Or More
NARRATIVES_STOCK_REQUESTLINESNon IdentifyingNARRATIVESSTOCK_REQUESTLINESZero Or More
NARRATIVES_STOCK_REQUESTSNon IdentifyingNARRATIVESSTOCK_REQUESTSZero Or More

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (SEQNO)
PK__NARRATIVES__2E31B632Primary KeyTable ConstraintPRIMARY KEY (SEQNO)



Entity: OPPORTUNITY
CommentThis table contains details of all Opportunities used by the EXO CRM module.
Primary key columnsSEQNO

Attributes:
Column namePrimary keyData typeNot NULLComment
SEQNOYesINTEGERYesA unique ID number for the Opportunity.
DESCRIPTIONNoVARCHAR(60)NoDescription text for the Opportunity.
OPPORTUNITY_TYPENoINTEGERNoThe Opportunity's type, taken from OPPORTUNITY_TYPE.SEQNO.
OPPORTUNITY_LEADNoINTEGERNoThe Opportunity's lead source, taken from OPPORTUNITY_LEAD.SEQNO.
OPPORTUNITY_STAGENoINTEGERNoThe Opportunity's stage, taken from OPPORTUNITY_STAGE.SEQNO.
PROBABILITYNoINTEGERNoThe Probability value entered for the Opportunity.
ASSIGNED_TONoINTEGERNoThe ID of the staff member to whom the Opportunity has been assigned.
ASSIGNED_BYNoINTEGERNoThe ID of the staff member who assigned the Opportunity.
COMPANYIDNoVARCHAR(50)NoThe ID number of the company (Debtor, Creditor or Non Account) that the Opportunity is assigned to.
CONTACTSEQNONoINTEGERNoThe ID number of the Contact that the Opportunity is assigned to.
AMOUNTNoFLOAT(53)NoThe quote value for the Opportunity.
START_DATENoDATETIMENoThe start date of the Opportunity.
DETAILSNoVARCHAR(4096)NoAny details or notes entered for the Opportunity.
CREATEDBYNoINTEGERNoThe ID number of the staff member who created the Opportunity.
CREATEDATENoDATETIMENoThe date and time that the Opportunity was created.
MODIFIEDBYNoINTEGERNoThe ID number of the staff member who most recently modified the Opportunity.
MODIFIEDDATENoDATETIMENoThe date and time that the Opportunity was most recently modified.
DUE_DATENoDATETIMENoThe due date for the Opportunity.
CLOSE_DATENoDATETIMENoThe date and time when the Opportunity was changed to Closed status.
IS_CLOSENoASNoSet to 'Y' if the Opportunity has been changed to Closed status.
ESTIMATENoFLOAT(53)YesThe estimated value entered for the Opportunity.
LOST_VALUENoFLOAT(53)YesThe total value of all lost lines on the Opportunity.
CLOSED_VALUENoFLOAT(53)YesThe total value of all closed lines on the Opportunity.
TAXTOTALNoFLOAT(53)YesThe total tax amount on the Opportunity.
TAXROUNDINGNoFLOAT(53)YesThe difference between the tax on the header and the sum of the tax on the individual lines.
CURRENCYNONoINTEGERNoThe ID number of the currency that the Sales Order is in.
EXCHRATENoFLOAT(53)NoThe exchange rate for the currency that the Opportunity is in.
WEIGHTED_VALUENoASNoThe Opportunity's weighted value.
WEIGHTED_ESTIMATENoASNoThe Opportunity's weighted estimate.
CAMPAIGN_WAVE_SEQNONoINTEGERNoIf the Opportunity is associated with a campaign wave (EXO Business CRM), the wave's ID number is stored here.

Relationships:
NameRelationship typeParentChildCardinality
CAMPAIGN_WAVE_OPPORTUNITYNon IdentifyingCAMPAIGN_WAVEOPPORTUNITYZero Or More
OPPORTUNITY_DR_TRANSNon IdentifyingOPPORTUNITYDR_TRANSZero Or More
OPPORTUNITY_JOBCOST_HDRNon IdentifyingOPPORTUNITYJOBCOST_HDRZero Or More
OPPORTUNITY_LEAD_OPPORTUNITYNon IdentifyingOPPORTUNITY_LEADOPPORTUNITYZero Or More
OPPORTUNITY_OPPORTUNITY_HISTNon IdentifyingOPPORTUNITYOPPORTUNITY_HISTZero Or More
OPPORTUNITY_OPPORTUNITY_QUOTENon IdentifyingOPPORTUNITYOPPORTUNITY_QUOTEZero Or More
OPPORTUNITY_OPPORTUNITY_QUOTE_OPTIONSNon IdentifyingOPPORTUNITYOPPORTUNITY_QUOTE_OPTIONSZero Or More
OPPORTUNITY_SALESORD_HDRNon IdentifyingOPPORTUNITYSALESORD_HDRZero Or More
OPPORTUNITY_STAGE_OPPORTUNITYNon IdentifyingOPPORTUNITY_STAGEOPPORTUNITYZero Or More
OPPORTUNITY_TASKSNon IdentifyingOPPORTUNITYTASKSZero Or More
OPPORTUNITY_TYPE_OPPORTUNITYNon IdentifyingOPPORTUNITY_TYPEOPPORTUNITYZero Or More

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (TAXROUNDING)
Not NullColumn ConstraintNOT NULL (SEQNO)
Not NullColumn ConstraintNOT NULL (TAXTOTAL)
Not NullColumn ConstraintNOT NULL (ESTIMATE)
Not NullColumn ConstraintNOT NULL (CLOSED_VALUE)
Not NullColumn ConstraintNOT NULL (LOST_VALUE)
CAMPAIGN_WAVE_OPPORTUNITYForeign KeyTable ConstraintFOREIGN KEY (CAMPAIGN_WAVE_SEQNO) REFERENCES CAMPAIGN_WAVE(SEQNO)
DF_OPPORTUNITY_AMOUNTDefaultColumn ConstraintAMOUNT DEFAULT 0
DF_OPPORTUNITY_CLOSED_VALUEDefaultColumn ConstraintCLOSED_VALUE DEFAULT 0
DF__OPPORTUNI__CAMPA__3F08D327DefaultColumn ConstraintCAMPAIGN_WAVE_SEQNO DEFAULT -1
DF__OPPORTUNI__CURRE__75CEF82CDefaultColumn ConstraintCURRENCYNO DEFAULT 0
DF__OPPORTUNI__ESTIM__63E5521BDefaultColumn ConstraintESTIMATE DEFAULT 0
DF__OPPORTUNI__EXCHR__76C31C65DefaultColumn ConstraintEXCHRATE DEFAULT 1
DF__OPPORTUNI__LOST___64D97654DefaultColumn ConstraintLOST_VALUE DEFAULT 0
DF__OPPORTUNI__TAXRO__3C967AD0DefaultColumn ConstraintTAXROUNDING DEFAULT 0
DF__OPPORTUNI__TAXTO__3BA25697DefaultColumn ConstraintTAXTOTAL DEFAULT 0
OPPORTUNITY_LEAD_OPPORTUNITYForeign KeyTable ConstraintFOREIGN KEY (OPPORTUNITY_LEAD) REFERENCES OPPORTUNITY_LEAD(SEQNO)
OPPORTUNITY_STAGE_OPPORTUNITYForeign KeyTable ConstraintFOREIGN KEY (OPPORTUNITY_STAGE) REFERENCES OPPORTUNITY_STAGE(SEQNO)
OPPORTUNITY_TYPE_OPPORTUNITYForeign KeyTable ConstraintFOREIGN KEY (OPPORTUNITY_TYPE) REFERENCES OPPORTUNITY_TYPE(SEQNO)
PK__OPPORTUNITY__56CA82C8Primary KeyTable ConstraintPRIMARY KEY (SEQNO)



Entity: PAYMENT_TYPES
CommentThis table contains details of all Payment Types.
Primary key columnsPTNO

Attributes:
Column namePrimary keyData typeNot NULLComment
PTNOYesINTEGERYesA unique ID number for the Payment Type.
PTDESCNoVARCHAR(12)NoThe Payment Type's name.
PTKEYNoCHAR(1)NoA one-character code for the Payment Type.
IMG_FILENoVARCHAR(80)NoThe filename of the image displayed for the Payment Type on websites.
WEB_SHOWNoCHAR(1)NoThis field is set to 'Y' if the Payment Type is set to appear on websites, i.e. if its "Show on web site" flag is ticked.
LIVE_TRANSNoCHAR(1)NoThis field is set to 'Y' if the Payment Type is set to be available on bank servers, i.e. if its "On live bank server" flag is ticked.
SHORTNAMENoVARCHAR(6)NoThe short name used for the Payment Type on some displays.
PTGROUPNoINTEGERNoThe ID number of the Payment Group that the Payment Type belongs to. Taken from the PGNO field of the PAYMENT_GROUP table.
CURRENCYNONoINTEGERNo
LISTSEQNoINTEGERNoThe value of this field determines the Payment Type's position in lists.
REFUNDNoCHAR(1)NoThis value is set to 'Y' if the Payment Type allows refunds, i.e. if its "Permit use on refund/credit" flag is enabled.
OVER_TENDNoCHAR(1)NoThis value is set to 'Y' if the Payment Type's "Allow to be over tendered" flag is enabled.
MIN_TENDNoFLOAT(53)No
MAX_TENDNoFLOAT(53)No
MAX_PAYOUTNoFLOAT(53)No
EFTPOSNoINTEGERNoThe Payment Type's EFTPOS behaviour. This will be one of:
0 = no EFT interface
1 = validate only (cheque)
2 = process EFT sale
3 = process EFT cash out
MEMBER_TYPENoINTEGERNo
ACC_MASKNoVARCHAR(20)No
ROUND_AMTNoINTEGERNoThis field specifies the number of cents that the Payment Type should round to.
ROUND_UPNoCHAR(1)NoThis field contains 'Y' if the Payment Type's "Round up when midway" flag is ticked.
FEE_AMTNoFLOAT(53)No
FEE_MAXNoFLOAT(53)No
FEE_STOCKITEMNoVARCHAR(40)No
IMAGE_FILE_INDEXNoINTEGERNoSpecifies the Toolbar image to display on EXO Business interfaces for the Payment Type.
ACTIVE_DRNoCHAR(1)NoThis field is ticked if the Payment Type is active for Debtors, i.e. if its "Active for debtors" flag is ticked.
ACTIVE_CRNoCHAR(1)NoThis field is ticked if the Payment Type is active for Creditors, i.e. if its "Active for creditors" flag is ticked.
ACTIVE_POSNoCHAR(1)NoThis field is ticked if the Payment Type is active for the EXO POS module, i.e. if its "Active for POS" flag is ticked.
CHEQUE_TYPENoCHAR(1)NoThis value is set to 'Y' if the Payment Type's Payment behaviour is set to "Cheque".
DIRECT_DEBIT_TYPENoCHAR(1)NoThis value is set to 'Y' if the Payment Type's Payment behaviour is set to "Direct Debit".
DIRECT_CREDIT_TYPENoCHAR(1)NoThis value is set to 'Y' if the Payment Type's Payment behaviour is set to "Direct Credit".
CASHOUTPTNONoINTEGERYesThis field contains the ID number of the Payment Type that this Payment Type uses as its Linked cash out payment type.
BANKFEENoCHAR(1)NoThis value is set to 'Y' if the Payment Type's "Apply payment group bank fee" flag is ticked.
ZERO_TENDNoCHAR(1)NoThis value is set to 'Y' if the Payment Type's "Allow zero tender value" flag is ticked.
GATEWAYNoINTEGERNoThis field specifies the Payment Type's Gateway Behaviour. This will be one of:
0 = None
1 = Purchase
2 = Authorise
POS_SALENoCHAR(1)NoThis value is set to 'Y' if the Payment Type can be used for sales in EXO Business POS, i.e. if its "Sales" flag is ticked in the Available on POS Transactions section.
POS_RECEIPTNoCHAR(1)NoThis value is set to 'Y' if the Payment Type can be used for receipts in EXO Business POS, i.e. if its "Receipts" flag is ticked in the Available on POS Transactions section.
POS_CREDITNoCHAR(1)NoThis value is set to 'Y' if the Payment Type can be used for credits in EXO Business POS, i.e. if its "Credits" flag is ticked in the Available on POS Transactions section.
POS_REFUNDNoCHAR(1)NoThis value is set to 'Y' if the Payment Type can be used for refunds in EXO Business POS, i.e. if its "Refunds" flag is ticked in the Available on POS Transactions section.
POS_QUOTENoCHAR(1)NoThis value is set to 'Y' if the Payment Type can be used for quote in EXO Business POS, i.e. if its "Quotes" flag is ticked in the Available on POS Transactions section.
POS_LAYBYNoCHAR(1)NoThis value is set to 'Y' if the Payment Type can be used for lay-bys in EXO Business POS, i.e. if its "Lay-bys" flag is ticked in the Available on POS Transactions section.
REFERENCELEVELNoINTEGERNoThis field specifies the Payment Type's Drawer/Reference level. This will be one of:
0 = Not Editable
1 = Editable
2 = Must Fill
INCASHDRAWERNoCHAR(1)NoThis value is set to 'Y' if the Payment Type's "Open Cash Drawer" flag is ticked.
MPOWERED_TYPENoCHAR(1)NoThis value is set to 'Y' if the Payment Type's Payment behaviour is set to "M-Powered".

Relationships:
NameRelationship typeParentChildCardinality
PAYMENT_GROUP_PAYMENT_TYPESNon IdentifyingPAYMENT_GROUPPAYMENT_TYPESZero Or More
PAYMENT_TYPES_DR_TRANSNon IdentifyingPAYMENT_TYPESDR_TRANSZero Or More

Indexes:
NameIndex columnsIndex type
PAYMENT_TYPES_DESC_INDEXPTDESC ASCUNIQUE

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (CASHOUTPTNO)
Not NullColumn ConstraintNOT NULL (PTNO)
DF__PAYMENT_T__ACTIV__25A75D29DefaultColumn ConstraintACTIVE_DR DEFAULT N
DF__PAYMENT_T__ACTIV__269B8162DefaultColumn ConstraintACTIVE_CR DEFAULT N
DF__PAYMENT_T__ACTIV__278FA59BDefaultColumn ConstraintACTIVE_POS DEFAULT N
DF__PAYMENT_T__BANKF__35FDC083DefaultColumn ConstraintBANKFEE DEFAULT N
DF__PAYMENT_T__CASHO__68343A95DefaultColumn ConstraintCASHOUTPTNO DEFAULT -1
DF__PAYMENT_T__GATEW__4BED01A2DefaultColumn ConstraintGATEWAY DEFAULT 0
DF__PAYMENT_T__INCAS__6BFAA9D8DefaultColumn ConstraintINCASHDRAWER DEFAULT Y
DF__PAYMENT_T__LIVE___20E2A80CDefaultColumn ConstraintLIVE_TRANS DEFAULT N
DF__PAYMENT_T__MPOWE__7D9A3726DefaultColumn ConstraintMPOWERED_TYPE DEFAULT N
DF__PAYMENT_T__OVER___23BF14B7DefaultColumn ConstraintOVER_TEND DEFAULT N
DF__PAYMENT_T__POS_C__61A73897DefaultColumn ConstraintPOS_CREDIT DEFAULT Y
DF__PAYMENT_T__POS_L__6483A542DefaultColumn ConstraintPOS_LAYBY DEFAULT Y
DF__PAYMENT_T__POS_Q__638F8109DefaultColumn ConstraintPOS_QUOTE DEFAULT Y
DF__PAYMENT_T__POS_R__60B3145EDefaultColumn ConstraintPOS_RECEIPT DEFAULT Y
DF__PAYMENT_T__POS_R__629B5CD0DefaultColumn ConstraintPOS_REFUND DEFAULT Y
DF__PAYMENT_T__POS_S__5FBEF025DefaultColumn ConstraintPOS_SALE DEFAULT Y
DF__PAYMENT_T__PTGRO__21D6CC45DefaultColumn ConstraintPTGROUP DEFAULT 0
DF__PAYMENT_T__REFER__18F76D81DefaultColumn ConstraintREFERENCELEVEL DEFAULT 0
DF__PAYMENT_T__REFUN__22CAF07EDefaultColumn ConstraintREFUND DEFAULT N
DF__PAYMENT_T__ROUND__24B338F0DefaultColumn ConstraintROUND_UP DEFAULT N
DF__PAYMENT_T__WEB_S__1FEE83D3DefaultColumn ConstraintWEB_SHOW DEFAULT N
DF__PAYMENT_T__ZERO___36F1E4BCDefaultColumn ConstraintZERO_TEND DEFAULT N
PAYMENT_GROUP_PAYMENT_TYPESForeign KeyTable ConstraintFOREIGN KEY (PTGROUP) REFERENCES PAYMENT_GROUP(PGNO)
PK__PAYMENT_TYPES__54EB90A0Primary KeyTable ConstraintPRIMARY KEY (PTNO)



Entity: PERIOD_STATUS
CommentThis table contains details of the age periods set up in the system.
Primary key columnsSEQNO

Attributes:
Column namePrimary keyData typeNot NULLComment
SEQNOYesINTEGERYesA unique ID number for the period.
AGENoINTEGERYesThe age of the period. The current period has an age of 0.
LEDGERNoCHAR(1)YesThe ledger for a specific age.
LOCKEDNoCHAR(1)NoIf set to 'Y', the period is locked, implying that this age in a specific ledger is closed and no more transactions should take place
PERIOD_SEQNONoINTEGERYesThe period's sequence number within fiscal year.
PERIODNAMENoVARCHAR(20)NoThe name/description for the period.
PERIOD_SHORTNAMENoVARCHAR(8)NoA short name for the period.
REPORTCODENoVARCHAR(8)NoA code used for reporting purposes.
YEARAGENoINTEGERYesThe ageing of the year that the period falls in. The current year has an age of 0.
STARTDATENoDATETIMENoThe start date for the period.
STOPDATENoDATETIMENoThe end date for the period.
MINSTOCKSEQNONoINTEGERNoThe first transaction for the period found in the Stock ledger.
MINGLSEQNONoINTEGERNoThe first transaction for the period found in the GLTRANS table.
MINTRANSEQNONoINTEGERNoFor the Debtors ledger, this specifies the first transaction for the period found in the DR_TRANS table.
For the Creditors ledger, this specifies the first transaction for the period found in the CR_TRANS table.
MINTRANLINESEQNONoINTEGERNoFor the Debtors ledger, this specifies the first transaction for the period found in the DR_INVLINES table.
For the Creditors ledger, this specifies the first transaction for the period found in the CR_INVLINES table.
MINORDSEQNONoINTEGERNoFor the Debtors ledger, this specifies the first transaction for the period found in the SALESORD_HDR table.
For the Creditors ledger, this specifies the first transaction for the period found in the PURCHORD_HDR table.
MINORDLINESEQNONoINTEGERNoFor the Debtors ledger, this specifies the first transaction for the period found in the SALESORD_LINES table.
For the Creditors ledger, this specifies the first transaction for the period found in the PURCHORD_LINES table.
FIN_QTRNoINTEGERYesThe financial quarter that the period belongs to.

Relationships:
NameRelationship typeParentChildCardinality
FK_CRM_BUDGET_PERIOD_STATUSNon IdentifyingPERIOD_STATUSCRM_BUDGETZero Or More
FK_CRM_BUDGET_PERIOD_STATUS1Non IdentifyingPERIOD_STATUSCRM_BUDGETZero Or More
PERIOD_STATUS_CR_ALLOCATIONSNon IdentifyingPERIOD_STATUSCR_ALLOCATIONSZero Or More
PERIOD_STATUS_CR_TRANSNon IdentifyingPERIOD_STATUSCR_TRANSZero Or More
PERIOD_STATUS_DR_ALLOCATIONSNon IdentifyingPERIOD_STATUSDR_ALLOCATIONSZero Or More
PERIOD_STATUS_DR_TRANSNon IdentifyingPERIOD_STATUSDR_TRANSZero Or More
PERIOD_STATUS_INWARDS_GOODS_COSTSNon IdentifyingPERIOD_STATUSINWARDS_GOODS_COSTSZero Or More
PERIOD_STATUS_INWARDS_GOODS_LINESNon IdentifyingPERIOD_STATUSINWARDS_GOODS_LINESZero Or More
PERIOD_STATUS_STOCK_TRANSNon IdentifyingPERIOD_STATUSSTOCK_TRANSZero Or More

Indexes:
NameIndex columnsIndex type
PERIOD_STATUS_AGE_INDEXAGE ASC

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (FIN_QTR)
Not NullColumn ConstraintNOT NULL (SEQNO)
Not NullColumn ConstraintNOT NULL (AGE)
Not NullColumn ConstraintNOT NULL (YEARAGE)
Not NullColumn ConstraintNOT NULL (LEDGER)
Not NullColumn ConstraintNOT NULL (PERIOD_SEQNO)
DF__PERIOD_STAT__AGE__0ABE5CC3DefaultColumn ConstraintAGE DEFAULT 0
DF__PERIOD_ST__FIN_Q__1F1104E1DefaultColumn ConstraintFIN_QTR DEFAULT 0
DF__PERIOD_ST__LOCKE__0BB280FCDefaultColumn ConstraintLOCKED DEFAULT N
DF__PERIOD_ST__MINGL__5B301089DefaultColumn ConstraintMINGLSEQNO DEFAULT -1
DF__PERIOD_ST__MINOR__5E0C7D34DefaultColumn ConstraintMINORDSEQNO DEFAULT -1
DF__PERIOD_ST__MINOR__5F00A16DDefaultColumn ConstraintMINORDLINESEQNO DEFAULT -1
DF__PERIOD_ST__MINST__5A3BEC50DefaultColumn ConstraintMINSTOCKSEQNO DEFAULT -1
DF__PERIOD_ST__MINTR__5C2434C2DefaultColumn ConstraintMINTRANSEQNO DEFAULT -1
DF__PERIOD_ST__MINTR__5D1858FBDefaultColumn ConstraintMINTRANLINESEQNO DEFAULT -1
DF__PERIOD_ST__PERIO__0CA6A535DefaultColumn ConstraintPERIOD_SEQNO DEFAULT 0
DF__PERIOD_ST__YEARA__0D9AC96EDefaultColumn ConstraintYEARAGE DEFAULT 0
PK__PERIOD_STATUS__09CA388APrimary KeyTable ConstraintPRIMARY KEY (SEQNO)



Entity: SALESORD_HDR
CommentThis table contains header information for all Sales Orders.
Primary key columnsSEQNO

Attributes:
Column namePrimary keyData typeNot NULLComment
SEQNOYesINTEGERYesA unique ID number for the Sales Order.
STATUSNoINTEGERNoThe status of the Sales Order. Will be one of:
0 = Not Processed
1 = Partly Processed
2 = Fully Processed
3 = Quotation
4 = Standing Order
5 = Layby
6 = Lost Quote
ACCNONoINTEGERNoThe ID number of the Debtor account that the Sales Order was created for.
ORDERDATENoDATETIMENoThe date and time when the Sales Order was created.
DUEDATENoDATETIMENoThe date and time when the Sales Order is due to the customer.
CUSTORDERNONoVARCHAR(20)NoThe customer's order number.
REFERENCENoVARCHAR(20)NoAn additional reference number for the Sales Order.
ADDRESS1NoVARCHAR(30)NoDelivery address line 1.
ADDRESS2NoVARCHAR(30)NoDelivery address line 2.
ADDRESS3NoVARCHAR(30)NoDelivery address line 3.
ADDRESS4NoVARCHAR(30)NoDelivery address line 4.
INSTRUCTIONSNoVARCHAR(255)NoNot used.
SUBTOTALNoFLOAT(53)NoThe subtotal amount on the Sales Order.
TAXTOTALNoFLOAT(53)NoThe total tax amount on the Sales Order.
SALESNONoINTEGERNoThe ID number of the salesperson assigned to the Sales Order.
CONTACT_SEQNONoINTEGERNoThe ID number of the Contact assigned to the Sales Order.
CURRENCYNONoINTEGERNoThe ID number of the currency that the Sales Order is in.
EXCHRATENoFLOAT(53)NoThe exchange rate for the currency that the Sales Order is in.
CONSIGNTOLOCNoINTEGERNoThe ID number of the consignment location.
BRANCHNONoINTEGERNoThe Branch number on the Sales Order.
TAXINCNoCHAR(1)NoSet to 'Y' if the Sales Order is tax-inclusive.
BACKORDERNoCHAR(1)NoSet to 'Y' if the Sales Order is on back order.
MANIFESTNoINTEGERNo
DISPATCH_INFONoVARCHAR(70)NoThe dispatch method for the Sales Order.
HSTATUSNoINTEGERNoNot used
LAST_UPDATEDNoDATETIMENoThe date and time when the Sales Order was last updated.
ADDRESS5NoVARCHAR(30)NoDelivery address line 5.
ADDRESS6NoVARCHAR(30)NoDelivery address line 6.
PAYMENT_STATUSNoINTEGERNoNot used.
ORDTOTALNoASNoThe total amount for the Sales Order.
DELIVERYCOUNTNoINTEGERYesA count of the number of times the order has been supplied.
INVOICECOUNTNoINTEGERYesA count of the number of invoices generated for the order.
NARRATIVE_SEQNONoINTEGERNoThe ID number of the narrative attached to the Sales Order header.
HAS_UNRELEASEDNoCHAR(1)YesSet to 'Y' if there are quantities on the Sales Order that have not been released yet.
HAS_BACKORDERSNoCHAR(1)YesSet to 'Y' if there are quantities on the Sales Order that are on back order.
HAS_UNSUPPLIEDNoCHAR(1)YesSet to 'Y' if there are quantities on the Sales Order that have not been supplied yet.
HAS_UNINVOICEDNoCHAR(1)YesSet to 'Y' if there are quantities on the Sales Order that have not been invoiced yet.
HAS_UNPICKEDNoCHAR(1)YesSet to 'Y' if there are quantities on the Sales Order that have not been picked yet.
PICKEDCOUNTNoINTEGERNoThe amount of items on the Sales Order that have been picked.
RELEASECOUNTNoINTEGERNoThe amount of items on the Sales Order that have been released.
ORDSTATUSNoINTEGERNoAdditional status information for the Sales Order. Will be one of:
10 = Quote
20 = Order
30 = Acknowledged Order
40 = Pick In Progress
50 = Pick Confirmed
70 = Supplied
80 = Invoiced
90 = Complete
100 = Lost Quote
160 = Force Fully Processed
DEFLOCNONoINTEGERNoThe default location that stock is being supplied from.
PROCESSFINALISATIONNoINTEGERNoWill be one of:
0 = Normal
1 = Deleted
2 = Forced Fully Processed
3 = Lost Quote
MAXCOURIERCHARGENoFLOAT(53)NoNot used.
SHIP_COMPLETENoCHAR(1)Yes
TXIDNoVARBINARY(256)NoThe Transaction ID assigned to the Sales Order - this applies when using a payment gateway.
ONHOLDNoCHAR(1)NoSet to 'Y' if the Sales Order is on hold.
TAXROUNDINGNoFLOAT(53)YesThe difference between the tax calculated on header and the sum of the tax on all lines.
CREATE_DATENoDATETIMENoThe date and time when the Sales Order was created.
ACTIVATION_DATENoDATETIMENoThe date and time when the Sales Order was activated.
FINALISATION_DATENoDATETIMENoThe date and time when the Sales Order was finalised.
WAS_BACKORDEREDNoCHAR(1)NoSet to 'Y' if the Sales Order has been placed in back order status at any time.
OPPORTUNITY_SEQNONoINTEGERNoIf the Sales Order is associated with an Opportunity (EXO Business CRM), the Opportunity's ID number is stored here.
CAMPAIGN_WAVE_SEQNONoINTEGERNoIf the Sales Order is associated with a campaign wave (EXO Business CRM), the wave's ID number is stored here.
LOCALVALUENoASNoThe value of the Sales Order in the local currency.

Relationships:
NameRelationship typeParentChildCardinality
CAMPAIGN_WAVE_SALESORD_HDRNon IdentifyingCAMPAIGN_WAVESALESORD_HDRZero Or More
DR_INVLINES_SALESORD_HDRNon IdentifyingDR_INVLINESSALESORD_HDRZero Or More
NARRATIVES_SALESORD_HDRNon IdentifyingNARRATIVESSALESORD_HDRZero Or More
OPPORTUNITY_SALESORD_HDRNon IdentifyingOPPORTUNITYSALESORD_HDRZero Or More
SALESORD_HDR_TASKSNon IdentifyingSALESORD_HDRTASKSZero Or More

Indexes:
NameIndex columnsIndex type
SALESORD_HDR_IDXSTATUS ASC, DUEDATE ASC
SALESORD_MULTIACCNO ASC, SALESNO ASC, OPPORTUNITY_SEQNO ASC

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (TAXROUNDING)
Not NullColumn ConstraintNOT NULL (SEQNO)
Not NullColumn ConstraintNOT NULL (SHIP_COMPLETE)
Not NullColumn ConstraintNOT NULL (HAS_UNPICKED)
Not NullColumn ConstraintNOT NULL (HAS_UNINVOICED)
Not NullColumn ConstraintNOT NULL (HAS_UNSUPPLIED)
Not NullColumn ConstraintNOT NULL (HAS_BACKORDERS)
Not NullColumn ConstraintNOT NULL (HAS_UNRELEASED)
Not NullColumn ConstraintNOT NULL (INVOICECOUNT)
Not NullColumn ConstraintNOT NULL (DELIVERYCOUNT)
CAMPAIGN_WAVE_SALESORD_HDRForeign KeyTable ConstraintFOREIGN KEY (CAMPAIGN_WAVE_SEQNO) REFERENCES CAMPAIGN_WAVE(SEQNO)
DF_SALESORD_HDR_ACCNODefaultColumn ConstraintACCNO DEFAULT 0
DF_SALESORD_HDR_DUEDATEDefaultColumn ConstraintDUEDATE DEFAULT getdate()
DF_SALESORD_HDR_ORDERDATEDefaultColumn ConstraintORDERDATE DEFAULT getdate()
DF_SALESORD_HDR_STATUSDefaultColumn ConstraintSTATUS DEFAULT 0
DF_SALESORD_HDR_SUBTOTALDefaultColumn ConstraintSUBTOTAL DEFAULT 0
DF_SALESORD_HDR_TAXTOTALDefaultColumn ConstraintTAXTOTAL DEFAULT 0
DF__SALESORD___BACKO__70FDBF69DefaultColumn ConstraintBACKORDER DEFAULT N
DF__SALESORD___BRANC__35DCF99BDefaultColumn ConstraintBRANCHNO DEFAULT 0
DF__SALESORD___CAMPA__552D1E70DefaultColumn ConstraintCAMPAIGN_WAVE_SEQNO DEFAULT -1
DF__SALESORD___CONSI__2EB0D91FDefaultColumn ConstraintCONSIGNTOLOC DEFAULT 0
DF__SALESORD___CURRE__2EE5E349DefaultColumn ConstraintCURRENCYNO DEFAULT 0
DF__SALESORD___DEFLO__3AC275A0DefaultColumn ConstraintDEFLOCNO DEFAULT 0
DF__SALESORD___DELIV__7FABD173DefaultColumn ConstraintDELIVERYCOUNT DEFAULT 0
DF__SALESORD___EXCHR__2FDA0782DefaultColumn ConstraintEXCHRATE DEFAULT 1
DF__SALESORD___HAS_B__68294D9DDefaultColumn ConstraintHAS_BACKORDERS DEFAULT N
DF__SALESORD___HAS_U__67352964DefaultColumn ConstraintHAS_UNRELEASED DEFAULT N
DF__SALESORD___HAS_U__691D71D6DefaultColumn ConstraintHAS_UNSUPPLIED DEFAULT N
DF__SALESORD___HAS_U__6A11960FDefaultColumn ConstraintHAS_UNINVOICED DEFAULT N
DF__SALESORD___HAS_U__6B05BA48DefaultColumn ConstraintHAS_UNPICKED DEFAULT N
DF__SALESORD___INVOI__009FF5ACDefaultColumn ConstraintINVOICECOUNT DEFAULT 0
DF__SALESORD___MANIF__71F1E3A2DefaultColumn ConstraintMANIFEST DEFAULT 0
DF__SALESORD___MAXCO__4CE125DBDefaultColumn ConstraintMAXCOURIERCHARGE DEFAULT 0
DF__SALESORD___ONHOL__44E0DCB7DefaultColumn ConstraintONHOLD DEFAULT N
DF__SALESORD___OPPOR__73C6B429DefaultColumn ConstraintOPPORTUNITY_SEQNO DEFAULT -1
DF__SALESORD___ORDST__1AF4C48CDefaultColumn ConstraintORDSTATUS DEFAULT 0
DF__SALESORD___PAYME__505BE5ADDefaultColumn ConstraintPAYMENT_STATUS DEFAULT 0
DF__SALESORD___PICKE__17D860BFDefaultColumn ConstraintPICKEDCOUNT DEFAULT 0
DF__SALESORD___PROCE__3CAABE12DefaultColumn ConstraintPROCESSFINALISATION DEFAULT 0
DF__SALESORD___RELEA__153BEB36DefaultColumn ConstraintRELEASECOUNT DEFAULT 0
DF__SALESORD___SALES__70E8B0D0DefaultColumn ConstraintSALESNO DEFAULT 0
DF__SALESORD___SHIP___0EAEE938DefaultColumn ConstraintSHIP_COMPLETE DEFAULT N
DF__SALESORD___TAXIN__5555A4F4DefaultColumn ConstraintTAXINC DEFAULT N
DF__SALESORD___TAXRO__5B651AB3DefaultColumn ConstraintTAXROUNDING DEFAULT 0
DF__SALESORD___WAS_B__65AD9EFCDefaultColumn ConstraintWAS_BACKORDERED DEFAULT N
DR_INVLINES_SALESORD_HDRForeign KeyTable ConstraintFOREIGN KEY (ACCNO) REFERENCES DR_INVLINES(ACCNO)
NARRATIVES_SALESORD_HDRForeign KeyTable ConstraintFOREIGN KEY (NARRATIVE_SEQNO) REFERENCES NARRATIVES(SEQNO)
OPPORTUNITY_SALESORD_HDRForeign KeyTable ConstraintFOREIGN KEY (OPPORTUNITY_SEQNO) REFERENCES OPPORTUNITY(SEQNO)
PK_SALESORD_HDR_1__11Primary KeyTable ConstraintPRIMARY KEY (SEQNO)



Entity: STAFF
CommentThis table stores details of all EXO Business staff members. These are the people who are authorised to log in to and use the EXO Business system.
Primary key columnsSTAFFNO

Attributes:
Column namePrimary keyData typeNot NULLComment
STAFFNOYesINTEGERYesA unique identifier for the staff record.
NAMENoVARCHAR(30)NoThe staff member's full name.
JOBTITLENoVARCHAR(30)NoThe staff member's job title.
EXTENSIONNoVARCHAR(12)NoThe staff member's telephone extension.
PHONENoVARCHAR(30)NoThe staff member's work telephone number.
HOMEPHONENoVARCHAR(30)NoThe staff member's home telephone number.
ISACTIVENoCHAR(1)NoThis field is set to 'Y' if the staff member is currently active, i.e. if their Active flag is ticked in EXO Business Configurator.
APP_PASSWORDNoVARCHAR(30)NoThe staff member's password, used when logging in to the EXO Business system. Passwords are stored in an encrypted format.
MENU_NONoINTEGERNoThe ID number of the Menu Definition specified for the staff member. Corresponds to the menu's SEQNO field in the MENU_COLLECTION table.
AUTH_AMTNoFLOAT(53)NoThe staff member's Credit Invoice Authorisation Limit.
STOCK_AUTH_AMTNoFLOAT(53)NoThe staff member's Stock Purchase Order Authorisation Limit.
NON_STOCK_AUTH_AMTNoFLOAT(53)NoThe staff member's Non-Stock Purchase Order Authorisation Limit.
SECURITYPROFILEIDNoINTEGERYesThe ID number of the staff member's Security profile. Corresponds to the profile's ID field in the PROFILE table.
USERPROFILEIDNoINTEGERYesThe ID number of the staff member's User profile. Corresponds to the profile's ID field in the PROFILE table.
LOGINIDNoVARCHAR(30)YesThe staff member's login ID. This is the ID used to log in to the EXO Business system.
PASSWORD_CHANGEDNoDATETIMEYesThe date and time when the staff member's password was last changed.
LAST_BAD_LOGINNoDATETIMENoThe date and time when the staff member last attempted to log in but failed.
BAD_LOGIN_COUNTNoINTEGERYesThe number of times the staff member has attempted to log in but failed.
LAST_LOGINNoDATETIMENoThe date and time when the staff member last successfully logged in.
ACCOUNT_STATUSNoINTEGERYesThe staff member's account status. Will be one of:
0 = Account OK
1 = Account Locked
2 = Password Expired
EMAIL_ADDRESSNoVARCHAR(50)NoThe staff member's email address.
DISCOUNTRATENoFLOAT(53)YesThe staff member's Discount Rate Limit.
PAYROLL_IDNoVARCHAR(15)NoThe staff member's Employee ID (Payroll) number. This field is used when EXO Business is integrating with an external payroll system, e.g. MYOB EXO Payroll. It must contain the employee's corresponding ID number in the payroll system.
IS_SUPERVISORNoCHAR(1)YesThis field is set to 'Y' if the staff member is designated as a supervisor, i.e. if their Has supervisory override authority flag is ticked.
NICKNAMENoVARCHAR(15)NoA short nickname for the employee.
ABSENTNoCHAR(1)YesThis field is set to 'Y' if the staff member is currently absent, i.e. if their Absent flag is ticked in EXO Business Configurator.
EMPLOYEE_CODENoINTEGERYesThis field is used by the payroll integration functionality.
SMTP_SEQNONoINTEGERNoWhere emails are sent via SMTP using the EXO Business Email Sender, this field contains the ID of the SMTP settings that apply to the staff member (SMTP_ACCOUNT.SEQNO). Set up via the SMTP Server Settings window.
HAS_BUDGETSNoCHAR(1)NoThis field is set to 'Y' if the staff member has been assigned a Sales Team Budget, i.e. if their Has Budget flag is ticked in EXO Business Configurator.
REPORTS_TO_STAFFNONoINTEGERNoThe ID number of the staff member that this staff member reports to.
FACEBOOK_ACCESS_TOKENNoVARCHAR(max)NoIf the staff member uses their own Facebook account when using the EXO Business social media functions, their encrypted access token is stored here.
LINKEDIN_TOKEN_KEYNoVARCHAR(max)NoIf the staff member uses their own LinkedIn account when using the EXO Business social media functions, their encrypted access token key is stored here.
LINKEDIN_TOKEN_SECRETNoVARCHAR(max)NoIf the staff member uses their own LinkedIn account when using the EXO Business social media functions, their encrypted access token secret is stored here.
TWITTER_TOKEN_KEYNoVARCHAR(max)NoIf the staff member uses their own Twitter account when using the EXO Business social media functions, their encrypted access token key is stored here.
TWITTER_TOKEN_SECRETNoVARCHAR(max)NoIf the staff member uses their own Twitter account when using the EXO Business social media functions, their encrypted access token secret is stored here.
API_ACCESSNoCHAR(1)NoThis field contains 'Y' if the staff member is authorised to use the EXO API.
MOBILE_ACCESSNoCHAR(1)YesThis field contains 'Y' if the staff member is authorised to use the EXO OnTheGo mobile app.
BANKFEED_REFRESHTOKENNoVARCHAR(500)NoEncrypted OAuth refresh token used for Bank Feeds.
SBR_REFRESHTOKENNoVARCHAR(1024)NoThe refresh token used for SBR authentication.

Relationships:
NameRelationship typeParentChildCardinality
FK_CRM_BUDGET_EXCLUDED_STAFF_STAFFNon IdentifyingSTAFFCRM_BUDGET_EXCLUDED_STAFFZero Or More
FK_CRM_BUDGET_LINE_STAFFNon IdentifyingSTAFFCRM_BUDGET_LINEZero Or More
MENU_COLLECTION_STAFFNon IdentifyingMENU_COLLECTIONSTAFFZero Or More
STAFF_BILLOMAT_TEMPNon IdentifyingSTAFFBILLOMAT_TEMPZero Or More
STAFF_CAMPAIGNNon IdentifyingSTAFFCAMPAIGNZero Or More
STAFF_CAMPAIGN_HISTNon IdentifyingSTAFFCAMPAIGN_HISTZero Or More
STAFF_CONTACTSNon IdentifyingSTAFFCONTACTSZero Or More
STAFF_CONTACT_LISTNon IdentifyingSTAFFCONTACT_LISTZero Or More
STAFF_CONTACT_LIST1Non IdentifyingSTAFFCONTACT_LISTZero Or More
STAFF_CR_ACCSNon IdentifyingSTAFFCR_ACCSZero Or More
STAFF_CR_CONT_HISTNon IdentifyingSTAFFCR_CONT_HISTZero Or More
STAFF_DR_ACCSNon IdentifyingSTAFFDR_ACCSOne Or More
STAFF_DR_CONT_HISTNon IdentifyingSTAFFDR_CONT_HISTOne Or More
STAFF_DR_TRANSNon IdentifyingSTAFFDR_TRANSZero Or More
STAFF_JOBCOST_HDRNon IdentifyingSTAFFJOBCOST_HDRZero Or More
STAFF_JOBCOST_HDR_MGRNon IdentifyingSTAFFJOBCOST_HDRZero Or More
STAFF_JOBCOST_RESOURCENon IdentifyingSTAFFJOBCOST_RESOURCEZero Or More
STAFF_JOB_TIMESHEETSNon IdentifyingSTAFFJOB_TIMESHEETSZero Or More
STAFF_JOB_TIMESHEET_ALLOWANCENon IdentifyingSTAFFJOB_TIMESHEET_ALLOWANCEZero Or More
STAFF_JOB_TRANSACTIONSNon IdentifyingSTAFFJOB_TRANSACTIONSZero Or More
STAFF_OPPORTUNITY_HISTNon IdentifyingSTAFFOPPORTUNITY_HISTZero Or More
STAFF_STOCK_REQUESTSNon IdentifyingSTAFFSTOCK_REQUESTSZero Or More
STAFF_STOCK_TRANS_HDRNon IdentifyingSTAFFSTOCK_TRANS_HDRZero Or More
STAFF_TASKSNon IdentifyingSTAFFTASKSZero Or More
STAFF_TASKS1Non IdentifyingSTAFFTASKSZero Or More
STAFF_TASKS2Non IdentifyingSTAFFTASKSZero Or More
STAFF_TASKS3Non IdentifyingSTAFFTASKSZero Or More

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (MOBILE_ACCESS)
Not NullColumn ConstraintNOT NULL (STAFFNO)
Not NullColumn ConstraintNOT NULL (SECURITYPROFILEID)
Not NullColumn ConstraintNOT NULL (EMPLOYEE_CODE)
Not NullColumn ConstraintNOT NULL (USERPROFILEID)
Not NullColumn ConstraintNOT NULL (ABSENT)
Not NullColumn ConstraintNOT NULL (LOGINID)
Not NullColumn ConstraintNOT NULL (PASSWORD_CHANGED)
Not NullColumn ConstraintNOT NULL (IS_SUPERVISOR)
Not NullColumn ConstraintNOT NULL (BAD_LOGIN_COUNT)
Not NullColumn ConstraintNOT NULL (DISCOUNTRATE)
Not NullColumn ConstraintNOT NULL (ACCOUNT_STATUS)
DF__STAFF__ABSENT__12CA5E36DefaultColumn ConstraintABSENT DEFAULT N
DF__STAFF__ACCOUNT_S__5CACADF9DefaultColumn ConstraintACCOUNT_STATUS DEFAULT 0
DF__STAFF__BAD_LOGIN__5BB889C0DefaultColumn ConstraintBAD_LOGIN_COUNT DEFAULT 0
DF__STAFF__DISCOUNTR__2C146396DefaultColumn ConstraintDISCOUNTRATE DEFAULT 0
DF__STAFF__EMPLOYEE___3DB4BC3BDefaultColumn ConstraintEMPLOYEE_CODE DEFAULT -1
DF__STAFF__HAS_BUDGE__6855017DDefaultColumn ConstraintHAS_BUDGETS DEFAULT N
DF__STAFF__IS_SUPERV__24F33012DefaultColumn ConstraintIS_SUPERVISOR DEFAULT N
DF__STAFF__MOBILE_AC__38F0D275DefaultColumn ConstraintMOBILE_ACCESS DEFAULT N
DF__STAFF__PASSWORD___5AC46587DefaultColumn ConstraintPASSWORD_CHANGED DEFAULT getdate()
DF__STAFF__REPORTS_T__694925B6DefaultColumn ConstraintREPORTS_TO_STAFFNO DEFAULT -1
DF__STAFF__SECURITYP__58DC1D15DefaultColumn ConstraintSECURITYPROFILEID DEFAULT 0
DF__STAFF__SMTP_SEQN__6B667852DefaultColumn ConstraintSMTP_SEQNO DEFAULT -1
DF__STAFF__USERPROFI__59D0414EDefaultColumn ConstraintUSERPROFILEID DEFAULT 0
MENU_COLLECTION_STAFFForeign KeyTable ConstraintFOREIGN KEY (MENU_NO) REFERENCES MENU_COLLECTION(SEQNO)
PK_STAFFPrimary KeyTable ConstraintPRIMARY KEY (STAFFNO)



Entity: STOCK_ITEMS
CommentThis table contains details of all stock items.
Primary key columnsSTOCKCODE

Attributes:
Column namePrimary keyData typeNot NULLComment
STOCKCODEYesVARCHAR(23)YesA unique ID code for the stock item.
DESCRIPTIONNoVARCHAR(40)NoThe stock item's description.
STOCKGROUPNoINTEGERNoThe Primary (Fine) Stock Group that the item belongs to.
STATUSNoCHAR(1)NoThe stock item's status. Will be one of:
S = Stock item
L = Lookup item
SELLPRICE1NoFLOAT(53)NoSell price 1.
SELLPRICE2NoFLOAT(53)NoSell price 2.
SELLPRICE3NoFLOAT(53)NoSell price 3.
SELLPRICE4NoFLOAT(53)NoSell price 4.
SELLPRICE5NoFLOAT(53)NoSell price 5.
SELLPRICE6NoFLOAT(53)NoSell price 6.
SELLPRICE7NoFLOAT(53)NoSell price 7.
SELLPRICE8NoFLOAT(53)NoSell price 8.
SELLPRICE9NoASNoSell price 9.
SELLPRICE10NoFLOAT(53)NoSell price 10.
LATESTCOSTNoFLOAT(53)NoThe stock item's Last Cost Price.
AVECOSTNoFLOAT(53)NoThe stock item's Average Cost Price.
MINSTOCKNoFLOAT(53)NoThe minimum default stock level for each location.
MAXSTOCKNoFLOAT(53)NoThe maximum default stock level for each location.
SUPPLIERNONoINTEGERNoThe ID number (CR_ACCS.ACCNO) of the stock item's main supplier.
MONTHUNITSNoFLOAT(53)NoSales totals in terms of quantity for the current month.
YEARUNITSNoFLOAT(53)NoYear to date sales totals in terms of quantity.
LASTYEARUNITSNoFLOAT(53)NoUnits of stock item sold in for the previous year.
MONTHVALUENoFLOAT(53)NoSales value for the current month.
YEARVALUENoFLOAT(53)NoSales value for the current year.
LASTYEARVALUENoFLOAT(53)NoSales value for last year.
BINCODENoVARCHAR(12)NoBincode for the stock item.
DISCOUNTLEVELNoINTEGERNo
DEFDAYSNoINTEGERNo
BARCODE1NoVARCHAR(30)NoBarcode/alternate code 1.
BARCODE2NoVARCHAR(30)NoBarcode/alternate code 2.
BARCODE3NoVARCHAR(30)NoBarcode/alternate code 3.
LASTMONTHVALUENoFLOAT(53)NoSales value for the previous month for the stock item.
LASTMONTHUNITSNoFLOAT(53)NoUnits of stock item sold in the previous month.
SALES_GL_CODENoINTEGERNoThe default GL code that sales transactions for this stock item are posted to.
PURCH_GL_CODENoINTEGERNoThe GL code that purchase transactions for this stock are posted to.
WEB_SHOWNoCHAR(1)No
ISACTIVENoCHAR(1)NoIf this field is set to 'Y', the stock item is active.
WEIGHTNoFLOAT(53)NoPhysical weight of the stock item.
CUBICNoFLOAT(53)NoCubic weight of the item.
ALERTNoVARCHAR(60)NoText of the pop-up alert message that appears when the stock item is sold or purchased.
NOTESNoVARCHAR(4096)NoAny notes for the stock item.
PQTYNoFLOAT(53)No
PACKNoVARCHAR(10)NoDescribes the unit of sale for pricing, e.g. EACH or PACK.
HAS_SNNoCHAR(1)NoThis field is set to 'Y' if the stock item is serial number tracked.
STDCOSTNoFLOAT(53)NoThe stock item's standard cost.
SUPPLIERNO2NoINTEGERNoAlternate supplier for the stock item.
SUPPLIERNO3NoINTEGERNoAlternate supplier for the stock item.
SALES_GLSUBCODENoINTEGERNoThe default GL sub-account code that sales transactions for this stock item are posted to.
PURCH_GLSUBCODENoINTEGERNoThe default GL sub-account code that purchase transactions for this stock item are posted to.
BRANCHNONoINTEGERNoBranch number for the stock item.
SALESTAXRATENoINTEGERNoDefault GST rate for sales transactions.
PURCHTAXRATENoINTEGERNoDefault GST rate for purchase transactions.
LAST_UPDATEDNoDATETIMENoDate and time when the stock item record was last updated.
UPDATEITEM_CODENoVARCHAR(23)NoOnly applies to lookup items. The ID number of the stocked item that maintains the actual stock.
UPDATEITEM_QTYNoFLOAT(53)NoOnly applies to lookup items. Quantity of the stocked item.
COS_GL_CODENoINTEGERNoThe Cost of Sales account updated in the General Ledger when this stock item is sold.
COS_GLSUBCODENoINTEGERNoThe Cost of Sales sub-account updated in the General Ledger when the stock item is sold.
STOCKPRICEGROUPNoINTEGERNoThe price group that the stock item belongs to.
SUPPLIERCOSTNoFLOAT(53)YesThe supplier cost price.
ECONORDERQTYNoFLOAT(53)NoThe economic order quantity (EOQ) for the stock item.
LINKED_BILLCODENoVARCHAR(23)No
STOCK_CLASSIFICATIONNoINTEGERYesThe stock classification that the item belongs to.
STOCKGROUP2NoINTEGERNoThe stock item's Secondary (Coarse) Stock Group.
TOTALSTOCKNoFLOAT(53)YesTotal units of stock for the item.
HAS_BNNoCHAR(1)NoThis field is set to 'Y' if the stock item is batch tracked.
HAS_EXPIRYNoCHAR(1)YesThis field is set to 'Y' if the stock item has an expiry date. This flag is only available in the UI if the "Use expiry dates for batched & serial numbers" profile setting is enabled.
EXPIRY_DAYSNoINTEGERNoNumber of days before expiry of the stock item.
DUTYNoFLOAT(53)YesThe duty percentage on the stock item.
SERIALNO_TYPENoINTEGERYesHow the stock item is serialised. Will be one of:
0 = Not Serialised
1 = Fully Tracked (In & Internal & Out)
2 = Creditor & Internal (In & Internal)
3 = Debtor Only (Out only)
4 = Creditor & Debtor (In & Out Only)
5 = Creditor Only (In Only)
6 = Internal & Debtor (Internal & Out only)
7 = Internal Only
COSTTYPENoINTEGERYes
COSTGROUPNoINTEGERYes
LABEL_QTYNoINTEGERYes
IS_DISCOUNTABLENoCHAR(1)YesThis field is set to 'Y' if the stock item is discountable.
RESTRICTED_ITEMNoCHAR(1)YesThis field is set to 'Y' if the stock item is a restricted item.
NUMDECIMALSNoINTEGERYesThe number of decimal places that can be entered for the stock item's quantity.
COGSMETHODNoINTEGERYes
DEFAULTWARRANTYNONoINTEGERYesThe default Warranty No for the stock item.
DIMENSIONSNoINTEGERYesHow the dimensions of the stock item are specified. Will be one of:
0=None
1=Length
2=Square
3=Cubic
X_SIZEIDNoINTEGERNoStyle size ID of the stock item. Used by the Style, Size Colour functionality.
X_COLOURIDNoINTEGERNoStyle colour ID of the stock item. Used by the Style, Size Colour functionality.
AUTO_NARRATIVENoINTEGERNoThe setting of the stock item's Auto Narrative property. Will be one of:
0=No
1=Yes with Blank
2=Yes with Notes
VARIABLECOSTNoCHAR(1)YesThe field is set to 'Y for Variable Cost stock items.
PRICEQTYNoFLOAT(53)NoThe stock item's sell price per quantity.
PRICEPERKGNoFLOAT(53)NoThe stock item's sell price per kg.
LOOKUP_RECOVERABLENoCHAR(1)NoIf this field contains 'Y', the stock item is a recoverable expense in EXO Job Costing.

Relationships:
NameRelationship typeParentChildCardinality
CR_ACCS_STOCK_ITEMSNon IdentifyingCR_ACCSSTOCK_ITEMSZero Or More
FK_CRM_BUDGET_EXCLUDED_STOCK_ITEMS_STOCK_ITEMSNon IdentifyingSTOCK_ITEMSCRM_BUDGET_EXCLUDED_STOCK_ITEMSZero Or More
FK_CRM_BUDGET_LINE_STOCK_ITEMSNon IdentifyingSTOCK_ITEMSCRM_BUDGET_LINEZero Or More
GLACCS_STOCK_ITEMSNon IdentifyingGLACCSSTOCK_ITEMSZero Or More
GLACCS_STOCK_ITEMS_COSNon IdentifyingGLACCSSTOCK_ITEMSZero Or More
GL_ACCS_STOCKITEMS_PONon IdentifyingGLACCSSTOCK_ITEMSZero Or More
STOCK_CLASSIFICATIONS_STOCK_ITEMSNon IdentifyingSTOCK_CLASSIFICATIONSSTOCK_ITEMSZero Or More
STOCK_GROUP2S_STOCK_ITEMSNon IdentifyingSTOCK_GROUP2SSTOCK_ITEMSZero Or More
STOCK_GROUPS_STOCK_ITEMSNon IdentifyingSTOCK_GROUPSSTOCK_ITEMSZero Or More
STOCK_ITEMS_BILLOMAT_LINESNon IdentifyingSTOCK_ITEMSBILLOMAT_LINESZero Or More
STOCK_ITEMS_BILLOMAT_TEMPNon IdentifyingSTOCK_ITEMSBILLOMAT_TEMPZero Or More
STOCK_ITEMS_CR_INVLINESNon IdentifyingSTOCK_ITEMSCR_INVLINESZero Or More
STOCK_ITEMS_DR_INVLINESNon IdentifyingSTOCK_ITEMSDR_INVLINESZero Or More
STOCK_ITEMS_DR_PRICESNon IdentifyingSTOCK_ITEMSDR_PRICESZero Or More
STOCK_ITEMS_INWARDS_GOODS_LINESNon IdentifyingSTOCK_ITEMSINWARDS_GOODS_LINESZero Or More
STOCK_ITEMS_JOBCOST_LINESNon IdentifyingSTOCK_ITEMSJOBCOST_LINESZero Or More
STOCK_ITEMS_JOBCOST_LINES_DESCNon IdentifyingSTOCK_ITEMSJOBCOST_LINESZero Or More
STOCK_ITEMS_JOB_CONTRACT_BILLINGSNon IdentifyingSTOCK_ITEMSJOB_CONTRACT_BILLINGSZero Or More
STOCK_ITEMS_JOB_OUTPUT_ITEMSNon IdentifyingSTOCK_ITEMSJOB_OUTPUT_ITEMSZero Or More
STOCK_ITEMS_JOB_OUTPUT_ITEMS_DESCNon IdentifyingSTOCK_ITEMSJOB_OUTPUT_ITEMSZero Or More
STOCK_ITEMS_JOB_TIMESHEETSNon IdentifyingSTOCK_ITEMSJOB_TIMESHEETSZero Or More
STOCK_ITEMS_JOB_TRANSACTIONSNon IdentifyingSTOCK_ITEMSJOB_TRANSACTIONSZero Or More
STOCK_ITEMS_JOB_TRANSACTIONS_DESCNon IdentifyingSTOCK_ITEMSJOB_TRANSACTIONSZero Or More
STOCK_ITEMS_OPPORTUNITY_QUOTENon IdentifyingSTOCK_ITEMSOPPORTUNITY_QUOTEZero Or More
STOCK_ITEMS_STOCKREQUIREMENTNon IdentifyingSTOCK_ITEMSSTOCKREQUIREMENTZero Or More
STOCK_ITEMS_STOCKTAKE_TOTALSNon IdentifyingSTOCK_ITEMSSTOCKTAKE_TOTALSZero Or More
STOCK_ITEMS_STOCKTAKE_TOTALS_BNNon IdentifyingSTOCK_ITEMSSTOCKTAKE_TOTALSZero Or More
STOCK_ITEMS_STOCKTAKE_TOTALS_EXPDAYSNon IdentifyingSTOCK_ITEMSSTOCKTAKE_TOTALSZero Or More
STOCK_ITEMS_STOCKTAKE_TOTALS_EXPIRYNon IdentifyingSTOCK_ITEMSSTOCKTAKE_TOTALSZero Or More
STOCK_ITEMS_STOCKTAKE_TOTALS_SERIALNon IdentifyingSTOCK_ITEMSSTOCKTAKE_TOTALSZero Or More
STOCK_ITEMS_STOCK_LOC_INFOIdentifyingSTOCK_ITEMSSTOCK_LOC_INFOZero Or More
STOCK_ITEMS_STOCK_REQUESTLINESNon IdentifyingSTOCK_ITEMSSTOCK_REQUESTLINESZero Or More
STOCK_ITEMS_STOCK_REQUESTLINES_DESCNon IdentifyingSTOCK_ITEMSSTOCK_REQUESTLINESZero Or More
STOCK_ITEMS_STOCK_SERIALNOSNon IdentifyingSTOCK_ITEMSSTOCK_SERIALNOSZero Or More
STOCK_ITEMS_STOCK_TRANSNon IdentifyingSTOCK_ITEMSSTOCK_TRANSZero Or More
STOCK_ITEMS_STOCK_WEBNon IdentifyingSTOCK_ITEMSSTOCK_WEBZero Or More
STOCK_ITEMS_SUPPLIER_STOCK_ITEMSNon IdentifyingSTOCK_ITEMSSUPPLIER_STOCK_ITEMSZero Or More
STOCK_PRICEGROUPS_STOCK_ITEMSNon IdentifyingSTOCK_PRICEGROUPSSTOCK_ITEMSZero Or More

Indexes:
NameIndex columnsIndex type
STOCK_ITEMS_DESCDESCRIPTION ASC

Constraints:
NameTypeLevelConstraint
DefaultColumn ConstraintLOOKUP_RECOVERABLE DEFAULT Y
Not NullColumn ConstraintNOT NULL (STOCKCODE)
Not NullColumn ConstraintNOT NULL (VARIABLECOST)
Not NullColumn ConstraintNOT NULL (DIMENSIONS)
Not NullColumn ConstraintNOT NULL (DEFAULTWARRANTYNO)
Not NullColumn ConstraintNOT NULL (COGSMETHOD)
Not NullColumn ConstraintNOT NULL (NUMDECIMALS)
Not NullColumn ConstraintNOT NULL (RESTRICTED_ITEM)
Not NullColumn ConstraintNOT NULL (IS_DISCOUNTABLE)
Not NullColumn ConstraintNOT NULL (LABEL_QTY)
Not NullColumn ConstraintNOT NULL (COSTGROUP)
Not NullColumn ConstraintNOT NULL (COSTTYPE)
Not NullColumn ConstraintNOT NULL (SERIALNO_TYPE)
Not NullColumn ConstraintNOT NULL (DUTY)
Not NullColumn ConstraintNOT NULL (HAS_EXPIRY)
Not NullColumn ConstraintNOT NULL (TOTALSTOCK)
Not NullColumn ConstraintNOT NULL (STOCK_CLASSIFICATION)
Not NullColumn ConstraintNOT NULL (SUPPLIERCOST)
CR_ACCS_STOCK_ITEMSForeign KeyTable ConstraintFOREIGN KEY (SUPPLIERNO) REFERENCES CR_ACCS(ACCNO)
DF__STOCK_ITEM__DUTY__675F4696DefaultColumn ConstraintDUTY DEFAULT 0
DF__STOCK_ITEM__PQTY__7C255952DefaultColumn ConstraintPQTY DEFAULT 1
DF__STOCK_ITE__AUTO___43ECB87EDefaultColumn ConstraintAUTO_NARRATIVE DEFAULT 0
DF__STOCK_ITE__AVECO__18A19C6FDefaultColumn ConstraintAVECOST DEFAULT 0
DF__STOCK_ITE__BRANC__5FD33367DefaultColumn ConstraintBRANCHNO DEFAULT 0
DF__STOCK_ITE__COGSM__0BD27C8DDefaultColumn ConstraintCOGSMETHOD DEFAULT 0
DF__STOCK_ITE__COSTG__50BBD860DefaultColumn ConstraintCOSTGROUP DEFAULT 0
DF__STOCK_ITE__COSTT__4FC7B427DefaultColumn ConstraintCOSTTYPE DEFAULT 0
DF__STOCK_ITE__COS_G__4D7F7902DefaultColumn ConstraintCOS_GL_CODE DEFAULT 0
DF__STOCK_ITE__COS_G__4E739D3BDefaultColumn ConstraintCOS_GLSUBCODE DEFAULT 0
DF__STOCK_ITE__CUBIC__45C948A1DefaultColumn ConstraintCUBIC DEFAULT 0
DF__STOCK_ITE__DEFAU__6F0133B5DefaultColumn ConstraintDEFAULTWARRANTYNO DEFAULT -1
DF__STOCK_ITE__DEFDA__2D9CB955DefaultColumn ConstraintDEFDAYS DEFAULT 0
DF__STOCK_ITE__DIMEN__3CFFC3CDDefaultColumn ConstraintDIMENSIONS DEFAULT 0
DF__STOCK_ITE__DISCO__2CA8951CDefaultColumn ConstraintDISCOUNTLEVEL DEFAULT 0
DF__STOCK_ITE__EXPIR__666B225DDefaultColumn ConstraintEXPIRY_DAYS DEFAULT 1
DF__STOCK_ITE__HAS_B__526429B0DefaultColumn ConstraintHAS_BN DEFAULT N
DF__STOCK_ITE__HAS_E__6576FE24DefaultColumn ConstraintHAS_EXPIRY DEFAULT N
DF__STOCK_ITE__HAS_S__7FF5EA36DefaultColumn ConstraintHAS_SN DEFAULT N
DF__STOCK_ITE__ISACT__74B941B4DefaultColumn ConstraintISACTIVE DEFAULT Y
DF__STOCK_ITE__IS_DI__3044E72DDefaultColumn ConstraintIS_DISCOUNTABLE DEFAULT Y
DF__STOCK_ITE__LABEL__6C04CB79DefaultColumn ConstraintLABEL_QTY DEFAULT 1
DF__STOCK_ITE__LASTM__2E90DD8EDefaultColumn ConstraintLASTMONTHVALUE DEFAULT 0
DF__STOCK_ITE__LASTM__2F8501C7DefaultColumn ConstraintLASTMONTHUNITS DEFAULT 0
DF__STOCK_ITE__LASTY__28D80438DefaultColumn ConstraintLASTYEARUNITS DEFAULT 0
DF__STOCK_ITE__LASTY__2BB470E3DefaultColumn ConstraintLASTYEARVALUE DEFAULT 0
DF__STOCK_ITE__LATES__17AD7836DefaultColumn ConstraintLATESTCOST DEFAULT 0
DF__STOCK_ITE__MAXST__25077354DefaultColumn ConstraintMAXSTOCK DEFAULT 0
DF__STOCK_ITE__MINST__24134F1BDefaultColumn ConstraintMINSTOCK DEFAULT 0
DF__STOCK_ITE__MONTH__26EFBBC6DefaultColumn ConstraintMONTHUNITS DEFAULT 0
DF__STOCK_ITE__MONTH__29CC2871DefaultColumn ConstraintMONTHVALUE DEFAULT 0
DF__STOCK_ITE__NUMDE__0801EBA9DefaultColumn ConstraintNUMDECIMALS DEFAULT -1
DF__STOCK_ITE__PURCH__451F3D2BDefaultColumn ConstraintPURCH_GLSUBCODE DEFAULT 0
DF__STOCK_ITE__PURCH__4727812EDefaultColumn ConstraintPURCH_GL_CODE DEFAULT 0
DF__STOCK_ITE__PURCH__68687968DefaultColumn ConstraintPURCHTAXRATE DEFAULT -1
DF__STOCK_ITE__RESTR__77CB83E0DefaultColumn ConstraintRESTRICTED_ITEM DEFAULT N
DF__STOCK_ITE__SALES__442B18F2DefaultColumn ConstraintSALES_GLSUBCODE DEFAULT 0
DF__STOCK_ITE__SALES__46335CF5DefaultColumn ConstraintSALES_GL_CODE DEFAULT 0
DF__STOCK_ITE__SALES__6774552FDefaultColumn ConstraintSALESTAXRATE DEFAULT -1
DF__STOCK_ITE__SELLP__13DCE752DefaultColumn ConstraintSELLPRICE1 DEFAULT 0
DF__STOCK_ITE__SELLP__14D10B8BDefaultColumn ConstraintSELLPRICE2 DEFAULT 0
DF__STOCK_ITE__SELLP__15C52FC4DefaultColumn ConstraintSELLPRICE3 DEFAULT 0
DF__STOCK_ITE__SELLP__16B953FDDefaultColumn ConstraintSELLPRICE4 DEFAULT 0
DF__STOCK_ITE__SELLP__39987BE6DefaultColumn ConstraintSELLPRICE5 DEFAULT 0
DF__STOCK_ITE__SELLP__3A8CA01FDefaultColumn ConstraintSELLPRICE6 DEFAULT 0
DF__STOCK_ITE__SELLP__3B80C458DefaultColumn ConstraintSELLPRICE7 DEFAULT 0
DF__STOCK_ITE__SELLP__3C74E891DefaultColumn ConstraintSELLPRICE8 DEFAULT 0
DF__STOCK_ITE__SELLP__3E5D3103DefaultColumn ConstraintSELLPRICE10 DEFAULT 0
DF__STOCK_ITE__SERIA__1C481021DefaultColumn ConstraintSERIALNO_TYPE DEFAULT 0
DF__STOCK_ITE__STATU__12E8C319DefaultColumn ConstraintSTATUS DEFAULT L
DF__STOCK_ITE__STDCO__392E6792DefaultColumn ConstraintSTDCOST DEFAULT 0
DF__STOCK_ITE__STOCK__11F49EE0DefaultColumn ConstraintSTOCKGROUP DEFAULT 0
DF__STOCK_ITE__STOCK__4F87BD05DefaultColumn ConstraintSTOCKGROUP2 DEFAULT 0
DF__STOCK_ITE__STOCK__6442E2C9DefaultColumn ConstraintSTOCK_CLASSIFICATION DEFAULT 0
DF__STOCK_ITE__STOCK__69279377DefaultColumn ConstraintSTOCKPRICEGROUP DEFAULT 0
DF__STOCK_ITE__SUPPL__16B953FDDefaultColumn ConstraintSUPPLIERCOST DEFAULT 0
DF__STOCK_ITE__SUPPL__25FB978DDefaultColumn ConstraintSUPPLIERNO DEFAULT 0
DF__STOCK_ITE__TOTAL__51700577DefaultColumn ConstraintTOTALSTOCK DEFAULT 0
DF__STOCK_ITE__UPDAT__257187A8DefaultColumn ConstraintUPDATEITEM_QTY DEFAULT 0
DF__STOCK_ITE__VARIA__611DF409DefaultColumn ConstraintVARIABLECOST DEFAULT N
DF__STOCK_ITE__WEB_S__44160A59DefaultColumn ConstraintWEB_SHOW DEFAULT N
DF__STOCK_ITE__WEIGH__44D52468DefaultColumn ConstraintWEIGHT DEFAULT 0
DF__STOCK_ITE__X_COL__02890975DefaultColumn ConstraintX_COLOURID DEFAULT 0
DF__STOCK_ITE__X_SIZ__0194E53CDefaultColumn ConstraintX_SIZEID DEFAULT 0
DF__STOCK_ITE__YEARU__27E3DFFFDefaultColumn ConstraintYEARUNITS DEFAULT 0
DF__STOCK_ITE__YEARV__2AC04CAADefaultColumn ConstraintYEARVALUE DEFAULT 0
GLACCS_STOCK_ITEMSForeign KeyTable ConstraintFOREIGN KEY (SALES_GL_CODE) REFERENCES GLACCS(ACCNO)
GLACCS_STOCK_ITEMS_COSForeign KeyTable ConstraintFOREIGN KEY (COS_GL_CODE) REFERENCES GLACCS(ACCNO)
GL_ACCS_STOCKITEMS_POForeign KeyTable ConstraintFOREIGN KEY (PURCH_GL_CODE) REFERENCES GLACCS(ACCNO)
PK__STOCK_ITEMS__11007AA7Primary KeyTable ConstraintPRIMARY KEY (STOCKCODE)
STOCK_CLASSIFICATIONS_STOCK_ITEMSForeign KeyTable ConstraintFOREIGN KEY (STOCK_CLASSIFICATION) REFERENCES STOCK_CLASSIFICATIONS(CLASSNO)
STOCK_GROUP2S_STOCK_ITEMSForeign KeyTable ConstraintFOREIGN KEY (STOCKGROUP2) REFERENCES STOCK_GROUP2S(GROUPNO)
STOCK_GROUPS_STOCK_ITEMSForeign KeyTable ConstraintFOREIGN KEY (STOCKGROUP) REFERENCES STOCK_GROUPS(GROUPNO)
STOCK_PRICEGROUPS_STOCK_ITEMSForeign KeyTable ConstraintFOREIGN KEY (STOCKPRICEGROUP) REFERENCES STOCK_PRICEGROUPS(GROUPNO)

Triggers:
Trigger nameCode
AFTER_STOCK_ITEMS_DELETECREATE TRIGGER [dbo].[AFTER_STOCK_ITEMS_DELETE] ON [dbo].[STOCK_ITEMS]
FOR DELETE
AS
SET NOCOUNT ON
  DELETE FROM STOCK_LOC_INFO WHERE STOCKCODE IN (SELECT STOCKCODE FROM DELETED)
SET NOCOUNT OFF
STOCK_ITEMS_LOC_INFOCREATE TRIGGER [dbo].[STOCK_ITEMS_LOC_INFO] ON [dbo].[STOCK_ITEMS]
FOR INSERT
AS
BEGIN
  SET NOCOUNT ON
  INSERT INTO STOCK_LOC_INFO
    (STOCKCODE, LOCATION, BINCODE, MINSTOCK, MAXSTOCK, QTY)
  SELECT I.STOCKCODE, SL.LOCNO, I.BINCODE, I.MINSTOCK, I.MAXSTOCK, 0
  FROM STOCK_LOCATIONS SL, INSERTED I
  SET NOCOUNT OFF
END
STOCK_ITEMS_ONEOFFCREATE TRIGGER [dbo].[STOCK_ITEMS_ONEOFF] ON [dbo].[STOCK_ITEMS]
FOR UPDATE
AS
BEGIN
  DECLARE @UPDATEDLINES INT
  SET @UPDATEDLINES=@@ROWCOUNT
  SET NOCOUNT ON
  IF (@UPDATEDLINES > 0) AND NOT UPDATE(ISACTIVE)
    BEGIN
    UPDATE S
    SET ISACTIVE = 'N'
    FROM [dbo].[STOCK_ITEMS] S
    JOIN INSERTED I ON S.STOCKCODE = I.STOCKCODE
    JOIN STOCK_TRANS ST ON I.STOCKCODE = ST.STOCKCODE
    WHERE ((S.STOCK_CLASSIFICATION = 100) OR (S.STOCK_CLASSIFICATION = 70))
    AND (S.TOTALSTOCK <= 0)
    END
  SET NOCOUNT OFF
END


Entity: TAX_RATES
CommentThis table contains all tax rates used by the system.
Primary key columnsSEQNO

Attributes:
Column namePrimary keyData typeNot NULLComment
SEQNOYesINTEGERYesA unique ID number for the tax rate.
RATENoFLOAT(53)NoThe percentage taxation rate.
NAMENoVARCHAR(30)NoThe full name of the taxation rate.
SHORTNAMENoVARCHAR(6)NoA short name for the taxation rate.
BASENoFLOAT(53)No
GLACCNoINTEGERNoThe GL account used for the tax rate (if it is not using the default control account).
GLSUBACCNoINTEGERNoThe GL subaccount used for the tax rate (if it is not using the default control subaccount).
KEY_POINTNoVARCHAR(5)NoThe tax return key point that applies to the tax rate.

Relationships:
NameRelationship typeParentChildCardinality
TAX_RATES_CR_INVLINESNon IdentifyingTAX_RATESCR_INVLINESZero Or More
TAX_RATES_CR_TRANSNon IdentifyingTAX_RATESCR_TRANSZero Or More
TAX_RATES_DR_INVLINESNon IdentifyingTAX_RATESDR_INVLINESZero Or More
TAX_RATES_DR_TRANSNon IdentifyingTAX_RATESDR_TRANSZero Or More
TAX_RATES_JOBCOST_LINESNon IdentifyingTAX_RATESJOBCOST_LINESZero Or More
TAX_RATES_JOB_TRANSACTIONSNon IdentifyingTAX_RATESJOB_TRANSACTIONSZero Or More
TAX_RATES_OPPORTUNITY_QUOTENon IdentifyingTAX_RATESOPPORTUNITY_QUOTEZero Or More

Constraints:
NameTypeLevelConstraint
Not NullColumn ConstraintNOT NULL (SEQNO)
DF__TAX_RATES__BASE__1E5A75C5DefaultColumn ConstraintBASE DEFAULT 0
DF__TAX_RATES__GLACC__1F4E99FEDefaultColumn ConstraintGLACC DEFAULT 0
DF__TAX_RATES__GLSUB__2042BE37DefaultColumn ConstraintGLSUBACC DEFAULT 0
DF__TAX_RATES__RATE__668030F6DefaultColumn ConstraintRATE DEFAULT 0
PK__TAX_RATES__658C0CBDPrimary KeyTable ConstraintPRIMARY KEY (SEQNO)

Triggers:
Trigger nameCode
BEFORE_TAX_RATES_INSERTCREATE TRIGGER [dbo].[BEFORE_TAX_RATES_INSERT] ON [dbo].[TAX_RATES]
FOR INSERT
AS
SET NOCOUNT ON
  DECLARE @NEW_SHORTNAME VARCHAR(6)
  DECLARE @NEW_SEQNO INTEGER
  DECLARE @NEW_RATE FLOAT
  SELECT
    @NEW_SHORTNAME=SHORTNAME,
    @NEW_RATE=RATE,
    @NEW_SEQNO=SEQNO
  FROM
    INSERTED
  IF (@NEW_SHORTNAME IS NULL) OR (@NEW_SHORTNAME = '')
    UPDATE [dbo].[TAX_RATES] SET SHORTNAME = CAST(@NEW_RATE AS VARCHAR(5))+'%' WHERE SEQNO=@NEW_SEQNO
SET NOCOUNT OFF
RETURN