SALESORDERITEMDISCOUNTOPTION

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

Primary Key

Primary Key Field Type
ID uniqueidentifier

Fields

Field Field Type Null Notes Description
NUMBERID int Default = 0 Numeric ID for the discount scenario
DISCOUNTGROUPID uniqueidentifier GUID of the DISCOUNTGROUP ID - Used during discount calculation and does not need to be a true foreign key.
DISCOUNTTYPECODE tinyint Default = 0 DISCOUNTTYPECODE value for discount.
DISCOUNTTICKETSFORCODE tinyint Default = 0 DISCOUNTTICKETSFORCODE value for discount
DISCOUNTSCENARIOID uniqueidentifier GUID of the discount scenario - can span multiple rows and this field links these rows.
APPLIEDMANUALLY tinyint Default = 0 Denotes whether the discount was manually added to order
NUMBEROFTIMESAPPLIED int Default = 0 Number of time this discount is applied in the discount scenario.
QUALIFYINGORDERITEMID uniqueidentifier Foreign key to the SALESORDERITEM table for the order item to be used to qualify for the discount.
QUALIFYINGGROUPITEMID uniqueidentifier Foreign key to either EVENTID or PROGRAMID depending on value of DISCOUNTTICKETSFORCODE (0 - EVENTID; 1 - PROGRAMID) for the qualifying item.
QUALIFYINGPRICETYPECODEID uniqueidentifier Foreign key to the PRICETYPECODE table for the price type of the order item to be used to qualify for the discount.
NUMBEROFQUALIFYINGITEMS int Default = 0 Number of qualifying items for the QUALIFYINGORDERITEMID of the row.
NUMBEROFQUALIFYINGITEMSSTILLNEEDED int Default = 0 Number of qualifying items still needed to complete discount scenario.
TOTALQUALIFYINGQUANTITY int Default = 0 Number of items for the QUALIFYINGORDERITEMID that exist in order - used to calculate other values.
DISCOUNTEDORDERITEMID uniqueidentifier Foreign key to the SALESORDERITEM table for the order item to be discounted.
DISCOUNTEDGROUPITEMID uniqueidentifier Foreign key to either EVENTID or PROGRAMID depending on value of DISCOUNTTICKETSFORCODE (0 - EVENTID; 1 - PROGRAMID) for the discounted item.
DISCOUNTEDPRICETYPECODEID uniqueidentifier Foreign key to the PRICETYPECODE table for the price type of the order item to be discounted.
NUMBEROFDISCOUNTEDITEMS int Default = 0 Number of discounted items for the DISCOUNTEDORDERITEMID of the row.
NUMBEROFDISCOUNTEDITEMSSTILLOPEN int Default = 0 Number of discounted items open to fill discount scenario.
TOTALDISCOUNTEDQUANTITY int Default = 0 Number of items for the DISCOUNTEDORDERITEMID that exist in order - used to calculate other values.
DISCOUNTAMOUNT money Default = 0 Total amount for discount for row - sum this column for a given discount scenario to get total discount for scenario.
COMPLETED tinyint Default = 0 Completed status of scenario 0 - incomplete, 1 - complete, 2 - failed.
DATEADDED datetime Default = getdate() Indicates the date this record was added.
DATECHANGED datetime Default = getdate() Indicates the date this record was last changed.
TS timestamp Timestamp.
TSLONG bigint (Computed) yes CONVERT(bigint, TS) Numeric representation of the timestamp.
DISCOUNTSCENARIOGROUPID uniqueidentifier GUID of the discount scenario group - groups together discount scenarios that have overlapping items. Discount scenarios groups can be combined independently.

Foreign Keys

Foreign Key Field Type Null Notes Description
SALESORDERAVAILABLEDISCOUNTGROUPCOMBINATIONID uniqueidentifier SALESORDERAVAILABLEDISCOUNTGROUPCOMBINATION.ID Foreign key to SALESORDERAVAILABLEDISCOUNTGROUPCOMBINATIONID table.
SALESORDERID uniqueidentifier SALESORDER.ID Foreign key to the SALESORDER table
ADDEDBYID uniqueidentifier CHANGEAGENT.ID FK to CHANGEAGENT.
CHANGEDBYID uniqueidentifier CHANGEAGENT.ID FK to CHANGEAGENT.

Indexes

Index Name Fields Unique Primary Clustered
IX_SALESORDERITEMDISCOUNTOPTION_DATEADDED DATEADDED yes
IX_SALESORDERITEMDISCOUNTOPTION_DATECHANGED DATECHANGED
IX_SALESORDERITEMDISCOUNTOPTION_DISCOUNTSCENARIOID DISCOUNTSCENARIOID
IX_SALESORDERITEMDISCOUNTOPTION_SALESORDERAVAILABLEDISCOUNTGROUPCOMBINATIONID SALESORDERAVAILABLEDISCOUNTGROUPCOMBINATIONID
IX_SALESORDERITEMDISCOUNTOPTION_SALESORDERID SALESORDERID
PK_SALESORDERITEMDISCOUNTOPTION ID yes yes

Triggers

Trigger Name Description
TR_SALESORDERITEMDISCOUNTOPTION_AUDIT_UPDATE
TR_SALESORDERITEMDISCOUNTOPTION_AUDIT_DELETE