-- --------------------------------------------------------
-- Server OS:                    Linux
-- HeidiSQL Version:             10.1.0.5464
-- --------------------------------------------------------



-- Dumping database structure for act1
DROP DATABASE IF EXISTS `act1`;
CREATE DATABASE IF NOT EXISTS `act1` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `act1`;

-- Dumping structure for table act1.currency
CREATE TABLE IF NOT EXISTS `currency` (
  `Currency_Id` varchar(15) NOT NULL COMMENT 'Unique Id',
  `Name` varchar(30) NOT NULL,
  `ISO_Code` varchar(3) NOT NULL,
  `Default_Exchange_Rate` decimal(16,5) NOT NULL COMMENT 'Exchange rate to USD for new part pricing',
  `Show_On_Price_List` tinyint(4) NOT NULL DEFAULT 0 COMMENT '1 to show on price list',
  `Locale` varchar(5) NOT NULL,
  `AR_GLAct` varchar(11) NOT NULL,
  `AR_Accrual_GLAct` varchar(11) NOT NULL,
  `Checkbook` varchar(15) NOT NULL,
  `Checkbook_Clearing` varchar(15) NOT NULL,
  `Deposit_GLact` varchar(11) NOT NULL,
  `Active` tinyint(4) NOT NULL DEFAULT 1,
  `CreateDate` datetime DEFAULT NULL,
  `CreatedBy` varchar(20) DEFAULT NULL,
  `ModifiedDate` datetime DEFAULT NULL,
  `ModifiedBy` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`Currency_Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Currency Types';

-- Data exporting was unselected.
-- Dumping structure for table act1.gldefault
CREATE TABLE IF NOT EXISTS `gldefault` (
  `GLDefaultKey` varchar(20) NOT NULL COMMENT 'Key for accessing a G/L Account #',
  `GLAct` varchar(11) NOT NULL COMMENT 'G/L Account #',
  `Description` varchar(200) NOT NULL,
  PRIMARY KEY (`GLDefaultKey`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Default G/L Accounts';

-- Data exporting was unselected.
-- Dumping structure for table act1.gpdoc
CREATE TABLE IF NOT EXISTS `gpdoc` (
  `GPDoc_Id` varchar(36) NOT NULL COMMENT 'Unique Id',
  `GPDoc_No` varchar(25) NOT NULL DEFAULT '0' COMMENT 'GP document number',
  `Doc_Type` enum('Invoice','Return','Credit Memo','Debit Memo','Journal Entry','Payroll','Freight Invoice') NOT NULL DEFAULT 'Invoice' COMMENT 'Document Type',
  `Doc_No` varchar(36) NOT NULL DEFAULT '0' COMMENT 'Sales/RMA No',
  `Doc_Date` date NOT NULL COMMENT 'Date the document was created',
  `Post_Date` date DEFAULT NULL COMMENT 'Date posted in GP',
  `Customer_Id` int(11) DEFAULT NULL COMMENT 'Bill To Customer',
  `Status` enum('Not Sent','Un-Posted','Posted','Voided','Hold') NOT NULL DEFAULT 'Not Sent' COMMENT 'Current Status of Document',
  `SentToGP` tinyint(4) NOT NULL DEFAULT 0 COMMENT '1 if Sent to GP',
  `Source_Type` enum('Sales Order','Shipment','Return','Credit Memo','Debit Memo','Commission','Bonus','Other') NOT NULL DEFAULT 'Sales Order' COMMENT 'Document Type this was base on',
  `SourceDoc_No` varchar(36) NOT NULL DEFAULT '0' COMMENT 'Document this was based on',
  `Sub_Type` enum('Spares','Service','Equipment') NOT NULL,
  `Customer_PO` varchar(25) DEFAULT '' COMMENT 'Customer PO',
  `Ship_Date` date DEFAULT NULL COMMENT 'Date the document was shipped',
  `Shipping_Code` varchar(2) DEFAULT '',
  `Ship_Term` varchar(50) DEFAULT '',
  `FreightPay_Method` varchar(30) NOT NULL DEFAULT 'Billed' COMMENT 'How freight will be paid',
  `ActualFreight` decimal(16,3) NOT NULL DEFAULT 0.000 COMMENT 'Actual Freight',
  `BilledFreight` decimal(16,3) NOT NULL DEFAULT 0.000 COMMENT 'Freight billed to customer',
  `WarrantyFreight` decimal(16,3) NOT NULL DEFAULT 0.000 COMMENT 'Freight for warranty shipments',
  `Payment_Code` varchar(2) DEFAULT '',
  `Pay_Term` varchar(50) DEFAULT '',
  `CODPlus` decimal(10,2) DEFAULT 0.00 COMMENT 'COD + Amount',
  `SalesRep_Code` varchar(3) DEFAULT '',
  `SalesRep_Name` varchar(50) DEFAULT '',
  `IsFreightTaxable` tinyint(4) DEFAULT 0,
  `TaxExemptNo` varchar(15) DEFAULT '' COMMENT 'Tax Exempt No',
  `TaxCode` varchar(10) DEFAULT '' COMMENT 'Link to Tax Table',
  `Tax` decimal(10,2) DEFAULT 0.00 COMMENT 'Only for orders with cc processed',
  `ShipTo_Name` varchar(65) DEFAULT '',
  `Address_1` varchar(61) DEFAULT '',
  `Address_2` varchar(61) DEFAULT '',
  `Address_3` varchar(61) DEFAULT '',
  `City` varchar(35) DEFAULT '',
  `State` varchar(29) DEFAULT '',
  `Zip` varchar(11) DEFAULT '',
  `Country` varchar(61) DEFAULT '',
  `Contact_Person` varchar(60) DEFAULT '',
  `Contact_Phone` varchar(25) DEFAULT '',
  `Notify_Emails` varchar(400) DEFAULT '',
  `Note` text DEFAULT NULL,
  `Currency_Id` varchar(15) DEFAULT 'USD' COMMENT 'Link to Currency',
  `Disputed` tinyint(4) DEFAULT 0 COMMENT 'Invoice in dispute, do not count as past due invoice',
  `ExcludeFromDaysToPayAvg` tinyint(1) DEFAULT 0,
  `Notes` text DEFAULT NULL,
  `Collect` tinyint(1) DEFAULT 0,
  `Description` varchar(30) DEFAULT NULL,
  `AssignedTo` varchar(65) DEFAULT '',
  `Unit_Count` int(11) DEFAULT 0,
  `Active` tinyint(4) NOT NULL DEFAULT 1,
  `CreateDate` datetime DEFAULT NULL,
  `CreatedBy` varchar(20) DEFAULT NULL,
  `ModifiedDate` datetime DEFAULT NULL,
  `ModifiedBy` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`GPDoc_Id`),
  KEY `SourceDoc_No` (`SourceDoc_No`),
  KEY `Doc_No` (`Doc_No`),
  KEY `GPDoc_No` (`GPDoc_No`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='GP Document';

-- Data exporting was unselected.
-- Dumping structure for table act1.gpdocdist
CREATE TABLE IF NOT EXISTS `gpdocdist` (
  `GPDocDist_Id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Unique No',
  `GPDoc_Id` varchar(36) NOT NULL COMMENT 'Links to GP Document',
  `GLAct` varchar(11) DEFAULT NULL,
  `DistributionType` varchar(10) DEFAULT NULL,
  `Value` decimal(16,2) DEFAULT NULL,
  `IsDebit` tinyint(1) DEFAULT NULL,
  `Active` tinyint(4) NOT NULL DEFAULT 1,
  `CreateDate` datetime DEFAULT NULL,
  `CreatedBy` varchar(20) DEFAULT NULL,
  `ModifiedDate` datetime DEFAULT NULL,
  `ModifiedBy` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`GPDocDist_Id`),
  KEY `GPDoc_Id` (`GPDoc_Id`)
) ENGINE=InnoDB AUTO_INCREMENT=9993644 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='G/L Distributions for a GP Doc';

