-- http://www.phpmyadmin.net
--


--
-- Database: `iaccountdb`
--

-- --------------------------------------------------------

--
-- Table structure for table `acount_type`
--

CREATE TABLE IF NOT EXISTS `acount_type` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `accountTypeName` varchar(64) CHARACTER SET utf8 NOT NULL,
  `createdBy` int(11) NOT NULL,
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `chat`
--

CREATE TABLE IF NOT EXISTS `chat` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `to` varchar(50) NOT NULL,
  `from` varchar(50) NOT NULL,
  `message` text NOT NULL,
  `sent` datetime NOT NULL,
  `recd` datetime NOT NULL,
  `createdID` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`),
  KEY `to` (`to`),
  KEY `from` (`from`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `chats`
--

CREATE TABLE IF NOT EXISTS `chats` (
  `id` int(5) unsigned NOT NULL AUTO_INCREMENT,
  `message` text NOT NULL,
  `time` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;

-- --------------------------------------------------------

--
-- Table structure for table `ci_sessions`
--

CREATE TABLE IF NOT EXISTS `ci_sessions` (
  `session_id` varchar(40) NOT NULL DEFAULT '0',
  `ip_address` varchar(16) NOT NULL DEFAULT '0',
  `user_agent` varchar(50) NOT NULL,
  `last_activity` int(10) unsigned NOT NULL DEFAULT '0',
  `user_data` text NOT NULL,
  PRIMARY KEY (`session_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `ci_users`
--

