SALESORDERITEMDISCOUNTOPTION (2.93)

Support table for auto apply discounts - Discount options for a sales order.

Primary Key
Primary Key Field Type

ID

uniqueidentifier

Foreign Key Fields
Foreign Key Field Type Null Notes Description

SALESORDERAVAILABLEDISCOUNTGROUPCOMBINATIONID

uniqueidentifier

false

Foreign key to SALESORDERAVAILABLEDISCOUNTGROUPCOMBINATIONID table.

SALESORDERID

uniqueidentifier

false

Foreign key to the SALESORDER table

ADDEDBYID

uniqueidentifier

false

FK to CHANGEAGENT.

CHANGEDBYID

uniqueidentifier

false

FK to CHANGEAGENT.

Fields
Field Field Type Null Notes Description

NUMBERID

int

false

0

Numeric ID for the discount scnenario

DISCOUNTGROUPID

uniqueidentifier

false

GUID of the DISCOUNTGROUP ID - Used during discount calculation and does not need to be a true foreign key.

DISCOUNTTYPECODE

tinyint

false

0

DISCOUNTTYPECODE value for discount.

DISCOUNTTICKETSFORCODE

tinyint

false

0

DISCOUNTTICKETSFORCODE value for discount

DISCOUNTSCENARIOID

uniqueidentifier

false

GUID of the discount scenario - can span multiple rows and this field links these rows.

APPLIEDMANUALLY

tinyint

false

0

Denotes whether the discount was manually added to order

NUMBEROFTIMESAPPLIED

int

false

0

Number of time this discount is applied in the discount scenario.

QUALIFYINGORDERITEMID

uniqueidentifier

false

Foreign key to the SALESORDERITEM table for the order item to be used to qualify for the discount.

QUALIFYINGGROUPITEMID

uniqueidentifier

false

Foreign key to either EVENTID or PROGRAMID depending on value of DISCOUNTTICKETSFORCODE (0 - EVENTID; 1 - PROGRAMID) for the qualifying item.

QUALIFYINGPRICETYPECODEID

uniqueidentifier

false

Foreign key to the PRICETYPECODE table for the price type of the order item to be used to qualify for the discount.

NUMBEROFQUALIFYINGITEMS

int

false

0

Number of qualifying items for the QUALIFYINGORDERITEMID of the row.

NUMBEROFQUALIFYINGITEMSSTILLNEEDED

int

false

0

Number of qualifying items still needed to complete discount scenario.

TOTALQUALIFYINGQUANTITY

int

false

0

Number of items for the QUALIFYINGORDERITEMID that exist in order - used to calculate other values.

DISCOUNTEDORDERITEMID

uniqueidentifier

false

Foreign key to the SALESORDERITEM table for the order item to be discounted.

DISCOUNTEDGROUPITEMID

uniqueidentifier

false

Foreign key to either EVENTID or PROGRAMID depending on value of DISCOUNTTICKETSFORCODE (0 - EVENTID; 1 - PROGRAMID) for the discounted item.

DISCOUNTEDPRICETYPECODEID

uniqueidentifier

false

Foreign key to the PRICETYPECODE table for the price type of the order item to be discounted.

NUMBEROFDISCOUNTEDITEMS

int

false

0

Number of discounted items for the DISCOUNTEDORDERITEMID of the row.

NUMBEROFDISCOUNTEDITEMSSTILLOPEN

int

false

0

Number of discounted items open to fill discount scenario.

TOTALDISCOUNTEDQUANTITY

int

false

0

Number of items for the DISCOUNTEDORDERITEMID that exist in order - used to calculate other values.

DISCOUNTAMOUNT

decimal(20, 2)

false

0

Total amount for discount for row - sum this column for a given discount secneario to get total discount for scenario.

COMPLETED

tinyint

false

0

Completed status of scenarion 0 - incomplete, 1 - complete, 2 - failed.

DATEADDED

datetime

false

getdate()

Indicates the date this record was added.

DATECHANGED

datetime

false

getdate()

Indicates the date this record was last changed.

TS

timestamp

false

Timestamp.

TSLONG

bigint (Computed)

true

Numeric representation of the timestamp.

DISCOUNTSCENARIOGROUPID

uniqueidentifier

false

GUID of the discount scenario group - groups together discount scenarios that have overlapping items. Discount scenarios groups can be combined independently.

Indexes
Index Name Field(s) Unique Primary Clustered

IX_SALESORDERITEMDISCOUNTOPTION_DATEADDED

DATEADDED

False

False

True

IX_SALESORDERITEMDISCOUNTOPTION_DATECHANGED

DATECHANGED

False

False

False

IX_SALESORDERITEMDISCOUNTOPTION_DISCOUNTSCENARIOID

DISCOUNTSCENARIOID

False

False

False

IX_SALESORDERITEMDISCOUNTOPTION_SALESORDERAVAILABLEDISCOUNTGROUPCOMBINATIONID

SALESORDERAVAILABLEDISCOUNTGROUPCOMBINATIONID

False

False

False

IX_SALESORDERITEMDISCOUNTOPTION_SALESORDERID

SALESORDERID

False

False

False

PK_SALESORDERITEMDISCOUNTOPTION

ID

True

True

False

Triggers
Trigger Name Description

TR_SALESORDERITEMDISCOUNTOPTION_AUDIT_UPDATE

TR_SALESORDERITEMDISCOUNTOPTION_AUDIT_DELETE