-- Data exporting was unselected.
-- Dumping structure for table act1.gpdocline
CREATE TABLE IF NOT EXISTS `gpdocline` (
  `GPDocLine_Id` varchar(36) NOT NULL COMMENT 'Unique Id',
  `GPDoc_Id` varchar(36) NOT NULL COMMENT 'Link to GPDoc',
  `Line_No` int(11) NOT NULL DEFAULT 0 COMMENT 'Unique Line # for the gp sales doc links to GP line',
  `SourceLine_Id` varchar(36) NOT NULL DEFAULT '0' COMMENT 'Link to source line',
  `GPSite` varchar(10) DEFAULT NULL COMMENT 'Shipping site',
  `Part_No` varchar(30) NOT NULL COMMENT 'Part #',
  `IsNonInventory` tinyint(1) NOT NULL DEFAULT 0 COMMENT '1 if Part is Non-Inventory',
  `Part_Description` varchar(254) DEFAULT '',
  `UOM` varchar(3) DEFAULT '' COMMENT 'Unit of Measure',
  `Qty` decimal(16,3) NOT NULL DEFAULT 0.000 COMMENT 'Quantity for GP Invoice/Return',
  `Price` decimal(16,3) DEFAULT 0.000 COMMENT 'Customer unit price',
  `Discount` decimal(16,3) DEFAULT 0.000 COMMENT 'Customer discount amount each',
  `ListPrice` decimal(16,3) DEFAULT NULL COMMENT 'Part List price each',
  `Cost` decimal(16,3) DEFAULT 0.000 COMMENT 'OMAX Cost each',
  `OtherCharge` decimal(16,3) DEFAULT 0.000 COMMENT 'Use for non-standard charges',
  `IsWarranty` tinyint(1) NOT NULL DEFAULT 0 COMMENT '1 for accounts treated as warranty',
  `COGS_GLAct` varchar(11) NOT NULL COMMENT 'COGS G/L Account',
  `Sales_GLAct` varchar(11) NOT NULL COMMENT 'Sales G/L Account #',
  `SerialNo` varchar(25) DEFAULT '',
  `Note` text DEFAULT NULL,
  `Active` tinyint(4) NOT NULL DEFAULT 1,
  `CreateDate` datetime DEFAULT NULL,
  `CreatedBy` varchar(20) DEFAULT NULL,
  `ModifiedDate` datetime DEFAULT NULL,
  `ModifiedBy` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`GPDocLine_Id`),
  KEY `gpdocline_ibfk_1` (`GPDoc_Id`),
  KEY `SourceLine_Id` (`SourceLine_Id`),
  KEY `idx_part_no` (`Part_No`),
  CONSTRAINT `gpdocline_ibfk_1` FOREIGN KEY (`GPDoc_Id`) REFERENCES `gpdoc` (`GPDoc_Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='GP Document Line';

-- Data exporting was unselected.
-- Dumping structure for table act1.vatinvoice
CREATE TABLE IF NOT EXISTS `vatinvoice` (
  `VatInvoice_Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Unique Id',
  `VatInvoice_YearSeq` int(11) NOT NULL COMMENT 'Vat Invoice #',
  `VatInvoice_Year` int(11) NOT NULL COMMENT 'Vat Invoice Year',
  `GPDoc_No` varchar(25) NOT NULL,
  `Active` tinyint(4) NOT NULL DEFAULT 1,
  `CreateDate` datetime DEFAULT NULL,
  `CreatedBy` varchar(20) DEFAULT NULL,
  `ModifiedDate` datetime DEFAULT NULL,
  `ModifiedBy` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`VatInvoice_Id`),
  KEY `VatInvoice_YearSeq` (`VatInvoice_YearSeq`),
  KEY `VatInvoice_Year` (`VatInvoice_Year`),
  KEY `GPDoc_No` (`GPDoc_No`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Vat Invoice #s';

-- Data exporting was unselected.

-- Dumping database structure for com
DROP DATABASE IF EXISTS `com`;
CREATE DATABASE IF NOT EXISTS `com` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `com`;

-- Dumping structure for function com.GetGlobal
DROP FUNCTION IF EXISTS `GetGlobal`;
DELIMITER //
CREATE DEFINER=`root`@`localhost` FUNCTION `GetGlobal`(Pname varchar(15)) RETURNS float
    READS SQL DATA
    DETERMINISTIC
BEGIN
  Declare val float;
  Select ParamValue into val from com.globalparameters where Name=Pname;
  RETURN val;
end//
DELIMITER ;

-- Dumping structure for table com.globalparameters
CREATE TABLE IF NOT EXISTS `globalparameters` (
  `Line_id` varchar(36) NOT NULL COMMENT 'Guid defining key',
  `Name` varchar(15) NOT NULL COMMENT 'Short name of the variable',
  `Description` mediumtext DEFAULT NULL COMMENT 'Long explaination of effect of variable',
  `ParamValue` float NOT NULL COMMENT 'Value set for current business climate',
  `ModifyBy` varchar(15) DEFAULT NULL COMMENT 'Trigger sets',
  `ModifyDate` datetime DEFAULT NULL COMMENT 'Trigger sets',
  `Category` varchar(15) DEFAULT NULL COMMENT 'For easy sorting of variables',
  PRIMARY KEY (`Line_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Set these parameters according to business conditions';

-- Data exporting was unselected.

-- Dumping database structure for com1
DROP DATABASE IF EXISTS `com1`;
CREATE DATABASE IF NOT EXISTS `com1` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `com1`;

-- Dumping structure for table com1.countriesofworld
CREATE TABLE IF NOT EXISTS `countriesofworld` (
  `CountryName` varchar(50) NOT NULL,
  `2LtrCode` char(2) NOT NULL,
  `3LtrCode` char(3) NOT NULL,
  `CoNumber` char(3) NOT NULL,
  `GeoRegion1` varchar(45) DEFAULT NULL,
  `GeoRegion2` varchar(45) DEFAULT NULL,
  `pardot_country` varchar(75) DEFAULT NULL,
  PRIMARY KEY (`CountryName`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Data exporting was unselected.
-- Dumping structure for table com1.payment_term
CREATE TABLE IF NOT EXISTS `payment_term` (
  `Payment_Code` varchar(2) NOT NULL DEFAULT '' COMMENT 'Payment Code',
  `Company_Type` enum('Customer','Vendor') NOT NULL COMMENT 'Type of company terms are used for',
  `Pay_Term` varchar(50) NOT NULL COMMENT 'Payment Term',
  `DaysToPay` int(11) DEFAULT 0,
  `Active` tinyint(4) NOT NULL DEFAULT 1,
  `CreateDate` datetime DEFAULT NULL,
  `CreatedBy` varchar(20) DEFAULT NULL,
  `ModifiedDate` datetime DEFAULT NULL,
  `ModifiedBy` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`Payment_Code`,`Company_Type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Payment Terms Table';

-- Data exporting was unselected.
-- Dumping structure for table com1.statesofusa
CREATE TABLE IF NOT EXISTS `statesofusa` (
  `StateName` varchar(30) NOT NULL,
  `Abreviation` varchar(2) NOT NULL,
  `StateFIPSCode` varchar(2) DEFAULT NULL,
  PRIMARY KEY (`StateName`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Data exporting was unselected.
-- Dumping structure for table com1.statesofworld
CREATE TABLE IF NOT EXISTS `statesofworld` (
  `CountryName` varchar(50) NOT NULL,
  `Country_ISO_A3` varchar(3) DEFAULT NULL,
  `StateName` varchar(50) NOT NULL,
  `Abbreviation` varchar(4) NOT NULL,
  PRIMARY KEY (`CountryName`,`StateName`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Data exporting was unselected.

-- Dumping database structure for cst1
DROP DATABASE IF EXISTS `cst1`;
CREATE DATABASE IF NOT EXISTS `cst1` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `cst1`;

-- Dumping structure for table cst1.customercontact
CREATE TABLE IF NOT EXISTS `customercontact` (
  `Contact_Id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Unique Id for a Customer Contact',
  `Customer_Id` int(11) DEFAULT NULL COMMENT 'Link to Customer Table',
  `First_Name` varchar(25) DEFAULT NULL COMMENT 'Contact first name',
  `Last_Name` varchar(25) DEFAULT NULL COMMENT 'Contact last name',
  `Email` varchar(200) DEFAULT NULL,
  `Email_Alt` varchar(200) DEFAULT NULL COMMENT 'Alternate Email address for contact',
  `Land_Phone` varchar(25) DEFAULT NULL,
  `Cell_Phone` varchar(25) DEFAULT NULL,
  `Phone_Other` varchar(25) DEFAULT NULL COMMENT 'Other phone #',
  `Fax` varchar(25) DEFAULT NULL,
  `Position` varchar(35) DEFAULT NULL COMMENT 'Position of contact',
  `JobFunctions` set('Owner','President','Management','Maintenance','Programmer','Operator','Buyer','Accounts Payable','Installation Coordinator','Other') DEFAULT NULL,
  `ShipNotify` tinyint(4) DEFAULT 0 COMMENT 'Notify on shipments',
  `Locked` tinyint(4) DEFAULT 0 COMMENT 'If locked on customer admin can make changes',
  `ContactType` set('Electronic Invoice','Month End Statement','Special Invoice Processing') DEFAULT NULL,
  `Notes` text DEFAULT NULL,
  `Active` tinyint(4) DEFAULT 1,
  `CreateDate` datetime DEFAULT NULL,
  `CreatedBy` varchar(20) DEFAULT NULL,
  `ModifiedDate` datetime DEFAULT NULL,
  `ModifiedBy` varchar(20) DEFAULT NULL,
  `last_modified` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
  `index_id` varchar(40) NOT NULL,
  `search_terms` text DEFAULT NULL,
  `search_exclude` tinyint(1) NOT NULL DEFAULT 0,
  PRIMARY KEY (`Contact_Id`),
  KEY `CustomerContact_Customer_Id` (`Customer_Id`)
) ENGINE=InnoDB AUTO_INCREMENT=45270 DEFAULT CHARSET=utf8 COMMENT='Customer Contacts';

-- Data exporting was unselected.
-- Dumping structure for table cst1.service
CREATE TABLE IF NOT EXISTS `service` (
  `Service_No` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Unique # for each onsite service',
  `CustomerCase_Id` int(11) NOT NULL COMMENT 'Link to customer case',
  `ServiceAddress_Id` int(11) NOT NULL COMMENT 'Link to customer address that service is taking place at',
  `Status` enum('Requested','Scheduled','On Hold','Tentative','Completed','Cancelled') NOT NULL DEFAULT 'Requested',
  `ServiceType` varchar(25) NOT NULL COMMENT 'Type of Service',
  `Customer_PO` varchar(40) DEFAULT '' COMMENT 'Customer PO # for billable service',
  `StartDate` date DEFAULT NULL COMMENT 'Date Service will start',
  `EndDate` date DEFAULT NULL COMMENT 'Date Service will end',
  `PrimaryTech` varchar(75) DEFAULT '' COMMENT 'Tech who can edit equip details on report',
  `ChangeHistory` text DEFAULT NULL,
  `Active` tinyint(4) NOT NULL DEFAULT 1,
  `CreateDate` datetime DEFAULT NULL,
  `CreatedBy` varchar(20) DEFAULT NULL,
  `ModifiedDate` datetime DEFAULT NULL,
  `ModifiedBy` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`Service_No`),
  KEY `CustomerCase_Id` (`CustomerCase_Id`)
) ENGINE=InnoDB AUTO_INCREMENT=11016 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Onsite Service';

-- Data exporting was unselected.

-- Dumping database structure for mis1
DROP DATABASE IF EXISTS `mis1`;
CREATE DATABASE IF NOT EXISTS `mis1` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `mis1`;

-- Dumping structure for table mis1.insight_user
CREATE TABLE IF NOT EXISTS `insight_user` (
  `user_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_name` varchar(50) NOT NULL,
  `user_password` char(60) DEFAULT NULL,
  `user_type` enum('employee','distributor','vendor','licensing','warehouse') NOT NULL DEFAULT 'employee',
  `user_first_name` varchar(75) NOT NULL,
  `user_last_name` varchar(75) NOT NULL,
  `federated_user_name` varchar(150) NOT NULL DEFAULT '',
  `is_ad_user` tinyint(1) NOT NULL DEFAULT 0,
  `Active` tinyint(1) NOT NULL DEFAULT 1,
  `InactiveBy` varchar(50) DEFAULT NULL,
  `InactiveDate` datetime DEFAULT NULL,
  `CreatedBy` varchar(50) NOT NULL,
  `CreateDate` datetime NOT NULL,
  `ModifiedBy` varchar(50) DEFAULT NULL,
  `ModifiedDate` datetime DEFAULT NULL,
  PRIMARY KEY (`user_id`),
  UNIQUE KEY `USER_NAME_UNIQ` (`user_name`)
) ENGINE=InnoDB AUTO_INCREMENT=933 DEFAULT CHARSET=utf8 COMMENT='Insight Users';

-- Data exporting was unselected.

-- Dumping database structure for sls1
DROP DATABASE IF EXISTS `sls1`;
CREATE DATABASE IF NOT EXISTS `sls1` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `sls1`;

-- Dumping structure for table sls1.rma
CREATE TABLE IF NOT EXISTS `rma` (
  `RMA_No` varchar(8) NOT NULL,
  `Customer_Id` int(11) DEFAULT 0 COMMENT 'Customer who receives any credits',
  `RMA_Type` enum('Spares','Equipment') NOT NULL DEFAULT 'Spares' COMMENT 'RMA Type',
  `Original_SO_No` varchar(25) DEFAULT '' COMMENT 'Original SO#',
  `Status` enum('Open','Canceled','Closed') DEFAULT 'Open',
  `RMA_Date` date NOT NULL COMMENT 'Date the RMA was created',
  `Reason` varchar(100) DEFAULT '' COMMENT 'Reason for RMA',
  `ShipTo_Customer_Id` int(11) DEFAULT 0 COMMENT 'Customer parts where originally shipped to',
  `ShipTo_Address_Id` int(11) DEFAULT 0,
  `ShipTo_Name` varchar(65) DEFAULT '',
  `ShipTo_Address_1` varchar(61) DEFAULT '',
  `ShipTo_Address_2` varchar(61) DEFAULT '',
  `ShipTo_Address_3` varchar(61) DEFAULT '',
  `ShipTo_City` varchar(35) DEFAULT '',
  `ShipTo_State` varchar(29) DEFAULT '',
  `ShipTo_Zip` varchar(11) DEFAULT '',
  `ShipTo_Country` varchar(61) DEFAULT '',
  `Taxable` tinyint(4) DEFAULT 0 COMMENT 'Is Address Taxable',
  `TaxExemptNo` varchar(15) DEFAULT '' COMMENT 'Tax Exempt No',
  `TaxCode` varchar(7) DEFAULT '' COMMENT 'Link to Tax Table',
  `Contact_Id` int(11) DEFAULT 0 COMMENT 'Contact requesting rma',
  `Contact_First_Name` varchar(25) DEFAULT '',
  `Contact_Last_Name` varchar(25) DEFAULT '',
  `Contact_Phone` varchar(25) DEFAULT '',
  `Contact_Email` varchar(200) DEFAULT '',
  `Contact_Fax` varchar(25) DEFAULT '',
  `SalesRep_Code` varchar(3) DEFAULT NULL,
  `SalesRep_Name` varchar(50) DEFAULT NULL,
  `FreightCredit` decimal(13,2) DEFAULT 0.00 COMMENT 'option credit for Freight',
  `Replacement_SO_No` varchar(8) DEFAULT '' COMMENT 'SO # for any replacements were sent',
  `CustomerCase_Id` int(11) DEFAULT 0 COMMENT '(optional) link to a customer case',
  `Note` text DEFAULT NULL,
  `ReceivedDate` datetime DEFAULT NULL COMMENT 'Date package arrived into receiving',
  `ReceivedBy` varchar(20) DEFAULT '' COMMENT 'Receiving user who received package',
  `Currency_Id` varchar(15) DEFAULT 'USD' COMMENT 'Link to Currency',
  `ChangeHistory` text DEFAULT NULL COMMENT 'Details of changes made',
  `Active` tinyint(4) NOT NULL DEFAULT 1,
  `CreateDate` datetime DEFAULT NULL,
  `CreatedBy` varchar(20) DEFAULT NULL,
  `ModifiedDate` datetime DEFAULT NULL,
  `ModifiedBy` varchar(20) DEFAULT NULL,
  `last_modified` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
  `index_id` varchar(40) NOT NULL,
  `search_terms` text DEFAULT NULL,
  `search_exclude` tinyint(1) NOT NULL DEFAULT 0,
  PRIMARY KEY (`RMA_No`),
  KEY `Original_SO_No` (`Original_SO_No`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='RMA';

-- Data exporting was unselected.
-- Dumping structure for table sls1.rmaline
CREATE TABLE IF NOT EXISTS `rmaline` (
  `RMALine_Id` varchar(36) NOT NULL COMMENT 'Unique Id for a RMA Line',
  `RMA_No` varchar(8) NOT NULL DEFAULT '0' COMMENT 'Link to RMA',
  `Line_No` int(11) NOT NULL DEFAULT 0,
  `RMA_Qty` decimal(16,3) NOT NULL DEFAULT 0.000 COMMENT 'RMA Quantity',
  `Credited_Qty` decimal(16,3) NOT NULL DEFAULT 0.000 COMMENT 'Quantity given credit for',
  `Plan` varchar(100) DEFAULT '' COMMENT 'Summary name for steps that occur with this RMA',
  `Part_No` varchar(30) NOT NULL DEFAULT '' COMMENT 'Part #',
  `IsNonInventory` tinyint(1) NOT NULL DEFAULT 0 COMMENT '1 if Part is Non-Inventory',
  `Part_Description` varchar(254) DEFAULT '',
  `UOM` varchar(3) DEFAULT '' COMMENT 'Unit of Measure',
  `Due_Date` date DEFAULT NULL COMMENT 'Date part is due',
  `SoldPrice` decimal(16,3) DEFAULT 0.000 COMMENT 'Price original paid',
  `SoldPrice_Currency_Id` varchar(15) DEFAULT 'USD' COMMENT 'Link to Currency',
  `Credit` decimal(16,3) DEFAULT 0.000 COMMENT 'Customer credit price each',
  `Cost` decimal(16,3) DEFAULT 0.000 COMMENT 'OMAX Cost each',
  `GLSalesAccount_Key` varchar(20) DEFAULT '' COMMENT 'Key for accessing a G/L Sales/COGS Pair',
  `SerialNo` varchar(25) DEFAULT '',
  `Note` text DEFAULT NULL,
  `ShippedPart_No` varchar(30) DEFAULT '' COMMENT 'Used for 2.2 Mis-Shipped Parts, this is what the customer was really shipped',
  `Active` tinyint(4) NOT NULL DEFAULT 1,
  `CreateDate` datetime DEFAULT NULL,
  `CreatedBy` varchar(20) DEFAULT NULL,
  `ModifiedDate` datetime DEFAULT NULL,
  `ModifiedBy` varchar(20) DEFAULT NULL,
  `last_modified` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
  `index_id` varchar(40) NOT NULL,
  `search_terms` text DEFAULT NULL,
  `search_exclude` tinyint(1) NOT NULL DEFAULT 0,
  PRIMARY KEY (`RMALine_Id`),
  KEY `RMA_No` (`RMA_No`),
  KEY `Part_No` (`Part_No`),
  CONSTRAINT `rmaline_ibfk_1` FOREIGN KEY (`RMA_No`) REFERENCES `rma` (`RMA_No`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='RMA Line';

-- Data exporting was unselected.
-- Dumping structure for table sls1.rmalinestep
CREATE TABLE IF NOT EXISTS `rmalinestep` (
  `RMALineStep_Id` varchar(36) NOT NULL COMMENT 'Unique Id ',
  `RMALine_Id` varchar(36) NOT NULL DEFAULT '0' COMMENT 'Link to RMA Line',
  `Step_No` int(11) NOT NULL DEFAULT 0,
  `Step` varchar(50) NOT NULL DEFAULT '' COMMENT 'Description of Step',
  `Doc_Type` enum('Receipt','Credit','Sales Order','WO','Transfer','OTX','Evaluate','Custom') NOT NULL COMMENT 'What document type is associated with this step',
  `Doc_Id` varchar(36) DEFAULT '' COMMENT 'Link to document this step applies to',
  `Step_Qty` decimal(16,3) NOT NULL DEFAULT 0.000 COMMENT 'Qty that applies to this step',
  `Status` enum('Planned','In Progress','Complete') NOT NULL DEFAULT 'Planned' COMMENT 'Status of step',
  `CompleteDate` datetime DEFAULT NULL,
  `CompletedBy` varchar(20) DEFAULT '',
  `Details` text DEFAULT NULL COMMENT 'Additional details that depend on the step type',
  `Note` text DEFAULT NULL,
  `Active` tinyint(4) NOT NULL DEFAULT 1,
  `CreateDate` datetime DEFAULT NULL,
  `CreatedBy` varchar(20) DEFAULT NULL,
  `ModifiedDate` datetime DEFAULT NULL,
  `ModifiedBy` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`RMALineStep_Id`),
  KEY `RMALine_Id` (`RMALine_Id`),
  CONSTRAINT `rmalinestep_ibfk_1` FOREIGN KEY (`RMALine_Id`) REFERENCES `rmaline` (`RMALine_Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='RMA Line Step';

-- Data exporting was unselected.
-- Dumping structure for table sls1.so_detail
CREATE TABLE IF NOT EXISTS `so_detail` (
  `SO_No` int(11) NOT NULL DEFAULT 0 COMMENT 'Link to Sales Order Header',
  `Line_No` int(11) NOT NULL DEFAULT 0 COMMENT 'Line #',
  `Part_No` varchar(30) NOT NULL COMMENT 'Part #',
  `IsNonInventory` tinyint(1) NOT NULL DEFAULT 0 COMMENT '1 if Part is Non-Inventory',
  `Part_Description` varchar(254) DEFAULT NULL,
  `NonInvItem_Type` enum('Note','Invoice Only Item') DEFAULT NULL COMMENT 'If this is a non-inventory item what is it',
  `UOM` varchar(3) DEFAULT NULL COMMENT 'Unit of Measure',
  `Order_Qty` decimal(16,3) NOT NULL DEFAULT 1.000 COMMENT 'Quantity Ordered',
  `Ship_Qty` decimal(16,3) NOT NULL DEFAULT 0.000 COMMENT 'Quantity Shipped',
  `Orig_Due_Date` date DEFAULT NULL,
  `Due_Date` date DEFAULT NULL COMMENT 'Date part is due',
  `Price` decimal(16,3) DEFAULT 0.000 COMMENT 'Customer price each',
  `Discount` decimal(16,3) DEFAULT 0.000 COMMENT 'Customer discount amount each',
  `Reason` varchar(100) DEFAULT '' COMMENT 'Reasons for free parts',
  `CustomerDiscount` decimal(16,3) DEFAULT 0.000 COMMENT 'Base customer discount amount each',
  `HasCustomDiscount` tinyint(4) DEFAULT 0 COMMENT 'True if user has entered the discount',
  `ListPrice` decimal(16,3) DEFAULT NULL COMMENT 'Part List price each',
  `Cost` decimal(16,3) DEFAULT 0.000 COMMENT 'OMAX Cost each',
  `CustomsPrice` decimal(16,3) DEFAULT NULL COMMENT 'Price for Commerical Invoice',
  `GLSalesAccount_Key` varchar(20) DEFAULT NULL COMMENT 'Key for accessing a G/L Sales/COGS Pair',
  `MPSKey` int(11) DEFAULT NULL COMMENT 'Link to Machine Production Schedule',
  `ConfigNote` varchar(100) DEFAULT NULL COMMENT 'Configuration Note (Voltage)',
  `SerialNo` varchar(25) DEFAULT NULL,
  `SubComponent_SerialNos` varchar(200) DEFAULT NULL,
  `InstallOn_SerialNo` varchar(25) DEFAULT NULL,
  `Note` text DEFAULT NULL,
  `Pick_Location_Id` int(11) DEFAULT 0 COMMENT 'If set, the planned pick will be from this location instead of the primary',
  `Pick_Store` int(11) DEFAULT 0 COMMENT 'If set, the planned pick will be from this store instead of the primary (for offsite picks)',
  `Pick_Location` varchar(15) DEFAULT '' COMMENT 'If set, the planned pick will be from this location instead of the primary (for offsite picks)',
  `DoNotShipEarly` tinyint(1) DEFAULT 0 COMMENT 'If 1 the line is not to ship before the due date',
  `Cnf_Id` varchar(36) DEFAULT '' COMMENT 'Linked to configuration builder',
  `SODetail_Id` varchar(36) NOT NULL,
  `Validated` tinyint(4) NOT NULL DEFAULT 0 COMMENT '1 if line data has been validated',
  `Active` tinyint(4) NOT NULL DEFAULT 1,
  `CreateDate` datetime DEFAULT NULL,
  `CreatedBy` varchar(20) DEFAULT NULL,
  `ModifiedDate` datetime DEFAULT NULL,
  `ModifiedBy` varchar(20) DEFAULT NULL,
  `last_modified` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
  `index_id` varchar(40) NOT NULL,
  `search_terms` text DEFAULT NULL,
  `search_exclude` tinyint(1) NOT NULL DEFAULT 0,
  PRIMARY KEY (`SO_No`,`Line_No`,`SODetail_Id`),
  UNIQUE KEY `SODetail_Id_UNIQUE` (`SODetail_Id`),
  KEY `Part_No` (`Part_No`),
  KEY `Cnf_Id` (`Cnf_Id`),
  KEY `MPSKey` (`MPSKey`),
  KEY `SerialNo` (`SerialNo`),
  CONSTRAINT `so_detail_ibfk_1` FOREIGN KEY (`SO_No`) REFERENCES `so_master` (`SO_No`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Sales Order Detail';

-- Data exporting was unselected.
-- Dumping structure for table sls1.so_master
CREATE TABLE IF NOT EXISTS `so_master` (
  `SO_No` int(11) NOT NULL DEFAULT 0 COMMENT 'Unique # for each Order Type',
  `Rev` varchar(2) DEFAULT '' COMMENT 'Revision is order sent multiple times to shipping',
  `Customer_Id` int(11) DEFAULT NULL COMMENT 'Bill To Customer',
  `Order_Type` enum('Sales Order','Quote') NOT NULL DEFAULT 'Sales Order' COMMENT 'Order type: Quote,Sales Order',
  `Sub_Type` enum('Spares','Service','Equipment') NOT NULL DEFAULT 'Spares' COMMENT 'Spares/Service/Equipment',
  `Status` enum('Draft','Open','Canceled','Closed') DEFAULT NULL,
  `Revising` tinyint(1) DEFAULT 0 COMMENT 'Order is being revised',
  `AccountingHold` tinyint(1) DEFAULT 0 COMMENT 'Accounting hold in place do not ship',
  `Released` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0 if Status = New or Canceled',
  `Release_Date` datetime DEFAULT NULL COMMENT 'Date/Time document initially released',
  `FreightPay_Method` varchar(30) NOT NULL DEFAULT 'Billed' COMMENT 'How freight will be paid',
  `ReleasedByRep` varchar(20) DEFAULT '' COMMENT 'Rep who released order',
  `PickPrintedBy` varchar(20) DEFAULT '' COMMENT 'user who printed poster',
  `PickPrinted_Date` datetime DEFAULT NULL COMMENT 'Date/Time poster was printed',
  `Entered_By` varchar(20) DEFAULT NULL COMMENT 'User Id who created the order',
  `Order_Source` enum('Fax','Email','Phone','Web') DEFAULT 'Phone' COMMENT 'How order was received',
  `Report_Flags` set('QA Inspection Required','Tech Onsite','Urgent','Must Ship Complete','Ok to Ship Partial','Customer Down','Engineering Review','Technician Required','Two Shipments','Ship As Available') DEFAULT NULL COMMENT 'Report Flags',
  `Order_Date` date NOT NULL COMMENT 'Date the order was created',
  `Customer_PO` varchar(25) DEFAULT NULL COMMENT 'Customer PO',
  `Payment_Code` varchar(2) DEFAULT NULL,
  `Pay_Term` varchar(50) DEFAULT NULL,
  `Shipping_Code` varchar(2) DEFAULT NULL,
  `Ship_Term` varchar(50) DEFAULT NULL,
  `IncoTerm` varchar(3) DEFAULT NULL,
  `Port` varchar(200) DEFAULT NULL,
  `Shipping_Ref` varchar(30) DEFAULT NULL COMMENT 'UPS #, FedEx #',
  `Backorder_Shipping_Code` varchar(2) DEFAULT NULL,
  `ShipTo_Customer_Id` int(11) DEFAULT NULL,
  `ShipTo_Address_Id` int(11) DEFAULT NULL,
  `ShipTo_Name` varchar(65) DEFAULT NULL,
  `ShipTo_Address_1` varchar(61) DEFAULT NULL,
  `ShipTo_Address_2` varchar(61) DEFAULT NULL,
  `ShipTo_Address_3` varchar(61) DEFAULT NULL,
  `ShipTo_City` varchar(35) DEFAULT NULL,
  `ShipTo_State` varchar(29) DEFAULT NULL,
  `ShipTo_Zip` varchar(11) DEFAULT NULL,
  `ShipTo_Country` varchar(61) DEFAULT NULL,
  `ShipAddressVerifiedDate` datetime DEFAULT NULL,
  `ShipAddressVerifiedBy` varchar(20) DEFAULT NULL,
  `DeliveryInstr` varchar(100) DEFAULT NULL COMMENT 'Delivery Instructions',
  `PO_Reference` varchar(25) DEFAULT NULL COMMENT 'Reference PO for Shipping Label',
  `ShipTo_Contact_Id` int(11) DEFAULT NULL COMMENT 'Link to Ship To Contact',
  `ShipTo_First_Name` varchar(25) DEFAULT NULL,
  `ShipTo_Last_Name` varchar(25) DEFAULT NULL,
  `ShipTo_Phone` varchar(25) DEFAULT NULL,
  `ShipTo_Email` varchar(500) DEFAULT NULL,
  `BillTo_Address_Id` int(11) DEFAULT NULL,
  `BillTo_Name` varchar(65) DEFAULT NULL,
  `BillTo_Address_1` varchar(61) DEFAULT NULL,
  `BillTo_Address_2` varchar(61) DEFAULT NULL,
  `BillTo_Address_3` varchar(61) DEFAULT NULL,
  `BillTo_City` varchar(35) DEFAULT NULL,
  `BillTo_State` varchar(29) DEFAULT NULL,
  `BillTo_Zip` varchar(11) DEFAULT NULL,
  `BillTo_Country` varchar(61) DEFAULT NULL,
  `Taxable` tinyint(4) DEFAULT NULL COMMENT 'Is Address Taxable',
  `TaxExemptNo` varchar(15) DEFAULT NULL COMMENT 'Tax Exempt No',
  `TaxCode` varchar(7) DEFAULT NULL COMMENT 'Link to Tax Table',
  `Contact_Id` int(11) DEFAULT NULL COMMENT 'Ship To Contact',
  `Contact_First_Name` varchar(25) DEFAULT NULL,
  `Contact_Last_Name` varchar(25) DEFAULT NULL,
  `Contact_Phone` varchar(25) DEFAULT NULL,
  `Contact_Email` varchar(200) DEFAULT NULL,
  `Contact_Fax` varchar(25) DEFAULT NULL,
  `Note` text DEFAULT NULL,
  `CommercialInvNote` text DEFAULT NULL,
  `NoteNotPrinted` text DEFAULT NULL,
  `SOReport_Printed` tinyint(4) NOT NULL DEFAULT 0,
  `InstallAt_Customer_Id` int(11) DEFAULT NULL,
  `Install_Contact_Id` int(11) DEFAULT NULL COMMENT 'Link to Install Contact',
  `Install_First_Name` varchar(25) DEFAULT NULL,
  `Install_Last_Name` varchar(25) DEFAULT NULL,
  `Install_Phone` varchar(25) DEFAULT NULL,
  `Install_Email` varchar(200) DEFAULT NULL,
  `InstallBy_Customer_Id` int(11) DEFAULT NULL,
  `Hold_Release_History` text DEFAULT NULL COMMENT 'User/dates/notes an accounting hold was released',
  `CODPlus` decimal(10,2) DEFAULT 0.00 COMMENT 'COD + Amount',
  `Freight` decimal(10,2) DEFAULT 0.00 COMMENT 'Freight for order if pre-set',
  `FreightIsEstimate` tinyint(4) DEFAULT 0 COMMENT 'If 1 Freight is an estimate only and will not be passed to shipping',
  `EstimatedTax` decimal(16,3) DEFAULT 0.000,
  `CCNo` varchar(128) DEFAULT NULL COMMENT 'CC # Encrypted',
  `CCExpMo` varchar(2) DEFAULT NULL COMMENT 'CC Exp Month',
  `CCExpYr` varchar(2) DEFAULT NULL COMMENT 'CC Exp Year',
  `CCCode` varchar(4) DEFAULT NULL COMMENT 'CC Code',
  `CCHolder` varchar(60) DEFAULT NULL COMMENT 'CC Holder Name',
  `CCReceiptTo` varchar(60) DEFAULT NULL COMMENT 'CC Receipt to fax/email',
  `CCProcessed` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'CC Processed',
  `SalesRep_Code` varchar(3) DEFAULT NULL,
  `SalesRep_Name` varchar(50) DEFAULT NULL,
  `PaymentStatus` enum('Test','Crate','Ship') DEFAULT NULL,
  `DeliverTo` text DEFAULT NULL COMMENT 'For when a 3rd address is needed',
  `CustomerCase_Id` int(11) DEFAULT 0 COMMENT '(optional) link to a customer case',
  `Rigger_Company` varchar(45) DEFAULT '',
  `Rigger_Contact` varchar(45) DEFAULT '',
  `Rigger_Phone` varchar(100) DEFAULT '',
  `Rigger_Email` varchar(100) DEFAULT NULL,
  `ProjectNo` int(10) DEFAULT NULL COMMENT 'Filled in if a custom engineering request is made',
  `InspectionRequired` tinyint(4) DEFAULT 0,
  `InspectionDate` date DEFAULT NULL,
  `InspectionNote` varchar(500) DEFAULT NULL,
  `Financed` enum('No','Loan','Leased','Contract','OMAX') DEFAULT NULL,
  `OrderDiscount` decimal(16,2) DEFAULT 0.00,
  `DiscountType` varchar(30) DEFAULT '',
  `DiscountOnInvoiceOnly` tinyint(4) DEFAULT 1,
  `Validated` tinyint(4) NOT NULL DEFAULT 0 COMMENT '1 if line data has been validated',
  `Currency_Id` varchar(15) DEFAULT 'USD' COMMENT 'Link to Currency',
  `ConfigurationNoticeSent` tinyint(4) DEFAULT 0,
  `Garnet` text DEFAULT NULL,
  `ChangeHistory` text DEFAULT NULL COMMENT 'Details of changes made',
  `Active` tinyint(4) NOT NULL DEFAULT 1,
  `CreateDate` datetime DEFAULT NULL,
  `CreatedBy` varchar(20) DEFAULT NULL,
  `ModifiedDate` datetime DEFAULT NULL,
  `ModifiedBy` varchar(20) DEFAULT NULL,
  `last_modified` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
  `index_id` varchar(40) NOT NULL,
  `search_terms` text DEFAULT NULL,
  `search_exclude` tinyint(1) NOT NULL DEFAULT 0,
  PRIMARY KEY (`SO_No`),
  UNIQUE KEY `SO_No` (`SO_No`),
  KEY `Status` (`Status`),
  KEY `Released` (`Released`),
  KEY `Active` (`Active`),
  KEY `Order_Type` (`Order_Type`),
  KEY `Sub_Type` (`Sub_Type`),
  KEY `AccountingHold` (`AccountingHold`),
  KEY `Customer_Id` (`Customer_Id`),
  KEY `ShipTo_Customer_Id` (`ShipTo_Customer_Id`),
  KEY `InstallAt_Customer_Id` (`InstallAt_Customer_Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Sales Order Master';

-- Data exporting was unselected.
-- Dumping structure for table sls1.so_payterm
CREATE TABLE IF NOT EXISTS `so_payterm` (
  `SOPayTerm_Id` int(11) NOT NULL AUTO_INCREMENT,
  `SO_No` int(10) NOT NULL COMMENT 'SO #',
  `Equip_Pay_Term` varchar(250) NOT NULL DEFAULT '',
  `Deposit_Pct` int(11) DEFAULT 0,
  `Deposit_Amount` decimal(16,3) DEFAULT 0.000,
  `Estimated_Receipt_Date` date DEFAULT NULL,
  `Active` tinyint(1) NOT NULL DEFAULT 1,
  `CreatedBy` varchar(16) NOT NULL,
  `CreateDate` datetime NOT NULL,
  `ModifiedBy` varchar(16) DEFAULT NULL,
  `ModifiedDate` datetime DEFAULT NULL,
  PRIMARY KEY (`SOPayTerm_Id`)
) ENGINE=InnoDB AUTO_INCREMENT=4804 DEFAULT CHARSET=utf8;

-- Data exporting was unselected.
