--
-- Table structure for table `INVOICE`
--

DROP TABLE IF EXISTS `INVOICE`;
CREATE TABLE `INVOICE` (
  `INVNO` int(11) NOT NULL AUTO_INCREMENT,
  `INVOICE` varchar(16) COLLATE utf8_estonian_ci NOT NULL,
  `CUSTCODE` varchar(20) COLLATE utf8_estonian_ci NOT NULL,
  `TYPE` int(11) NOT NULL,
  `INVOICEDATE` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `CUSTNAME` varchar(40) COLLATE utf8_estonian_ci DEFAULT NULL,
  `PHONE` varchar(25) COLLATE utf8_estonian_ci DEFAULT NULL,
  `EMAIL` varchar(40) COLLATE utf8_estonian_ci DEFAULT NULL,
  `ADDRESS1` varchar(40) COLLATE utf8_estonian_ci DEFAULT NULL,
  `ADDRESS2` varchar(40) COLLATE utf8_estonian_ci DEFAULT NULL,
  `ADDRESS3` varchar(40) COLLATE utf8_estonian_ci DEFAULT NULL,
  `ADDRESS4` varchar(40) COLLATE utf8_estonian_ci DEFAULT NULL,
  `ADDRESS5` varchar(40) COLLATE utf8_estonian_ci DEFAULT NULL,
  `COMMENT` varchar(200) COLLATE utf8_estonian_ci NOT NULL,
  `OINFO` varchar(200) COLLATE utf8_estonian_ci DEFAULT NULL,
  `REFNUM` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
  `AMOUNT` decimal(18,4) DEFAULT NULL,
  `VATAMOUNT` decimal(18,4) DEFAULT NULL,
  `STOCKNO` smallint(6) DEFAULT NULL,
  `CAUSENO` smallint(6) DEFAULT NULL,
  `CUSTPERSONNO` smallint(6) DEFAULT NULL,
  `TABLENO` smallint(6) DEFAULT NULL,
  PRIMARY KEY (`INVNO`),
  UNIQUE KEY `INVOICE` (`INVOICE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_estonian_ci;

--
-- Table structure for table `OUTITEMS`
--

DROP TABLE IF EXISTS `OUTITEMS`;
CREATE TABLE `OUTITEMS` (
  `INVNO` int(11) NOT NULL,
  `LINENO` int(11) NOT NULL,
  `ARTNO` int(11) NOT NULL,
  `QTY` decimal(18,4) NOT NULL,
  `AMOUNT` decimal(18,4) NOT NULL,
  `VATAMOUNT` decimal(18,4) DEFAULT NULL,
  `RCOMMENT` varchar(200) COLLATE utf8_estonian_ci DEFAULT NULL,
  `SIZENO` smallint(6) DEFAULT NULL,
  PRIMARY KEY (`INVNO`,`LINENO`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_estonian_ci;

--
-- Table structure for table `PAYMENTS`
--

DROP TABLE IF EXISTS `PAYMENTS`;
CREATE TABLE `PAYMENTS` (
  `INVNO` int(11) NOT NULL,
  `LINENO` int(11) NOT NULL,
  `AMOUNT` decimal(18,4) NOT NULL,
  `PAYDATE` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `PAYDOC` varchar(16) COLLATE utf8_estonian_ci NOT NULL,
  `CAUSENO` smallint(6) DEFAULT NULL,
  PRIMARY KEY (`INVNO`,`LINENO`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_estonian_ci;

--
-- Table structure for table `TRANS_LOG`
--

DROP TABLE IF EXISTS `TRANS_LOG`;
CREATE TABLE `TRANS_LOG` (
  `TRANS_LOG_ID` bigint(20) NOT NULL AUTO_INCREMENT,
  `TABLE_NAME` varchar(31) COLLATE utf8_estonian_ci NOT NULL,
  `ID` int(11) NOT NULL,
  `EVENT_CODE` varchar(1) COLLATE utf8_estonian_ci NOT NULL,
  `EVENT_TIME` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `RETRY_COUNT` smallint(6) NOT NULL DEFAULT 0,
  PRIMARY KEY (`TRANS_LOG_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=1008 DEFAULT CHARSET=utf8 COLLATE=utf8_estonian_ci;