CREATE TABLE IF NOT EXISTS `ci_users` (
  `user_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_name` varchar(255) NOT NULL,
  `user_email` varchar(255) NOT NULL,
  `user_password` varchar(255) NOT NULL,
  `registered_date` datetime NOT NULL,
  `status` int(5) NOT NULL,
  `online` int(5) NOT NULL,
  PRIMARY KEY (`user_id`,`user_email`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `company`
--

CREATE TABLE IF NOT EXISTS `company` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyName` varchar(128) NOT NULL,
  `companyNo` varchar(16) NOT NULL,
  `incorporateDate` date NOT NULL,
  `businessTypeID` int(11) NOT NULL,
  `line1` varchar(128) NOT NULL,
  `line2` varchar(128) NOT NULL,
  `line3` varchar(128) NOT NULL,
  `city` varchar(128) NOT NULL,
  `companyPostCode` varchar(8) NOT NULL,
  `companyStateID` int(11) NOT NULL,
  `phoneNo` varchar(16) NOT NULL,
  `faxNo` varchar(16) NOT NULL,
  `email` varchar(32) NOT NULL,
  `website` varchar(32) NOT NULL,
  `uploadLogo` varchar(64) NOT NULL,
  `currencyID` int(11) NOT NULL,
  `languageID` int(11) NOT NULL,
  `countryID` int(11) NOT NULL,
  `muslimShareholder` double NOT NULL,
  `gstRegisteredNo` varchar(16) NOT NULL,
  `gstRegisteredDate` date DEFAULT NULL,
  `gstSubmissionBuffer` int(16) NOT NULL,
  `taxablePeriod` smallint(6) NOT NULL,
  `masterMSIC` INT(12) NOT NULL,
  `dateFormat` int(16) NOT NULL DEFAULT '1',
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(6) NOT NULL,
  `keyCode` varchar(128) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_acct_group_bak`
--

CREATE TABLE IF NOT EXISTS `comp_acct_group_bak` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `acctTypeID` int(11) NOT NULL,
  `acctGroupName` varchar(128) NOT NULL,
  `acctCode` char(9) NOT NULL,
  `orderNo` int(11) NOT NULL,
  `parentID` int(11) NOT NULL,
  `title` tinyint(1) DEFAULT '0',
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `refID` int(11) NOT NULL COMMENT '_ref_acct_group.ID',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1023 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_acct_type`
--

CREATE TABLE IF NOT EXISTS `comp_acct_type` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `acctTypeName` varchar(128) NOT NULL,
  `acctClass` smallint(6) NOT NULL,
  `balance` smallint(1) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_acc_det`
--

CREATE TABLE IF NOT EXISTS `comp_acc_det` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) DEFAULT NULL,
  `acctGroupID` int(11) DEFAULT NULL,
  `acctID` int(11) DEFAULT NULL,
  `year` int(11) DEFAULT NULL,
  `period` varchar(2) DEFAULT NULL,
  `amountdr` double DEFAULT NULL,
  `amountcr` double DEFAULT NULL,
  `total` double DEFAULT '0',
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `is_delete` smallint(6) DEFAULT NULL,
  PRIMARY KEY (`ID`),
  KEY `Index 2` (`companyID`,`acctID`,`year`,`period`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=774 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_address`
--

CREATE TABLE IF NOT EXISTS `comp_address` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `addressName` varchar(128) NOT NULL,
  `line1` varchar(128) NOT NULL,
  `line2` varchar(128) NOT NULL,
  `line3` varchar(128) NOT NULL,
  `city` varchar(128) NOT NULL,
  `postCode` varchar(8) NOT NULL,
  `stateID` int(11) NOT NULL,
  `countryID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` tinyint(1) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=51 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_alert_table`
--

CREATE TABLE IF NOT EXISTS `comp_alert_table` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `acctTypeID` int(11) NOT NULL,
  `badRelief` tinyint(1) NOT NULL,
  `registration` tinyint(1) NOT NULL,
  `gstReturn` tinyint(1) NOT NULL,
  `accountReceivable` tinyint(1) NOT NULL,
  `accountPayable` tinyint(1) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_bank`
--

CREATE TABLE IF NOT EXISTS `comp_bank` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `bankName` varchar(64) NOT NULL,
  `bankShortName` varchar(8) NOT NULL,
  `branch` varchar(64) NOT NULL,
  `bankAccountNo` varchar(32) NOT NULL,
  `currentBalance` double NOT NULL,
  `line1` varchar(64) NOT NULL,
  `line2` varchar(64) NOT NULL,
  `line3` varchar(64) NOT NULL,
  `city` varchar(64) NOT NULL,
  `PostCode` varchar(8) NOT NULL,
  `bankStateID` int(11) NOT NULL,
  `bankCountryID` int(11) NOT NULL,
  `attention` varchar(32) NOT NULL,
  `phoneNumber1` varchar(64) NOT NULL,
  `phoneNumber2` varchar(64) NOT NULL,
  `fax` varchar(64) NOT NULL,
  `generalNote` varchar(255) NOT NULL,
  `creditLimit` int(8) NOT NULL,
  `creditLimitAlert` tinyint(1) NOT NULL,
  `linkAccountID` int(11) NOT NULL,
  `createdDate` date NOT NULL,
  `currencyID` int(11) NOT NULL,
  `email` varchar(32) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` int(16) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=81 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_bank_reconcile`
--

CREATE TABLE IF NOT EXISTS `comp_bank_reconcile` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `bankLinkAcctCode` int(11) NOT NULL,
  `reconcileDate` date NOT NULL,
  `reconcileBalance` double NOT NULL,
  `concileDebit` double NOT NULL,
  `concileCredit` double NOT NULL,
  `glBalance` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=62 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_bank_reconcile_track_back`
--

CREATE TABLE IF NOT EXISTS `comp_bank_reconcile_track_back` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `reconID` int(11) NOT NULL,
  `transDate` date NOT NULL,
  `refNo` varchar(255) NOT NULL,
  `description` varchar(255) NOT NULL,
  `debitAmount` double NOT NULL,
  `creditAmount` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=79 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_budget`
--

CREATE TABLE IF NOT EXISTS `comp_budget` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) DEFAULT NULL,
  `acctGroupID` int(11) DEFAULT NULL,
  `acctID` int(11) DEFAULT NULL,
  `year` int(11) DEFAULT NULL,
  `period` int(2) DEFAULT NULL,
  `amountdr` double DEFAULT NULL,
  `amountcr` double DEFAULT NULL,
  `total` double DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `is_delete` smallint(6) DEFAULT NULL,
  PRIMARY KEY (`ID`),
  KEY `Index 2` (`companyID`,`acctID`,`year`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT AUTO_INCREMENT=6085 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_cash_sales`
--

CREATE TABLE IF NOT EXISTS `comp_cash_sales` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `serialNo` int(11) NOT NULL DEFAULT '1',
  `companyID` int(11) NOT NULL,
  `formNo` varchar(32) NOT NULL,
  `salesInvoiceDate` date NOT NULL,
  `locationID` int(11) NOT NULL,
  `projectID` int(11) NOT NULL,
  `paymentMethodID` int(11) NOT NULL,
  `termsID` int(11) NOT NULL,
  `memo` text NOT NULL,
  `paymentFrom` varchar(128) NOT NULL,
  `totalAmountIncludeTax` double NOT NULL,
  `totalTaxAmount` double NOT NULL,
  `totalamountExcludeTax` double NOT NULL,
  `discount` double NOT NULL,
  `outOfBalance` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(6) NOT NULL DEFAULT '0',
  `updateAble` smallint(6) NOT NULL DEFAULT '1',
  `journalNo` varchar(32) NOT NULL,
  `bankID` int(11) NOT NULL,
  `amountReceived` double NOT NULL,
  `referenceNo` varchar(32) NOT NULL,
  `bankReconcileID` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=275 ;

--
-- Triggers `comp_cash_sales`
--
DROP TRIGGER IF EXISTS `triger_cash_sales`;
DELIMITER //
CREATE TRIGGER `triger_cash_sales` BEFORE INSERT ON `comp_cash_sales`
 FOR EACH ROW set new.serialNo = (select nextSerialNo 
			   from view_serial_comp_cash_sales
                    where companyID = new.companyID)
//
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_cash_sales_charges`
--

CREATE TABLE IF NOT EXISTS `comp_cash_sales_charges` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `cashSaleID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `accountNoID` int(11) NOT NULL,
  `chargeDescription` text NOT NULL,
  `amountExcludedTax` double NOT NULL,
  `taxID` int(11) NOT NULL,
  `taxRate` double NOT NULL,
  `taxAmount` double NOT NULL,
  `amountIncludedTax` double NOT NULL,
  `drAccountID` int(11) NOT NULL,
  `crAccountID` int(11) NOT NULL,
  `drTaxAccountID` int(11) NOT NULL,
  `crTaxAccountID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_cash_sales_detail`
--

CREATE TABLE IF NOT EXISTS `comp_cash_sales_detail` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `lineNo` int(11) NOT NULL,
  `invoiceID` int(11) NOT NULL,
  `itemID` int(11) NOT NULL,
  `quantity` int(11) NOT NULL,
  `umID` int(11) NOT NULL,
  `unitPrice` double NOT NULL,
  `amountExcludedTax` double NOT NULL,
  `taxID` int(11) NOT NULL,
  `taxRate` double NOT NULL,
  `taxAmount` double NOT NULL,
  `amountIncludedTax` double NOT NULL,
  `accountID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=612 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_chart_of_acct`
--

CREATE TABLE IF NOT EXISTS `comp_chart_of_acct` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `acctGroupID` int(11) NOT NULL,
  `acctCode` char(9) NOT NULL,
  `acctName` varchar(128) NOT NULL,
  `acctDesc` varchar(128) NOT NULL,
  `openingBalanceDr` double NOT NULL,
  `openingBalanceCr` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(6) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=32500 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_chart_of_acct_bak`
--

CREATE TABLE IF NOT EXISTS `comp_chart_of_acct_bak` (
  `ID` int(11) NOT NULL DEFAULT '0',
  `companyID` int(11) NOT NULL,
  `acctGroupID` int(11) NOT NULL,
  `acctCode` char(9) NOT NULL,
  `acctName` varchar(128) NOT NULL,
  `acctDesc` varchar(128) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(6) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `comp_contact`
--

CREATE TABLE IF NOT EXISTS `comp_contact` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `company_contact_name` varchar(128) NOT NULL,
  `position` varchar(32) NOT NULL,
  `telOffice` varchar(32) NOT NULL,
  `telHp` varchar(32) NOT NULL,
  `email` varchar(64) NOT NULL,
  `remaks` text NOT NULL,
  `createdID` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_control_acct_setup`
--

CREATE TABLE IF NOT EXISTS `comp_control_acct_setup` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `refID` int(11) NOT NULL,
  `groupDisplay` int(11) NOT NULL,
  `companyID` int(11) NOT NULL,
  `accountCode` varchar(64) NOT NULL,
  `updateable` smallint(6) NOT NULL DEFAULT '1',
  `accountID` int(11) NOT NULL DEFAULT '0',
  `orderNo` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(16) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2691 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_currency_conv`
--

CREATE TABLE IF NOT EXISTS `comp_currency_conv` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) DEFAULT NULL,
  `currencyFrom` int(11) DEFAULT NULL,
  `currencyTo` int(11) DEFAULT NULL,
  `startDate` date DEFAULT NULL,
  `endDate` date DEFAULT NULL,
  `rateConv` double DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `is_delete` smallint(6) DEFAULT NULL,
  PRIMARY KEY (`ID`),
  KEY `Index 2` (`companyID`,`currencyFrom`,`startDate`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT AUTO_INCREMENT=14 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_delivery_detail`
--

CREATE TABLE IF NOT EXISTS `comp_delivery_detail` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `deliveryID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `orderID` int(11) NOT NULL,
  `invoiceID` int(11) NOT NULL DEFAULT '0',
  `soDetailsLine` int(11) NOT NULL,
  `itemID` int(11) NOT NULL,
  `unitPrice` double NOT NULL,
  `quantityOrdered` int(11) NOT NULL,
  `requiredDate` date NOT NULL,
  `totalQuantitySent` int(11) NOT NULL,
  `quantitySent` int(11) NOT NULL,
  `amount` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `standUM` int(11) NOT NULL,
  `salesID` int(11) NOT NULL,
  `umID` int(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=798 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_delivery_order`
--

CREATE TABLE IF NOT EXISTS `comp_delivery_order` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `serialNo` int(11) NOT NULL DEFAULT '1',
  `companyID` int(11) NOT NULL,
  `deliveryCode` varchar(32) NOT NULL,
  `salesOrderID` int(11) NOT NULL,
  `customerID` int(11) NOT NULL,
  `formNo` varchar(32) NOT NULL,
  `deliveryOrderDate` date NOT NULL,
  `locationID` int(11) NOT NULL,
  `deliverToID` text NOT NULL,
  `toAddress` varchar(200) NOT NULL,
  `currencyID` int(11) NOT NULL,
  `employeeID` int(11) NOT NULL,
  `memo` text NOT NULL,
  `shippingMethodID` int(11) NOT NULL,
  `totalAmount` double NOT NULL,
  `exchangeRate` double NOT NULL,
  `totalReceivable` double NOT NULL,
  `updateAble` int(11) NOT NULL DEFAULT '1',
  `isDelete` int(11) NOT NULL DEFAULT '0',
  `journalNo` varchar(32) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=616 ;

--
-- Triggers `comp_delivery_order`
--
DROP TRIGGER IF EXISTS `trigger_before_insert_donn1_add_serialNo`;
DELIMITER //
CREATE TRIGGER `trigger_before_insert_donn1_add_serialNo` BEFORE INSERT ON `comp_delivery_order`
 FOR EACH ROW set new.serialNo = (select nextSerialNo 
			   from view_serial_comp_delivery_order 
			   where companyID = new.companyID)
//
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_department`
--

CREATE TABLE IF NOT EXISTS `comp_department` (
  `fldid` int(11) NOT NULL DEFAULT '0',
  `code` varchar(18) CHARACTER SET utf8 DEFAULT NULL,
  `description` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
  `dept_head` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
  PRIMARY KEY (`fldid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `comp_employee`
--

CREATE TABLE IF NOT EXISTS `comp_employee` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `employeeCode` varchar(16) NOT NULL,
  `employeeName` varchar(64) NOT NULL,
  `employeePosition` varchar(32) NOT NULL,
  `line1` varchar(64) NOT NULL,
  `line2` varchar(64) NOT NULL,
  `line3` varchar(64) NOT NULL,
  `postCode` varchar(8) NOT NULL,
  `city` varchar(32) NOT NULL,
  `stateID` int(11) NOT NULL,
  `countryID` int(11) NOT NULL,
  `phoneNo` varchar(32) NOT NULL,
  `email` varchar(128) NOT NULL,
  `dateOfJoin` date NOT NULL,
  `gender` smallint(6) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `is_delete` smallint(6) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=110 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_financial_year`
--

CREATE TABLE IF NOT EXISTS `comp_financial_year` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `financialYear` int(4) NOT NULL,
  `startDate` date NOT NULL,
  `endDate` date NOT NULL,
  `period` smallint(2) NOT NULL,
  `status` smallint(1) NOT NULL COMMENT '0=Open, 1=close',
  `yearEnd` smallint(1) NOT NULL DEFAULT '1',
  `updateAble` tinyint(1) DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(6) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=139263 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_form_control`
--

CREATE TABLE IF NOT EXISTS `comp_form_control` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `formID` int(11) NOT NULL,
  `formCode` varchar(8) NOT NULL,
  `formYear` tinyint(1) NOT NULL,
  `formMonth` tinyint(1) NOT NULL,
  `formDay` tinyint(1) NOT NULL,
  `formInitial` varchar(16) NOT NULL,
  `formInitialNo` int(11) NOT NULL DEFAULT '1',
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `orderNo` int(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1133 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_gl`
--

CREATE TABLE IF NOT EXISTS `comp_gl` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) DEFAULT '0',
  `acctCode` char(9) DEFAULT '0',
  `acctGroupID` int(11) DEFAULT '0',
  `description` varchar(128) DEFAULT '0',
  `amount_cr` double DEFAULT '0',
  `amount_dr` double DEFAULT '0',
  `period` smallint(2) DEFAULT '0',
  `year` year(4) DEFAULT NULL,
  `createdID` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT AUTO_INCREMENT=3005 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_gst_report`
--

CREATE TABLE IF NOT EXISTS `comp_gst_report` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) DEFAULT NULL,
  `ammendment` int(2) DEFAULT '0',
  `A1` varchar(12) NOT NULL DEFAULT '0',
  `A2` varchar(64) NOT NULL DEFAULT '0',
  `B3a` date DEFAULT NULL,
  `B3b` date DEFAULT NULL,
  `B4` date DEFAULT NULL,
  `B5a` double DEFAULT NULL,
  `B5b` double DEFAULT NULL,
  `B6a` double DEFAULT NULL,
  `B6b` double DEFAULT NULL,
  `B7` double DEFAULT NULL,
  `B8` double DEFAULT NULL,
  `B9` double DEFAULT NULL,
  `C10` double DEFAULT NULL,
  `C11` double DEFAULT NULL,
  `C12` double DEFAULT NULL,
  `C13` double DEFAULT NULL,
  `C14` double DEFAULT NULL,
  `C15` double DEFAULT NULL,
  `C16` double DEFAULT NULL,
  `C17` double DEFAULT NULL,
  `C18` double DEFAULT NULL,
  `C19a1` varchar(32) DEFAULT NULL,
  `C19a2` double DEFAULT NULL,
  `C19b1` varchar(32) DEFAULT NULL,
  `C19b2` double DEFAULT NULL,
  `C19c1` varchar(32) DEFAULT NULL,
  `C19c2` double DEFAULT NULL,
  `C19d1` varchar(32) DEFAULT NULL,
  `C19d2` double DEFAULT NULL,
  `C19e1` varchar(32) DEFAULT NULL,
  `C19e2` double DEFAULT NULL,
  `C19f` double DEFAULT NULL,
  `C19g` double DEFAULT NULL,
  `D20` varchar(128) DEFAULT NULL,
  `D21a` varchar(16) DEFAULT NULL,
  `D21b` varchar(16) DEFAULT NULL,
  `D22` varchar(32) DEFAULT NULL,
  `D23` varchar(128) DEFAULT NULL,
  `D24` date DEFAULT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updateAble` tinyint(4) NOT NULL DEFAULT '1',
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=49 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_industry`
--

CREATE TABLE IF NOT EXISTS `comp_industry` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `industryID` int(11) NOT NULL,
  `businessTypeID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`),
  KEY `companyID` (`companyID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_item_category`
--

CREATE TABLE IF NOT EXISTS `comp_item_category` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `code` varchar(4) NOT NULL,
  `name` varchar(64) NOT NULL,
  `shortName` varchar(8) NOT NULL,
  `description` varchar(128) NOT NULL,
  `orderNo` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updateBy` int(11) NOT NULL,
  `updateTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(6) NOT NULL,
  PRIMARY KEY (`ID`),
  KEY `companyID` (`companyID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=130 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_jl_seq`
--

CREATE TABLE IF NOT EXISTS `comp_jl_seq` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `compID` int(11) DEFAULT NULL,
  `moduleID` int(11) DEFAULT NULL,
  `initial` varchar(2) CHARACTER SET utf8 DEFAULT NULL,
  `year` year(4) NOT NULL,
  `period` int(2) NOT NULL,
  `seqNo` int(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=237 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_journal`
--

CREATE TABLE IF NOT EXISTS `comp_journal` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) DEFAULT NULL,
  `journalID` varchar(50) DEFAULT NULL,
  `description` varchar(128) DEFAULT NULL,
  `referrence` varchar(128) DEFAULT NULL,
  `batch` varchar(50) DEFAULT NULL,
  `module` int(11) DEFAULT NULL,
  `effective_date` date DEFAULT NULL,
  `entered_date` date DEFAULT NULL,
  `period` smallint(2) DEFAULT NULL,
  `year` year(4) DEFAULT NULL,
  `total_amount_dr` double DEFAULT NULL,
  `total_amount_cr` double DEFAULT NULL,
  `total_amount` double DEFAULT '0',
  `status` tinyint(4) DEFAULT '0' COMMENT 'unposted = 0, posted = 1',
  `remarks` varchar(128) DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `formNo` varchar(100) DEFAULT NULL,
  `is_delete` smallint(16) NOT NULL,
  PRIMARY KEY (`ID`),
  KEY `status` (`status`),
  KEY `journalID` (`journalID`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=9563 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_journal_detail`
--

CREATE TABLE IF NOT EXISTS `comp_journal_detail` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) DEFAULT '0',
  `journalID` varchar(50) DEFAULT '0',
  `sequence` int(11) DEFAULT '0',
  `acctCode` int(11) DEFAULT '0',
  `projectID` int(11) DEFAULT '0',
  `description` varchar(200) DEFAULT '0',
  `amount_cr` double DEFAULT '0',
  `amount_dr` double DEFAULT '0',
  `currencyID` int(11) DEFAULT '0',
  `currency_amount` double DEFAULT '0',
  `exchange_rate` double DEFAULT '0',
  `enter_exchange_rate` double DEFAULT '0',
  `period` smallint(2) DEFAULT '0',
  `year` year(4) DEFAULT NULL,
  `formNo` varchar(50) DEFAULT NULL,
  `supplier` varchar(200) DEFAULT NULL,
  `line` int(11) DEFAULT NULL,
  `status` smallint(2) DEFAULT '0',
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(16) NOT NULL,
  `bankReconcileID` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`),
  KEY `journalID` (`journalID`),
  KEY `comp_acc_det` (`companyID`,`acctCode`,`period`,`year`,`status`,`is_delete`),
  KEY `acctCode` (`acctCode`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=45159 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_location_transfer`
--

CREATE TABLE IF NOT EXISTS `comp_location_transfer` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `serialNo` int(11) NOT NULL,
  `companyID` int(11) NOT NULL,
  `fromLocationID` int(11) NOT NULL,
  `toLocationID` int(11) NOT NULL,
  `formNo` varchar(32) NOT NULL,
  `movementTypeID` int(11) NOT NULL,
  `dateTransfer` date NOT NULL,
  `memo` text NOT NULL,
  `is_delete` smallint(6) NOT NULL,
  `updateable` smallint(6) NOT NULL DEFAULT '1',
  `createdby` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=62 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_location_transfer_detail`
--

CREATE TABLE IF NOT EXISTS `comp_location_transfer_detail` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `locationTransferID` int(11) NOT NULL,
  `LineNo` int(11) NOT NULL,
  `itemID` int(11) NOT NULL,
  `quantity` int(11) NOT NULL,
  `fromStock` int(11) NOT NULL,
  `is_delete` smallint(6) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=80 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_opening_balance`
--

CREATE TABLE IF NOT EXISTS `comp_opening_balance` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `accountID` int(11) NOT NULL,
  `year` int(11) NOT NULL,
  `debit` double NOT NULL,
  `credit` double NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `createdBy` int(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=8007 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_payment`
--

CREATE TABLE IF NOT EXISTS `comp_payment` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `serialNo` int(11) NOT NULL DEFAULT '1',
  `companyID` int(11) NOT NULL,
  `supplierID` int(11) NOT NULL,
  `projectID` int(11) NOT NULL,
  `amountPaid` double NOT NULL,
  `paymentMethodID` int(11) NOT NULL,
  `referenceNo` varchar(16) NOT NULL,
  `bankID` int(11) NOT NULL,
  `reconcile` smallint(6) NOT NULL DEFAULT '0',
  `accountID` int(11) NOT NULL,
  `formNo` varchar(32) NOT NULL,
  `paymentDate` date NOT NULL,
  `updateAble` smallint(1) NOT NULL DEFAULT '1',
  `currencyID` int(11) NOT NULL,
  `exchangeRate` double NOT NULL,
  `addressID` int(11) NOT NULL,
  `memo` text NOT NULL,
  `totalDiscount` double NOT NULL,
  `bankCharges` double NOT NULL,
  `totalOtherCharge` double NOT NULL,
  `totalPaid` double NOT NULL,
  `totalApplied` double NOT NULL,
  `outOfBalance` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(16) NOT NULL,
  `accountDescription` varchar(128) NOT NULL DEFAULT 'Temp Description',
  `paymentID` int(11) NOT NULL,
  `journalNo` varchar(32) NOT NULL,
  `bankReconcileID` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=496 ;

--
-- Triggers `comp_payment`
--
DROP TRIGGER IF EXISTS `trigger_before_insert_cp_add_serialNo`;
DELIMITER //
CREATE TRIGGER `trigger_before_insert_cp_add_serialNo` BEFORE INSERT ON `comp_payment`
 FOR EACH ROW set new.serialNo = (select nextSerialNo 
			   from view_serial_comp_payment 
			   where companyID = new.companyID)
//
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_payment_detail`
--

CREATE TABLE IF NOT EXISTS `comp_payment_detail` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `paymentID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `purchaseInvoiceID` int(11) NOT NULL,
  `totalAmount` double NOT NULL,
  `APBalance` double NOT NULL,
  `discount` double NOT NULL,
  `amountApplied` double NOT NULL,
  `debtRecoverID` INT(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(16) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1585 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_payment_others`
--

CREATE TABLE IF NOT EXISTS `comp_payment_others` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `serialNo` int(11) NOT NULL DEFAULT '1',
  `otherPaymentType` smallint(6) NOT NULL COMMENT '0=with item. 1=without item',
  `companyID` int(11) NOT NULL,
  `payTo` text NOT NULL,
  `projectID` int(11) NOT NULL,
  `amountPaid` double NOT NULL,
  `paymentMethodID` int(11) NOT NULL,
  `referenceNo` varchar(32) NOT NULL,
  `accountID` int(11) NOT NULL,
  `formNo` varchar(32) NOT NULL,
  `paymentDate` date NOT NULL,
  `updateAble` smallint(1) NOT NULL DEFAULT '1',
  `currencyID` int(11) NOT NULL,
  `exchangeRate` double NOT NULL,
  `addressID` int(11) NOT NULL,
  `locationID` int(11) NOT NULL,
  `memo` text NOT NULL,
  `simplifiedTax`  int(1) NOT NULL DEFAULT '0',
  `totalDiscount` double NOT NULL,
  `bankCharges` double NOT NULL,
  `bankId` int(11) NOT NULL,
  `totalOtherCharge` double NOT NULL,
  `totalPaid` double NOT NULL,
  `totalApplied` double NOT NULL,
  `outOfBalance` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(16) NOT NULL,
  `accountDescription` varchar(128) NOT NULL,
  `paymentID` int(11) NOT NULL,
  `journalNo` varchar(32) NOT NULL,
  `reconcile` smallint(6) NOT NULL,
  `bankReconcileID` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1150 ;

--
-- Triggers `comp_payment_others`
--
DROP TRIGGER IF EXISTS `trigger_before_insert_payo_add_serialNo`;
DELIMITER //
CREATE TRIGGER `trigger_before_insert_payo_add_serialNo` BEFORE INSERT ON `comp_payment_others`
 FOR EACH ROW set new.serialNo = (select nextSerialNo 
			   from view_serial_comp_payment_others 
			   where companyID = new.companyID)
//
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_payment_others_without_item`
--

CREATE TABLE IF NOT EXISTS `comp_payment_others_without_item` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `otherPaymentID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `accountID` int(11) NOT NULL,
  `itemdescription` text NOT NULL,
  `amountExcludedTax` double NOT NULL,
  `taxID` int(11) NOT NULL,
  `taxBL` DOUBLE NOT NULL,
  `taxRate` double NOT NULL,
  `taxAmount` double NOT NULL,
  `amountIncludedTax` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1148 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_payment_others_with_item`
--

CREATE TABLE IF NOT EXISTS `comp_payment_others_with_item` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `otherPaymentID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `itemID` int(11) NOT NULL,
  `itemname` varchar(64) NOT NULL,
  `itemdescription` text NOT NULL,
  `quantity` int(11) NOT NULL,
  `umID` int(11) NOT NULL,
  `unitPrice` double NOT NULL,
  `amountExcludedTax` double NOT NULL,
  `taxID` int(11) NOT NULL,
  `taxRate` double NOT NULL,
  `taxAmount` double NOT NULL,
  `amountIncludedTax` double NOT NULL,
  `accountID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `is_delete` smallint(16) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=723 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_project`
--

CREATE TABLE IF NOT EXISTS `comp_project` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `project_name` varchar(128) NOT NULL,
  `projectManagerID` int(11) NOT NULL,
  `totalBudget` double NOT NULL,
  `remarks` text NOT NULL,
  `createdID` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(16) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=36 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_purchase_order`
--

CREATE TABLE IF NOT EXISTS `comp_purchase_order` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `serialNo` int(11) NOT NULL,
  `companyID` int(11) NOT NULL,
  `purchaserID` int(11) NOT NULL,
  `supplierID` int(11) NOT NULL,
  `invoiceID` int(11) NOT NULL DEFAULT '0',
  `shiptoID` int(11) NOT NULL,
  `purchaseOrderNo` varchar(32) NOT NULL,
  `salesAgentName` varchar(64) NOT NULL,
  `formNo` varchar(16) NOT NULL,
  `poDate` date NOT NULL,
  `exchangeRate` double NOT NULL,
  `termAndConditionID` int(11) NOT NULL,
  `currencyID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updateAble` tinyint(4) NOT NULL DEFAULT '1',
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `memo` varchar(255) NOT NULL,
  `is_delete` int(11) NOT NULL DEFAULT '0',
  `journalNo` varchar(32) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=729 ;

--
-- Triggers `comp_purchase_order`
--
DROP TRIGGER IF EXISTS `mytrigerfopobeforeinsert`;
DELIMITER //
CREATE TRIGGER `mytrigerfopobeforeinsert` BEFORE INSERT ON `comp_purchase_order`
 FOR EACH ROW set new.serialNo = 
(select nextSerialNo from view_serial_comp_purchase_order 
	where companyID = new.companyID)
//
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_purchase_order_detail`
--

CREATE TABLE IF NOT EXISTS `comp_purchase_order_detail` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `purchaseOrderID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `itemID` int(11) NOT NULL,
  `itemCode` varchar(16) NOT NULL,
  `itemName` varchar(128) NOT NULL,
  `description` text,
  `unitPrice` double NOT NULL,
  `umID` int(11) NOT NULL,
  `quantityOrder` int(11) NOT NULL,
  `quantityReceivedTotal` int(11) NOT NULL DEFAULT '0',
  `amount` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1315 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_purchase_price`
--

CREATE TABLE IF NOT EXISTS `comp_purchase_price` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `itemID` int(11) NOT NULL,
  `supplierID` int(11) NOT NULL,
  `currencyID` int(11) NOT NULL,
  `umID` int(11) NOT NULL,
  `price` double NOT NULL,
  `startDate` date NOT NULL,
  `endDate` date NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` varchar(50) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=117 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_quotation`
--

CREATE TABLE IF NOT EXISTS `comp_quotation` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `serialNo` int(11) NOT NULL DEFAULT '1',
  `companyID` int(11) NOT NULL,
  `customerID` int(11) NOT NULL,
  `quotationCode` varchar(32) NOT NULL,
  `salesAgentID` int(11) NOT NULL,
  `employeeID` int(11) unsigned NOT NULL,
  `formNo` varchar(32) NOT NULL,
  `quotationDate` date NOT NULL,
  `deliverToID` int(11) NOT NULL,
  `currencyID` int(11) NOT NULL,
  `supplierID` text NOT NULL,
  `memo` varchar(128) NOT NULL,
  `totalTaxAmount` double NOT NULL,
  `exchangeRate` double NOT NULL,
  `totalReceivable` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=54 ;

--
-- Triggers `comp_quotation`
--
DROP TRIGGER IF EXISTS `trigger_before_insert_cq_add_serialNo`;
DELIMITER //
CREATE TRIGGER `trigger_before_insert_cq_add_serialNo` BEFORE INSERT ON `comp_quotation`
 FOR EACH ROW set new.serialNo = 
(select nextSerialNo from view_serial_comp_quotation 
	where companyID = new.companyID)
//
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_quotation_detail`
--

CREATE TABLE IF NOT EXISTS `comp_quotation_detail` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `quotationID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `itemID` int(11) NOT NULL,
  `description` varchar(200) NOT NULL,
  `unitOfPrice` double NOT NULL,
  `quantityOrder` int(11) NOT NULL,
  `amountExcludeTax` double DEFAULT NULL,
  `taxID` int(11) NOT NULL,
  `umID` int(11) NOT NULL,
  `taxRate` double NOT NULL,
  `taxAmount` double NOT NULL,
  `amountIncudeTax` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=76 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_receive_delivery_conn`
--

CREATE TABLE IF NOT EXISTS `comp_receive_delivery_conn` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `receiveDetailID` int(11) NOT NULL,
  `deliveryDetailID` int(11) NOT NULL,
  `type` int(11) NOT NULL COMMENT '1 = DO, 2 = LocTrans, 3 = salesDebitNote, 4 = supplierDebitNote, 5 = cashSale, 6 = item adjustment',
  `qty` bigint(20) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2207 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_receive_item`
--

CREATE TABLE IF NOT EXISTS `comp_receive_item` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `serialNo` int(11) NOT NULL DEFAULT '1',
  `companyID` int(11) NOT NULL,
  `opening_balance` tinyint(1) NOT NULL DEFAULT '0',
  `supplierDoNo` varchar(32) NOT NULL,
  `purchaseOrderID` int(11) NOT NULL,
  `supplierID` int(11) NOT NULL,
  `formNo` varchar(32) NOT NULL,
  `deliveryDate` date NOT NULL,
  `locationID` int(11) NOT NULL,
  `deliverToID` int(11) NOT NULL,
  `currencyID` int(11) NOT NULL,
  `exchangeRate` float NOT NULL,
  `employeeID` int(11) NOT NULL,
  `memo` text NOT NULL,
  `shippingMethodID` int(11) NOT NULL,
  `totalAmount` double NOT NULL,
  `totalPayable` double NOT NULL,
  `journalNo` varchar(32) NOT NULL,
  `updateAble` smallint(6) NOT NULL DEFAULT '1',
  `isDelete` tinyint(1) NOT NULL DEFAULT '0',
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3214 ;

--
-- Triggers `comp_receive_item`
--
DROP TRIGGER IF EXISTS `triger_BEFORE_Insert_addSerialForReceiveItem`;
DELIMITER //
CREATE TRIGGER `triger_BEFORE_Insert_addSerialForReceiveItem` BEFORE INSERT ON `comp_receive_item`
 FOR EACH ROW set new.serialNo = 
(select nextSerialNo from view_serial_comp_receive_item 
	where companyID = new.companyID)
//
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_receive_item_detail`
--

CREATE TABLE IF NOT EXISTS `comp_receive_item_detail` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `receiveID` int(11) NOT NULL,
  `invoiceID` int(11) NOT NULL DEFAULT '0',
  `lineNo` int(11) NOT NULL,
  `poDetailID` int(11) NOT NULL,
  `itemID` int(11) NOT NULL,
  `itemCode` varchar(16) NOT NULL,
  `itemName` varchar(128) NOT NULL,
  `description` text,
  `unitPrice` double NOT NULL,
  `quantityOrder` double NOT NULL,
  `quantityReceived` double NOT NULL DEFAULT '0',
  `umID` int(11) NOT NULL DEFAULT '0',
  `standUM` int(11) NOT NULL,
  `amount` double NOT NULL,
  `balanceItem` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4398 ;

--
-- Triggers `comp_receive_item_detail`
--
DROP TRIGGER IF EXISTS `updateBalanceItem`;
DELIMITER //
CREATE TRIGGER `updateBalanceItem` BEFORE INSERT ON `comp_receive_item_detail`
 FOR EACH ROW if new.balanceitem is null then
set new.balanceItem = new.quantityReceived;
end if
//
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_receive_payment`
--

CREATE TABLE IF NOT EXISTS `comp_receive_payment` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `serialNo` int(11) NOT NULL DEFAULT '1',
  `companyID` int(11) NOT NULL,
  `customerID` int(11) NOT NULL,
  `projectID` int(11) NOT NULL,
  `paymentMethodID` int(11) NOT NULL,
  `referenceNo` varchar(32) NOT NULL,
  `bankID` int(11) NOT NULL,
  `accountID` int(11) NOT NULL,
  `formNo` varchar(32) NOT NULL,
  `receivePaymentDate` date NOT NULL,
  `currencyID` int(11) NOT NULL,
  `exchangeRate` double NOT NULL,
  `addressID` int(11) NOT NULL,
  `memo` text NOT NULL,
  `totalDiscount` double NOT NULL,
  `bankCharges` double NOT NULL,
  `totalOtherCharge` double NOT NULL,
  `totalReceived` double NOT NULL,
  `totalApplied` double NOT NULL,
  `outOfBalance` double NOT NULL,
  `updateAble` smallint(1) NOT NULL DEFAULT '1',
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(6) NOT NULL DEFAULT '0',
  `journalNo` varchar(32) NOT NULL,
  `bankReconcileID` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=367 ;

--
-- Triggers `comp_receive_payment`
--
DROP TRIGGER IF EXISTS `trigger_before_insert_rpay_add_serialNo`;
DELIMITER //
CREATE TRIGGER `trigger_before_insert_rpay_add_serialNo` BEFORE INSERT ON `comp_receive_payment`
 FOR EACH ROW set new.serialNo = (select nextSerialNo 
			   from view_serial_comp_receive_payment
			   where companyID = new.companyID)
//
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_receive_payment_detail`
--

CREATE TABLE IF NOT EXISTS `comp_receive_payment_detail` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `receivePaymentID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `invoiceID` int(11) NOT NULL,
  `totalAmount` double NOT NULL,
  `ARBalance` double NOT NULL,
  `discount` double NOT NULL,
  `amountApplied` double NOT NULL,
  `debtRecoverID` int(11) NOT NULL DEFAULT '0',
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=446 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_receive_payment_others`
--

CREATE TABLE IF NOT EXISTS `comp_receive_payment_others` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `serialNo` int(11) NOT NULL DEFAULT '1',
  `companyID` int(11) NOT NULL,
  `receiveFrom` varchar(128) NOT NULL,
  `projectID` int(11) NOT NULL,
  `paymentMethodID` int(11) NOT NULL,
  `referenceNo` varchar(32) NOT NULL,
  `bankID` int(11) NOT NULL,
  `accountID` int(11) NOT NULL,
  `formNo` varchar(32) NOT NULL,
  `receivePaymentDate` date NOT NULL,
  `currencyID` int(11) NOT NULL,
  `exchangeRate` double NOT NULL,
  `addressID` int(11) NOT NULL,
  `memo` text NOT NULL,
  `totalDiscount` double NOT NULL,
  `bankCharges` double NOT NULL,
  `totalOtherCharge` double NOT NULL,
  `totalReceived` double NOT NULL,
  `totalApplied` double NOT NULL,
  `updateAble` smallint(1) NOT NULL DEFAULT '1',
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(6) NOT NULL DEFAULT '0',
  `journalNo` varchar(32) NOT NULL,
  `bankReconcileID` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=506 ;

--
-- Triggers `comp_receive_payment_others`
--
DROP TRIGGER IF EXISTS `trigger_before_insert_rpay_add_others_serialNo`;
DELIMITER //
CREATE TRIGGER `trigger_before_insert_rpay_add_others_serialNo` BEFORE INSERT ON `comp_receive_payment_others`
 FOR EACH ROW set new.serialNo = (select nextSerialNo 
			   from view_serial_comp_receive_payment_others
			   where companyID = new.companyID)
//
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_receive_payment_others_detail`
--

CREATE TABLE IF NOT EXISTS `comp_receive_payment_others_detail` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `receivePaymentOthersID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `accountNoID` int(11) NOT NULL,
  `description` text NOT NULL,
  `amountExcludedTax` double NOT NULL,
  `taxID` int(11) NOT NULL,
  `taxRate` double NOT NULL,
  `taxAmount` double NOT NULL,
  `amountIncludedTax` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1209 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_sales_agent`
--

CREATE TABLE IF NOT EXISTS `comp_sales_agent` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `agentCode` varchar(32) NOT NULL,
  `agentName` varchar(128) NOT NULL,
  `position` varchar(32) NOT NULL,
  `telOffice` varchar(32) NOT NULL,
  `telHp` varchar(32) NOT NULL,
  `email` varchar(64) NOT NULL,
  `commisionRate` double NOT NULL,
  `remarks` text NOT NULL,
  `createdID` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=42 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_sales_bad_debt`
--

CREATE TABLE IF NOT EXISTS `comp_sales_bad_debt` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `custID` int(11) NOT NULL,
  `valueBadDebt` double NOT NULL,
  `gstBadDebt` double NOT NULL,
  `transDate` date NOT NULL,
  `updateAble` tinyint(1) NOT NULL DEFAULT '1',
  `journalNo` varchar(255) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=27 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_sales_creditnote`
--

CREATE TABLE IF NOT EXISTS `comp_sales_creditnote` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `serialNo` int(11) NOT NULL DEFAULT '1',
  `companyID` int(11) NOT NULL,
  `customerID` int(11) NOT NULL,
  `formNo` varchar(32) NOT NULL,
  `creditNoteDate` date NOT NULL,
  `salesInvoiceID` int(11) NOT NULL,
  `projectID` int(11) NOT NULL,
  `termsID` int(11) NOT NULL,
  `currencyID` int(11) NOT NULL,
  `exchangeRate` double NOT NULL,
  `agentID` int(11) NOT NULL,
  `memo` text NOT NULL,
  `employeeID` int(11) NOT NULL,
  `shippingMethodID` int(11) NOT NULL,
  `totalAmount` double NOT NULL,
  `amountPaid` decimal(10,0) NOT NULL,
  `totalTaxAmount` double NOT NULL,
  `totalPayable` double NOT NULL,
  `total` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(16) NOT NULL,
  `updateAble` tinyint(1) NOT NULL DEFAULT '1',
  `journalNo` varchar(32) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=370 ;

--
-- Triggers `comp_sales_creditnote`
--
DROP TRIGGER IF EXISTS `trigger_before_insert_scn_add_serialNo`;
DELIMITER //
CREATE TRIGGER `trigger_before_insert_scn_add_serialNo` BEFORE INSERT ON `comp_sales_creditnote`
 FOR EACH ROW set new.serialNo = (select nextSerialNo 
			   from view_serial_comp_sales_creditnote
			   where companyID = new.companyID)
//
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_sales_creditnote_charges`
--

CREATE TABLE IF NOT EXISTS `comp_sales_creditnote_charges` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `creditNoteID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `accountNoID` int(11) NOT NULL,
  `chargeDescription` text NOT NULL,
  `amountExcludedTax` double NOT NULL,
  `taxID` int(11) NOT NULL,
  `taxRate` double NOT NULL,
  `taxAmount` double NOT NULL,
  `amountIncludedTax` double NOT NULL,
  `drAccountID` int(11) NOT NULL,
  `crAccountID` int(11) NOT NULL,
  `drTaxAccountID` int(11) NOT NULL,
  `crTaxAccountID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=82 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_sales_creditnote_detail`
--

CREATE TABLE IF NOT EXISTS `comp_sales_creditnote_detail` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `creditnoteID` int(11) NOT NULL,
  `invoiceDetailID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `itemID` int(11) NOT NULL,
  `itemname` varchar(64) NOT NULL,
  `itemdescription` text NOT NULL,
  `umID` int(11) NOT NULL,
  `quantity` int(11) NOT NULL,
  `unitPrice` double NOT NULL,
  `amountExcludedTax` double NOT NULL,
  `taxID` int(11) NOT NULL,
  `taxRate` double NOT NULL,
  `taxAmount` double NOT NULL,
  `amountIncludedTax` double NOT NULL,
  `accountID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=396 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_sales_debitnote`
--

CREATE TABLE IF NOT EXISTS `comp_sales_debitnote` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `serialNo` int(11) NOT NULL DEFAULT '1',
  `companyID` int(11) NOT NULL,
  `customerID` int(11) NOT NULL,
  `formNo` varchar(32) NOT NULL,
  `debitNoteDate` date NOT NULL,
  `salesInvoiceID` int(11) NOT NULL,
  `projectID` int(11) NOT NULL,
  `termsID` int(11) NOT NULL,
  `currencyID` int(11) NOT NULL,
  `exchangeRate` double NOT NULL,
  `agentID` int(11) NOT NULL,
  `memo` text NOT NULL,
  `employeeID` int(11) NOT NULL,
  `shippingMethodID` int(11) NOT NULL,
  `totalAmount` double NOT NULL,
  `amountPaid` decimal(10,0) NOT NULL,
  `totalTaxAmount` double NOT NULL,
  `totalPayable` double NOT NULL,
  `total` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(16) NOT NULL,
  `updateAble` tinyint(1) NOT NULL DEFAULT '1',
  `journalNo` varchar(32) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=375 ;

--
-- Triggers `comp_sales_debitnote`
--
DROP TRIGGER IF EXISTS `trigger_before_insert_sdn_add_serialNo`;
DELIMITER //
CREATE TRIGGER `trigger_before_insert_sdn_add_serialNo` BEFORE INSERT ON `comp_sales_debitnote`
 FOR EACH ROW set new.serialNo = (select nextSerialNo 
			   from view_serial_comp_sales_debitnote
			   where companyID = new.companyID)
//
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_sales_debitnote_charges`
--

CREATE TABLE IF NOT EXISTS `comp_sales_debitnote_charges` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `debitNoteID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `accountNoID` int(11) NOT NULL,
  `chargeDescription` text NOT NULL,
  `amountExcludedTax` double NOT NULL,
  `taxID` int(11) NOT NULL,
  `taxRate` double NOT NULL,
  `taxAmount` double NOT NULL,
  `amountIncludedTax` double NOT NULL,
  `drAccountID` int(11) NOT NULL,
  `crAccountID` int(11) NOT NULL,
  `drTaxAccountID` int(11) NOT NULL,
  `crTaxAccountID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=140 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_sales_debitnote_detail`
--

CREATE TABLE IF NOT EXISTS `comp_sales_debitnote_detail` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `debitnoteID` int(11) NOT NULL,
  `invoiceDetailID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `itemID` int(11) NOT NULL,
  `itemname` varchar(64) NOT NULL,
  `itemdescription` text NOT NULL,
  `umID` int(11) NOT NULL,
  `quantity` int(11) NOT NULL,
  `unitPrice` double NOT NULL,
  `amountExcludedTax` double NOT NULL,
  `taxID` int(11) NOT NULL,
  `taxRate` double NOT NULL,
  `taxAmount` double NOT NULL,
  `amountIncludedTax` double NOT NULL,
  `accountID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=421 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_sales_debt_recover`
--

CREATE TABLE IF NOT EXISTS `comp_sales_debt_recover` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `custID` int(11) NOT NULL,
  `valueDebtRecover` double NOT NULL,
  `gstDebtRecover` double NOT NULL,
  `transDate` date NOT NULL,
  `updateAble` tinyint(1) NOT NULL DEFAULT '1',
  `journalNo` varchar(255) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_sales_detail`
--

CREATE TABLE IF NOT EXISTS `comp_sales_detail` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `salesID` int(11) NOT NULL,
  `invoiceID` int(11) NOT NULL DEFAULT '0',
  `lineNo` int(11) NOT NULL,
  `itemID` int(11) NOT NULL,
  `description` varchar(200) DEFAULT NULL,
  `unitPrice` double DEFAULT NULL,
  `unitmeasure` int(11) DEFAULT NULL,
  `umID` int(11) NOT NULL,
  `standUM` int(11) NOT NULL,
  `quantityOrder` double DEFAULT NULL,
  `quantityShip` double DEFAULT '0',
  `amount` double DEFAULT NULL,
  `requiredDate` date DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=648 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_sales_invoice`
--

CREATE TABLE IF NOT EXISTS `comp_sales_invoice` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `serialNo` int(11) NOT NULL DEFAULT '1',
  `companyID` int(11) NOT NULL,
  `invoiceCodeID` int(11) NOT NULL COMMENT '1=sales inv, 2=direct sales inv,  3=debitNote, 4=creditNte',
  `salesID` int(11) NOT NULL,
  `customerID` int(11) NOT NULL,
  `formNo` varchar(32) NOT NULL,
  `salesInvoiceDate` date NOT NULL,
  `customerPoNo` varchar(32) NOT NULL,
  `locationID` int(11) NOT NULL,
  `projectID` int(11) NOT NULL,
  `termsID` int(11) NOT NULL,
  `shipToID` int(11) NOT NULL,
  `currencyID` int(11) NOT NULL,
  `exchangeRate` double NOT NULL,
  `agentID` int(11) NOT NULL,
  `printInInvoice` smallint(6) NOT NULL DEFAULT '0',
  `memo` text NOT NULL,
  `employeeID` int(11) NOT NULL,
  `showSaleAgent` tinyint(4) NOT NULL,
  `shippingMethodID` int(11) NOT NULL,
  `totalTaxAmount` double NOT NULL,
  `totalReceivable` double NOT NULL,
  `totalamount` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(6) NOT NULL DEFAULT '0',
  `updateAble` smallint(6) NOT NULL DEFAULT '1',
  `journalNo` varchar(32) NOT NULL,
  `salesOrderID` int(11) DEFAULT NULL,
  `badDebtID` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=678 ;

--
-- Triggers `comp_sales_invoice`
--
DROP TRIGGER IF EXISTS `trir_befor_inser_SI`;
DELIMITER //
CREATE TRIGGER `trir_befor_inser_SI` BEFORE INSERT ON `comp_sales_invoice`
 FOR EACH ROW set new.serialNo = (select nextSerialNo 
			   from view_serial_comp_sales_invoice
			   where companyID = new.companyID)
//
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_sales_invoice_charges`
--

CREATE TABLE IF NOT EXISTS `comp_sales_invoice_charges` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `invoiceID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `accountNoID` int(11) NOT NULL,
  `chargeDescription` text NOT NULL,
  `amountExcludedTax` double NOT NULL,
  `taxID` int(11) NOT NULL,
  `taxRate` double NOT NULL,
  `taxAmount` double NOT NULL,
  `amountIncludedTax` double NOT NULL,
  `drAccountID` int(11) NOT NULL,
  `crAccountID` int(11) NOT NULL,
  `drTaxAccountID` int(11) NOT NULL,
  `crTaxAccountID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`),
  KEY `invoice` (`invoiceID`),
  KEY `tax` (`taxID`),
  KEY `accountID` (`accountNoID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_sales_invoice_detail`
--

CREATE TABLE IF NOT EXISTS `comp_sales_invoice_detail` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `invoiceID` int(11) NOT NULL,
  `doID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `itemID` int(11) NOT NULL,
  `itemdescription` varchar(128) NOT NULL,
  `umID` int(11) NOT NULL,
  `quantity` int(11) NOT NULL,
  `unitPrice` double NOT NULL,
  `amountExcludedTax` double NOT NULL,
  `taxID` int(11) NOT NULL,
  `taxRate` double NOT NULL,
  `taxAmount` double NOT NULL,
  `amountIncludedTax` double NOT NULL,
  `accountID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`ID`),
  KEY `item` (`itemID`),
  KEY `tax` (`taxID`),
  KEY `invoice` (`invoiceID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_sales_order`
--

CREATE TABLE IF NOT EXISTS `comp_sales_order` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `serialNo` int(16) NOT NULL,
  `companyID` int(11) NOT NULL,
  `invoiceID` int(11) NOT NULL,
  `customerID` int(11) DEFAULT NULL,
  `OrderNo` varchar(32) DEFAULT NULL,
  `formNo` varchar(32) DEFAULT NULL,
  `currencyID` int(11) DEFAULT NULL,
  `exchangeRate` double DEFAULT '1',
  `salesOrderDate` date DEFAULT NULL,
  `dateRequired` date DEFAULT NULL,
  `deliveryToID` int(11) DEFAULT NULL,
  `salesPerson` int(11) DEFAULT NULL,
  `memo` varchar(128) DEFAULT NULL,
  `supplierID` int(11) DEFAULT NULL,
  `totalAmount` double DEFAULT NULL,
  `totalReceivable` double DEFAULT NULL,
  `status` tinyint(1) DEFAULT '1',
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `is_delete` smallint(16) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=377 ;

--
-- Triggers `comp_sales_order`
--
DROP TRIGGER IF EXISTS `Addserialsaleorder`;
DELIMITER //
CREATE TRIGGER `Addserialsaleorder` BEFORE INSERT ON `comp_sales_order`
 FOR EACH ROW set new.serialNo = (select nextSerialNo 
			   from view_serial_comp_sales_order
			   where companyID = new.companyID)
//
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_sales_price`
--

CREATE TABLE IF NOT EXISTS `comp_sales_price` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `customerID` int(11) NOT NULL,
  `itemID` int(11) NOT NULL,
  `currencyID` int(11) NOT NULL,
  `umID` int(11) NOT NULL,
  `startDate` date NOT NULL,
  `endDate` date NOT NULL,
  `price` double NOT NULL,
  `updatedBy` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=110 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_section`
--

CREATE TABLE IF NOT EXISTS `comp_section` (
  `fldid` int(11) NOT NULL DEFAULT '0',
  `code` varchar(18) CHARACTER SET utf8 DEFAULT NULL,
  `department` varchar(18) CHARACTER SET utf8 DEFAULT NULL,
  `description` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
  `section_head` varchar(50) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `comp_so_seq`
--

CREATE TABLE IF NOT EXISTS `comp_so_seq` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `compID` int(11) DEFAULT NULL,
  `moduleID` int(11) DEFAULT NULL,
  `initial` varchar(2) CHARACTER SET utf8 DEFAULT NULL,
  `year` year(4) DEFAULT NULL,
  `period` int(2) DEFAULT NULL,
  `seqNo` int(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_supplier_closing`
--

CREATE TABLE IF NOT EXISTS `comp_supplier_closing` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `supplierID` int(11) NOT NULL,
  `yearMonth` varchar(6) NOT NULL,
  `openBalance` double NOT NULL,
  `totalDr` double NOT NULL,
  `totalCr` double NOT NULL,
  `balance` double NOT NULL,
  PRIMARY KEY (`ID`),
  KEY `companyID` (`companyID`,`supplierID`,`yearMonth`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=16 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_supplier_closing_daily`
--

CREATE TABLE IF NOT EXISTS `comp_supplier_closing_daily` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `supplierID` int(11) NOT NULL,
  `transDate` date NOT NULL,
  `openBalance` double NOT NULL,
  `totalDr` double NOT NULL,
  `totalCr` double NOT NULL,
  `balance` double NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=795 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_supplier_creditnote`
--

CREATE TABLE IF NOT EXISTS `comp_supplier_creditnote` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `serialNo` int(11) NOT NULL DEFAULT '1',
  `companyID` int(11) NOT NULL,
  `supplierID` int(11) NOT NULL,
  `formNo` varchar(32) NOT NULL,
  `creditNoteDate` date NOT NULL,
  `supplierInvoiceID` int(11) NOT NULL,
  `projectID` int(11) NOT NULL,
  `termsID` int(11) NOT NULL,
  `currencyID` int(11) NOT NULL,
  `exchangeRate` double NOT NULL,
  `agentID` int(11) NOT NULL,
  `memo` text NOT NULL,
  `employeeID` int(11) NOT NULL,
  `shippingMethodID` int(11) NOT NULL,
  `totalAmount` double NOT NULL,
  `amountPaid` decimal(10,0) NOT NULL,
  `totalTaxAmount` double NOT NULL,
  `totalPayable` double NOT NULL,
  `total` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(16) NOT NULL,
  `updateAble` tinyint(1) NOT NULL DEFAULT '1',
  `journalNo` varchar(32) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=672 ;

--
-- Triggers `comp_supplier_creditnote`
--
DROP TRIGGER IF EXISTS `trigger_before_insert_scno_add_serialNo`;
DELIMITER //
CREATE TRIGGER `trigger_before_insert_scno_add_serialNo` BEFORE INSERT ON `comp_supplier_creditnote`
 FOR EACH ROW set new.serialNo = (select nextSerialNo 
			   from view_serial_comp_supplier_creditnote
			   where companyID = new.companyID)
//
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_supplier_creditnote_charges`
--

CREATE TABLE IF NOT EXISTS `comp_supplier_creditnote_charges` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `creditNoteID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `accountNoID` int(11) NOT NULL,
  `itemname` varchar(64) NOT NULL,
  `itemdescription` text NOT NULL,
  `umID` int(11) NOT NULL,
  `quantity` int(11) NOT NULL,
  `unitPrice` double NOT NULL,
  `amountExcludedTax` double NOT NULL,
  `taxID` int(11) NOT NULL,
  `taxRate` double NOT NULL,
  `taxAmount` double NOT NULL,
  `amountIncludedTax` double NOT NULL,
  `drAccountID` int(11) NOT NULL,
  `crAccountID` int(11) NOT NULL,
  `drTaxAccountID` int(11) NOT NULL,
  `crTaxAccountID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=68 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_supplier_creditnote_detail`
--

CREATE TABLE IF NOT EXISTS `comp_supplier_creditnote_detail` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `creditnoteID` int(11) NOT NULL,
  `invoiceDetailID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `itemID` int(11) NOT NULL,
  `itemname` varchar(64) NOT NULL,
  `itemdescription` text NOT NULL,
  `umID` int(11) NOT NULL,
  `quantity` int(11) NOT NULL,
  `unitPrice` double NOT NULL,
  `amountExcludedTax` double NOT NULL,
  `taxID` int(11) NOT NULL,
  `taxRate` double NOT NULL,
  `taxAmount` double NOT NULL,
  `amountIncludedTax` double NOT NULL,
  `accountID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=717 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_supplier_debitnote`
--

CREATE TABLE IF NOT EXISTS `comp_supplier_debitnote` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `serialNo` int(11) NOT NULL DEFAULT '1',
  `companyID` int(11) NOT NULL,
  `supplierID` int(11) NOT NULL,
  `formNo` varchar(32) NOT NULL,
  `debitNoteDate` date NOT NULL,
  `supplierInvoiceID` int(11) NOT NULL,
  `projectID` int(11) NOT NULL,
  `termsID` int(11) NOT NULL,
  `currencyID` int(11) NOT NULL,
  `exchangeRate` double NOT NULL,
  `agentID` int(11) NOT NULL,
  `memo` text NOT NULL,
  `employeeID` int(11) NOT NULL,
  `shippingMethodID` int(11) NOT NULL,
  `totalAmount` double NOT NULL,
  `amountPaid` decimal(10,0) NOT NULL,
  `totalTaxAmount` double NOT NULL,
  `totalPayable` double NOT NULL,
  `total` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(16) NOT NULL,
  `updateAble` tinyint(1) NOT NULL DEFAULT '1',
  `journalNo` varchar(32) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=544 ;

--
-- Triggers `comp_supplier_debitnote`
--
DROP TRIGGER IF EXISTS `trigger_before_insert_sdno_add_serialNo`;
DELIMITER //
CREATE TRIGGER `trigger_before_insert_sdno_add_serialNo` BEFORE INSERT ON `comp_supplier_debitnote`
 FOR EACH ROW set new.serialNo = (select nextSerialNo 
			   from view_serial_comp_supplier_debitnote
			   where companyID = new.companyID)
//
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_supplier_debitnote_charges`
--

CREATE TABLE IF NOT EXISTS `comp_supplier_debitnote_charges` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `debitNoteID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `accountNoID` int(11) NOT NULL,
  `itemname` varchar(64) NOT NULL,
  `itemdescription` text NOT NULL,
  `umID` int(11) NOT NULL,
  `quantity` int(11) NOT NULL,
  `unitPrice` double NOT NULL,
  `amountExcludedTax` double NOT NULL,
  `taxID` int(11) NOT NULL,
  `taxRate` double NOT NULL,
  `taxAmount` double NOT NULL,
  `amountIncludedTax` double NOT NULL,
  `drAccountID` int(11) NOT NULL,
  `crAccountID` int(11) NOT NULL,
  `drTaxAccountID` int(11) NOT NULL,
  `crTaxAccountID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=91 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_supplier_debitnote_detail`
--

CREATE TABLE IF NOT EXISTS `comp_supplier_debitnote_detail` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `debitnoteID` int(11) NOT NULL,
  `invoiceDetailID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `itemID` int(11) NOT NULL,
  `itemname` varchar(64) NOT NULL,
  `itemdescription` text NOT NULL,
  `umID` int(11) NOT NULL,
  `quantity` int(11) NOT NULL,
  `unitPrice` double NOT NULL,
  `amountExcludedTax` double NOT NULL,
  `taxID` int(11) NOT NULL,
  `taxRate` double NOT NULL,
  `taxAmount` double NOT NULL,
  `amountIncludedTax` double NOT NULL,
  `accountID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=573 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_supplier_invoice`
--

CREATE TABLE IF NOT EXISTS `comp_supplier_invoice` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `serialNo` int(11) NOT NULL DEFAULT '1',
  `companyID` int(11) NOT NULL,
  `purchaseInvoiceCodeID` int(11) NOT NULL COMMENT '1=puchase inv, 2=direct purch inv, 3=debit note, 4=credit note',
  `purchaserID` int(11) NOT NULL,
  `supplierID` int(11) NOT NULL,
  `formNo` varchar(32) NOT NULL,
  `invoiceDate` date NOT NULL,
  `supplierInvoiceNo` varchar(32) NOT NULL,
  `projectID` int(11) NOT NULL,
  `termsID` int(11) NOT NULL,
  `shipToID` int(11) NOT NULL,
  `locationID` int(11) NOT NULL,
  `currencyID` int(11) NOT NULL,
  `exchangeRate` double NOT NULL,
  `agentID` int(11) NOT NULL,
  `memo` text NOT NULL,
  `employeeID` int(11) NOT NULL,
  `shippingMethodID` int(11) NOT NULL,
  `totalAmount` double NOT NULL,
  `amountPaid` DOUBLE NOT NULL,
  `totalTaxAmount` double NOT NULL,
  `totalPayable` double NOT NULL,
  `total` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(16) NOT NULL,
  `updateAble` tinyint(1) NOT NULL DEFAULT '1',
  `journalNo` varchar(32) NOT NULL,
  `badDebtID` varchar(11) NOT NULL,
  `invoiceType` TINYINT(1) NOT NULL,
  PRIMARY KEY (`ID`),
  KEY `supplier` (`ID`,`supplierID`,`updateAble`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1227 ;

--
-- Triggers `comp_supplier_invoice`
--
DROP TRIGGER IF EXISTS `trigger_before_insert_supinv_add_serialNo`;
DELIMITER //
CREATE TRIGGER `trigger_before_insert_supinv_add_serialNo` BEFORE INSERT ON `comp_supplier_invoice`
 FOR EACH ROW set new.serialNo = (select nextSerialNo 
			   from view_serial_comp_supplier_invoice 
			   where companyID = new.companyID)
//
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_supplier_invoice_charges`
--

CREATE TABLE IF NOT EXISTS `comp_supplier_invoice_charges` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `invoiceID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `accountNoID` int(11) NOT NULL,
  `chargeDescription` text NOT NULL,
  `itemname` varchar(64) NOT NULL,
  `itemdescription` text NOT NULL,
  `umID` int(11) NOT NULL,
  `quantity` int(11) NOT NULL,
  `unitPrice` double NOT NULL,
  `amountExcludedTax` double NOT NULL,
  `taxID` int(11) NOT NULL,
  `taxRate` double NOT NULL,
  `taxAmount` double NOT NULL,
  `amountIncludedTax` double NOT NULL,
  `drAccountID` int(11) NOT NULL,
  `crAccountID` int(11) NOT NULL,
  `drTaxAccountID` int(11) NOT NULL,
  `crTaxAccountID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=254 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_supplier_invoice_detail`
--

CREATE TABLE IF NOT EXISTS `comp_supplier_invoice_detail` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `invoiceID` int(11) NOT NULL,
  `receiveID` int(11) NOT NULL COMMENT 'Is used for receive detail id instead of receive ID',
  `lineNo` int(11) NOT NULL,
  `itemID` int(11) NOT NULL,
  `itemname` varchar(64) NOT NULL,
  `itemdescription` text NOT NULL,
  `umID` int(11) NOT NULL,
  `quantity` int(11) NOT NULL,
  `unitPrice` double NOT NULL,
  `amountExcludedTax` double NOT NULL,
  `taxID` int(11) NOT NULL,
  `taxRate` double NOT NULL,
  `taxAmount` double NOT NULL,
  `amountIncludedTax` double NOT NULL,
  `accountID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1686 ;

-- --------------------------------------------------------

--
-- Table structure for table `comp_supplier_statement`
--

CREATE TABLE IF NOT EXISTS `comp_supplier_statement` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `debit` double NOT NULL,
  `credit` double NOT NULL,
  `balance` double NOT NULL,
  `supplierCode` int(11) NOT NULL,
  `supplierName` varchar(16) NOT NULL,
  `description` varchar(255) NOT NULL,
  `referenceNo` varchar(5) NOT NULL,
  `is_delete` smallint(16) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------


CREATE TABLE IF NOT EXISTS `comp_unpresented_check` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `transDate` date NOT NULL,
  `transNo` varchar(255) NOT NULL,
  `desc` text NOT NULL,
  `referenceNo` varchar(255) NOT NULL,
  `bankID` int(11) NOT NULL,
  `debit` double NOT NULL,
  `credit` double NOT NULL,
  `bankReconcileID` int(11) NOT NULL DEFAULT '0',
  `is_delete` int(11) NOT NULL DEFAULT '0',
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `createdBy` int(11) DEFAULT NULL,
  `updateTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--
-- Table structure for table `customer`
--

CREATE TABLE IF NOT EXISTS `customer` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `customerName` varchar(128) NOT NULL,
  `accountCode` varchar(8) NOT NULL,
  `customerCompanyNo` varchar(32) NOT NULL,
  `line1` varchar(128) NOT NULL,
  `line2` varchar(128) NOT NULL,
  `line3` varchar(128) NOT NULL,
  `city` varchar(128) NOT NULL,
  `customerPostCode` varchar(8) NOT NULL,
  `customerStateID` int(11) NOT NULL,
  `customerCountryID` int(11) NOT NULL,
  `attention` varchar(16) NOT NULL,
  `website` varchar(32) NOT NULL,
  `phoneNumber1` varchar(50) NOT NULL,
  `phoneNumber2` varchar(50) NOT NULL,
  `fax` varchar(50) NOT NULL,
  `generalNote` varchar(255) NOT NULL,
  `gstRegNo` varchar(16) NOT NULL,
  `termsID` int(11) NOT NULL,
  `creditLimit` int(8) NOT NULL,
  `creditLimitAlert` tinyint(1) NOT NULL,
  `linkedAPAccountID` varchar(11) NOT NULL,
  `createdDate` date NOT NULL,
  `currencyID` int(11) NOT NULL,
  `email` VARCHAR(64) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `termstatus` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` int(16) NOT NULL,
  `position` varchar(16) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=92 ;

-- --------------------------------------------------------

--
-- Table structure for table `customer_address`
--

CREATE TABLE IF NOT EXISTS `customer_address` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `customerID` int(11) NOT NULL,
  `addressCode` varchar(50) NOT NULL,
  `addressName` varchar(128) NOT NULL,
  `line1` varchar(128) NOT NULL,
  `line2` varchar(128) NOT NULL,
  `line3` varchar(128) NOT NULL,
  `city` varchar(128) NOT NULL,
  `postCode` varchar(8) NOT NULL,
  `stateID` int(11) NOT NULL,
  `countryID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` tinyint(1) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=54 ;

-- --------------------------------------------------------

--
-- Table structure for table `customer_contact`
--

CREATE TABLE IF NOT EXISTS `customer_contact` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `customerID` int(11) NOT NULL,
  `customer_contact_name` varchar(128) NOT NULL,
  `position` varchar(32) NOT NULL,
  `telOffice` varchar(32) NOT NULL,
  `telHp` varchar(32) NOT NULL,
  `email` varchar(64) NOT NULL,
  `remaks` text NOT NULL,
  `createdID` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `gl_setup`
--

CREATE TABLE IF NOT EXISTS `gl_setup` (
  `ID` int(11) NOT NULL,
  `companyID` int(11) NOT NULL,
  `accountTypeID` int(11) NOT NULL,
  `accountNoID` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `item`
--

CREATE TABLE IF NOT EXISTS `item` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `itemCode` varchar(32) NOT NULL,
  `name` varchar(64) NOT NULL,
  `description` text NOT NULL,
  `itemCategoryID` int(11) NOT NULL,
  `itemTypeID` int(11) NOT NULL,
  `quantity` int(11) NOT NULL,
  `unitOfMeasureID` int(11) NOT NULL,
  `editDescription` tinyint(1) NOT NULL,
  `imageFile` varchar(64) NOT NULL,
  `itemStatusID` tinyint(4) NOT NULL DEFAULT '1' COMMENT 'default to active=1',
  `reorderLevel` int(11) NOT NULL,
  `incomeID` int(11) NOT NULL,
  `cogsID` int(11) NOT NULL,
  `inventoriesID` int(11) NOT NULL,
  `inputTaxID` int(11) NOT NULL,
  `outputTaxID` int(11) NOT NULL,
  `supplierID` int(11) NOT NULL,
  `memo` text NOT NULL,
  `locationID` int(11) NOT NULL,
  `is_delete` smallint(6) NOT NULL,
  `updateable` smallint(6) NOT NULL,
  `totalAmount` double NOT NULL,
  `totalPayable` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `supplierPrice` double NOT NULL,
  `salesPrice` double NOT NULL,
  `currencyID` int(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=203 ;

--
-- Triggers `item`
--
DROP TRIGGER IF EXISTS `trigger_before_insert_item`;
DELIMITER //
CREATE TRIGGER `trigger_before_insert_item` BEFORE INSERT ON `item`
 FOR EACH ROW begin
if new.incomeID = 0 or new.incomeID is null then 
set new.incomeID = (select accountID from comp_control_acct_setup where ID > 0 and companyID = new.companyID and accountCode='saleacct'); 
end if;
if new.cogsID = 0 or new.cogsID is null then 
set new.cogsID = (select accountID from comp_control_acct_setup where id>0 and companyID = new.companyID and accountCode = 'saleacct');
end if;

end
//
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `item_adjustment`
--

CREATE TABLE IF NOT EXISTS `item_adjustment` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `locationID` int(11) NOT NULL,
  `formNo` varchar(32) NOT NULL,
  `updateAble` smallint(11) NOT NULL DEFAULT '1',
  `adjustmentDate` date NOT NULL,
  `createdBy` varchar(50) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=64 ;

-- --------------------------------------------------------

--
-- Table structure for table `item_adjustment_detail`
--

CREATE TABLE IF NOT EXISTS `item_adjustment_detail` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `adjustmentID` int(11) NOT NULL,
  `itemID` int(11) NOT NULL,
  `lineNo` int(11) NOT NULL,
  `unitOfMeasureID` int(11) NOT NULL,
  `umID` int(11) NOT NULL,
  `qtyOnHand` double NOT NULL COMMENT 'The number of items on the time of Adjustment',
  `counted` double NOT NULL COMMENT 'The actual number of items on the time of adjustment',
  `onDatePrice` double NOT NULL,
  `updateAble` smallint(11) NOT NULL DEFAULT '1',
  `adjustmentDate` date NOT NULL,
  `createdBy` varchar(50) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=63 ;

-- --------------------------------------------------------

--
-- Table structure for table `item_details`
--

CREATE TABLE IF NOT EXISTS `item_details` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) DEFAULT NULL,
  `itemID` int(11) DEFAULT NULL,
  `locationID` int(11) DEFAULT NULL,
  `onHandQty` double DEFAULT NULL,
  `umID` int(11) DEFAULT NULL,
  `acctID` int(11) DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `is_delete` smallint(6) DEFAULT NULL,
  PRIMARY KEY (`ID`),
  KEY `Index 2` (`companyID`,`acctID`,`locationID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT AUTO_INCREMENT=444 ;

-- --------------------------------------------------------

--
-- Table structure for table `master`
--

CREATE TABLE IF NOT EXISTS `master` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(64) NOT NULL,
  `description` varchar(128) NOT NULL,
  `updatedby` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `usedBySystem` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=23 ;

-- --------------------------------------------------------

--
-- Table structure for table `master_code`
--

CREATE TABLE IF NOT EXISTS `master_code` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `masterID` int(11) NOT NULL,
  `parentFilterID` int(11) DEFAULT NULL,
  `code` varchar(4) NOT NULL,
  `name` varchar(64) NOT NULL,
  `shortName` varchar(8) NOT NULL,
  `description` varchar(128) NOT NULL,
  `orderNo` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updateBy` int(11) NOT NULL,
  `updateTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(6) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=158 ;

-- --------------------------------------------------------

--
-- Table structure for table `module`
--

CREATE TABLE IF NOT EXISTS `module` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `parentModuleID` int(11) NOT NULL,
  `moduleName` varchar(64) NOT NULL,
  `description` varchar(254) NOT NULL,
  `orderNo` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;

-- --------------------------------------------------------

--
-- Table structure for table `person`
--

CREATE TABLE IF NOT EXISTS `person` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `name` int(11) NOT NULL,
  `position` varchar(64) NOT NULL,
  `employeeCode` varchar(16) NOT NULL,
  `genderID` int(11) NOT NULL,
  `dateOfBirth` date NOT NULL,
  `dateOfJoint` date NOT NULL,
  `remaks` text NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `person_contact`
--

CREATE TABLE IF NOT EXISTS `person_contact` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `personID` int(11) NOT NULL,
  `companyID` int(11) NOT NULL,
  `contactType` varchar(32) NOT NULL,
  `contact` tinytext NOT NULL,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `poke`
--

CREATE TABLE IF NOT EXISTS `poke` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `who` int(11) NOT NULL,
  `whom` int(11) NOT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1',
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=32 ;

-- --------------------------------------------------------

--
-- Table structure for table `prospect`
--

CREATE TABLE IF NOT EXISTS `prospect` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(64) NOT NULL,
  `email` varchar(64) NOT NULL,
  `login` varchar(32) NOT NULL,
  `paswd` varchar(32) NOT NULL,
  `tel` varchar(16) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `ip` varchar(32) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

-- --------------------------------------------------------

--
-- Table structure for table `supplier`
--

CREATE TABLE IF NOT EXISTS `supplier` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `supplierName` varchar(128) NOT NULL,
  `supplierCode` varchar(8) NOT NULL,
  `supplierCompanyNo` varchar(32) NOT NULL,
  `line1` varchar(128) NOT NULL,
  `line2` varchar(128) NOT NULL,
  `line3` varchar(128) NOT NULL,
  `city` varchar(128) NOT NULL,
  `supplierPostCode` varchar(8) NOT NULL,
  `supplierStateID` int(11) NOT NULL,
  `supplierCountryID` int(11) NOT NULL,
  `attention` varchar(100) NOT NULL,
  `website` varchar(32) NOT NULL,
  `phoneNumber1` varchar(50) NOT NULL,
  `phoneNumber2` varchar(50) NOT NULL,
  `fax` varchar(50) NOT NULL,
  `generalNote` varchar(255) NOT NULL,
  `gstRegNo` varchar(16) NOT NULL,
  `termsID` int(11) NOT NULL,
  `creditLimit` double NOT NULL,
  `creditLimitAlert` tinyint(1) NOT NULL,
  `linkedAPAccountID` int(11) NOT NULL,
  `createdDate` date NOT NULL,
  `currencyID` int(11) NOT NULL,
  `email` VARCHAR(64) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `termstatus` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(16) NOT NULL,
  `approvalNo` VARCHAR(32) NOT NULL,
  `commenceDate` DATE NOT NULL,
  `ceaseDate` DATE NOT NULL,
  `verifyDate` DATE NOT NULL,
  PRIMARY KEY (`ID`),
  KEY `ID` (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=121 ;

--
-- Triggers `supplier`
--
DROP TRIGGER IF EXISTS `trigger_default_created_date`;
DELIMITER //
CREATE TRIGGER `trigger_default_created_date` BEFORE INSERT ON `supplier`
 FOR EACH ROW if ( isnull(new.createddate) ) then
 set new.createddate=curdate();
end if
//
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `supplier_address`
--

CREATE TABLE IF NOT EXISTS `supplier_address` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `supplierID` int(11) NOT NULL,
  `addressCode` varchar(50) DEFAULT NULL,
  `addressName` varchar(128) DEFAULT NULL,
  `line1` varchar(128) DEFAULT NULL,
  `line2` varchar(128) DEFAULT NULL,
  `line3` varchar(128) DEFAULT NULL,
  `city` varchar(128) DEFAULT NULL,
  `postCode` varchar(8) DEFAULT NULL,
  `stateID` int(11) DEFAULT NULL,
  `countryID` int(11) DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `is_delete` smallint(16) DEFAULT '0',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=47 ;

-- --------------------------------------------------------

--
-- Table structure for table `supplier_contact`
--

CREATE TABLE IF NOT EXISTS `supplier_contact` (
  `ID` int(11) NOT NULL DEFAULT '0',
  `supplierID` int(11) NOT NULL,
  `personID` int(11) NOT NULL,
  `position` varchar(32) NOT NULL,
  `is_delete` smallint(16) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `tax_class`
--

CREATE TABLE IF NOT EXISTS `tax_class` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(10) DEFAULT NULL,
  `shortName` varchar(10) DEFAULT NULL,
  `description` varchar(128) DEFAULT NULL,
  `taxAccount` int(11) DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

-- --------------------------------------------------------

--
-- Table structure for table `tax_group`
--

CREATE TABLE IF NOT EXISTS `tax_group` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(10) DEFAULT NULL,
  `description` varchar(128) DEFAULT NULL,
  `taxAccount` int(11) DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT AUTO_INCREMENT=3 ;

-- --------------------------------------------------------

--
-- Table structure for table `tax_master`
--

CREATE TABLE IF NOT EXISTS `tax_master` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL DEFAULT '0',
  `code` varchar(10) DEFAULT NULL,
  `name` varchar(128) DEFAULT NULL,
  `taxType` int(11) DEFAULT NULL,
  `taxPercentage` double DEFAULT NULL,
  `taxClass` int(11) DEFAULT NULL,
  `taxGroup` int(11) DEFAULT NULL,
  `description` varchar(128) DEFAULT NULL,
  `taxAccount` int(11) DEFAULT NULL,
  `status` tinyint(1) DEFAULT '0',
  `createdBy` int(11) DEFAULT '0',
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`,`companyID`),
  KEY `FK_tax_master_tax_class` (`taxClass`),
  KEY `FK_tax_master_tax_group` (`taxGroup`),
  KEY `FK_tax_master_tax_type` (`taxType`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2623 ;

-- --------------------------------------------------------

--
-- Table structure for table `tax_type`
--

CREATE TABLE IF NOT EXISTS `tax_type` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(10) DEFAULT NULL,
  `taxGroupID` int(11) DEFAULT NULL,
  `description` varchar(128) DEFAULT NULL,
  `taxClass` int(11) NOT NULL,
  `taxAccount` int(11) DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT AUTO_INCREMENT=21 ;

-- --------------------------------------------------------

--
-- Table structure for table `tax_work_footer`
--

CREATE TABLE IF NOT EXISTS `tax_work_footer` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `recordID` varchar(1) DEFAULT NULL COMMENT 'Must be a single character corresponding to record type. Must be ‘F’',
  `purchaseCount` int(11) DEFAULT NULL COMMENT 'Number of P records',
  `purchaseAmount` double DEFAULT NULL COMMENT 'Debit Amount',
  `purchaseAmountGST` double DEFAULT NULL COMMENT 'Purchase GST Amount GST',
  `supplyCount` int(11) DEFAULT NULL COMMENT 'Supply Count',
  `supplyAmountSum` double DEFAULT NULL COMMENT 'Sum of all supplies',
  `supplyAmountSumGst` double DEFAULT NULL COMMENT 'Sum of GST on all supplies',
  `ledgerCount` int(11) DEFAULT NULL COMMENT 'Number of L records',
  `debitSum` double DEFAULT NULL COMMENT 'Debit Sum',
  `creditSum` double DEFAULT NULL COMMENT 'Credit Sum',
  `balanceSum` double DEFAULT NULL COMMENT 'Balance Sum',
  `status` smallint(1) DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `tax_work_gl`
--

CREATE TABLE IF NOT EXISTS `tax_work_gl` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `recordID` varchar(1) DEFAULT NULL COMMENT 'Must be a single character corresponding to record type.Must be ‘L’',
  `transactionDate` date DEFAULT NULL COMMENT 'Format: dd/MM/yyyy',
  `Account ID` int(11) DEFAULT NULL COMMENT 'General Ledger Code for individual account',
  `Account Name` varchar(3) DEFAULT NULL COMMENT 'Name of individual General Ledger account',
  `description` varchar(128) DEFAULT NULL COMMENT 'Transaction Description',
  `name` varchar(128) DEFAULT NULL COMMENT 'Name of entity involved (if applicable)',
  `journalID` varchar(128) DEFAULT NULL COMMENT 'A unique number that can group related double entries',
  `documentID` varchar(128) DEFAULT NULL COMMENT 'Source document number to which line relates (For example, cheque number, invoice number, credit note number, trust receipt number) ',
  `type` varchar(128) DEFAULT NULL COMMENT 'Refers to type of transaction such as AR. Refers to the type of transaction such as AR, AP, Inventory, Sales, Purchases, Cash Disbursement, Cash Receipt, General Journal etc.',
  `amount_dr` double DEFAULT NULL COMMENT 'Debit Amount',
  `amount_cr` double DEFAULT NULL COMMENT 'Credit amount',
  `Balance` double DEFAULT NULL COMMENT 'Balance Amount',
  `status` smallint(1) DEFAULT NULL,
  `gafID` int(11) DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `tax_work_header`
--

CREATE TABLE IF NOT EXISTS `tax_work_header` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `recordID` varchar(1) DEFAULT NULL COMMENT 'Must be a single character corresponding to record type. Must be ‘C’',
  `name` varchar(128) DEFAULT NULL COMMENT 'The name of the company for which this file is reporting on.',
  `BRN` varchar(128) DEFAULT NULL COMMENT 'Business registration number for company',
  `gstNo` varchar(128) DEFAULT NULL COMMENT 'Company GST number',
  `periodStart` date DEFAULT NULL COMMENT 'Filing Period Start Date Must be in format dd/MM/yyyy example: 01/12/2014’',
  `periodEnd` date DEFAULT NULL COMMENT 'Filing Period End Date Must be in format dd/MM/yyyy example: 31/12/2014’',
  `version` varchar(128) DEFAULT NULL COMMENT 'Accounting software name and version Example: XYB Accountsoft v.2.0',
  `GAFversion` varchar(128) DEFAULT NULL COMMENT 'GST Audit File (GAF) version number',
  `status` smallint(1) DEFAULT NULL,
  `gafID` smallint(1) DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `tax_work_purchase`
--

CREATE TABLE IF NOT EXISTS `tax_work_purchase` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `recordID` varchar(1) DEFAULT NULL COMMENT 'Must be a single character corresponding to record type. Must be ‘P’',
  `name` varchar(128) DEFAULT NULL COMMENT 'AN Name for supplier.',
  `BRN` varchar(128) DEFAULT NULL COMMENT 'BRN for company from which purchase was made.',
  `invoiceDate` date DEFAULT NULL COMMENT 'Invoice Date Format dd/MM/yyyy',
  `invoiceNo` varchar(128) DEFAULT NULL COMMENT 'Invoice Number',
  `importDeclare` varchar(128) DEFAULT NULL COMMENT 'Import Declaration Number. (e.g. Customs Form No. 1 reference',
  `invoiceLine` varchar(3) DEFAULT NULL COMMENT 'Number of Invoice Line',
  `description` varchar(128) DEFAULT NULL COMMENT 'Description for what was purchased',
  `amount` double DEFAULT NULL COMMENT 'Value of purchase excluding GST in Malaysia Ringgit.',
  `taxAmount` double DEFAULT NULL COMMENT 'Value of GST in Malaysia Ringgit.',
  `taxID` int(11) DEFAULT NULL,
  `taxCode` varchar(128) DEFAULT NULL COMMENT 'Tax code for lookup in tables. Please refer to Appendix',
  `currencyID` int(11) DEFAULT NULL,
  `currencyCode` varchar(128) DEFAULT NULL COMMENT 'ISO’s currency codes (3-letter alphabetical code) of foreign Currency. Example: USD',
  `currencyAmount` double DEFAULT NULL COMMENT 'Value of purchase excluding GST in Foreign Currency (If applicable).',
  `taxCurrencyAmount` double DEFAULT NULL COMMENT 'Value of GST in Foreign Currency (If applicable)',
  `status` smallint(2) DEFAULT NULL,
  `gafID` int(11) DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `tax_work_sales`
--

CREATE TABLE IF NOT EXISTS `tax_work_sales` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `recordID` varchar(1) DEFAULT NULL COMMENT 'Must be a single character corresponding to record type. Must be ‘S’',
  `name` varchar(128) DEFAULT NULL COMMENT 'Name of customer.',
  `BRN` varchar(128) DEFAULT NULL COMMENT 'BRN for supplier.',
  `invoiceDate` date DEFAULT NULL COMMENT 'Invoice Date Format dd/MM/yyyy',
  `invoiceNo` varchar(128) DEFAULT NULL COMMENT 'Invoice Number',
  `invoiceLine` varchar(3) DEFAULT NULL COMMENT 'Number of Invoice Line',
  `description` varchar(128) DEFAULT NULL COMMENT 'Description for what was sold',
  `amount` double DEFAULT NULL COMMENT 'Value of supply excluding GST in Malaysia Ringgit',
  `taxAmount` double DEFAULT NULL COMMENT 'Value of GST in Malaysia Ringgit',
  `taxID` int(11) DEFAULT NULL,
  `taxCode` varchar(128) DEFAULT NULL COMMENT 'Tax code for lookup in tables. Please refer to Appendix 2Example: SR',
  `countryID` int(11) DEFAULT NULL COMMENT 'Destination of goods being exported. Example: KOREA',
  `currencyID` int(11) DEFAULT NULL,
  `currencyCode` varchar(128) DEFAULT NULL COMMENT 'ISO’s currency codes (3-letter alphabetical code) of foreign Currency. Example: USD',
  `currencyAmount` double DEFAULT NULL COMMENT 'Value of purchase excluding GST in Foreign Currency (If applicable).',
  `taxCurrencyAmount` double DEFAULT NULL COMMENT 'Value of GST in Foreign Currency (If applicable)',
  `status` smallint(1) DEFAULT NULL,
  `gafID` int(11) DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `tbl_department`
--

CREATE TABLE IF NOT EXISTS `tbl_department` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `code` varchar(18) DEFAULT NULL,
  `description` varchar(100) DEFAULT NULL,
  `dept_head` int(11) DEFAULT NULL,
  `createdBy` int(11) NOT NULL,
  `is_deleted` tinyint(4) NOT NULL,
  `updatedBy` int(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT AUTO_INCREMENT=12 ;

-- --------------------------------------------------------

--
-- Table structure for table `tbl_location`
--

CREATE TABLE IF NOT EXISTS `tbl_location` (
  `fldid` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `code` varchar(20) DEFAULT NULL,
  `desc` varchar(100) DEFAULT NULL,
  `address` varchar(200) DEFAULT NULL,
  `line2` varchar(128) NOT NULL,
  `line3` varchar(128) NOT NULL,
  `postcode` varchar(10) DEFAULT NULL,
  `city` varchar(50) DEFAULT NULL,
  `state` int(10) DEFAULT NULL,
  `country` int(10) DEFAULT NULL,
  `phone_no` varchar(25) DEFAULT NULL,
  `fax_no` varchar(25) DEFAULT NULL,
  `create_by` varchar(50) DEFAULT NULL,
  `create_date` date DEFAULT NULL,
  PRIMARY KEY (`fldid`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=76 ;

-- --------------------------------------------------------

--
-- Table structure for table `tbl_section`
--

CREATE TABLE IF NOT EXISTS `tbl_section` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `code` varchar(18) DEFAULT NULL,
  `departmentID` int(11) DEFAULT NULL,
  `description` varchar(100) DEFAULT NULL,
  `section_head` int(11) DEFAULT NULL,
  `createdBy` int(11) NOT NULL,
  `updatedBy` int(11) NOT NULL,
  `is_deleted` tinyint(4) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT AUTO_INCREMENT=11 ;

-- --------------------------------------------------------

--
-- Table structure for table `tbl_usermaster`
--

CREATE TABLE IF NOT EXISTS `tbl_usermaster` (
  `fldid` int(11) NOT NULL AUTO_INCREMENT,
  `userid` varchar(50) NOT NULL DEFAULT '0',
  `password` varchar(32) DEFAULT '0',
  `username` varchar(150) DEFAULT NULL,
  `position` varchar(50) DEFAULT NULL,
  `email` varchar(100) DEFAULT NULL,
  `homepage` varchar(100) DEFAULT NULL,
  `phone_off` varchar(30) DEFAULT NULL,
  `phone_ext` varchar(10) DEFAULT NULL,
  `phone_mobile` varchar(100) DEFAULT NULL,
  `department` varchar(18) DEFAULT NULL,
  `section` varchar(18) DEFAULT NULL,
  `role` varchar(150) DEFAULT NULL,
  `status` smallint(1) DEFAULT NULL,
  `birthday` date DEFAULT NULL,
  `online` int(5) NOT NULL,
  `last_seen` datetime NOT NULL,
  `access_comp` varchar(255) NOT NULL,
  `last_seen_ip` varchar(30) NOT NULL,
  `create_dt` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `create_user` varchar(150) DEFAULT NULL,
  `modified_dt` date DEFAULT NULL,
  `modified_user` varchar(150) DEFAULT NULL,
  `is_delete` smallint(6) DEFAULT '0',
  `language` varchar(10) NOT NULL,
  PRIMARY KEY (`fldid`),
  UNIQUE KEY `userid` (`userid`),
  KEY `Index 3` (`userid`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT AUTO_INCREMENT=75 ;

-- --------------------------------------------------------

--
-- Table structure for table `terms`
--

CREATE TABLE IF NOT EXISTS `terms` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `termName` varchar(64) NOT NULL,
  `termDescription` varchar(255) NOT NULL,
  `dueDays` int(11) NOT NULL,
  `termStatusID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(16) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=80 ;

-- --------------------------------------------------------

--
-- Table structure for table `ug_content`
--

CREATE TABLE IF NOT EXISTS `ug_content` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `ugID` int(11) NOT NULL,
  `language` varchar(8) NOT NULL,
  `title` varchar(100) NOT NULL,
  `content` text NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=168 ;

-- --------------------------------------------------------

--
-- Table structure for table `ug_relatedtopic`
--

CREATE TABLE IF NOT EXISTS `ug_relatedtopic` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `ugID` int(11) NOT NULL,
  `relatedUgID` int(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;

-- --------------------------------------------------------

--
-- Table structure for table `ug_topic`
--

CREATE TABLE IF NOT EXISTS `ug_topic` (
  `fldid` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(8) CHARACTER SET utf8 DEFAULT NULL,
  `name` varchar(30) CHARACTER SET utf8 DEFAULT NULL,
  `parents` varchar(8) CHARACTER SET utf8 DEFAULT '0',
  `module` varchar(8) CHARACTER SET utf8 DEFAULT '0',
  `submenu` smallint(1) DEFAULT '0',
  `urls` varchar(100) CHARACTER SET utf8 DEFAULT '0',
  `urls2` varchar(100) CHARACTER SET utf8 DEFAULT '0',
  `access` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
  `seq` int(11) NOT NULL,
  `display` smallint(1) DEFAULT '1',
  `icons` varchar(32) CHARACTER SET utf8 DEFAULT 'i-film',
  `language` varchar(3) CHARACTER SET utf8 DEFAULT 'EN',
  PRIMARY KEY (`fldid`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=339 ;

-- --------------------------------------------------------

--
-- Table structure for table `ug_video`
--

CREATE TABLE IF NOT EXISTS `ug_video` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `ugID` int(11) NOT NULL,
  `title` varchar(64) NOT NULL,
  `videoLink` varchar(128) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=64 ;

-- --------------------------------------------------------

--
-- Table structure for table `user`
--

CREATE TABLE IF NOT EXISTS `user` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `userName` varchar(32) NOT NULL,
  `password` varchar(64) NOT NULL,
  `fullName` varchar(64) NOT NULL,
  `telephoneNo` varchar(16) NOT NULL,
  `emailAddress` varchar(16) NOT NULL,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `user_module_access`
--

CREATE TABLE IF NOT EXISTS `user_module_access` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) DEFAULT NULL,
  `userID` int(11) NOT NULL,
  `moduleID` int(11) NOT NULL,
  `transaction` smallint(2) NOT NULL DEFAULT '0',
  `reports` smallint(2) NOT NULL DEFAULT '0',
  `setup` smallint(2) NOT NULL DEFAULT '0',
  `accessRight` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1859 ;

-- --------------------------------------------------------

--
-- Table structure for table `user_module_access_details`
--

CREATE TABLE IF NOT EXISTS `user_module_access_details` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) DEFAULT NULL,
  `userID` int(11) NOT NULL,
  `menuCode` varchar(8) NOT NULL,
  `accessRight` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT AUTO_INCREMENT=1;

--
-- Table structure for table `wakaf`
--

CREATE TABLE IF NOT EXISTS `wakaf` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `waqifID` int(11) NOT NULL COMMENT 'link to mastercode',
  `wakafCenterID` int(11) NOT NULL,
  `allocation` tinyint(4) NOT NULL COMMENT '0=lumpsum,1=percentage',
  `periodYear` smallint(6) NOT NULL,
  `periodFrom` tinyint(4) NOT NULL,
  `periodTo` tinyint(4) NOT NULL,
  `amountAllocated` double NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=52 ;

-- --------------------------------------------------------

--
-- Table structure for table `wakaf_acrual`
--

CREATE TABLE IF NOT EXISTS `wakaf_acrual` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `salesAccountID` int(11) NOT NULL,
  `from` date NOT NULL,
  `to` date NOT NULL,
  `wakafPercent` decimal(10,0) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ;

-- --------------------------------------------------------

--
-- Table structure for table `wakaf_beneficiaries`
--

CREATE TABLE IF NOT EXISTS `wakaf_beneficiaries` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `shortName` varchar(12) NOT NULL DEFAULT '0',
  `name` varchar(128) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `createdBy` int(11) NOT NULL,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT AUTO_INCREMENT=7 ;

-- --------------------------------------------------------

--
-- Table structure for table `wakaf_center`
--

CREATE TABLE IF NOT EXISTS `wakaf_center` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `shortName` varchar(12) NOT NULL DEFAULT '0',
  `name` varchar(128) NOT NULL,
  `line1` varchar(128) NOT NULL,
  `line2` varchar(128) NOT NULL,
  `line3` varchar(128) NOT NULL,
  `city` varchar(64) NOT NULL,
  `postCode` varchar(8) NOT NULL,
  `stateID` int(11) NOT NULL,
  `countryID` int(11) NOT NULL,
  `noTel` varchar(50) NOT NULL,
  `noFax` varchar(50) NOT NULL,
  `email` varchar(128) NOT NULL,
  `website` varchar(128) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `createdBy` int(11) NOT NULL,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(16) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT AUTO_INCREMENT=40 ;

-- --------------------------------------------------------

--
-- Table structure for table `wakaf_details_allocation`
--

CREATE TABLE IF NOT EXISTS `wakaf_details_allocation` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `wakafID` varchar(64) NOT NULL DEFAULT '0',
  `accountID` int(11) NOT NULL,
  `saleAmount` double NOT NULL,
  `contributionPercentage` double NOT NULL,
  `amount` double NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `createdBy` int(11) NOT NULL,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT AUTO_INCREMENT=43 ;

-- --------------------------------------------------------

--
-- Table structure for table `wakaf_details_distribution`
--

CREATE TABLE IF NOT EXISTS `wakaf_details_distribution` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `wakafID` varchar(64) NOT NULL DEFAULT '0',
  `beneficiariesID` int(11) NOT NULL,
  `description` varchar(128) NOT NULL,
  `contributionPercentage` double NOT NULL,
  `amount` double NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `createdBy` int(11) NOT NULL,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT AUTO_INCREMENT=119 ;

-- --------------------------------------------------------

--
-- Table structure for table `wakaf_master`
--

CREATE TABLE IF NOT EXISTS `wakaf_master` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL DEFAULT '0',
  `waqif` varchar(64) NOT NULL DEFAULT '0',
  `category` varchar(24) NOT NULL,
  `allocationID` int(11) NOT NULL,
  `beneficiariesID` int(11) NOT NULL,
  `description` varchar(128) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `createdBy` int(11) NOT NULL,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT AUTO_INCREMENT=14 ;

-- --------------------------------------------------------

--
-- Table structure for table `zakat_center`
--

CREATE TABLE IF NOT EXISTS `zakat_center` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `shortName` varchar(12) NOT NULL DEFAULT '0',
  `name` varchar(128) NOT NULL,
  `line1` varchar(128) NOT NULL,
  `line2` varchar(128) NOT NULL,
  `line3` varchar(128) NOT NULL,
  `city` varchar(64) NOT NULL,
  `postCode` varchar(8) NOT NULL,
  `stateID` int(11) NOT NULL,
  `countryID` int(11) NOT NULL,
  `noTel` varchar(50) NOT NULL,
  `noFax` varchar(50) NOT NULL,
  `email` varchar(128) NOT NULL,
  `website` varchar(128) NOT NULL,
  `is_delete` tinyint(4) NOT NULL DEFAULT '0',
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `createdBy` int(11) NOT NULL,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT AUTO_INCREMENT=23 ;

-- --------------------------------------------------------

--
-- Table structure for table `zakat_details`
--

CREATE TABLE IF NOT EXISTS `zakat_details` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `zakatSummaryID` int(11) NOT NULL,
  `acctGroup` varchar(64) DEFAULT NULL,
  `desc` varchar(64) DEFAULT NULL,
  `amount` double DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT AUTO_INCREMENT=271 ;

-- --------------------------------------------------------

--
-- Table structure for table `zakat_group`
--

CREATE TABLE IF NOT EXISTS `zakat_group` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL DEFAULT '1',
  `name` varchar(50) DEFAULT NULL,
  `description` varchar(255) DEFAULT NULL,
  `parentID` int(11) DEFAULT '0',
  `sequence` int(11) DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT AUTO_INCREMENT=72 ;

-- --------------------------------------------------------

--
-- Table structure for table `zakat_group_details`
--

CREATE TABLE IF NOT EXISTS `zakat_group_details` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL DEFAULT '1',
  `groupID` int(11) DEFAULT NULL,
  `acctID` int(11) DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT AUTO_INCREMENT=35 ;

-- --------------------------------------------------------

--
-- Table structure for table `zakat_nisab`
--

CREATE TABLE IF NOT EXISTS `zakat_nisab` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL DEFAULT '0',
  `centerID` int(11) DEFAULT NULL,
  `year` year(4) DEFAULT NULL,
  `nisab` double DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT AUTO_INCREMENT=13 ;

-- --------------------------------------------------------

--
-- Table structure for table `zakat_summary`
--

CREATE TABLE IF NOT EXISTS `zakat_summary` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL DEFAULT '1',
  `centerID` int(11) NOT NULL DEFAULT '1',
  `year` varchar(4) DEFAULT NULL,
  `calculationMethod` varchar(32) NOT NULL,
  `muslimOwnershipShare` double NOT NULL,
  `nisab` double NOT NULL,
  `netCurrentAsset` double NOT NULL,
  `totalDueForZakat` double NOT NULL,
  `zakatPayableForTheYear` double NOT NULL,
  `monthlyZakatPayable` double NOT NULL,
  `totalAmount` double DEFAULT NULL,
  `totalZakatPaid` double DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT AUTO_INCREMENT=39 ;

-- --------------------------------------------------------

--
-- Table structure for table `_log_query`
--

CREATE TABLE IF NOT EXISTS `_log_query` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `userID` int(11) NOT NULL,
  `userIP` varchar(30) NOT NULL,
  `type` varchar(50) NOT NULL,
  `query` text NOT NULL,
  `url` varchar(255) NOT NULL,
  `executionTime` varchar(256) NOT NULL,
  `createdTS` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=339541 ;

-- --------------------------------------------------------

--
-- Table structure for table `_ref_acct_group`
--

CREATE TABLE IF NOT EXISTS `_ref_acct_group` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `acctTypeID` int(11) NOT NULL,
  `acctGroupName` varchar(128) NOT NULL,
  `acctCode` char(9) NOT NULL,
  `orderNo` int(11) DEFAULT NULL,
  `parentID` int(11) DEFAULT NULL,
  `title` tinyint(4) DEFAULT '0',
  `status` tinyint(4) DEFAULT '0',
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`),
  KEY `ID` (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=45 ;

-- --------------------------------------------------------

--
-- Table structure for table `_ref_acct_group_bakup`
--

CREATE TABLE IF NOT EXISTS `_ref_acct_group_bakup` (
  `ID` int(11) NOT NULL DEFAULT '0',
  `acctTypeID` int(11) NOT NULL,
  `acctGroupName` varchar(128) NOT NULL,
  `acctCode` char(9) NOT NULL,
  `orderNo` int(11) NOT NULL,
  `parentID` int(11) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `_ref_acct_type`
--

CREATE TABLE IF NOT EXISTS `_ref_acct_type` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `acctTypeName` varchar(128) NOT NULL,
  `acctClass` smallint(6) NOT NULL COMMENT '0=Balance Shit, 1=Profit and Lost',
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

-- --------------------------------------------------------

--
-- Table structure for table `_ref_business_type`
--

CREATE TABLE IF NOT EXISTS `_ref_business_type` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `industryID` int(11) NOT NULL,
  `name` varchar(128) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=27 ;

-- --------------------------------------------------------

--
-- Table structure for table `_ref_chart_of_acct`
--

CREATE TABLE IF NOT EXISTS `_ref_chart_of_acct` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `businessTypeID` int(11) NOT NULL,
  `acctGroupID` int(11) NOT NULL,
  `acctCode` char(9) NOT NULL,
  `parentID` int(11) NOT NULL,
  `acctName` varchar(128) NOT NULL,
  `acctDescription` varchar(128) NOT NULL,
  `defaultID` int(11) DEFAULT NULL COMMENT 'id default acct for general setup',
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=218 ;

-- --------------------------------------------------------

--
-- Table structure for table `_ref_chart_of_acct_back`
--

CREATE TABLE IF NOT EXISTS `_ref_chart_of_acct_back` (
  `ID` int(11) NOT NULL DEFAULT '0',
  `businessTypeID` int(11) NOT NULL,
  `acctGroupID` int(11) NOT NULL,
  `acctCode` char(9) NOT NULL,
  `parentID` int(11) NOT NULL,
  `acctName` varchar(128) NOT NULL,
  `acctDescription` varchar(128) NOT NULL,
  `defaultID` int(11) DEFAULT NULL COMMENT 'id default acct for general setup',
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `_ref_chart_of_acct_back_20141103`
--

CREATE TABLE IF NOT EXISTS `_ref_chart_of_acct_back_20141103` (
  `ID` int(11) NOT NULL DEFAULT '0',
  `businessTypeID` int(11) NOT NULL,
  `acctGroupID` int(11) NOT NULL,
  `acctCode` char(9) NOT NULL,
  `parentID` int(11) NOT NULL,
  `acctName` varchar(128) NOT NULL,
  `acctDescription` varchar(128) NOT NULL,
  `defaultID` int(11) DEFAULT NULL COMMENT 'id default acct for general setup',
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `_ref_control_acct_setup`
--

CREATE TABLE IF NOT EXISTS `_ref_control_acct_setup` (
  `ID` int(11) NOT NULL DEFAULT '0',
  `groupDisplay` smallint(6) NOT NULL,
  `code` varchar(4) NOT NULL,
  `name` varchar(64) NOT NULL,
  `shortName` varchar(8) NOT NULL,
  `description` varchar(128) NOT NULL,
  `orderNo` int(11) NOT NULL,
  `defaultAcctCode` varchar(9) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updateBy` int(11) NOT NULL,
  `updateTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `is_delete` smallint(6) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `_ref_country`
--

CREATE TABLE IF NOT EXISTS `_ref_country` (
  `fldid` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `fldcountry` varchar(45) DEFAULT NULL,
  `fldcontinent` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`fldid`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT AUTO_INCREMENT=895 ;

-- --------------------------------------------------------

--
-- Table structure for table `_ref_currency`
--

CREATE TABLE IF NOT EXISTS `_ref_currency` (
  `fldid` int(5) NOT NULL AUTO_INCREMENT,
  `fldcurr_code` varchar(5) DEFAULT NULL,
  `fldcurr_desc` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`fldid`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT AUTO_INCREMENT=13 ;

-- --------------------------------------------------------

--
-- Table structure for table `_ref_dateformat`
--

CREATE TABLE IF NOT EXISTS `_ref_dateformat` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(24) DEFAULT NULL,
  `codeJava` varchar(24) DEFAULT NULL,
  `description` varchar(64) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

-- --------------------------------------------------------

--
-- Table structure for table `_ref_industry`
--

CREATE TABLE IF NOT EXISTS `_ref_industry` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(128) NOT NULL,
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

-- --------------------------------------------------------

--
-- Table structure for table `_ref_language`
--

CREATE TABLE IF NOT EXISTS `_ref_language` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(3) DEFAULT '0',
  `description` varchar(64) DEFAULT '0',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

-- --------------------------------------------------------

--
-- Table structure for table `_ref_state`
--

CREATE TABLE IF NOT EXISTS `_ref_state` (
  `fldid` int(10) NOT NULL AUTO_INCREMENT,
  `fldregion_id` int(10) unsigned DEFAULT NULL,
  `fldname` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`fldid`),
  KEY `subregion_region_id` (`fldregion_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT AUTO_INCREMENT=3880 ;

-- --------------------------------------------------------

--
-- Table structure for table `_ref_tax_master`
--

CREATE TABLE IF NOT EXISTS `_ref_tax_master` (
  `ID` int(11) NOT NULL DEFAULT '0',
  `code` varchar(10) DEFAULT NULL,
  `name` varchar(128) DEFAULT NULL,
  `taxType` int(11) DEFAULT NULL,
  `taxPercentage` double DEFAULT NULL,
  `taxClass` int(11) DEFAULT NULL,
  `taxGroup` int(11) DEFAULT NULL,
  `description` varchar(128) DEFAULT NULL,
  `defaultTaxAccount` varchar(9) DEFAULT NULL,
  `status` tinyint(1) DEFAULT '0',
  `createdBy` int(11) DEFAULT '0',
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `_ref_zakat_group`
--

CREATE TABLE IF NOT EXISTS `_ref_zakat_group` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `defaultAcctCode` varchar(9) NOT NULL,
  `name` varchar(64) CHARACTER SET utf8 DEFAULT NULL,
  `description` varchar(128) CHARACTER SET utf8 DEFAULT NULL,
  `parentID` int(11) DEFAULT '0',
  `sequence` int(11) DEFAULT NULL,
  `createdBy` int(11) DEFAULT NULL,
  `createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) DEFAULT NULL,
  `updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

-- --------------------------------------------------------

--
-- Table structure for table `_sys_menu`
--

CREATE TABLE IF NOT EXISTS `_sys_menu` (
  `fldid` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(8) DEFAULT NULL,
  `name` varchar(30) DEFAULT NULL,
  `parents` varchar(8) DEFAULT '0',
  `module` varchar(8) DEFAULT '0',
  `submenu` smallint(1) DEFAULT '0',
  `urls` varchar(100) DEFAULT '0',
  `urls2` varchar(100) DEFAULT '0',
  `access` varchar(100) DEFAULT NULL,
  `seq` int(11) NOT NULL,
  `display` smallint(1) DEFAULT '1',
  `icons` varchar(32) DEFAULT 'i-film',
  `language` varchar(3) DEFAULT 'EN',
  PRIMARY KEY (`fldid`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT AUTO_INCREMENT=373 ;

-- --------------------------------------------------------

--
-- Table structure for table `_sys_um`
--

CREATE TABLE IF NOT EXISTS `_sys_um` (
  `fldid` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `code` varchar(10) DEFAULT NULL,
  `desc` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`fldid`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT AUTO_INCREMENT=96 ;

-- --------------------------------------------------------

--
-- Table structure for table `_sys_um_conv`
--

CREATE TABLE IF NOT EXISTS `_sys_um_conv` (
  `fldid` int(11) NOT NULL AUTO_INCREMENT,
  `companyID` int(11) NOT NULL,
  `itemID` int(11) DEFAULT NULL,
  `from_um` int(11) DEFAULT NULL,
  `to_um` int(11) DEFAULT NULL,
  `unitm` decimal(10,5) DEFAULT NULL,
  `factor` decimal(10,5) DEFAULT NULL,
  `create_by` varchar(50) DEFAULT NULL,
  `create_dt` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `modified_by` varchar(50) DEFAULT NULL,
  `modified_dt` datetime DEFAULT NULL,
  PRIMARY KEY (`fldid`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;

-- --------------------------------------------------------

--
-- Table structure for table `_sys_um_conv_bak`
--

CREATE TABLE IF NOT EXISTS `_sys_um_conv_bak` (
  `fldid` int(11) NOT NULL DEFAULT '0',
  `companyID` int(11) NOT NULL,
  `itemID` int(11) DEFAULT NULL,
  `from_um` int(11) DEFAULT NULL,
  `to_um` int(11) DEFAULT NULL,
  `unitm` decimal(10,5) DEFAULT NULL,
  `factor` decimal(10,5) DEFAULT NULL,
  `create_by` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
  `create_dt` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `modified_by` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
  `modified_dt` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS `comp_gst_transaction` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `serialNo` int(11) NOT NULL,
  `companyID` int(11) NOT NULL,
  `formNo` varchar(255) NOT NULL,
  `vendor_cust_name` varchar(255) NOT NULL,
  `type` varchar(255) NOT NULL,
  `gst_number` varchar(255) NOT NULL,
  `Description` text NOT NULL,
  `date` date NOT NULL,
  `reference` varchar(255) NOT NULL,
  `based_amount` double NOT NULL,
  `updateAble` tinyint(1) NOT NULL DEFAULT '1',
  `journalNo` varchar(255) NOT NULL,
  `reverse` BOOLEAN NOT NULL DEFAULT FALSE,
  `isDelete` int(11) NOT NULL DEFAULT '0',
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `comp_gst_transaction_detail` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `gstTransID` int(11) NOT NULL,
  `accountID` int(11) NOT NULL,
  `description` varchar(255) NOT NULL,
  `taxID` int(11) NOT NULL,
  `taxRate` double NOT NULL,
  `taxAmountDr` double NOT NULL DEFAULT '0',
  `taxAmountCr` double NOT NULL DEFAULT '0',
  `createdBy` int(11) NOT NULL,
  `createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedBy` int(11) NOT NULL,
  `updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `comp_gst_preference` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`companyID` int(11) NOT NULL,
`GSTTaxablePeriod` int(11) NOT NULL,
`badDebtReliefMinMonth` int(11) NOT NULL,
`MaxInputTaxClaim` int(11) NOT NULL,
`DaysLimits` int(11) NOT NULL,
`Totalexemptsuppliesnotexceed` int(11) NOT NULL,
`TotalexemptsuppliesnotexceedPercentage` int(11) NOT NULL,
`createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedBy` int(11) NOT NULL,
`updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `comp_gst_field_mapping` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`companyID` int(11) NOT NULL,
`item` varchar(255) NOT NULL,
`description` text NOT NULL,
`taxCode` varchar(255) NOT NULL,
`changeable` tinyint(1) NOT NULL DEFAULT '1',
`createdBy` int(11) NOT NULL,
`createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedBy` int(11) NOT NULL,
`updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


CREATE TABLE IF NOT EXISTS `_ref_gst_03_field` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`item` varchar(255) NOT NULL,
`description` varchar(255) NOT NULL,
`taxCode` varchar(255) NOT NULL,
`changeable` tinyint(1) NOT NULL DEFAULT '1',
`createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


CREATE TABLE IF NOT EXISTS `comp_purchase_bad_debt` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`companyID` int(11) NOT NULL,
`supplierID` int(11) NOT NULL,
`valueBadDebt` double NOT NULL,
`gstBadDebt` double NOT NULL,
`transDate` date NOT NULL,
`updateAble` tinyint(1) NOT NULL DEFAULT '1',
`journalNo` varchar(255) NOT NULL,
`createdBy` int(11) NOT NULL,
`createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedBy` int(11) NOT NULL,
`updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `comp_purchase_debt_recover` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`companyID` int(11) NOT NULL,
`suppID` int(11) NOT NULL,
`valueDebtRecover` double NOT NULL,
`gstDebtRecover` double NOT NULL,
`transDate` date NOT NULL,
`updateAble` tinyint(1) NOT NULL DEFAULT '1',
`journalNo` varchar(255) NOT NULL,
`createdBy` int(11) NOT NULL,
`createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`updatedBy` int(11) NOT NULL,
`updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `trash_comp_journal` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`oldID` int(11) NOT NULL,
`companyID` int(11) DEFAULT NULL,
`journalID` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
`description` varchar(128) CHARACTER SET utf8 DEFAULT NULL,
`referrence` varchar(128) CHARACTER SET utf8 DEFAULT NULL,
`batch` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
`module` int(11) DEFAULT NULL,
`effective_date` date DEFAULT NULL,
`entered_date` date DEFAULT NULL,
`period` smallint(2) DEFAULT NULL,
`year` year(4) DEFAULT NULL,
`total_amount_dr` double DEFAULT NULL,
`total_amount_cr` double DEFAULT NULL,
`total_amount` double DEFAULT '0',
`status` tinyint(4) DEFAULT '0' COMMENT 'unposted = 0, posted = 1',
`remarks` varchar(128) CHARACTER SET utf8 DEFAULT NULL,
`createdBy` int(11) DEFAULT NULL,
`createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`formNo` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
`is_delete` smallint(16) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;


CREATE TABLE IF NOT EXISTS `trash_comp_journal_detail` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`trashID` int(11) NOT NULL,
`oldID` int(11) NOT NULL,
`companyID` int(11) DEFAULT '0',
`journalID` varchar(50) CHARACTER SET utf8 DEFAULT '0',
`sequence` int(11) DEFAULT '0',
`acctCode` int(11) DEFAULT '0',
`projectID` int(11) DEFAULT '0',
`description` varchar(200) CHARACTER SET utf8 DEFAULT '0',
`amount_cr` double DEFAULT '0',
`amount_dr` double DEFAULT '0',
`currencyID` int(11) DEFAULT '0',
`currency_amount` double DEFAULT '0',
`exchange_rate` double DEFAULT '0',
`enter_exchange_rate` double DEFAULT '0',
`period` smallint(2) DEFAULT '0',
`year` year(4) DEFAULT NULL,
`formNo` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
`supplier` varchar(200) CHARACTER SET utf8 DEFAULT NULL,
`line` int(11) DEFAULT NULL,
`status` smallint(2) DEFAULT '0',
`createdBy` int(11) DEFAULT NULL,
`createdTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`updatedBy` int(11) DEFAULT NULL,
`updatedTS` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`is_delete` smallint(16) NOT NULL,
`bankReconcileID` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;

CREATE TABLE IF NOT EXISTS `comp_gst_field_mapping` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`companyID` int(11) NOT NULL,
`item` varchar(255) NOT NULL,
`description` text NOT NULL,
`taxCode` varchar(255) NOT NULL,
`changeable` tinyint(1) NOT NULL DEFAULT '1',
`createdBy` int(11) NOT NULL,
`createdTS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedBy` int(11) NOT NULL,
`updatedTS` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=91 ;

-- --------------------------------------------------------