DROP TABLE IF EXISTS `orderdiscountcode`;
CREATE TABLE `orderdiscountcode` (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `code` varchar(20) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `accountCodeRevenue` varchar(10) NOT NULL DEFAULT '',
  `accountCodeCost` varchar(10) NOT NULL DEFAULT '',
  `active` tinyint(1) NOT NULL DEFAULT 1,
  `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
  `createdById` int(10) UNSIGNED NOT NULL DEFAULT 0 ,
  `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `updatedById` int(10) UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  INDEX `accountCodeRevenue` (`accountCodeRevenue`) USING BTREE,
  INDEX `accountCodeCOst` (`accountCodeCost`) USING BTREE,
  INDEX `name` (`name`) USING BTREE,
  INDEX `code` (`code`) USING BTREE
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `orderdiscount`;
CREATE TABLE `orderdiscount` (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `orderId` int(10) NULL DEFAULT 0,
  `orderDiscountCodeId` int(10) NOT NULL DEFAULT 0,
  `supplierInvNo` varchar(50) NULL DEFAULT '',
  `amount` double(10,2) NOT NULL DEFAULT 0.00,
  `syncedWithXero` TINYINT(1) NOT NULL DEFAULT 0,
  `active` tinyint(1) NOT NULL DEFAULT 1,
  `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
  `createdById` int(10) UNSIGNED NOT NULL DEFAULT 0 ,
  `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `updatedById` int(10) UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  INDEX `orderId` (`orderId`) USING BTREE,
  INDEX `orderDiscountCodeId` (`orderDiscountCodeId`) USING BTREE,
  INDEX `supplierInvNo` (`supplierInvNo`) USING BTREE,
  INDEX `syncedWithXero` (`syncedWithXero`) USING BTREE,
  INDEX `amount` (`amount`) USING BTREE
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
