HEX
Server: Apache/2.2.15 (CentOS)
System: Linux ip-10-0-2-146.eu-west-1.compute.internal 2.6.32-754.35.1.el6.centos.plus.x86_64 #1 SMP Sat Nov 7 11:33:42 UTC 2020 x86_64
User: root (0)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: //www/exchange2/sql/schema/Exchange-2.0-Schema-2022-02-16.sql
-- MySQL dump 10.13  Distrib 5.5.47, for Linux (x86_64)
--
-- Host: prod-exchange-vpc.c6wcnnogohkm.eu-west-1.rds.amazonaws.com    Database: exchange
-- ------------------------------------------------------
-- Server version	5.6.51-log

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Current Database: `exchange`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `exchange` /*!40100 DEFAULT CHARACTER SET utf8 */;

USE `exchange`;

--
-- Table structure for table `a_etr`
--

DROP TABLE IF EXISTS `a_etr`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `a_etr` (
  `a_etr_id` int(11) NOT NULL AUTO_INCREMENT,
  `organisation_id` int(11) NOT NULL,
  `reference_id` bigint(20) DEFAULT NULL,
  `friendly_name` varchar(255) DEFAULT NULL,
  `number_of_periods` int(11) NOT NULL,
  `period_type` varchar(45) NOT NULL,
  `sell_rate` decimal(6,3) NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `currency_id` int(11) NOT NULL,
  `description` varchar(255) DEFAULT NULL,
  `a_etr_type` varchar(255) DEFAULT NULL,
  `supplier` varchar(255) DEFAULT NULL,
  `serial_number` varchar(255) DEFAULT NULL,
  `address_id` int(11) DEFAULT NULL,
  `status` tinyint(4) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `modified_at` datetime DEFAULT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `submitted_at` datetime DEFAULT NULL,
  `submitted_by` int(11) DEFAULT NULL,
  `approved_at` datetime DEFAULT NULL,
  `approved_by` int(11) DEFAULT NULL,
  `rejected_at` datetime DEFAULT NULL,
  `rejected_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`a_etr_id`),
  KEY `org_idx` (`organisation_id`)
) ENGINE=InnoDB AUTO_INCREMENT=219 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `account_label`
--

DROP TABLE IF EXISTS `account_label`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `account_label` (
  `account_label_id` bigint(10) NOT NULL AUTO_INCREMENT,
  `account_label_type` varchar(255) NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(10) NOT NULL,
  PRIMARY KEY (`account_label_id`),
  UNIQUE KEY `account_label_type` (`account_label_type`),
  KEY `modified_by` (`modified_by`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `accounting_software`
--

DROP TABLE IF EXISTS `accounting_software`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `accounting_software` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `sort` int(5) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `accounts_journal`
--

DROP TABLE IF EXISTS `accounts_journal`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `accounts_journal` (
  `aj_id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
  `bank_account_id` varchar(50) DEFAULT NULL,
  `aj_account_id` smallint(5) unsigned DEFAULT NULL,
  `sort_order` tinyint(3) unsigned DEFAULT NULL,
  PRIMARY KEY (`aj_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `activity_logs`
--

DROP TABLE IF EXISTS `activity_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `activity_logs` (
  `activity_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL,
  `link` varchar(255) NOT NULL,
  `log_element_id` int(10) NOT NULL,
  `admin_user_id` int(10) NOT NULL,
  `user_id` int(10) NOT NULL,
  `debtor_id` int(10) NOT NULL,
  `organisation_id` int(10) NOT NULL,
  `invoice_id` int(10) NOT NULL,
  `created_at` datetime NOT NULL,
  `pc_value` decimal(6,2) NOT NULL DEFAULT '0.00',
  `old_value` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`activity_id`)
) ENGINE=MyISAM AUTO_INCREMENT=569465 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `address_details`
--

DROP TABLE IF EXISTS `address_details`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `address_details` (
  `address_id` mediumint(40) unsigned NOT NULL AUTO_INCREMENT,
  `address_line_one` varchar(255) NOT NULL,
  `address_line_two` varchar(255) NOT NULL,
  `address_area` varchar(255) NOT NULL,
  `address_city` varchar(255) NOT NULL,
  `address_state` varchar(255) NOT NULL,
  `address_country` tinyint(25) unsigned NOT NULL,
  `address_zipcode` varchar(20) NOT NULL,
  `address_phone_country` varchar(5) DEFAULT NULL,
  `address_phone_code` varchar(5) DEFAULT NULL,
  `address_phone` varchar(40) DEFAULT NULL,
  `address_mobile_country` varchar(5) DEFAULT NULL,
  `address_mobile_code` varchar(5) DEFAULT NULL,
  `address_mobile` varchar(10) DEFAULT NULL,
  `address_fax_country` varchar(5) DEFAULT NULL,
  `address_fax_code` varchar(5) DEFAULT NULL,
  `address_fax` varchar(10) DEFAULT NULL,
  `address_email` varchar(255) NOT NULL,
  `address_email1` varchar(255) NOT NULL,
  `address_all_details` text NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` tinyint(20) unsigned NOT NULL,
  PRIMARY KEY (`address_id`),
  KEY `address_country` (`address_country`,`address_email`)
) ENGINE=InnoDB AUTO_INCREMENT=46660 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `admin_sessions`
--

DROP TABLE IF EXISTS `admin_sessions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `admin_sessions` (
  `aid` int(10) NOT NULL AUTO_INCREMENT,
  `admin_user_id` varchar(255) NOT NULL,
  `hostname` varchar(255) NOT NULL,
  `logged_time` datetime NOT NULL,
  `modified_time` datetime NOT NULL,
  PRIMARY KEY (`aid`)
) ENGINE=MyISAM AUTO_INCREMENT=31475 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `admin_users`
--

DROP TABLE IF EXISTS `admin_users`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `admin_users` (
  `admin_user_id` bigint(10) NOT NULL AUTO_INCREMENT,
  `first_name` varchar(255) NOT NULL,
  `last_name` varchar(255) NOT NULL,
  `admin_email` varchar(200) NOT NULL,
  `admin_password` varchar(200) NOT NULL,
  `admin_code` varchar(255) NOT NULL,
  `admin_type` tinyint(5) NOT NULL COMMENT '1-Admin,2- DEBX Employee',
  `admin_status` tinyint(5) NOT NULL COMMENT '1-Active,2-Inactive',
  `user_id` int(40) NOT NULL,
  `admin_created_by` bigint(10) NOT NULL,
  `admin_created_on` datetime NOT NULL,
  `admin_last_login` datetime NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`admin_user_id`),
  UNIQUE KEY `admin_email` (`admin_email`),
  KEY `admin_created_by` (`admin_created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=94 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `api_access`
--

DROP TABLE IF EXISTS `api_access`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `api_access` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` bigint(40) NOT NULL,
  `organisation_id` bigint(40) NOT NULL,
  `api_key` varchar(40) NOT NULL,
  `params` text NOT NULL,
  `ip_address` varchar(20) NOT NULL,
  `status` int(11) NOT NULL,
  `created_at` datetime NOT NULL,
  `created_by` bigint(40) NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(40) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `archive_debtor_relation`
--

DROP TABLE IF EXISTS `archive_debtor_relation`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `archive_debtor_relation` (
  `relation_id` mediumint(40) unsigned NOT NULL,
  `trader_id` smallint(40) unsigned NOT NULL,
  `debtor_id` mediumint(40) unsigned NOT NULL,
  `organisation_id` smallint(40) unsigned NOT NULL,
  `child_id` bigint(40) NOT NULL DEFAULT '0',
  `status` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `notify` int(5) NOT NULL DEFAULT '0',
  `invt_status` tinyint(2) NOT NULL,
  `revolving_etr` tinyint(2) unsigned NOT NULL DEFAULT '0',
  `ed_status` tinyint(4) unsigned NOT NULL COMMENT '0-false,1-true',
  `bcc_status` tinyint(4) unsigned NOT NULL COMMENT '0-false,1-true',
  `noad_link` text NOT NULL,
  `noad_notified` datetime NOT NULL,
  `noid_link` text NOT NULL,
  `noid_notified` datetime NOT NULL,
  `changed_status` tinyint(4) unsigned NOT NULL COMMENT '2-notified,6-rate',
  `noid_status` tinyint(4) unsigned NOT NULL COMMENT '1-Issued,2-Approved,3-Rejected',
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`relation_id`),
  KEY `relation_id` (`relation_id`),
  KEY `trader_id` (`trader_id`,`debtor_id`,`organisation_id`,`status`,`ed_status`,`bcc_status`),
  KEY `debtor_id` (`debtor_id`),
  KEY `IDX_debtor_relation_organisation_id` (`organisation_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `archive_debtors_detail`
--

DROP TABLE IF EXISTS `archive_debtors_detail`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `archive_debtors_detail` (
  `debtor_id` mediumint(20) unsigned NOT NULL AUTO_INCREMENT,
  `debtor_reference_id` bigint(50) NOT NULL,
  `debtor_contact_first_name` varchar(200) DEFAULT NULL,
  `debtor_contact_last_name` varchar(200) NOT NULL,
  `website` varchar(255) NOT NULL,
  `job_title` varchar(255) NOT NULL,
  `pronounced` varchar(255) NOT NULL,
  `phone1` varchar(20) NOT NULL,
  `phone2` varchar(20) NOT NULL,
  `debtor_company_registration_number` varchar(200) NOT NULL,
  `nace_id` smallint(20) unsigned NOT NULL DEFAULT '261',
  `nace_group_id` tinyint(10) unsigned NOT NULL DEFAULT '16',
  `debtor_name` varchar(200) NOT NULL,
  `trade_name` varchar(200) NOT NULL,
  `previous_name` varchar(200) NOT NULL,
  `customer_since` year(4) NOT NULL,
  `total_debtor_value` bigint(40) NOT NULL,
  `average_payment_cycle` bigint(40) NOT NULL,
  `no_credit_note_issued` bigint(40) NOT NULL,
  `avg_invoice_predicted_annum` bigint(40) NOT NULL,
  `avg_revenue_predicted_annum` double NOT NULL,
  `debtor_risk` int(11) NOT NULL,
  `debtor_limit` int(11) NOT NULL,
  `credit_limit` int(11) NOT NULL,
  `credit_limit_changed_at` datetime DEFAULT NULL,
  `credit_limit_changed_by` tinyint(3) DEFAULT NULL,
  `credit_limit_old_value` int(11) DEFAULT NULL,
  `purchase_price` decimal(6,2) NOT NULL DEFAULT '0.00',
  `credit_risk` int(11) NOT NULL,
  `cr_changed_at` datetime DEFAULT NULL,
  `cr_changed_by` tinyint(3) DEFAULT NULL,
  `cr_old_value` int(11) DEFAULT NULL,
  `credit_today_limit` int(11) NOT NULL,
  `filepdf` text,
  `filescv` text,
  `address_id` mediumint(11) unsigned DEFAULT NULL,
  `billing_address_id` mediumint(11) unsigned DEFAULT NULL,
  `contact_address_id` mediumint(11) unsigned DEFAULT NULL,
  `currency_id` tinyint(3) unsigned NOT NULL,
  `created_by` tinyint(10) unsigned NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` tinyint(10) unsigned NOT NULL,
  `published` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '0-Waiting:1-Approved:2-Rejected:3-Expired',
  `founded` date NOT NULL,
  `parent_id` mediumint(40) unsigned NOT NULL DEFAULT '0',
  `created` datetime NOT NULL,
  `dmc` int(5) NOT NULL DEFAULT '0',
  `interface_added` tinyint(2) NOT NULL DEFAULT '0',
  `type` enum('debtor','creditor') NOT NULL DEFAULT 'debtor',
  `payment_discount` double(4,2) unsigned NOT NULL DEFAULT '0.00',
  `sell_rate` decimal(10,4) DEFAULT NULL,
  `trade_limit` bigint(10) DEFAULT NULL,
  `trade_limit_changed_at` datetime DEFAULT NULL,
  `trade_limit_changed_by` tinyint(3) DEFAULT NULL,
  `trade_limit_old_value` int(11) DEFAULT NULL,
  `is_rva` tinyint(4) DEFAULT '1',
  `aig_dl` decimal(10,2) DEFAULT '0.00',
  `insurance_specified_limit` decimal(10,0) DEFAULT '0',
  `isl_changed_at` datetime DEFAULT NULL,
  `isl_changed_by` tinyint(3) DEFAULT NULL,
  `isl_old_value` int(11) DEFAULT NULL,
  `cs_changed_at` datetime DEFAULT '0000-00-00 00:00:00',
  `cs_changed_by` tinyint(3) unsigned DEFAULT '0',
  `cs_old_value` int(11) DEFAULT '0',
  `etr_type` varchar(3) DEFAULT NULL,
  PRIMARY KEY (`debtor_id`),
  UNIQUE KEY `UK_debtors_detail_debtor_id` (`debtor_id`),
  KEY `created_by` (`created_by`),
  KEY `modified_by` (`modified_by`),
  KEY `debtor_reference_id` (`debtor_reference_id`,`nace_id`,`nace_group_id`,`debtor_name`,`trade_name`,`average_payment_cycle`,`no_credit_note_issued`,`avg_invoice_predicted_annum`,`avg_revenue_predicted_annum`,`debtor_risk`,`debtor_limit`,`parent_id`),
  KEY `currency_id` (`currency_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5860 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `asset_purchase_invoice`
--

DROP TABLE IF EXISTS `asset_purchase_invoice`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `asset_purchase_invoice` (
  `purchase_invoice_id` int(11) NOT NULL AUTO_INCREMENT,
  `purchase_document_no` varchar(255) NOT NULL,
  `purchase_date` date NOT NULL,
  `currency_id` int(11) NOT NULL,
  `face_value` double NOT NULL,
  `quantity` int(11) NOT NULL,
  `vendor_name` varchar(255) DEFAULT NULL,
  `document_link` varchar(255) NOT NULL,
  `a_etr_id` int(11) NOT NULL,
  PRIMARY KEY (`purchase_invoice_id`),
  KEY `a_etr_idx` (`a_etr_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `auto_trade_settings`
--

DROP TABLE IF EXISTS `auto_trade_settings`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `auto_trade_settings` (
  `auto_trade_setting_id` int(5) NOT NULL AUTO_INCREMENT,
  `global_trade_status` tinyint(2) NOT NULL COMMENT '1-Active,2-Inactive',
  `global_risk_status` tinyint(2) NOT NULL COMMENT '1-Active,2-Inactive',
  `global_credit_limit_status` tinyint(2) NOT NULL COMMENT '1-Active,2-Inactive',
  `global_reserve_status` tinyint(2) NOT NULL COMMENT '1-Active,2-Inactive',
  `global_advance_status` tinyint(2) NOT NULL COMMENT '1-Active,2-Inactive',
  `global_buy_status` tinyint(2) NOT NULL COMMENT '1-Active,2-Inactive',
  `global_category_status` tinyint(2) NOT NULL COMMENT '1-Active,2-Inactive',
  `global_debtor_status` tinyint(2) NOT NULL COMMENT '1-Active,2-Inactive',
  `global_treder_status` tinyint(2) NOT NULL COMMENT '1-Active,2-Inactive',
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`auto_trade_setting_id`),
  KEY `modified_by` (`modified_by`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `bank_account`
--

DROP TABLE IF EXISTS `bank_account`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bank_account` (
  `account_id` tinyint(40) unsigned NOT NULL AUTO_INCREMENT,
  `bank_account_name` varchar(50) NOT NULL,
  `names` varchar(50) NOT NULL,
  `account_type` tinyint(2) unsigned NOT NULL,
  `bank_account_no` varchar(50) NOT NULL,
  `iban_code` varchar(50) NOT NULL,
  `swift_code` varchar(20) NOT NULL,
  `sort_code` varchar(20) NOT NULL,
  `currency_id` tinyint(40) unsigned NOT NULL,
  `address_id` mediumint(40) unsigned NOT NULL,
  `status_type` tinyint(3) unsigned NOT NULL COMMENT '1-Segregated Retail Investor Trust A/c,2-Segregated Clearing Trust A/c,3-Exchange Loss & Default Control A/c,4-Segregated Debtor Trust A/c,5-Exchange Intermediary & Agent A/c,6-Exchange Loss & Default Reserve A/c,7-Exchange Operations Deposit A/c',
  `status` tinyint(2) unsigned NOT NULL,
  `authorise` tinyint(2) unsigned NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` datetime NOT NULL,
  `created_by` tinyint(20) unsigned NOT NULL,
  `modified_by` tinyint(20) unsigned NOT NULL,
  PRIMARY KEY (`account_id`)
) ENGINE=MyISAM AUTO_INCREMENT=28 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `bank_account_change_request`
--

DROP TABLE IF EXISTS `bank_account_change_request`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bank_account_change_request` (
  `request_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `account_name` varchar(255) NOT NULL,
  `account_no` varchar(255) NOT NULL,
  `sort_code` varchar(255) NOT NULL,
  `iban_code` varchar(50) NOT NULL,
  `swift_code` varchar(50) NOT NULL,
  `account_id` bigint(40) NOT NULL,
  `status` tinyint(10) NOT NULL,
  `created` datetime NOT NULL,
  `h_account_name` varchar(255) NOT NULL,
  `h_account_no` varchar(255) NOT NULL,
  `h_sort_code` varchar(255) NOT NULL,
  `h_iban_code` varchar(50) NOT NULL,
  `h_swift_code` varchar(50) NOT NULL,
  `log` int(2) NOT NULL DEFAULT '0',
  `modified` datetime NOT NULL,
  PRIMARY KEY (`request_id`)
) ENGINE=MyISAM AUTO_INCREMENT=351 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `bank_accounts`
--

DROP TABLE IF EXISTS `bank_accounts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bank_accounts` (
  `account_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `account_type` int(2) NOT NULL,
  `command` varchar(10) NOT NULL,
  `version` varchar(5) NOT NULL,
  `benificiary_account` varchar(50) NOT NULL,
  `benificiary_name` varchar(50) NOT NULL,
  `payment_type` varchar(5) NOT NULL,
  `currency` varchar(5) NOT NULL,
  `organisation_id` bigint(40) NOT NULL,
  `temp_reg_id` bigint(40) NOT NULL,
  `user_type` int(5) NOT NULL,
  `iban` varchar(50) NOT NULL,
  `swift_code` varchar(50) NOT NULL,
  `sort_code` varchar(50) NOT NULL,
  `efts_userid` varchar(50) NOT NULL,
  `electronic_advice` varchar(5) NOT NULL,
  `status` int(2) NOT NULL DEFAULT '0',
  `authorise` int(2) NOT NULL DEFAULT '0',
  `created_date` datetime NOT NULL,
  `modified_date` datetime NOT NULL,
  `created_by` bigint(20) NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`account_id`)
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `bank_details`
--

DROP TABLE IF EXISTS `bank_details`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bank_details` (
  `bank_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `bank_name` varchar(250) NOT NULL,
  `bank_country` int(5) NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  `bank_status` tinyint(2) NOT NULL COMMENT '0-Suspend,1-Active',
  PRIMARY KEY (`bank_id`)
) ENGINE=MyISAM AUTO_INCREMENT=647 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `calclator_settings`
--

DROP TABLE IF EXISTS `calclator_settings`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `calclator_settings` (
  `cal_id` int(50) NOT NULL AUTO_INCREMENT,
  `field_name` varchar(50) NOT NULL,
  `field_value` varchar(50) NOT NULL,
  PRIMARY KEY (`cal_id`)
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `categories`
--

DROP TABLE IF EXISTS `categories`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `categories` (
  `nace_id` smallint(20) unsigned NOT NULL AUTO_INCREMENT,
  `nace_code` varchar(20) NOT NULL,
  `nace_group` varchar(10) NOT NULL,
  `nace_group_id` tinyint(10) unsigned NOT NULL,
  `nace_title` varchar(255) NOT NULL,
  `nace_description` text NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` tinyint(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`nace_id`),
  KEY `sic_group_id` (`nace_group_id`),
  KEY `modified_by` (`modified_by`),
  KEY `nace_code` (`nace_code`),
  KEY `nace_group` (`nace_group`),
  KEY `nace_group_id` (`nace_group_id`)
) ENGINE=InnoDB AUTO_INCREMENT=694 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `category_group`
--

DROP TABLE IF EXISTS `category_group`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `category_group` (
  `nace_group_id` tinyint(10) unsigned NOT NULL AUTO_INCREMENT,
  `nace_group_code` varchar(10) NOT NULL,
  `nace_group_title` varchar(255) NOT NULL,
  `nace_group_description` text NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` tinyint(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`nace_group_id`),
  UNIQUE KEY `sic_group_code` (`nace_group_code`),
  KEY `modified_by` (`modified_by`),
  KEY `nace_group_code` (`nace_group_code`),
  KEY `nace_group_id` (`nace_group_id`)
) ENGINE=InnoDB AUTO_INCREMENT=34 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `central_banking`
--

DROP TABLE IF EXISTS `central_banking`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `central_banking` (
  `transfer_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `document_id` bigint(40) NOT NULL,
  `debx_id` bigint(40) NOT NULL,
  `debtor_id` bigint(40) NOT NULL,
  `trader_id` bigint(40) NOT NULL,
  `investor_id` bigint(40) NOT NULL,
  `command` varchar(10) NOT NULL,
  `version` varchar(10) NOT NULL,
  `ordering_account` varchar(50) NOT NULL,
  `efts_userid` varchar(10) NOT NULL,
  `ben_account` varchar(50) NOT NULL,
  `amount` double NOT NULL,
  `date` varchar(10) NOT NULL,
  `currency` varchar(5) NOT NULL,
  `payment_type` varchar(5) NOT NULL,
  `ben_name` varchar(50) NOT NULL,
  `ordering_account_text` varchar(50) NOT NULL,
  `ben_ref_text` varchar(75) NOT NULL,
  `message_for_ben1` varchar(75) NOT NULL,
  `message_for_ben2` varchar(75) NOT NULL,
  `message_for_ben3` varchar(75) NOT NULL,
  `message_for_ben4` varchar(75) NOT NULL,
  `payers_name` varchar(50) NOT NULL,
  `technical_ref` varchar(75) NOT NULL,
  `device_type` varchar(10) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`transfer_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `central_banking_cmii`
--

DROP TABLE IF EXISTS `central_banking_cmii`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `central_banking_cmii` (
  `transfer_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `cmii_master_id` bigint(40) NOT NULL,
  `statement_id` bigint(40) NOT NULL,
  `bank_master_id` bigint(40) NOT NULL,
  `document_id` bigint(40) NOT NULL,
  `debx_id` bigint(40) NOT NULL,
  `debtor_id` bigint(40) NOT NULL,
  `trader_id` bigint(40) NOT NULL,
  `investor_id` bigint(40) NOT NULL,
  `command` varchar(10) NOT NULL,
  `version` varchar(10) NOT NULL,
  `ordering_account` varchar(50) NOT NULL,
  `efts_userid` varchar(10) NOT NULL,
  `ben_account` varchar(50) NOT NULL,
  `amount` double NOT NULL,
  `date` varchar(10) NOT NULL,
  `currency` varchar(5) NOT NULL,
  `payment_type` varchar(5) NOT NULL,
  `ben_name` varchar(50) NOT NULL,
  `ordering_account_text` varchar(50) NOT NULL,
  `ben_ref_text` varchar(75) NOT NULL,
  `message_for_ben1` varchar(75) NOT NULL,
  `message_for_ben2` varchar(75) NOT NULL,
  `message_for_ben3` varchar(75) NOT NULL,
  `message_for_ben4` varchar(75) NOT NULL,
  `payers_name` varchar(50) NOT NULL,
  `technical_ref` varchar(75) NOT NULL,
  `device_type` varchar(10) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`transfer_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `central_banking_details`
--

DROP TABLE IF EXISTS `central_banking_details`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `central_banking_details` (
  `transfer_id` bigint(40) NOT NULL,
  `document_id` bigint(40) NOT NULL,
  `transfer_date` date NOT NULL,
  `transfer_from` bigint(40) NOT NULL,
  `transfer_to` bigint(40) NOT NULL,
  `transfer_out` double NOT NULL,
  `transfer_in` double NOT NULL,
  `transfer_balance` double NOT NULL,
  `transfer_details` text NOT NULL,
  `central_bank_id` int(10) NOT NULL DEFAULT '1',
  `created_date` datetime NOT NULL,
  `modified_date` datetime NOT NULL,
  PRIMARY KEY (`transfer_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `central_banking_documents`
--

DROP TABLE IF EXISTS `central_banking_documents`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `central_banking_documents` (
  `document_id` bigint(40) NOT NULL,
  `document_path` text NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `central_banking_feof`
--

DROP TABLE IF EXISTS `central_banking_feof`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `central_banking_feof` (
  `eof_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `eof_label_identity` varchar(3) NOT NULL,
  `eof_lable_no` varchar(1) NOT NULL,
  `eof_file_identity` varchar(17) NOT NULL,
  `eof_file_set_identity` varchar(6) NOT NULL,
  `eof_file_section` varchar(4) NOT NULL,
  `eof_sequence` varchar(4) NOT NULL,
  `eof_gen_no` varchar(4) NOT NULL,
  `eof_gen_version_no` varchar(2) NOT NULL,
  `eof_created` varchar(6) NOT NULL,
  `eof_expire` varchar(6) NOT NULL,
  `eof_access` varchar(1) NOT NULL,
  `eof_block_count` varchar(6) NOT NULL,
  `eof_code` varchar(13) NOT NULL,
  `eof_filler` varchar(7) NOT NULL,
  `bank_master_id` bigint(40) NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`eof_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `central_banking_ffhr`
--

DROP TABLE IF EXISTS `central_banking_ffhr`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `central_banking_ffhr` (
  `header_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `header_label_identity` varchar(3) NOT NULL,
  `header_lable_no` varchar(1) NOT NULL,
  `header_file_identity` varchar(17) NOT NULL,
  `header_file_set_identity` varchar(6) NOT NULL,
  `header_file_section` varchar(4) NOT NULL,
  `header_sequence` varchar(4) NOT NULL,
  `header_gen_no` varchar(4) NOT NULL,
  `header_gen_version_no` varchar(2) NOT NULL,
  `header_created` varchar(6) NOT NULL,
  `header_expire` varchar(6) NOT NULL,
  `header_access` varchar(1) NOT NULL,
  `header_block_count` varchar(6) NOT NULL,
  `header_code` varchar(13) NOT NULL,
  `bank_master_id` bigint(40) NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`header_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `central_banking_master`
--

DROP TABLE IF EXISTS `central_banking_master`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `central_banking_master` (
  `master_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `master_document_path` text NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  PRIMARY KEY (`master_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `central_banking_seof`
--

DROP TABLE IF EXISTS `central_banking_seof`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `central_banking_seof` (
  `seof_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `seof_label_identity` varchar(3) NOT NULL,
  `seof_lable_no` varchar(1) NOT NULL,
  `seof_record_format` varchar(1) NOT NULL,
  `seof_block_length` varchar(5) NOT NULL,
  `seof_record_length` varchar(5) NOT NULL,
  `seof_filler` varchar(35) NOT NULL,
  `seof_buffet_offset` varchar(2) NOT NULL,
  `seof_filler2` varchar(28) NOT NULL,
  `bank_master_id` bigint(40) NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`seof_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `central_banking_sfhr`
--

DROP TABLE IF EXISTS `central_banking_sfhr`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `central_banking_sfhr` (
  `sheader_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `sheader_label_identity` varchar(3) NOT NULL,
  `sheader_lable_no` varchar(1) NOT NULL,
  `sheader_record_format` varchar(1) NOT NULL,
  `sheader_block_length` varchar(5) NOT NULL,
  `sheader_record_length` varchar(5) NOT NULL,
  `sheader_filler` varchar(35) NOT NULL,
  `sheader_buffet_offset` varchar(2) NOT NULL,
  `sheader_filler2` varchar(28) NOT NULL,
  `bank_master_id` bigint(40) NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`sheader_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `central_banking_statements`
--

DROP TABLE IF EXISTS `central_banking_statements`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `central_banking_statements` (
  `statement_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `statement_receiver_sort_code` varchar(6) NOT NULL,
  `statement_receiver_account_no` varchar(8) NOT NULL,
  `statement_account_type` varchar(1) NOT NULL,
  `statement_transaction_code` varchar(2) NOT NULL,
  `statement_sender_sort_code` varchar(6) NOT NULL,
  `statement_sender_account_no` varchar(8) NOT NULL,
  `statement_filler` varchar(4) NOT NULL,
  `statement_amount` varchar(11) NOT NULL,
  `statement_reference` varchar(18) NOT NULL,
  `statement_description` varchar(18) NOT NULL,
  `statement_beneficiary_name` varchar(18) NOT NULL,
  `statement_process_date` varchar(6) NOT NULL,
  `bank_master_id` bigint(40) NOT NULL,
  `account_type` int(3) NOT NULL COMMENT '1-Investor,2-Retail Investor,3-Trade',
  `org_id` bigint(40) NOT NULL,
  `closed_id` bigint(40) DEFAULT NULL,
  `instruction` varchar(4) DEFAULT NULL,
  `invoice_id` bigint(40) DEFAULT NULL,
  `cmii_id` bigint(40) DEFAULT NULL,
  `status` int(5) NOT NULL DEFAULT '0',
  `authorise_status` int(2) NOT NULL DEFAULT '0',
  `interven_status` int(2) NOT NULL DEFAULT '0',
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`statement_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `central_banking_uhl`
--

DROP TABLE IF EXISTS `central_banking_uhl`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `central_banking_uhl` (
  `user_header_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `user_label_identity` varchar(3) NOT NULL,
  `user_lable_no` varchar(1) NOT NULL,
  `user_processing` varchar(6) NOT NULL,
  `user_receiver` varchar(10) NOT NULL,
  `user_currency` varchar(3) NOT NULL,
  `user_space` varchar(5) NOT NULL,
  `user_work_code` varchar(9) NOT NULL,
  `user_file_number` varchar(3) NOT NULL,
  `user_space1` varchar(14) NOT NULL,
  `user_space2` varchar(26) NOT NULL,
  `bank_master_id` bigint(40) NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`user_header_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `central_banking_utl`
--

DROP TABLE IF EXISTS `central_banking_utl`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `central_banking_utl` (
  `trailer_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `trailer_label_identity` varchar(3) NOT NULL,
  `trailer_lable_no` varchar(1) NOT NULL,
  `trailer_mdebtit` varchar(13) NOT NULL,
  `trailer_mcredit` varchar(13) NOT NULL,
  `trailer_debit_count` varchar(7) NOT NULL,
  `trailer_credit_count` varchar(7) NOT NULL,
  `trailer_filler` varchar(10) NOT NULL,
  `trailer_record_party` varchar(26) NOT NULL,
  `bank_master_id` bigint(40) NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`trailer_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `central_banking_vhr`
--

DROP TABLE IF EXISTS `central_banking_vhr`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `central_banking_vhr` (
  `volume_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `vol_label` varchar(5) NOT NULL,
  `vol_label_no` varchar(5) NOT NULL,
  `vol_identity` varchar(10) NOT NULL,
  `vol_access` varchar(10) NOT NULL,
  `vol_sorting_code` varchar(25) NOT NULL,
  `vol_owner_identity` varchar(20) NOT NULL,
  `vol_filler` varchar(30) NOT NULL,
  `vol_label_standard` varchar(5) NOT NULL,
  `bank_master_id` bigint(40) NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`volume_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `certificate_history`
--

DROP TABLE IF EXISTS `certificate_history`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `certificate_history` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `certificate` blob NOT NULL,
  `certificate_name` varchar(255) NOT NULL,
  `certificate_password` varchar(255) NOT NULL,
  `expired_at` datetime NOT NULL,
  `first_name` varchar(255) NOT NULL,
  `last_name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `created_at` datetime NOT NULL,
  `created_by` int(11) NOT NULL,
  `sent` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=748 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `cheatsheet`
--

DROP TABLE IF EXISTS `cheatsheet`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `cheatsheet` (
  `sheet_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `do_name` varchar(255) NOT NULL,
  `invoice_id` bigint(40) NOT NULL,
  `view_by` bigint(20) NOT NULL,
  `user_type` int(5) NOT NULL,
  `agent` bigint(20) NOT NULL,
  `sales_date` date NOT NULL,
  `organisation_id` bigint(40) NOT NULL,
  `debtor_id` bigint(40) NOT NULL,
  `sub_debtor_id` bigint(40) NOT NULL,
  `cid` bigint(40) NOT NULL,
  `trade_id` bigint(40) NOT NULL,
  `interface` int(11) NOT NULL DEFAULT '0',
  `trading_as` varchar(255) NOT NULL,
  `website` varchar(255) NOT NULL,
  `comment` text NOT NULL,
  `result` int(5) NOT NULL,
  `result_type` int(5) NOT NULL,
  `filepath` text NOT NULL,
  `links` text NOT NULL,
  `reminder` datetime NOT NULL,
  `reminder_status` int(2) NOT NULL DEFAULT '0',
  `auth` int(2) NOT NULL DEFAULT '0',
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  `created_by` bigint(20) NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`sheet_id`),
  KEY `sub_debtor_id` (`sub_debtor_id`)
) ENGINE=MyISAM AUTO_INCREMENT=49235 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `closed_indexes_temp`
--

DROP TABLE IF EXISTS `closed_indexes_temp`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `closed_indexes_temp` (
  `purchase` double(21,4) DEFAULT NULL,
  `won_by` smallint(20) unsigned NOT NULL,
  `invoice_id` mediumint(20) unsigned DEFAULT '0',
  `transaction_date` date DEFAULT NULL,
  `closed_date` date DEFAULT NULL,
  KEY `won_by` (`won_by`),
  KEY `invoice_id` (`invoice_id`),
  KEY `transaction_date` (`transaction_date`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `contact_details`
--

DROP TABLE IF EXISTS `contact_details`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `contact_details` (
  `contact_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `parent_id` bigint(40) DEFAULT NULL,
  `temp_reg_id` bigint(40) DEFAULT NULL,
  `debtor_id` bigint(40) DEFAULT NULL,
  `sub_debtor_id` bigint(40) NOT NULL,
  `retailer_id` bigint(40) DEFAULT NULL,
  `organisation_id` bigint(40) DEFAULT NULL,
  `debtor_masterid` bigint(40) NOT NULL,
  `bank_id` bigint(40) NOT NULL,
  `prospect_id` bigint(40) DEFAULT NULL,
  `prospect_type` bigint(40) NOT NULL DEFAULT '0',
  `first_name` varchar(255) NOT NULL,
  `middle_name` varchar(255) NOT NULL,
  `last_name` varchar(255) NOT NULL,
  `phone1` varchar(20) DEFAULT NULL,
  `phone2` varchar(20) NOT NULL,
  `job_title` varchar(255) NOT NULL,
  `pronounced` varchar(255) NOT NULL,
  `home_address_id` bigint(40) NOT NULL,
  `hq_address_id` bigint(40) NOT NULL,
  `work_address_id` bigint(40) NOT NULL,
  `birth_date` date NOT NULL,
  `passport_number` varchar(100) NOT NULL,
  `passport_issue_date` date NOT NULL,
  `driving_licence_number` varchar(100) NOT NULL,
  `driving_licence_number_issue_date` date NOT NULL,
  `percent_owned` int(2) NOT NULL,
  `ownership` int(3) NOT NULL COMMENT '''0-yes,1-no''',
  `active_participation` tinyint(3) NOT NULL COMMENT '1-yes,2-no',
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  `position` int(11) NOT NULL DEFAULT '0' COMMENT '1=BankForm: 2=step 3',
  `contact_flag` tinyint(2) NOT NULL COMMENT '0 - User, 1 - Admin',
  `type` int(11) DEFAULT NULL,
  `dmc` int(2) NOT NULL DEFAULT '0',
  `salesforce_id` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`contact_id`),
  KEY `organization_id` (`organisation_id`),
  KEY `sub_debtor_id` (`sub_debtor_id`),
  KEY `parent_id` (`parent_id`,`temp_reg_id`,`debtor_id`,`sub_debtor_id`,`retailer_id`,`organisation_id`,`debtor_masterid`,`bank_id`,`prospect_id`,`home_address_id`,`hq_address_id`,`work_address_id`,`position`,`contact_flag`)
) ENGINE=InnoDB AUTO_INCREMENT=5852 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `contact_details_quick`
--

DROP TABLE IF EXISTS `contact_details_quick`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `contact_details_quick` (
  `quick_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `contact_id` bigint(40) NOT NULL,
  `org_id` bigint(40) NOT NULL,
  `debtor_id` bigint(40) DEFAULT NULL,
  `sub_debtor_id` bigint(40) NOT NULL,
  `contact_name1` varchar(255) NOT NULL,
  `contact_phone1` varchar(20) NOT NULL,
  `contact_name2` varchar(255) NOT NULL,
  `contact_phone2` varchar(20) NOT NULL,
  `contact_name3` varchar(255) NOT NULL,
  `contact_phone3` varchar(20) NOT NULL,
  `contact_name4` varchar(255) NOT NULL,
  `contact_phone4` varchar(20) NOT NULL,
  `contact_name5` varchar(255) NOT NULL,
  `contact_phone5` varchar(20) NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  `created_by` int(11) NOT NULL,
  `modified_by` int(11) NOT NULL,
  PRIMARY KEY (`quick_id`)
) ENGINE=MyISAM AUTO_INCREMENT=65 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `contents`
--

DROP TABLE IF EXISTS `contents`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `contents` (
  `content_id` int(10) NOT NULL AUTO_INCREMENT,
  `content_title` varchar(255) NOT NULL,
  `content` longtext NOT NULL,
  `modified_by` bigint(10) NOT NULL,
  `modifed_at` datetime NOT NULL,
  `content_type` tinyint(3) unsigned DEFAULT '0',
  PRIMARY KEY (`content_id`),
  KEY `modified_by` (`modified_by`),
  KEY `content_type` (`content_type`)
) ENGINE=InnoDB AUTO_INCREMENT=49678 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `country_mas`
--

DROP TABLE IF EXISTS `country_mas`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `country_mas` (
  `country_id` int(25) NOT NULL,
  `country_name` varchar(255) DEFAULT NULL,
  `country_value` varchar(20) DEFAULT NULL,
  `latitude` varchar(50) DEFAULT NULL,
  `longitude` varchar(50) DEFAULT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`country_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `credebtor_balances`
--

DROP TABLE IF EXISTS `credebtor_balances`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `credebtor_balances` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `debtor_id` int(11) NOT NULL,
  `outstanding_balance` double NOT NULL,
  `calculation_date` datetime NOT NULL,
  `is_last` tinyint(4) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`),
  KEY `is_last` (`is_last`)
) ENGINE=InnoDB AUTO_INCREMENT=6571864 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `credebtor_balances_cron_requests`
--

DROP TABLE IF EXISTS `credebtor_balances_cron_requests`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `credebtor_balances_cron_requests` (
  `request_id` int(11) NOT NULL AUTO_INCREMENT,
  `event_type` tinyint(4) NOT NULL,
  `status` tinyint(4) NOT NULL,
  `start_time` datetime DEFAULT NULL,
  `end_time` datetime DEFAULT NULL,
  PRIMARY KEY (`request_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1252 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `currencies`
--

DROP TABLE IF EXISTS `currencies`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `currencies` (
  `currency_id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
  `currency_code` varchar(3) DEFAULT '0',
  `currency_symbol` varchar(3) DEFAULT '0',
  `currency_rate` decimal(5,4) unsigned DEFAULT '0.0000',
  `is_active` tinyint(3) unsigned DEFAULT '0',
  PRIMARY KEY (`currency_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `currency_rates`
--

DROP TABLE IF EXISTS `currency_rates`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `currency_rates` (
  `currency_id` tinyint(3) unsigned DEFAULT NULL,
  `currency_rate` double(6,4) unsigned DEFAULT NULL,
  `currency_date` date DEFAULT NULL,
  UNIQUE KEY `Index 1` (`currency_id`,`currency_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `daily_summary`
--

DROP TABLE IF EXISTS `daily_summary`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `daily_summary` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `account_id` int(11) DEFAULT NULL,
  `daily_summary` double DEFAULT NULL,
  `date` datetime DEFAULT NULL,
  `type` varchar(32) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=18697 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `debtor_bank_details`
--

DROP TABLE IF EXISTS `debtor_bank_details`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `debtor_bank_details` (
  `debtor_bank_id` mediumint(40) unsigned NOT NULL AUTO_INCREMENT,
  `master_debtor_id` mediumint(40) unsigned NOT NULL,
  `debtor_id` mediumint(40) unsigned NOT NULL,
  `bank_name` varchar(255) NOT NULL,
  `account_no` varchar(255) NOT NULL,
  `sort_code` varchar(255) NOT NULL,
  `iban_code` varchar(50) NOT NULL,
  `swift_code` varchar(50) NOT NULL,
  `phone_country` varchar(5) NOT NULL,
  `phone_area` varchar(5) NOT NULL,
  `phone` varchar(10) NOT NULL,
  `deb_address_line_one` varchar(255) NOT NULL,
  `deb_address_line_two` varchar(255) NOT NULL,
  `post_code` varchar(10) NOT NULL,
  `banking_url` varchar(250) NOT NULL,
  `username` varchar(250) NOT NULL,
  `password` varchar(250) NOT NULL,
  `passcode` varchar(250) NOT NULL,
  `token_id` varchar(250) NOT NULL,
  `helpline_number` varchar(250) NOT NULL,
  PRIMARY KEY (`debtor_bank_id`),
  KEY `master_debtor_id` (`master_debtor_id`,`debtor_id`)
) ENGINE=MyISAM AUTO_INCREMENT=3049 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `debtor_contacts`
--

DROP TABLE IF EXISTS `debtor_contacts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `debtor_contacts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `debtor_id` int(11) NOT NULL,
  `firstname` varchar(50) NOT NULL,
  `lastname` varchar(50) NOT NULL,
  `phone` varchar(50) NOT NULL,
  `email` varchar(50) NOT NULL,
  `etr_delivery` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7552 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `debtor_history_report`
--

DROP TABLE IF EXISTS `debtor_history_report`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `debtor_history_report` (
  `debtor_history_report_id` bigint(50) NOT NULL AUTO_INCREMENT,
  `debtor_id` bigint(20) NOT NULL,
  `report_type` varchar(200) NOT NULL,
  `report_number` varchar(64) DEFAULT NULL,
  `report_date` date NOT NULL,
  `report_branch` varchar(100) NOT NULL,
  `report_total` double(10,2) NOT NULL,
  `report_document_path` varchar(255) NOT NULL,
  PRIMARY KEY (`debtor_history_report_id`),
  KEY `report_type` (`report_type`),
  KEY `report_date` (`report_date`),
  KEY `debtor_id` (`debtor_id`),
  KEY `report_total` (`report_total`)
) ENGINE=InnoDB AUTO_INCREMENT=81768 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `debtor_notes`
--

DROP TABLE IF EXISTS `debtor_notes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `debtor_notes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `debtor_id` int(11) NOT NULL,
  `text` text NOT NULL,
  `created_at` datetime NOT NULL,
  `created_by` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=31750 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `debtor_relation`
--

DROP TABLE IF EXISTS `debtor_relation`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `debtor_relation` (
  `relation_id` mediumint(40) unsigned NOT NULL AUTO_INCREMENT,
  `trader_id` smallint(40) unsigned NOT NULL,
  `debtor_id` mediumint(40) unsigned NOT NULL,
  `organisation_id` smallint(40) unsigned NOT NULL,
  `child_id` bigint(40) NOT NULL DEFAULT '0',
  `status` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `notify` int(5) NOT NULL DEFAULT '0',
  `invt_status` tinyint(2) NOT NULL,
  `revolving_etr` tinyint(2) unsigned NOT NULL DEFAULT '0',
  `ed_status` tinyint(4) unsigned NOT NULL COMMENT '0-false,1-true',
  `bcc_status` tinyint(4) unsigned NOT NULL COMMENT '0-false,1-true',
  `noad_link` text NOT NULL,
  `noad_notified` datetime NOT NULL,
  `noid_link` text NOT NULL,
  `noid_notified` datetime NOT NULL,
  `changed_status` tinyint(4) unsigned NOT NULL COMMENT '2-notified,6-rate',
  `noid_status` tinyint(4) unsigned NOT NULL COMMENT '1-Issued,2-Approved,3-Rejected',
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`relation_id`),
  KEY `relation_id` (`relation_id`),
  KEY `trader_id` (`trader_id`,`debtor_id`,`organisation_id`,`status`,`ed_status`,`bcc_status`),
  KEY `debtor_id` (`debtor_id`),
  KEY `IDX_debtor_relation_organisation_id` (`organisation_id`)
) ENGINE=MyISAM AUTO_INCREMENT=7737 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `debtor_rva`
--

DROP TABLE IF EXISTS `debtor_rva`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `debtor_rva` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `debtor_id` mediumint(8) unsigned DEFAULT NULL,
  `date_sent` datetime DEFAULT NULL,
  `date_status_change` datetime DEFAULT NULL,
  `status` tinyint(4) unsigned DEFAULT NULL,
  `sub_status` tinyint(4) unsigned DEFAULT NULL,
  `reminder` tinyint(4) unsigned DEFAULT '0',
  `balance` double DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `created_by` tinyint(3) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3065 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `debtor_settings`
--

DROP TABLE IF EXISTS `debtor_settings`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `debtor_settings` (
  `debtor_setting_id` mediumint(20) unsigned NOT NULL AUTO_INCREMENT,
  `debtor_id` mediumint(10) unsigned NOT NULL,
  `max_advance` double NOT NULL,
  `min_thirty_reserve` int(10) NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` tinyint(20) unsigned NOT NULL,
  PRIMARY KEY (`debtor_setting_id`),
  UNIQUE KEY `debtor_id` (`debtor_id`),
  KEY `modified_by` (`modified_by`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `debtors_detail`
--

DROP TABLE IF EXISTS `debtors_detail`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `debtors_detail` (
  `debtor_id` mediumint(20) unsigned NOT NULL AUTO_INCREMENT,
  `debtor_reference_id` bigint(50) NOT NULL,
  `debtor_contact_first_name` varchar(200) DEFAULT NULL,
  `debtor_contact_last_name` varchar(200) NOT NULL,
  `website` varchar(255) NOT NULL,
  `job_title` varchar(255) NOT NULL,
  `pronounced` varchar(255) NOT NULL,
  `phone1` varchar(20) NOT NULL,
  `phone2` varchar(20) NOT NULL,
  `debtor_company_registration_number` varchar(200) NOT NULL,
  `nace_id` smallint(20) unsigned NOT NULL DEFAULT '261',
  `nace_group_id` tinyint(10) unsigned NOT NULL DEFAULT '16',
  `debtor_name` varchar(200) NOT NULL,
  `trade_name` varchar(200) NOT NULL,
  `previous_name` varchar(200) NOT NULL,
  `customer_since` year(4) NOT NULL,
  `total_debtor_value` bigint(40) NOT NULL,
  `average_payment_cycle` bigint(40) NOT NULL,
  `no_credit_note_issued` bigint(40) NOT NULL,
  `avg_invoice_predicted_annum` bigint(40) NOT NULL,
  `avg_revenue_predicted_annum` double NOT NULL,
  `debtor_risk` int(11) NOT NULL,
  `debtor_limit` int(11) NOT NULL,
  `credit_limit` int(11) NOT NULL,
  `credit_limit_changed_at` datetime DEFAULT NULL,
  `credit_limit_changed_by` tinyint(3) DEFAULT NULL,
  `credit_limit_old_value` int(11) DEFAULT NULL,
  `purchase_price` decimal(6,2) NOT NULL DEFAULT '0.00',
  `credit_risk` varchar(20) NOT NULL,
  `cr_changed_at` datetime DEFAULT NULL,
  `cr_changed_by` tinyint(3) DEFAULT NULL,
  `cr_old_value` int(11) DEFAULT NULL,
  `credit_today_limit` int(11) NOT NULL,
  `filepdf` text,
  `filescv` text,
  `address_id` mediumint(11) unsigned DEFAULT NULL,
  `billing_address_id` mediumint(11) unsigned DEFAULT NULL,
  `contact_address_id` mediumint(11) unsigned DEFAULT NULL,
  `currency_id` tinyint(3) unsigned NOT NULL,
  `created_by` tinyint(10) unsigned NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` tinyint(10) unsigned NOT NULL,
  `published` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '0-Waiting:1-Approved:2-Rejected:3-Expired',
  `founded` date NOT NULL,
  `parent_id` mediumint(40) unsigned NOT NULL DEFAULT '0',
  `created` datetime NOT NULL,
  `dmc` int(5) NOT NULL DEFAULT '0',
  `interface_added` tinyint(2) NOT NULL DEFAULT '0',
  `type` enum('debtor','creditor') NOT NULL DEFAULT 'debtor',
  `payment_discount` double(4,2) unsigned NOT NULL DEFAULT '0.00',
  `sell_rate` decimal(10,4) DEFAULT NULL,
  `trade_limit` bigint(10) DEFAULT NULL,
  `trade_limit_changed_at` datetime DEFAULT NULL,
  `trade_limit_changed_by` tinyint(3) DEFAULT NULL,
  `trade_limit_old_value` int(11) DEFAULT NULL,
  `trade_limit_review_date` date DEFAULT NULL,
  `trade_limit_reviewed` tinyint(1) NOT NULL DEFAULT '0',
  `is_rva` tinyint(4) DEFAULT '1',
  `aig_dl` decimal(10,2) DEFAULT '0.00',
  `insurance_specified_limit` decimal(10,0) DEFAULT '0',
  `isl_changed_at` datetime DEFAULT NULL,
  `isl_changed_by` tinyint(3) DEFAULT NULL,
  `isl_old_value` int(11) DEFAULT NULL,
  `cs_changed_at` datetime DEFAULT '0000-00-00 00:00:00',
  `cs_changed_by` tinyint(3) unsigned DEFAULT '0',
  `cs_old_value` int(11) DEFAULT '0',
  `etr_type` varchar(3) DEFAULT NULL,
  `override_180_day_rule` tinyint(1) NOT NULL DEFAULT '0',
  `face_value_charge` double(5,3) DEFAULT NULL,
  `ldc_premium` double(6,3) DEFAULT NULL,
  `agent_commission` double(6,3) DEFAULT NULL,
  `is_aetr` tinyint(1) DEFAULT NULL,
  `a_etr_limit` int(11) DEFAULT NULL,
  PRIMARY KEY (`debtor_id`),
  UNIQUE KEY `UK_debtors_detail_debtor_id` (`debtor_id`),
  KEY `created_by` (`created_by`),
  KEY `modified_by` (`modified_by`),
  KEY `debtor_reference_id` (`debtor_reference_id`,`nace_id`,`nace_group_id`,`debtor_name`,`trade_name`,`average_payment_cycle`,`no_credit_note_issued`,`avg_invoice_predicted_annum`,`avg_revenue_predicted_annum`,`debtor_risk`,`debtor_limit`,`parent_id`),
  KEY `currency_id` (`currency_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7735 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `debtors_invoices_stat`
--

DROP TABLE IF EXISTS `debtors_invoices_stat`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `debtors_invoices_stat` (
  `avginvoice` double DEFAULT NULL,
  `debtor_id` mediumint(40) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `debtors_master`
--

DROP TABLE IF EXISTS `debtors_master`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `debtors_master` (
  `debtor_master_id` bigint(10) NOT NULL AUTO_INCREMENT,
  `master_reference_id` bigint(40) NOT NULL,
  `debtor_name` varchar(255) NOT NULL,
  `debtor_company_reg_no` varchar(100) CHARACTER SET utf8 NOT NULL,
  `debtor_trade_name` varchar(255) NOT NULL,
  `website` varchar(255) NOT NULL,
  `debtor_previous_name` varchar(255) NOT NULL,
  `debtor_founded` date NOT NULL,
  `debtor_status` tinyint(5) NOT NULL,
  `debtor_address_id` bigint(40) NOT NULL,
  `debtor_ticker` varchar(255) DEFAULT NULL,
  `debtor_start_price` varchar(255) DEFAULT NULL,
  `debtor_min_offers` decimal(6,3) DEFAULT NULL,
  `debtor_max_offers` decimal(6,3) DEFAULT NULL,
  `debtor_insurance_cost` decimal(6,3) DEFAULT NULL,
  `debtor_max_bid` decimal(6,3) DEFAULT NULL,
  `nace_id` int(5) NOT NULL,
  `nace_group_id` int(5) NOT NULL,
  `debtor_limit` varchar(20) NOT NULL DEFAULT '0',
  `credit_limit` int(11) NOT NULL,
  `debtor_revenue` int(11) NOT NULL,
  `debtor_risk` varchar(20) NOT NULL DEFAULT '0',
  `no_of_trades` bigint(5) NOT NULL,
  `no_of_traders` bigint(5) NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  `modified_on` datetime NOT NULL,
  `created_date` date NOT NULL,
  `type` enum('debtor','creditor') NOT NULL DEFAULT 'debtor',
  `payment_discount` double(4,2) unsigned NOT NULL DEFAULT '0.00',
  PRIMARY KEY (`debtor_master_id`),
  KEY `master_reference_id` (`master_reference_id`,`debtor_name`,`debtor_trade_name`,`debtor_status`,`debtor_address_id`,`nace_id`,`nace_group_id`,`debtor_limit`,`debtor_risk`)
) ENGINE=MyISAM AUTO_INCREMENT=8329 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `demo_opentrade`
--

DROP TABLE IF EXISTS `demo_opentrade`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `demo_opentrade` (
  `trade_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `contact_id` bigint(20) NOT NULL,
  `po_id` varchar(255) NOT NULL,
  `debtor_name` varchar(50) NOT NULL,
  `face_value` double NOT NULL,
  `buy_out` tinyint(3) NOT NULL,
  `description` text NOT NULL,
  `payment_terms` int(10) NOT NULL,
  `actual_date` date NOT NULL,
  `expected_date` date NOT NULL,
  `trading_close_date` datetime NOT NULL,
  `discount_price` double NOT NULL,
  `buyout_discount_price` decimal(6,3) NOT NULL,
  `debx` int(5) NOT NULL,
  `sales_type` int(5) NOT NULL,
  `invoice_type` tinyint(3) NOT NULL COMMENT '1-Single,2-Multiple,3-Batch',
  `draft` int(2) NOT NULL,
  `closing_type` int(2) NOT NULL,
  `invoice_document_path` varchar(255) NOT NULL,
  `invoice_support_document_path` varchar(255) NOT NULL,
  `purchase_order_document_path` varchar(255) NOT NULL,
  `modified_at` datetime NOT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`trade_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `directorate`
--

DROP TABLE IF EXISTS `directorate`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `directorate` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `first_name` varchar(255) DEFAULT NULL,
  `last_name` varchar(255) DEFAULT NULL,
  `user_id` bigint(20) DEFAULT NULL,
  `address_1` varchar(255) DEFAULT NULL,
  `address_2` varchar(255) DEFAULT NULL,
  `country_code` varchar(4) DEFAULT NULL,
  `city` varchar(255) DEFAULT NULL,
  `phone_number` varchar(255) DEFAULT NULL,
  `email_address` varchar(255) DEFAULT NULL,
  `area_code` varchar(255) DEFAULT NULL,
  `organization_id` bigint(20) DEFAULT NULL,
  `ph_country` varchar(10) DEFAULT NULL,
  `ph_area` varchar(10) DEFAULT NULL,
  `ph_code` varchar(10) DEFAULT NULL,
  `financial_advisor` varchar(255) DEFAULT NULL,
  `pension_value` decimal(10,2) DEFAULT '0.00',
  `savings_value` decimal(10,2) DEFAULT '0.00',
  `consent_status` varchar(10) DEFAULT NULL,
  `consent_request_date` datetime DEFAULT NULL,
  `consent_request_last_date` datetime DEFAULT NULL,
  `consent_confirm_date` datetime DEFAULT NULL,
  `consent_request_id` varchar(255) DEFAULT NULL,
  `consent_success_date` datetime DEFAULT NULL,
  `is_user` int(11) DEFAULT NULL,
  `salesforce_id` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1310 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `discount_provider`
--

DROP TABLE IF EXISTS `discount_provider`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `discount_provider` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `wording` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `discounts_index`
--

DROP TABLE IF EXISTS `discounts_index`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `discounts_index` (
  `originator_id` smallint(40) unsigned NOT NULL,
  `currency_id` tinyint(3) unsigned,
  `bank_currency` tinyint(3) unsigned DEFAULT NULL,
  `total_setteled_discounts` decimal(32,2) DEFAULT NULL,
  `total_discounts` decimal(32,2) DEFAULT NULL,
  KEY `my_unique_index_name` (`originator_id`,`currency_id`,`bank_currency`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `email_logs`
--

DROP TABLE IF EXISTS `email_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `email_logs` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL,
  `error` varchar(255) NOT NULL,
  `info` text NOT NULL,
  `sent_date` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=128611 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `email_queue`
--

DROP TABLE IF EXISTS `email_queue`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `email_queue` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `timestamp` int(11) DEFAULT NULL,
  `mail` blob,
  `noa_invoice_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2339 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `error_logs`
--

DROP TABLE IF EXISTS `error_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `error_logs` (
  `error_log_id` bigint(50) NOT NULL,
  `error_detail` text NOT NULL,
  `borwser_information` text NOT NULL,
  `ip_details` varchar(20) NOT NULL,
  `error_date` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `etr_id_list`
--

DROP TABLE IF EXISTS `etr_id_list`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `etr_id_list` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `etr_id` int(11) NOT NULL,
  `etr_type` varchar(5) NOT NULL,
  `reference_id` bigint(20) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `etr_unique` (`etr_id`,`etr_type`)
) ENGINE=InnoDB AUTO_INCREMENT=379 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `etr_outstanding_temp`
--

DROP TABLE IF EXISTS `etr_outstanding_temp`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `etr_outstanding_temp` (
  `etr_outstanding` double DEFAULT NULL,
  `fx_etr_outstanding` double DEFAULT NULL,
  `debtor_id` mediumint(20) unsigned DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `ewallet`
--

DROP TABLE IF EXISTS `ewallet`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `ewallet` (
  `ew_transaction_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `ew_user_id` bigint(20) NOT NULL,
  `ew_amount` double NOT NULL,
  `ew_transaction_type` tinyint(3) NOT NULL COMMENT '1-Credit,2-Debit',
  `ew_transaction_desc` varchar(255) NOT NULL,
  `ew_transaction_date` datetime NOT NULL,
  `transaction_id` bigint(40) NOT NULL,
  PRIMARY KEY (`ew_transaction_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `exchange_rate`
--

DROP TABLE IF EXISTS `exchange_rate`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `exchange_rate` (
  `exchange_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `sellrate` double NOT NULL,
  `sell_userid` int(11) NOT NULL,
  `selldate` date NOT NULL,
  `sell_modfifieddate` date NOT NULL,
  `buyrate` double NOT NULL,
  `buy_userid` int(11) NOT NULL,
  `buydate` date NOT NULL,
  `buy_modfifieddate` date NOT NULL,
  `commisionrate` double(10,2) NOT NULL,
  `commision_userid` bigint(40) NOT NULL,
  `commision_modifieddate` date NOT NULL,
  `timestamps` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `rsa_date` date NOT NULL,
  `rsa_value` double NOT NULL,
  `raf_value` double NOT NULL,
  `raf_paid` double NOT NULL,
  `prom_value` double NOT NULL,
  `ft_value` double NOT NULL,
  `status` tinyint(1) NOT NULL,
  `status_userid` int(11) NOT NULL,
  `status_modifieddate` date NOT NULL,
  PRIMARY KEY (`exchange_id`)
) ENGINE=MyISAM AUTO_INCREMENT=2152 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `expired_cetr_list`
--

DROP TABLE IF EXISTS `expired_cetr_list`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `expired_cetr_list` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `cetr_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=512 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `fill_solver`
--

DROP TABLE IF EXISTS `fill_solver`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `fill_solver` (
  `solver_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `amount` decimal(10,2) NOT NULL,
  `file_path` varchar(255) NOT NULL,
  `modified_at` datetime NOT NULL,
  PRIMARY KEY (`solver_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `help_tips_settings`
--

DROP TABLE IF EXISTS `help_tips_settings`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `help_tips_settings` (
  `help_tip_id` smallint(50) unsigned NOT NULL AUTO_INCREMENT,
  `help_title_id` tinyint(50) unsigned NOT NULL,
  `content` varchar(250) NOT NULL,
  `help_key` varchar(250) NOT NULL,
  `ordering` tinyint(10) unsigned NOT NULL,
  `status` tinyint(2) unsigned NOT NULL COMMENT '0-Inactive,1-Active',
  PRIMARY KEY (`help_tip_id`)
) ENGINE=MyISAM AUTO_INCREMENT=827 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `help_title_settings`
--

DROP TABLE IF EXISTS `help_title_settings`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `help_title_settings` (
  `help_title_id` tinyint(50) unsigned NOT NULL AUTO_INCREMENT,
  `help_title` varchar(100) NOT NULL,
  PRIMARY KEY (`help_title_id`)
) ENGINE=MyISAM AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `insurance`
--

DROP TABLE IF EXISTS `insurance`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `insurance` (
  `insurance_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `r_name` varchar(250) NOT NULL,
  `r_long` varchar(250) NOT NULL,
  `r_medium` varchar(250) NOT NULL,
  `r_short` varchar(250) NOT NULL,
  `insurance_cost` decimal(6,3) DEFAULT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`insurance_id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `insurance_provider`
--

DROP TABLE IF EXISTS `insurance_provider`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `insurance_provider` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `intermediary_transactions`
--

DROP TABLE IF EXISTS `intermediary_transactions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `intermediary_transactions` (
  `transaction_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `transaction_date` date DEFAULT NULL,
  `amount` decimal(10,2) unsigned DEFAULT NULL,
  `intermediary_id` smallint(5) unsigned DEFAULT NULL,
  `created_by` tinyint(3) unsigned DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `remove_comment` text,
  `removed_at` datetime DEFAULT NULL,
  `removed_by` tinyint(3) unsigned DEFAULT NULL,
  `status` tinyint(3) unsigned DEFAULT NULL,
  `authorised_by` tinyint(3) unsigned DEFAULT NULL,
  `authorised_at` datetime DEFAULT NULL,
  `comment` text,
  PRIMARY KEY (`transaction_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `investor_accounts_summary`
--

DROP TABLE IF EXISTS `investor_accounts_summary`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `investor_accounts_summary` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  `investabill_etr_funds` double NOT NULL,
  `leasabill_etr_funds` double NOT NULL,
  `deferred_yields` double NOT NULL,
  `crystallised_yields` double NOT NULL,
  `1001_adj` double DEFAULT NULL,
  `1002_adj` double DEFAULT NULL,
  `1003_adj` double DEFAULT NULL,
  `1201_adj` double DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `modified_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `date` (`date`)
) ENGINE=InnoDB AUTO_INCREMENT=1837 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `investor_investments`
--

DROP TABLE IF EXISTS `investor_investments`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `investor_investments` (
  `investment_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `investment_date` date DEFAULT NULL,
  `investment_group` smallint(3) unsigned DEFAULT '0',
  `investor_id` mediumint(8) unsigned DEFAULT '0',
  `currency_id` tinyint(3) unsigned DEFAULT '0',
  `investment_type` tinyint(3) unsigned DEFAULT '0',
  `amount` decimal(10,2) unsigned DEFAULT '0.00',
  `change_principal` decimal(10,2) unsigned DEFAULT '0.00',
  `change_date` date DEFAULT NULL,
  `buy_rate` double(5,3) unsigned DEFAULT '0.000',
  `commission` double(4,3) unsigned DEFAULT '0.000',
  `months` tinyint(3) unsigned DEFAULT '0',
  `early_exit` date DEFAULT NULL,
  `change_id` smallint(5) unsigned DEFAULT '0',
  `comment` tinytext,
  `status` tinyint(3) unsigned DEFAULT '0',
  `created_by` tinyint(3) unsigned DEFAULT '0',
  `created_at` datetime DEFAULT NULL,
  `modified_by` tinyint(3) unsigned DEFAULT '0',
  `modified_at` datetime DEFAULT NULL,
  `authorised_by` tinyint(3) unsigned DEFAULT '0',
  `authorised_at` datetime DEFAULT NULL,
  `removed_at` datetime DEFAULT NULL,
  `removed_by` tinyint(3) unsigned DEFAULT NULL,
  `remove_comment` tinytext,
  `is_completed` tinyint(3) unsigned DEFAULT '0',
  `is_latest` tinyint(3) unsigned DEFAULT '0',
  `public_comment` tinytext,
  `investment_source` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`investment_id`),
  KEY `Index 2` (`investor_id`),
  KEY `Index 3` (`investment_type`),
  KEY `Index 4` (`investment_date`),
  KEY `Index 5` (`currency_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7814 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `investor_investments_history`
--

DROP TABLE IF EXISTS `investor_investments_history`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `investor_investments_history` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `investment_id` int(11) NOT NULL,
  `currency_id` tinyint(3) DEFAULT '0',
  `commission` double(4,3) DEFAULT '0.000',
  `months` tinyint(3) DEFAULT '0',
  `buy_rate` double(5,3) DEFAULT '0.000',
  `comment` tinytext,
  `amount` decimal(10,2) DEFAULT '0.00',
  `investment_source` varchar(50) DEFAULT NULL,
  `modified_by` tinyint(3) DEFAULT '0',
  `modified_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=389 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `investor_relation`
--

DROP TABLE IF EXISTS `investor_relation`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `investor_relation` (
  `relation_id` smallint(40) unsigned NOT NULL AUTO_INCREMENT,
  `investor_id` smallint(20) unsigned NOT NULL DEFAULT '0',
  `intermediary_id` smallint(20) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`relation_id`),
  KEY `investor_id` (`investor_id`,`intermediary_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1227 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_additional_documents`
--

DROP TABLE IF EXISTS `invoice_additional_documents`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_additional_documents` (
  `document_id` int(11) NOT NULL AUTO_INCREMENT,
  `invoice_id` int(11) NOT NULL,
  `name` varchar(50) NOT NULL,
  `amount` decimal(10,2) DEFAULT '0.00',
  `path` varchar(255) DEFAULT NULL,
  `requested_date` date NOT NULL,
  `expected_date` date NOT NULL,
  `uploaded_date` date DEFAULT NULL,
  `approved_date` date DEFAULT NULL,
  `approved_by` int(10) unsigned DEFAULT NULL,
  `notification_status` enum('1','2') NOT NULL DEFAULT '1',
  PRIMARY KEY (`document_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5400 DEFAULT CHARSET=utf8 AVG_ROW_LENGTH=8192;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_adjustments`
--

DROP TABLE IF EXISTS `invoice_adjustments`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_adjustments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `invoice_id` int(11) NOT NULL,
  `adjustment_id` int(11) NOT NULL,
  `created_by` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_amendments`
--

DROP TABLE IF EXISTS `invoice_amendments`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_amendments` (
  `amendment_id` mediumint(20) unsigned NOT NULL AUTO_INCREMENT,
  `invoice_id` mediumint(20) unsigned NOT NULL,
  `po_id` varchar(256) NOT NULL,
  `invoice_no` varchar(100) NOT NULL,
  `root_invoice_id` mediumint(40) unsigned NOT NULL,
  `debtor_id` mediumint(40) unsigned NOT NULL,
  `user_id` smallint(20) unsigned NOT NULL,
  `trade_reference_id` bigint(40) NOT NULL,
  `amendment_face_value` double NOT NULL,
  `face_value` double NOT NULL,
  `document_value` double NOT NULL,
  `revolving` tinyint(2) unsigned NOT NULL DEFAULT '0',
  `revolving_total` int(10) NOT NULL DEFAULT '0',
  `revolving_months` int(10) NOT NULL DEFAULT '0',
  `instalment` tinyint(4) NOT NULL,
  `paid_instalments` int(10) NOT NULL,
  `per_instalment_amt` double(10,2) NOT NULL,
  `no_of_instalments` int(10) NOT NULL,
  `payments_remaining` int(10) NOT NULL,
  `paid_to_debtors` tinyint(4) NOT NULL COMMENT '0-Not Paid,1-Paid',
  `buy_out` tinyint(3) NOT NULL COMMENT '1-Active,2-Inactive',
  `description` text NOT NULL,
  `payment_terms` int(10) NOT NULL,
  `actual_date` date NOT NULL,
  `approved_date` date NOT NULL,
  `expected_date` date NOT NULL,
  `trading_close_date` datetime NOT NULL,
  `min_advance` double NOT NULL,
  `max_thirty_day_reserve` decimal(6,3) NOT NULL,
  `buy_min_advance` double NOT NULL,
  `buy_max_thirty_day_reserve` decimal(6,3) NOT NULL,
  `debx` tinyint(5) unsigned NOT NULL DEFAULT '2' COMMENT '1-Active:2-Deactive',
  `invoice_status` tinyint(2) unsigned NOT NULL DEFAULT '1' COMMENT '0-Inactive:1-Published:2-frozen:3-Closed',
  `revolving_status` int(2) NOT NULL DEFAULT '0',
  `invoice_authorise` tinyint(5) unsigned NOT NULL DEFAULT '0' COMMENT '0-New:1-Contacted:2-Confirmed:3-Authorised',
  `draft` int(2) NOT NULL DEFAULT '0',
  `instalment_draft` tinyint(4) NOT NULL,
  `revolving_draft` tinyint(2) unsigned NOT NULL DEFAULT '0',
  `closing_type` int(2) NOT NULL DEFAULT '1',
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  `bids` int(2) NOT NULL DEFAULT '0',
  `sales_type` int(5) NOT NULL,
  `yield` double DEFAULT NULL,
  `buy_yield` double DEFAULT NULL,
  `bid_yield` double DEFAULT NULL,
  `return` double DEFAULT NULL,
  `buy_return` double DEFAULT NULL,
  `bid_return` double DEFAULT NULL,
  `noa_link` varchar(250) DEFAULT NULL,
  `etr_link` varchar(250) DEFAULT NULL,
  `noa_status` tinyint(2) unsigned NOT NULL DEFAULT '0',
  `noa_id` bigint(40) DEFAULT NULL,
  `noa_notifed` datetime DEFAULT NULL,
  `discount_rate` decimal(5,5) DEFAULT '0.00000',
  `mail_status` tinyint(2) NOT NULL DEFAULT '0' COMMENT '0-not respond,1-respond',
  `response_mail_status` tinyint(5) NOT NULL DEFAULT '0' COMMENT '1-24,2-48,3-96,4-192,5-384',
  `posting_interface` tinyint(2) unsigned NOT NULL DEFAULT '0',
  `manual_transaction_id` mediumint(20) NOT NULL,
  `auto_assign` tinyint(4) NOT NULL COMMENT '0-auto,1-not',
  `reserve_on` tinyint(4) NOT NULL COMMENT '0-not reserved,1-reserved',
  `payment_status` tinyint(4) NOT NULL COMMENT '0-Unpaid,1-Paid',
  `amendment_status` tinyint(4) NOT NULL COMMENT '0-Off,1-On',
  `multiple_count` int(10) NOT NULL,
  `created_at` datetime NOT NULL,
  `authorised_at` datetime NOT NULL,
  `log_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1-Approved,2-rejected',
  `logapprove_date` datetime NOT NULL,
  `rejected_date` datetime NOT NULL,
  `reject_message` varchar(356) NOT NULL,
  PRIMARY KEY (`amendment_id`),
  KEY `user_id` (`user_id`),
  KEY `invoice_id` (`invoice_id`),
  KEY `posting_interface` (`posting_interface`),
  KEY `invoice_no` (`invoice_no`,`root_invoice_id`,`debtor_id`,`user_id`,`trade_reference_id`,`face_value`,`buy_out`,`min_advance`,`max_thirty_day_reserve`,`buy_min_advance`,`buy_max_thirty_day_reserve`,`revolving_draft`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_api_access`
--

DROP TABLE IF EXISTS `invoice_api_access`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_api_access` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `status` int(11) unsigned DEFAULT NULL,
  `user_id` int(11) unsigned DEFAULT NULL,
  `organisation_id` bigint(11) unsigned DEFAULT NULL,
  `api_key` varchar(100) DEFAULT NULL,
  `ip_address` text,
  `params` text,
  `created_at` datetime DEFAULT NULL,
  `created_by` int(10) unsigned DEFAULT NULL,
  `modified_at` datetime DEFAULT NULL,
  `modified_by` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_api_data`
--

DROP TABLE IF EXISTS `invoice_api_data`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_api_data` (
  `api_data_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `originatorid` bigint(40) NOT NULL,
  `debtorid` bigint(40) NOT NULL,
  `invoiceno` varchar(100) NOT NULL,
  `invoicedate` datetime NOT NULL,
  `invoicevalue` decimal(10,2) NOT NULL,
  `invoicecurrency` int(4) NOT NULL,
  `paymentterms` int(11) NOT NULL,
  `invoicediscount` decimal(6,6) NOT NULL,
  `invoiceclassification` int(2) NOT NULL,
  `pono` varchar(100) NOT NULL,
  `purchasedate` datetime NOT NULL,
  `expecteddate` date NOT NULL,
  `paymentdate` datetime NOT NULL,
  `invoicepdf` text CHARACTER SET utf8 NOT NULL,
  `attributes` text NOT NULL,
  `log_id` bigint(40) NOT NULL,
  `created_at` datetime NOT NULL,
  `status` tinyint(4) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`api_data_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7282 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_api_logs`
--

DROP TABLE IF EXISTS `invoice_api_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_api_logs` (
  `log_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `orginator_id` bigint(40) NOT NULL,
  `ip_address` varchar(20) NOT NULL,
  `response` varchar(255) NOT NULL,
  `request_date` datetime NOT NULL,
  `xmldata` varchar(255) NOT NULL,
  PRIMARY KEY (`log_id`)
) ENGINE=MyISAM AUTO_INCREMENT=95144 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_bidding`
--

DROP TABLE IF EXISTS `invoice_bidding`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_bidding` (
  `invoice_bidding_id` mediumint(40) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` smallint(20) unsigned NOT NULL,
  `invoice_id` mediumint(20) unsigned NOT NULL,
  `min_advance` double NOT NULL,
  `max_thirty_reserve` decimal(10,5) NOT NULL,
  `bidding_yield` double NOT NULL,
  `buy_out` tinyint(3) NOT NULL DEFAULT '2' COMMENT '1-Yes,2-No',
  `auto_bid` tinyint(3) NOT NULL DEFAULT '2' COMMENT '1-Yes,2-No',
  `bid_time` datetime NOT NULL,
  `buyout_status` int(11) NOT NULL DEFAULT '0',
  `flag` int(2) NOT NULL DEFAULT '0',
  `posted_by` int(10) NOT NULL,
  PRIMARY KEY (`invoice_bidding_id`),
  KEY `user_id` (`user_id`),
  KEY `invoice_id` (`invoice_id`),
  KEY `user_id_2` (`user_id`,`invoice_id`,`min_advance`,`max_thirty_reserve`,`bidding_yield`,`flag`)
) ENGINE=InnoDB AUTO_INCREMENT=168172 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_bidding_history`
--

DROP TABLE IF EXISTS `invoice_bidding_history`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_bidding_history` (
  `history_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `invoice_bidding_id` bigint(40) NOT NULL,
  `user_id` bigint(20) NOT NULL,
  `invoice_id` bigint(20) NOT NULL,
  `min_advance` double NOT NULL,
  `max_thirty_reserve` decimal(10,5) NOT NULL,
  `history_yield` double NOT NULL,
  `buy_out` tinyint(3) NOT NULL DEFAULT '2' COMMENT '1-Yes,2-No',
  `auto_bid` tinyint(3) NOT NULL DEFAULT '2' COMMENT '1-Yes,2-No',
  `bid_time` datetime NOT NULL,
  PRIMARY KEY (`history_id`),
  KEY `user_id` (`user_id`),
  KEY `invoice_id` (`invoice_id`),
  KEY `invoice_bidding_id` (`invoice_bidding_id`,`user_id`,`invoice_id`,`min_advance`,`max_thirty_reserve`)
) ENGINE=InnoDB AUTO_INCREMENT=37009 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_bulk_closed`
--

DROP TABLE IF EXISTS `invoice_bulk_closed`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_bulk_closed` (
  `bulk_id` mediumint(40) unsigned NOT NULL AUTO_INCREMENT,
  `bulk_ref_id` varchar(40) NOT NULL,
  `investor_id` smallint(40) unsigned NOT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`bulk_id`),
  KEY `bulk_ref_id` (`bulk_ref_id`,`investor_id`)
) ENGINE=MyISAM AUTO_INCREMENT=133440 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_closed`
--

DROP TABLE IF EXISTS `invoice_closed`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_closed` (
  `close_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `closed_ref_id` varchar(40) DEFAULT NULL,
  `bulk_closed_id` mediumint(40) unsigned NOT NULL,
  `invoice_id` mediumint(20) unsigned NOT NULL,
  `won_by` smallint(20) unsigned NOT NULL,
  `min_advance` double NOT NULL,
  `max_thirty_reserve` decimal(10,5) NOT NULL,
  `inv_purchase_price` double(10,2) NOT NULL,
  `org_purchase_payment` double(10,2) NOT NULL,
  `purchase_price` double(10,2) NOT NULL,
  `closed_yield` double NOT NULL,
  `yield_value` double(10,2) NOT NULL DEFAULT '0.00',
  `purchase_payment` double(10,2) NOT NULL DEFAULT '0.00',
  `value_return` double(10,2) NOT NULL,
  `invoice_bidding_id` mediumint(40) unsigned NOT NULL,
  `payment_status` tinyint(3) NOT NULL DEFAULT '0' COMMENT '0-Not Paid,1-Payment Completd',
  `close_time` datetime NOT NULL,
  `accept_status` tinyint(2) unsigned NOT NULL DEFAULT '0',
  `bought_by` int(10) NOT NULL,
  PRIMARY KEY (`close_id`),
  KEY `won_by` (`won_by`),
  KEY `invoice_id` (`invoice_id`),
  KEY `close_time` (`close_time`)
) ENGINE=InnoDB AUTO_INCREMENT=168182 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_closed_attributes`
--

DROP TABLE IF EXISTS `invoice_closed_attributes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_closed_attributes` (
  `attribute_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `invoice_closed_id` bigint(40) NOT NULL,
  `invoice_id` bigint(40) NOT NULL,
  `maturity_days` int(11) NOT NULL,
  `trade_commission` double NOT NULL,
  `ex_commission` double NOT NULL,
  `agent_commission` double NOT NULL,
  `intermed_commission` double NOT NULL,
  `cdp_cost` double NOT NULL,
  `agreed_buy_rate` double NOT NULL,
  `agreed_sell_rate` double NOT NULL,
  `purchase_discount` double NOT NULL,
  `active_debtors` int(11) NOT NULL,
  `posting_fee` double NOT NULL,
  `processing_fee` double NOT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`attribute_id`),
  KEY `Index 2` (`invoice_id`)
) ENGINE=InnoDB AUTO_INCREMENT=167996 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_closed_ins_etr`
--

DROP TABLE IF EXISTS `invoice_closed_ins_etr`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_closed_ins_etr` (
  `ins_close_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `invoice_close_id` bigint(20) NOT NULL,
  `closed_ref_id` varchar(40) DEFAULT NULL,
  `bulk_closed_id` bigint(40) NOT NULL,
  `invoice_id` int(11) NOT NULL,
  `won_by` bigint(20) NOT NULL,
  `min_advance` double NOT NULL,
  `max_thirty_reserve` decimal(10,5) NOT NULL,
  `inv_purchase_price` double(10,2) NOT NULL,
  `org_purchase_payment` double(10,2) NOT NULL,
  `purchase_price` double(10,2) NOT NULL,
  `closed_yield` double NOT NULL,
  `yield_value` double(10,2) NOT NULL DEFAULT '0.00',
  `purchase_payment` double(10,2) NOT NULL DEFAULT '0.00',
  `value_return` double(10,2) NOT NULL,
  `invoice_bidding_id` bigint(40) NOT NULL,
  `payment_status` tinyint(3) NOT NULL DEFAULT '0' COMMENT '0-Not Paid,1-Payment Completd',
  `close_time` datetime NOT NULL,
  `accept_status` int(2) NOT NULL DEFAULT '0',
  `bought_by` int(10) NOT NULL,
  PRIMARY KEY (`ins_close_id`),
  KEY `won_by` (`won_by`),
  KEY `invoice_bidding_id` (`invoice_bidding_id`),
  KEY `closed_ref_id` (`closed_ref_id`,`bulk_closed_id`,`won_by`,`min_advance`,`max_thirty_reserve`,`purchase_price`,`purchase_payment`,`invoice_bidding_id`,`payment_status`),
  KEY `invoice_closed_id_fk` (`invoice_close_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_documents`
--

DROP TABLE IF EXISTS `invoice_documents`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_documents` (
  `invoice_document_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `invoice_id` bigint(40) NOT NULL,
  `invoice_document_path` varchar(255) NOT NULL,
  `invoice_support_document_path` varchar(255) NOT NULL,
  `purchase_order_document_path` varchar(255) NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`invoice_document_id`),
  KEY `invoice_id` (`invoice_id`)
) ENGINE=InnoDB AUTO_INCREMENT=170281 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_margin_calls`
--

DROP TABLE IF EXISTS `invoice_margin_calls`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_margin_calls` (
  `invoice_id` mediumint(8) unsigned DEFAULT NULL,
  `is_rtrade` mediumint(8) unsigned DEFAULT NULL,
  `is_drp` mediumint(8) unsigned DEFAULT NULL,
  `engine_id` tinyint(3) unsigned DEFAULT NULL,
  `rtrade_value` double unsigned DEFAULT NULL,
  `drp_value` double unsigned DEFAULT NULL,
  UNIQUE KEY `Index 1` (`invoice_id`),
  KEY `Index 2` (`is_rtrade`),
  KEY `Index 3` (`is_drp`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_master`
--

DROP TABLE IF EXISTS `invoice_master`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_master` (
  `invoice_id` mediumint(20) unsigned NOT NULL AUTO_INCREMENT,
  `po_id` varchar(256) NOT NULL,
  `invoice_no` varchar(100) NOT NULL,
  `root_invoice_id` mediumint(40) unsigned NOT NULL,
  `debtor_id` mediumint(40) unsigned NOT NULL,
  `user_id` smallint(20) unsigned NOT NULL,
  `trade_reference_id` bigint(40) NOT NULL,
  `face_value` double NOT NULL,
  `document_value` double NOT NULL,
  `revolving` tinyint(2) unsigned NOT NULL DEFAULT '0',
  `revolving_total` int(10) NOT NULL DEFAULT '0',
  `revolving_months` int(10) NOT NULL DEFAULT '0',
  `instalment` tinyint(4) NOT NULL,
  `paid_instalments` int(10) NOT NULL,
  `per_instalment_amt` double(10,2) NOT NULL,
  `no_of_instalments` int(10) NOT NULL,
  `payments_remaining` int(10) NOT NULL,
  `paid_to_debtors` tinyint(4) NOT NULL COMMENT '0-Not Paid,1-Paid',
  `buy_out` tinyint(3) NOT NULL COMMENT '1-Active,2-Inactive',
  `description` text NOT NULL,
  `payment_terms` int(10) NOT NULL,
  `actual_date` date NOT NULL,
  `approved_date` date NOT NULL,
  `expected_date` date NOT NULL,
  `trading_close_date` datetime NOT NULL,
  `min_advance` double NOT NULL,
  `max_thirty_day_reserve` decimal(6,3) NOT NULL,
  `buy_min_advance` double NOT NULL,
  `buy_max_thirty_day_reserve` decimal(6,3) NOT NULL,
  `purchase_price_percent` double DEFAULT NULL,
  `debx` tinyint(5) unsigned NOT NULL DEFAULT '2' COMMENT '1-Active:2-Deactive',
  `invoice_status` tinyint(2) unsigned NOT NULL DEFAULT '1' COMMENT '0-Inactive:1-Published:2-frozen:3-Closed',
  `revolving_status` int(2) NOT NULL DEFAULT '0',
  `invoice_authorise` tinyint(5) unsigned NOT NULL DEFAULT '0' COMMENT '0-New:1-Contacted:2-Confirmed:3-Authorised',
  `draft` tinyint(2) unsigned NOT NULL DEFAULT '0',
  `instalment_draft` tinyint(4) NOT NULL,
  `revolving_draft` tinyint(2) unsigned NOT NULL DEFAULT '0',
  `closing_type` tinyint(2) unsigned NOT NULL DEFAULT '1',
  `modified_at` datetime NOT NULL,
  `modified_by` smallint(20) unsigned NOT NULL,
  `bids` tinyint(2) unsigned NOT NULL DEFAULT '0',
  `sales_type` tinyint(5) unsigned NOT NULL,
  `yield` double DEFAULT NULL,
  `buy_yield` double DEFAULT NULL,
  `bid_yield` double DEFAULT NULL,
  `return` double DEFAULT NULL,
  `buy_return` double DEFAULT NULL,
  `bid_return` double DEFAULT NULL,
  `noa_link` varchar(250) DEFAULT NULL,
  `etr_link` varchar(250) DEFAULT NULL,
  `nopo_link` varchar(250) DEFAULT NULL,
  `noa_status` tinyint(2) unsigned NOT NULL DEFAULT '0',
  `noa_id` bigint(40) DEFAULT NULL,
  `noa_notifed` datetime DEFAULT NULL,
  `noa_contact_id` int(11) NOT NULL DEFAULT '0',
  `noa_need_send` tinyint(4) NOT NULL DEFAULT '0',
  `discount_rate` decimal(7,5) DEFAULT '0.00000',
  `mail_status` tinyint(2) NOT NULL DEFAULT '0' COMMENT '0-not respond,1-respond',
  `response_mail_status` tinyint(5) NOT NULL DEFAULT '0' COMMENT '1-24,2-48,3-96,4-192,5-384',
  `posting_interface` tinyint(2) unsigned NOT NULL DEFAULT '0',
  `manual_transaction_id` mediumint(20) unsigned NOT NULL,
  `auto_assign` tinyint(4) NOT NULL COMMENT '0-auto,1-not',
  `reserve_on` tinyint(4) NOT NULL COMMENT '0-not reserved,1-reserved',
  `payment_status` tinyint(4) NOT NULL COMMENT '0-Unpaid,1-Paid',
  `amendment_status` tinyint(4) NOT NULL COMMENT '0-Off,1-On',
  `multiple_count` int(10) NOT NULL,
  `created_at` datetime NOT NULL,
  `authorised_at` datetime NOT NULL,
  `log_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1-Approved,2-rejected',
  `logapprove_date` datetime NOT NULL,
  `logapproved_by` int(11) DEFAULT NULL,
  `rejected_date` datetime NOT NULL,
  `reject_message` varchar(356) NOT NULL,
  `payment_discount` double(4,2) NOT NULL DEFAULT '0.00',
  `is_auto_send` tinyint(4) NOT NULL DEFAULT '0',
  `reserve` double(10,2) DEFAULT NULL,
  `drp_id` mediumint(20) unsigned NOT NULL DEFAULT '0',
  `rerouted` int(11) DEFAULT '0',
  `spooled` int(11) DEFAULT '0',
  `c_etr_commission` decimal(10,4) DEFAULT NULL,
  `trade_commission` decimal(10,4) DEFAULT NULL,
  `processing_fee` decimal(10,4) DEFAULT NULL,
  `traded_processing_fee` decimal(10,4) DEFAULT NULL,
  `drp_processing_fee` decimal(10,4) DEFAULT NULL,
  `orpa_id` int(11) DEFAULT NULL,
  `amount_rerouted` double DEFAULT NULL,
  `vat_included` enum('0','1') NOT NULL DEFAULT '0',
  `unscheduled_cetr` enum('0','1') NOT NULL DEFAULT '0',
  `is_synced` enum('0','1') NOT NULL DEFAULT '0',
  `synced_date` datetime DEFAULT NULL,
  `is_claimabill` tinyint(4) NOT NULL DEFAULT '0',
  `etr_type` varchar(3) DEFAULT NULL,
  `override_180_day_rule` tinyint(1) NOT NULL DEFAULT '0',
  `face_value_charge_applied` tinyint(1) NOT NULL DEFAULT '0',
  `face_value_charge` double(5,3) DEFAULT NULL,
  `is_aetr` tinyint(1) NOT NULL DEFAULT '0',
  `ldc_premium` double(6,3) NOT NULL DEFAULT '0.000',
  `agent_commission` double(6,3) NOT NULL DEFAULT '0.000',
  PRIMARY KEY (`invoice_id`),
  KEY `user_id` (`user_id`),
  KEY `invoice_id` (`invoice_id`),
  KEY `posting_interface` (`posting_interface`),
  KEY `invoice_no` (`invoice_no`,`root_invoice_id`,`debtor_id`,`user_id`,`trade_reference_id`,`face_value`,`buy_out`,`min_advance`,`max_thirty_day_reserve`,`buy_min_advance`,`buy_max_thirty_day_reserve`,`revolving_draft`),
  KEY `Index 8` (`manual_transaction_id`),
  KEY `Debtor_id` (`debtor_id`),
  KEY `status_authorise` (`invoice_authorise`,`invoice_status`,`revolving`),
  KEY `invoice_status` (`invoice_status`),
  KEY `DRP` (`drp_id`),
  KEY `orpa_id` (`invoice_status`,`orpa_id`),
  KEY `IDX_invoice_master_orpa_id` (`orpa_id`)
) ENGINE=InnoDB AUTO_INCREMENT=170544 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_master_assets`
--

DROP TABLE IF EXISTS `invoice_master_assets`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_master_assets` (
  `asset_id` int(11) NOT NULL AUTO_INCREMENT,
  `lessee_id` int(11) NOT NULL,
  `a_etr_id` int(11) NOT NULL,
  `reference_id` bigint(20) DEFAULT NULL,
  `purchase_invoice_id` int(11) DEFAULT NULL,
  `purchase_date` date NOT NULL,
  `asset_name` varchar(255) NOT NULL,
  `asset_number` varchar(255) NOT NULL,
  `number_of_periods` int(11) NOT NULL,
  `period_type` varchar(45) NOT NULL,
  `sell_rate` decimal(6,3) NOT NULL,
  `quantity` int(11) NOT NULL,
  `unit_price` double NOT NULL,
  `face_value` double NOT NULL,
  `income_value` double NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `currency_id` int(11) NOT NULL,
  `address_id` int(11) DEFAULT NULL,
  `description` varchar(255) DEFAULT NULL,
  `supplier` varchar(255) DEFAULT NULL,
  `serial_number` varchar(255) DEFAULT NULL,
  `repair_amount` double DEFAULT NULL,
  `asset_type` varchar(45) DEFAULT NULL,
  `a_etr_type` varchar(255) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `modified_at` datetime DEFAULT NULL,
  `modified_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`asset_id`),
  KEY `lessee_idx` (`lessee_id`),
  KEY `a_etr_idx` (`purchase_invoice_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1158 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_master_edit_history`
--

DROP TABLE IF EXISTS `invoice_master_edit_history`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_master_edit_history` (
  `invoice_history_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `invoice_id` mediumint(20) unsigned NOT NULL,
  `invoice_no` varchar(100) NOT NULL,
  `debtor_id` mediumint(40) unsigned NOT NULL,
  `user_id` smallint(20) unsigned NOT NULL,
  `face_value` double NOT NULL,
  `actual_date` date NOT NULL,
  `expected_date` date NOT NULL,
  `payment_terms` int(10) NOT NULL,
  `max_thirty_day_reserve` decimal(6,3) NOT NULL,
  `purchase_price_percent` double DEFAULT NULL,
  `invoice_link` varchar(250) DEFAULT NULL,
  `po_link` varchar(250) DEFAULT NULL,
  `logapprove_date` datetime NOT NULL,
  `reserve` double(10,2) DEFAULT NULL,
  `c_etr_commission` decimal(10,4) DEFAULT NULL,
  `trade_fee` decimal(10,4) DEFAULT NULL,
  `orpa_id` int(11) DEFAULT NULL,
  `vat_included` enum('0','1') NOT NULL DEFAULT '0',
  `unscheduled_cetr` enum('0','1') NOT NULL DEFAULT '0',
  `etr_type` varchar(3) DEFAULT NULL,
  `override_180_day_rule` tinyint(1) NOT NULL DEFAULT '0',
  `face_value_charge_applied` tinyint(1) NOT NULL DEFAULT '0',
  `face_value_charge` double(5,3) DEFAULT NULL,
  `is_aetr` tinyint(1) NOT NULL DEFAULT '0',
  `ldc_premium` double(6,3) NOT NULL DEFAULT '0.000',
  `agent_commission` double(6,3) NOT NULL DEFAULT '0.000',
  `created_at` datetime NOT NULL,
  `created_by` int(11) NOT NULL,
  `created_type` varchar(10) NOT NULL,
  `history_action` tinyint(4) NOT NULL,
  PRIMARY KEY (`invoice_history_id`)
) ENGINE=InnoDB AUTO_INCREMENT=92309 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_notes`
--

DROP TABLE IF EXISTS `invoice_notes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_notes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `invoice_id` int(11) NOT NULL,
  `text` text NOT NULL,
  `created_at` datetime NOT NULL,
  `created_by` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_reject_log`
--

DROP TABLE IF EXISTS `invoice_reject_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_reject_log` (
  `reject_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `invoice_id` int(20) NOT NULL,
  `status` tinyint(4) NOT NULL COMMENT '0-Approved,1-Rejected',
  `rejected_at` datetime NOT NULL,
  PRIMARY KEY (`reject_id`)
) ENGINE=InnoDB AUTO_INCREMENT=8806 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoice_rejected`
--

DROP TABLE IF EXISTS `invoice_rejected`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoice_rejected` (
  `invoice_id` mediumint(20) unsigned NOT NULL AUTO_INCREMENT,
  `reject_id` mediumint(20) unsigned NOT NULL,
  `po_id` varchar(256) NOT NULL,
  `invoice_no` varchar(100) NOT NULL,
  `root_invoice_id` mediumint(40) unsigned NOT NULL,
  `debtor_id` mediumint(40) unsigned NOT NULL,
  `user_id` smallint(20) unsigned NOT NULL,
  `trade_reference_id` bigint(40) NOT NULL,
  `face_value` double NOT NULL,
  `document_value` double NOT NULL,
  `revolving` tinyint(2) unsigned NOT NULL DEFAULT '0',
  `revolving_total` int(10) NOT NULL DEFAULT '0',
  `revolving_months` int(10) NOT NULL DEFAULT '0',
  `instalment` tinyint(4) NOT NULL,
  `paid_instalments` int(10) NOT NULL,
  `per_instalment_amt` double(10,2) NOT NULL,
  `no_of_instalments` int(10) NOT NULL,
  `payments_remaining` int(10) NOT NULL,
  `paid_to_debtors` tinyint(4) NOT NULL COMMENT '0-Not Paid,1-Paid',
  `buy_out` tinyint(3) NOT NULL COMMENT '1-Active,2-Inactive',
  `description` text NOT NULL,
  `payment_terms` int(10) NOT NULL,
  `actual_date` date NOT NULL,
  `approved_date` date NOT NULL,
  `expected_date` date NOT NULL,
  `trading_close_date` datetime NOT NULL,
  `min_advance` double NOT NULL,
  `max_thirty_day_reserve` decimal(6,3) NOT NULL,
  `buy_min_advance` double NOT NULL,
  `buy_max_thirty_day_reserve` decimal(6,3) NOT NULL,
  `debx` tinyint(5) unsigned NOT NULL DEFAULT '2' COMMENT '1-Active:2-Deactive',
  `sales_type` int(5) NOT NULL,
  `noa_link` varchar(250) DEFAULT NULL,
  `etr_link` varchar(250) DEFAULT NULL,
  `noa_status` tinyint(2) unsigned NOT NULL DEFAULT '0',
  `noa_id` bigint(40) DEFAULT NULL,
  `noa_notifed` datetime DEFAULT NULL,
  `discount_rate` decimal(5,5) DEFAULT '0.00000',
  `invoice_document_path` varchar(255) NOT NULL,
  `posting_interface` tinyint(2) unsigned NOT NULL DEFAULT '0',
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`invoice_id`),
  KEY `user_id` (`user_id`),
  KEY `invoice_id` (`invoice_id`),
  KEY `posting_interface` (`posting_interface`),
  KEY `invoice_no` (`invoice_no`,`root_invoice_id`,`debtor_id`,`user_id`,`trade_reference_id`,`face_value`,`buy_out`,`min_advance`,`max_thirty_day_reserve`,`buy_min_advance`,`buy_max_thirty_day_reserve`)
) ENGINE=InnoDB AUTO_INCREMENT=7324 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoices_fv_used`
--

DROP TABLE IF EXISTS `invoices_fv_used`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoices_fv_used` (
  `invoice_id` mediumint(8) unsigned DEFAULT NULL,
  `transaction_id` mediumint(8) unsigned DEFAULT NULL,
  `used` decimal(10,2) unsigned DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `used_id` mediumint(8) unsigned NOT NULL,
  `comission` decimal(10,2) unsigned NOT NULL DEFAULT '0.00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `invoices_index`
--

DROP TABLE IF EXISTS `invoices_index`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoices_index` (
  `user_id` smallint(20) unsigned NOT NULL,
  `currency_id` tinyint(3) unsigned,
  `bank_currency` tinyint(3) unsigned DEFAULT NULL,
  `face_value` double DEFAULT NULL,
  `face_value_traded_fx` double DEFAULT NULL,
  `face_value_setteled` double DEFAULT NULL,
  `face_value_setteled_fx` double DEFAULT NULL,
  KEY `my_unique_index_name` (`user_id`,`currency_id`,`bank_currency`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `ip_block`
--

DROP TABLE IF EXISTS `ip_block`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `ip_block` (
  `ip_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `ip` varchar(20) NOT NULL,
  `status` int(2) NOT NULL DEFAULT '0',
  `created` date NOT NULL,
  `modified` date NOT NULL,
  PRIMARY KEY (`ip_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `label_type_settings`
--

DROP TABLE IF EXISTS `label_type_settings`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `label_type_settings` (
  `label_type_id` tinyint(10) unsigned NOT NULL AUTO_INCREMENT,
  `label_type` varchar(255) NOT NULL,
  `label_type_status` tinyint(2) unsigned NOT NULL COMMENT '1-active,2-inactive',
  `modified_by` tinyint(10) unsigned NOT NULL,
  `modified_on` datetime NOT NULL,
  PRIMARY KEY (`label_type_id`),
  UNIQUE KEY `label_type` (`label_type`),
  KEY `modified_by` (`modified_by`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `labels_settings`
--

DROP TABLE IF EXISTS `labels_settings`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `labels_settings` (
  `label_id` smallint(20) unsigned NOT NULL AUTO_INCREMENT,
  `label_type` tinyint(10) unsigned NOT NULL,
  `label_title` varchar(255) NOT NULL,
  `label_description` text NOT NULL,
  `label_added_on` datetime NOT NULL,
  `label_added_by` tinyint(10) unsigned NOT NULL,
  `ordering` tinyint(10) unsigned NOT NULL DEFAULT '0',
  `modified_at` datetime NOT NULL,
  `modified_by` tinyint(10) unsigned NOT NULL,
  PRIMARY KEY (`label_id`),
  KEY `label_type` (`label_type`),
  KEY `label_modified_by` (`modified_by`),
  KEY `label_added_by` (`label_added_by`)
) ENGINE=InnoDB AUTO_INCREMENT=57 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `mail_management`
--

DROP TABLE IF EXISTS `mail_management`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mail_management` (
  `mail_id` tinyint(10) unsigned NOT NULL AUTO_INCREMENT,
  `smtp_host` varchar(50) NOT NULL,
  `smtp_port` varchar(50) NOT NULL,
  `smtp_username` varchar(50) NOT NULL,
  `smtp_password` varchar(50) NOT NULL,
  `mail_name` varchar(50) NOT NULL,
  `mail_to` varchar(250) DEFAULT NULL,
  `mail_from` varchar(250) NOT NULL,
  `mail_from_name` varchar(255) DEFAULT NULL,
  `mail_subject` varchar(255) NOT NULL,
  `mail_type` tinyint(2) unsigned NOT NULL DEFAULT '0',
  `mail_content` text NOT NULL,
  `mail_content_text` text NOT NULL,
  `mail_status` tinyint(3) unsigned NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` tinyint(10) unsigned NOT NULL,
  PRIMARY KEY (`mail_id`),
  KEY `modified_by` (`modified_by`),
  KEY `smtp_host` (`smtp_host`,`smtp_port`,`smtp_username`,`smtp_password`,`mail_to`,`mail_from`,`mail_from_name`,`mail_type`)
) ENGINE=InnoDB AUTO_INCREMENT=65 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `manual_transactions`
--

DROP TABLE IF EXISTS `manual_transactions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `manual_transactions` (
  `manual_transaction_id` mediumint(40) unsigned NOT NULL AUTO_INCREMENT,
  `transaction_type` tinyint(7) unsigned NOT NULL COMMENT '1-Payment By Debtor,2-Transfer of payment by Originator,3-Remittance Notice from Debtor,4-Credit Note issued to Debtor,5-Other Discount offered to Debtor,6-Upload of Debtor Reconciliation,7-Originator Payment on Account,8-Bank Transmission Receipt,9-Paid ',
  `debtor_id` mediumint(40) unsigned NOT NULL,
  `originator_id` smallint(40) unsigned NOT NULL,
  `currency_id` tinyint(20) unsigned NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `reference_to` text NOT NULL,
  `specific_allocation` tinyint(4) NOT NULL COMMENT '0-not with,1-with',
  `notes` text NOT NULL,
  `credit_note_no` varchar(100) DEFAULT NULL,
  `transaction_file` varchar(255) NOT NULL,
  `specific_deductible` tinyint(4) NOT NULL COMMENT '0-Not specfic deductible,1- Specific deductible',
  `deductible_amount` decimal(10,2) NOT NULL,
  `trailing_balance` tinyint(4) NOT NULL COMMENT '0-not with,1-with',
  `trailing_balance_amt` decimal(10,2) NOT NULL,
  `transref_list` text NOT NULL COMMENT 'ref=>manual_transaction_id ',
  `reconcile_payment` mediumint(10) unsigned NOT NULL,
  `reconcile_ref` mediumint(10) unsigned NOT NULL,
  `payment_return` mediumint(10) unsigned NOT NULL,
  `false_payment` mediumint(10) unsigned NOT NULL,
  `amendment_id` mediumint(10) unsigned NOT NULL,
  `status` tinyint(10) NOT NULL COMMENT '0-Created,1-Authorised,2-Notified',
  `reconcile_status` tinyint(5) NOT NULL DEFAULT '0' COMMENT '0-non reconcile,1-reconcile',
  `reconcile_credit` tinyint(4) NOT NULL COMMENT '0-Non reconcile,1-Reconcile',
  `multiple_payments` text NOT NULL,
  `multiple_status` tinyint(4) NOT NULL COMMENT '0-Off,1-On',
  `interface` tinyint(4) NOT NULL COMMENT '0-User,1-Admin',
  `paid_status` tinyint(4) NOT NULL COMMENT '0-Unpaid,1-Paid',
  `transaction_date` date NOT NULL,
  `notification_title` tinyint(4) NOT NULL COMMENT '1-Fee Notice,2-RSA Offer,3-Other',
  `transaction_name` varchar(250) NOT NULL,
  `issue_date` date NOT NULL,
  `created_at` datetime NOT NULL,
  `created_by` tinyint(4) NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` tinyint(4) NOT NULL,
  `authorised_at` datetime NOT NULL,
  `authorised_by` tinyint(4) NOT NULL,
  `reserve_on` mediumint(4) unsigned NOT NULL DEFAULT '0',
  `rerouted` int(11) DEFAULT '0',
  `spooled` int(11) DEFAULT '0',
  `orpa_id` int(11) DEFAULT NULL,
  `fees_commissions` int(11) NOT NULL DEFAULT '0',
  `is_synced` enum('0','1') NOT NULL DEFAULT '0',
  `synced_date` datetime DEFAULT NULL,
  `is_aetr` tinyint(1) NOT NULL DEFAULT '0',
  `a_etr_id` int(11) DEFAULT NULL,
  `asset_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`manual_transaction_id`),
  KEY `reconcile_payment` (`reconcile_payment`),
  KEY `reconcile_ref` (`reconcile_ref`),
  KEY `transaction_type_only` (`transaction_type`),
  KEY `Index 3` (`debtor_id`),
  KEY `transaction_type` (`transaction_type`,`originator_id`,`amount`,`specific_allocation`,`status`),
  KEY `originator_id` (`originator_id`)
) ENGINE=InnoDB AUTO_INCREMENT=227308 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `manual_transactions_archive`
--

DROP TABLE IF EXISTS `manual_transactions_archive`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `manual_transactions_archive` (
  `id` mediumint(40) unsigned NOT NULL AUTO_INCREMENT,
  `manual_transaction_id` mediumint(40) unsigned NOT NULL,
  `transaction_type` tinyint(7) unsigned NOT NULL COMMENT '1-Payment By Debtor,2-Transfer of payment by Originator,3-Remittance Notice from Debtor,4-Credit Note issued to Debtor,5-Other Discount offered to Debtor,6-Upload of Debtor Reconciliation,7-Originator Payment on Account,8-Bank Transmission Receipt,9-Paid ',
  `debtor_id` mediumint(40) unsigned NOT NULL,
  `originator_id` smallint(40) unsigned NOT NULL,
  `currency_id` tinyint(20) unsigned NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `reference_to` text NOT NULL,
  `specific_allocation` tinyint(4) NOT NULL COMMENT '0-not with,1-with',
  `notes` text NOT NULL,
  `credit_note_no` varchar(100) DEFAULT NULL,
  `transaction_file` varchar(255) NOT NULL,
  `specific_deductible` tinyint(4) NOT NULL COMMENT '0-Not specfic deductible,1- Specific deductible',
  `deductible_amount` decimal(10,2) NOT NULL,
  `trailing_balance` tinyint(4) NOT NULL COMMENT '0-not with,1-with',
  `trailing_balance_amt` decimal(10,2) NOT NULL,
  `transref_list` text NOT NULL COMMENT 'ref=>manual_transaction_id ',
  `reconcile_payment` mediumint(10) unsigned NOT NULL,
  `reconcile_ref` mediumint(10) unsigned NOT NULL,
  `payment_return` mediumint(10) unsigned NOT NULL,
  `false_payment` mediumint(10) unsigned NOT NULL,
  `amendment_id` mediumint(10) unsigned NOT NULL,
  `status` tinyint(10) NOT NULL COMMENT '0-Created,1-Authorised,2-Notified',
  `reconcile_status` tinyint(5) NOT NULL DEFAULT '0' COMMENT '0-non reconcile,1-reconcile',
  `reconcile_credit` tinyint(4) NOT NULL COMMENT '0-Non reconcile,1-Reconcile',
  `multiple_payments` text NOT NULL,
  `multiple_status` tinyint(4) NOT NULL COMMENT '0-Off,1-On',
  `interface` tinyint(4) NOT NULL COMMENT '0-User,1-Admin',
  `paid_status` tinyint(4) NOT NULL COMMENT '0-Unpaid,1-Paid',
  `transaction_date` date NOT NULL,
  `notification_title` tinyint(4) NOT NULL COMMENT '1-Fee Notice,2-RSA Offer,3-Other',
  `transaction_name` varchar(250) NOT NULL,
  `issue_date` date NOT NULL,
  `created_at` datetime NOT NULL,
  `created_by` tinyint(4) NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` tinyint(4) NOT NULL,
  `authorised_at` datetime NOT NULL,
  `authorised_by` tinyint(4) NOT NULL,
  `reserve_on` mediumint(4) unsigned NOT NULL DEFAULT '0',
  `rerouted` int(11) DEFAULT '0',
  `spooled` int(11) DEFAULT '0',
  `orpa_id` int(11) DEFAULT NULL,
  `fees_commissions` int(11) NOT NULL DEFAULT '0',
  `is_synced` enum('0','1') NOT NULL DEFAULT '0',
  `synced_date` datetime DEFAULT NULL,
  `is_aetr` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2381 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `manual_transactions_invoice`
--

DROP TABLE IF EXISTS `manual_transactions_invoice`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `manual_transactions_invoice` (
  `t_id` int(40) unsigned NOT NULL AUTO_INCREMENT,
  `transaction_id` mediumint(40) unsigned NOT NULL,
  `invoice_id` mediumint(40) unsigned NOT NULL,
  `allocation` tinyint(11) unsigned NOT NULL COMMENT '1-Reconcile,0-Non Reconcile',
  `balance_amount` decimal(10,2) NOT NULL,
  `reserve_amount` decimal(10,2) NOT NULL,
  `ra_status` tinyint(4) unsigned NOT NULL COMMENT '0 - not reconcile, 1 - reconcile',
  `trailing_status` tinyint(4) unsigned NOT NULL COMMENT '0-not with specific allocation,1-with specific allocation',
  `created_at` datetime NOT NULL,
  `modified_at` datetime NOT NULL,
  PRIMARY KEY (`t_id`),
  KEY `Index 2` (`transaction_id`)
) ENGINE=InnoDB AUTO_INCREMENT=55685 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `manual_transactions_rejected`
--

DROP TABLE IF EXISTS `manual_transactions_rejected`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `manual_transactions_rejected` (
  `trans_reject_id` mediumint(11) unsigned NOT NULL AUTO_INCREMENT,
  `manual_transaction_id` mediumint(11) unsigned NOT NULL,
  `transaction_type` tinyint(7) unsigned NOT NULL,
  `debtor_id` mediumint(40) unsigned NOT NULL,
  `originator_id` smallint(40) unsigned NOT NULL,
  `currency_id` tinyint(20) unsigned NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `debtors` text NOT NULL,
  `reference_to` text NOT NULL,
  `specific_allocation` tinyint(4) NOT NULL COMMENT '0-not with,1-with',
  `notes` text NOT NULL,
  `credit_note_no` varchar(100) DEFAULT NULL,
  `transaction_file` varchar(255) NOT NULL,
  `specific_deductible` tinyint(4) NOT NULL COMMENT '0-Not specfic deductible,1- Specific deductible',
  `deductible_amount` decimal(10,2) NOT NULL,
  `trailing_balance` tinyint(4) NOT NULL COMMENT '0-not with,1-with',
  `trailing_balance_amt` decimal(10,2) NOT NULL,
  `transref_list` text NOT NULL COMMENT 'ref=>manual_transaction_id ',
  `reconcile_payment` mediumint(10) unsigned NOT NULL,
  `reconcile_ref` mediumint(10) unsigned NOT NULL,
  `payment_return` mediumint(10) unsigned NOT NULL,
  `false_payment` mediumint(10) unsigned NOT NULL,
  `amendment_id` mediumint(10) unsigned NOT NULL,
  `status` tinyint(10) unsigned NOT NULL,
  `reconcile_status` int(5) NOT NULL DEFAULT '0' COMMENT '0-non reconcile,1-reconcile',
  `reconcile_credit` tinyint(4) NOT NULL,
  `multiple_payments` text NOT NULL,
  `multiple_status` tinyint(4) NOT NULL COMMENT '0-Off,1-On',
  `interface` tinyint(4) NOT NULL COMMENT '0-User,1-Admin',
  `paid_status` tinyint(4) NOT NULL COMMENT '0-Unpaid,1-Paid',
  `transaction_date` date NOT NULL,
  `notification_title` tinyint(4) NOT NULL COMMENT '1-Fee Notice,2-RSA Offer,3-Other',
  `transaction_name` varchar(250) NOT NULL,
  `issue_date` date NOT NULL,
  `delete_notes` text NOT NULL,
  `reject_status` tinytext NOT NULL COMMENT '0-Off,1-On',
  `created_at` datetime NOT NULL,
  `created_by` tinyint(4) NOT NULL,
  `reject_created_at` datetime NOT NULL,
  `reject_created_by` tinyint(4) NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` tinyint(4) NOT NULL,
  `authorised_at` datetime NOT NULL,
  `authorised_by` tinyint(4) NOT NULL,
  `reserve_on` mediumint(4) unsigned NOT NULL DEFAULT '0',
  `rerouted` int(11) DEFAULT '0',
  `spooled` int(11) DEFAULT '0',
  `orpa_id` int(11) DEFAULT NULL,
  `fees_commissions` int(11) NOT NULL DEFAULT '0',
  `is_synced` enum('0','1') NOT NULL DEFAULT '0',
  `synced_date` datetime DEFAULT NULL,
  `is_aetr` tinyint(1) NOT NULL DEFAULT '0',
  `a_etr_id` int(11) DEFAULT NULL,
  `asset_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`trans_reject_id`),
  KEY `transaction_type` (`transaction_type`,`debtor_id`,`originator_id`,`currency_id`,`amount`,`specific_allocation`,`status`,`paid_status`)
) ENGINE=InnoDB AUTO_INCREMENT=44082 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `messages`
--

DROP TABLE IF EXISTS `messages`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `messages` (
  `message_id` bigint(60) NOT NULL AUTO_INCREMENT,
  `message_from` bigint(40) NOT NULL,
  `message_to` bigint(40) NOT NULL,
  `message_title` varchar(255) NOT NULL,
  `message` longtext NOT NULL,
  `message_created_date` datetime NOT NULL,
  `message_flag` tinyint(5) NOT NULL COMMENT '1-Unread,2-Read,3-Deleted',
  PRIMARY KEY (`message_id`),
  KEY `message_from` (`message_from`),
  KEY `message_to` (`message_to`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `new_users`
--

DROP TABLE IF EXISTS `new_users`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `new_users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(50) NOT NULL,
  `password` varchar(255) NOT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `order`
--

DROP TABLE IF EXISTS `order`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `order` (
  `order_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `real_order_id` varchar(40) NOT NULL,
  `name` varchar(250) NOT NULL,
  `promo_id` int(10) DEFAULT NULL,
  `tax` varchar(10) NOT NULL,
  `discount` varchar(10) NOT NULL,
  `amount` float NOT NULL,
  `currency` varchar(10) NOT NULL,
  `auth_code` varchar(255) NOT NULL,
  `bank` varchar(255) NOT NULL,
  `batchid` bigint(40) NOT NULL,
  `message` varchar(255) NOT NULL,
  `pasref` bigint(40) NOT NULL,
  `country` varchar(255) NOT NULL,
  `result` varchar(30) NOT NULL,
  `payment_method` int(10) DEFAULT NULL,
  `temp_reg_id` bigint(40) NOT NULL,
  `user_id` bigint(40) NOT NULL,
  `organisation_id` bigint(40) DEFAULT NULL,
  `p_id` int(20) NOT NULL DEFAULT '1',
  `cart_session` varchar(255) DEFAULT NULL,
  `modified_date` datetime NOT NULL,
  `modified_by` int(20) NOT NULL,
  PRIMARY KEY (`order_id`)
) ENGINE=MyISAM AUTO_INCREMENT=81 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `organisation_bank_account_details`
--

DROP TABLE IF EXISTS `organisation_bank_account_details`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `organisation_bank_account_details` (
  `account_id` smallint(40) unsigned NOT NULL AUTO_INCREMENT,
  `account_name` varchar(255) NOT NULL,
  `account_no` varchar(255) NOT NULL,
  `sort_code` varchar(255) NOT NULL,
  `iban_code` varchar(50) NOT NULL,
  `swift_code` varchar(50) NOT NULL,
  `retailer_id` bigint(40) DEFAULT NULL,
  `organisation_id` mediumint(40) unsigned NOT NULL,
  `organisation_bank_id` bigint(40) NOT NULL,
  `status` tinyint(10) NOT NULL,
  `created` datetime NOT NULL,
  `change` int(2) NOT NULL DEFAULT '0',
  `account_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0-Application,1-Currency',
  PRIMARY KEY (`account_id`)
) ENGINE=MyISAM AUTO_INCREMENT=2201 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `organisation_bank_details`
--

DROP TABLE IF EXISTS `organisation_bank_details`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `organisation_bank_details` (
  `organisation_bank_id` mediumint(40) unsigned NOT NULL AUTO_INCREMENT,
  `organisation_id` smallint(40) unsigned NOT NULL,
  `retailer_id` smallint(40) unsigned DEFAULT NULL,
  `address_id` bigint(40) NOT NULL,
  `bank_id` bigint(40) NOT NULL,
  `contact_id` bigint(40) NOT NULL,
  `currency_id` tinyint(3) unsigned NOT NULL,
  PRIMARY KEY (`organisation_bank_id`),
  KEY `organisation_id` (`organisation_id`,`retailer_id`,`address_id`,`bank_id`,`contact_id`)
) ENGINE=MyISAM AUTO_INCREMENT=2200 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `organisation_branch_details`
--

DROP TABLE IF EXISTS `organisation_branch_details`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `organisation_branch_details` (
  `organisation_branch_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `organisation_id` bigint(40) NOT NULL,
  `address_id` bigint(40) NOT NULL,
  `branch_status` tinyint(2) NOT NULL DEFAULT '0',
  PRIMARY KEY (`organisation_branch_id`),
  KEY `organisation_id` (`organisation_id`),
  KEY `address_id` (`address_id`),
  KEY `organisation_id_2` (`organisation_id`,`address_id`,`branch_status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `organisation_commission`
--

DROP TABLE IF EXISTS `organisation_commission`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `organisation_commission` (
  `commission_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `organisation_id` bigint(40) NOT NULL,
  `commission` varchar(40) NOT NULL,
  `user_commission` decimal(6,4) DEFAULT NULL,
  `insurance` int(2) NOT NULL DEFAULT '0',
  `parent` bigint(40) DEFAULT NULL,
  `org_type` int(2) NOT NULL DEFAULT '1',
  `mode` int(2) NOT NULL DEFAULT '0',
  `created_at` datetime NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`commission_id`),
  KEY `organisation_id` (`organisation_id`,`commission`,`user_commission`,`insurance`,`parent`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `organisation_crediblity`
--

DROP TABLE IF EXISTS `organisation_crediblity`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `organisation_crediblity` (
  `organisation_crediblity_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `risk_credit_id` bigint(20) NOT NULL,
  `organisation_id` bigint(40) NOT NULL,
  `ccj` varchar(255) NOT NULL,
  `mdm` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `issued_date` date NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(10) NOT NULL,
  PRIMARY KEY (`organisation_crediblity_id`),
  KEY `risk_credit_id` (`risk_credit_id`),
  KEY `modified_by` (`modified_by`),
  KEY `organisation_id` (`organisation_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `organisation_currencies`
--

DROP TABLE IF EXISTS `organisation_currencies`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `organisation_currencies` (
  `account_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `organisation_id` bigint(5) unsigned DEFAULT '0',
  `user_id` bigint(5) unsigned DEFAULT '0',
  `long_id` varchar(50) DEFAULT '',
  `currency_code` varchar(3) DEFAULT '',
  `currency_id` tinyint(3) unsigned DEFAULT '0',
  `account_name` varchar(200) DEFAULT '',
  `iban_code` varchar(200) DEFAULT '',
  `swift_code` varchar(200) DEFAULT '',
  PRIMARY KEY (`account_id`),
  KEY `Index 2` (`user_id`,`currency_id`),
  KEY `IDX_organisation_currencies_organisation_id` (`organisation_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1002 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `organisation_currency`
--

DROP TABLE IF EXISTS `organisation_currency`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `organisation_currency` (
  `org_currency_id` smallint(40) unsigned NOT NULL AUTO_INCREMENT,
  `organisation_id` smallint(25) unsigned NOT NULL,
  `branch_id` int(25) NOT NULL,
  `currency_id` tinyint(25) unsigned NOT NULL,
  `bank_account_type` tinyint(4) NOT NULL DEFAULT '1' COMMENT '1-Existing,2-New Acc',
  `currency_bank_id` int(40) NOT NULL,
  `salesforce_bank_id` varchar(255) DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `is_main` tinyint(3) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`org_currency_id`),
  KEY `organisation_id` (`organisation_id`,`branch_id`,`bank_account_type`,`currency_bank_id`,`currency_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1181 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `organisation_details`
--

DROP TABLE IF EXISTS `organisation_details`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `organisation_details` (
  `organisation_id` smallint(40) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` smallint(20) unsigned DEFAULT NULL,
  `organisation_reference_id` bigint(40) NOT NULL,
  `organisation_name` varchar(255) NOT NULL,
  `organisation_ticker` varchar(10) NOT NULL,
  `organisation_start_price` varchar(255) DEFAULT NULL,
  `organisation_trade_name` varchar(255) NOT NULL,
  `organisation_overview` text NOT NULL,
  `tradingas` varchar(255) NOT NULL,
  `agreed_rate` decimal(10,4) NOT NULL,
  `posting_fee` decimal(6,2) NOT NULL DEFAULT '0.00',
  `processing_fee` decimal(6,2) NOT NULL DEFAULT '0.00',
  `trade_fee` decimal(6,2) NOT NULL,
  `purchase_price` varchar(10) NOT NULL,
  `trade_limit` varchar(10) NOT NULL,
  `valid_date` date NOT NULL,
  `membership` varchar(10) NOT NULL,
  `arrangement` varchar(10) NOT NULL,
  `instalment_etr` tinyint(4) NOT NULL COMMENT '0-Not Seleted,1-Selected',
  `reserve` double(10,3) NOT NULL,
  `nace_group_id` tinyint(10) unsigned NOT NULL,
  `nace_id` smallint(20) unsigned NOT NULL,
  `organisation_address_id` bigint(40) DEFAULT NULL,
  `organisation_regoffice_id` varchar(50) DEFAULT NULL,
  `corporation_number` varchar(20) NOT NULL,
  `vat_number` varchar(50) NOT NULL,
  `tax_number` varchar(20) NOT NULL,
  `tax_url` varchar(255) NOT NULL,
  `tax_username` varchar(255) NOT NULL,
  `tax_password` varchar(255) NOT NULL,
  `parent_company_name` varchar(255) NOT NULL,
  `business_entity_type` tinyint(10) unsigned DEFAULT NULL,
  `business_function_type` tinyint(10) unsigned DEFAULT NULL,
  `organisation_jurisdiction` int(10) NOT NULL,
  `formation_year` year(4) NOT NULL,
  `last_filling` year(4) NOT NULL,
  `share_capital` int(10) NOT NULL,
  `filling_year` year(4) NOT NULL,
  `organisation_risk` varchar(20) DEFAULT NULL,
  `organisation_limit` varchar(20) DEFAULT NULL,
  `active_debtors` smallint(5) unsigned NOT NULL DEFAULT '2',
  `debtor_credit_limit` int(11) NOT NULL,
  `mail_address_id` bigint(40) NOT NULL,
  `billing_address_id` bigint(40) NOT NULL,
  `website` varchar(255) NOT NULL,
  `management_assets` int(10) DEFAULT NULL,
  `duns_number` int(10) DEFAULT NULL,
  `organisation_type` tinyint(3) NOT NULL COMMENT '1-Public Company,2-Private Company',
  `type` tinyint(6) NOT NULL COMMENT '1-Originator,2-Investor,3-Intermediary,4-Retail Investor,5-Debtor,6-Pension Trustee',
  `total_employee` int(10) NOT NULL,
  `accounting_software` varchar(255) NOT NULL,
  `exchange_timeframe` varchar(255) NOT NULL,
  `previous_company_name` varchar(255) NOT NULL,
  `other_changes` text NOT NULL,
  `other_details` text NOT NULL,
  `submitter_firstname` varchar(255) NOT NULL,
  `submitter_lastname` varchar(255) NOT NULL,
  `submitted_date` date NOT NULL,
  `submitter_legally_approved` tinyint(3) unsigned NOT NULL COMMENT '1-Yes,2-No',
  `application_status` tinyint(50) unsigned NOT NULL COMMENT '0-Waiting for Review ,1-Approved,2-Rejected',
  `application_step` varchar(30) NOT NULL DEFAULT '0',
  `organisation_status` tinyint(10) unsigned NOT NULL COMMENT '1-Apply,2-Applied,3-Approve,4-Rate or Bank or Active,5-Lodged or Notified,6-Authorised,7-Suspended,8-Terminated',
  `organisation_confirm` tinyint(2) unsigned NOT NULL COMMENT '0-Off,1-On',
  `org_interface` tinyint(2) unsigned NOT NULL COMMENT '0-User,1-Admin',
  `auto_trade` int(2) NOT NULL DEFAULT '0',
  `rate_status` tinyint(2) NOT NULL COMMENT '1-Approve,2-Confirm',
  `etr_auto_submit` int(2) NOT NULL DEFAULT '1',
  `etr_manual_submit` int(2) NOT NULL DEFAULT '1',
  `etr_pod_mandatory` int(2) NOT NULL DEFAULT '1',
  `etr_pod_mail` int(2) NOT NULL DEFAULT '0',
  `modified_at` datetime NOT NULL,
  `modified_by` tinyint(20) unsigned NOT NULL,
  `created_at` datetime NOT NULL,
  `created_by` tinyint(20) unsigned NOT NULL,
  `number_of_directors` smallint(11) unsigned NOT NULL DEFAULT '0',
  `consent_level` varchar(3) NOT NULL DEFAULT '1',
  `insurance_provider_id` varchar(255) DEFAULT NULL,
  `discount_provider_id` varchar(255) DEFAULT NULL,
  `credit_agreed_rate` decimal(10,4) DEFAULT NULL,
  `trade_limit_c_etr` bigint(10) DEFAULT NULL,
  `trade_limit_threshold` decimal(10,4) DEFAULT NULL,
  `trade_limit_level` smallint(4) DEFAULT '0',
  `orpa_margin` decimal(6,2) DEFAULT NULL COMMENT 'Optimum ORPA margin',
  `orpa_deposit_percent` decimal(6,2) DEFAULT NULL COMMENT 'ORPA Deposit %',
  `orpa_enabled` int(11) DEFAULT NULL COMMENT 'o-RPA Enabled',
  `rav_percent` int(11) NOT NULL COMMENT 'RAV%',
  `from_salesforce` enum('0','1') NOT NULL DEFAULT '0',
  `tar_status` tinyint(4) NOT NULL DEFAULT '1',
  `etr_type` varchar(3) DEFAULT NULL,
  `face_value_charge` double(5,3) NOT NULL DEFAULT '0.000',
  `creditor_face_value_charge` double(5,3) NOT NULL DEFAULT '0.000',
  `credebt_facility_type` enum('fixed','variable') NOT NULL DEFAULT 'variable',
  `ldc_premium` double(6,3) NOT NULL DEFAULT '0.000',
  `creditor_ldc_premium` double(6,3) NOT NULL DEFAULT '0.000',
  `agent_commission` double(6,3) NOT NULL DEFAULT '0.000',
  `creditor_agent_commission` double(6,3) NOT NULL DEFAULT '0.000',
  `is_aetr` tinyint(1) NOT NULL DEFAULT '0',
  `a_etr_limit` int(11) DEFAULT NULL,
  PRIMARY KEY (`organisation_id`),
  KEY `user_id` (`user_id`),
  KEY `sic_group_id` (`nace_group_id`),
  KEY `sic_id` (`nace_id`),
  KEY `organisation_name` (`organisation_name`,`organisation_trade_name`,`agreed_rate`,`posting_fee`,`processing_fee`,`purchase_price`,`organisation_risk`,`organisation_limit`,`active_debtors`,`application_status`,`application_step`,`organisation_status`),
  KEY `id_name_trade_name` (`organisation_reference_id`,`organisation_name`,`organisation_trade_name`)
) ENGINE=InnoDB AUTO_INCREMENT=1968 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `organisation_documents`
--

DROP TABLE IF EXISTS `organisation_documents`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `organisation_documents` (
  `organization_document_id` smallint(20) unsigned NOT NULL AUTO_INCREMENT,
  `organisation_id` smallint(20) unsigned NOT NULL,
  `identification_path` varchar(200) NOT NULL,
  `debtors_report_path` varchar(200) NOT NULL,
  `debtors_report_csv` varchar(200) NOT NULL,
  `creditors_report_path` varchar(200) NOT NULL,
  `creditors_report_csv` varchar(200) NOT NULL,
  `bank_report_path` varchar(255) NOT NULL,
  `bank_report_csv` varchar(255) NOT NULL,
  `loss_report_path` varchar(200) NOT NULL,
  `loss_report_csv` varchar(200) NOT NULL,
  `balance_report_path` varchar(200) NOT NULL,
  `balance_report_csv` varchar(200) NOT NULL,
  `vat_report_path` varchar(200) NOT NULL,
  `vat_report_csv` varchar(200) NOT NULL,
  `paye_report_path` varchar(200) NOT NULL,
  `paye_report_csv` varchar(200) NOT NULL,
  `photoid_report_path` varchar(200) NOT NULL,
  `photoid_report_csv` varchar(200) NOT NULL,
  `utility_report_path` varchar(200) NOT NULL,
  `utility_report_csv` varchar(200) NOT NULL,
  `bank_statement_path` varchar(200) DEFAULT NULL,
  `bank_statement_csv` varchar(200) DEFAULT NULL,
  `file_agreement_proof` varchar(200) NOT NULL,
  `file_bank_statement_proof` varchar(200) NOT NULL,
  `published_date` date NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` tinyint(20) unsigned NOT NULL,
  `personal_identity` varchar(250) NOT NULL,
  PRIMARY KEY (`organization_document_id`),
  KEY `trader_id` (`organisation_id`)
) ENGINE=InnoDB AUTO_INCREMENT=899 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `organisation_process`
--

DROP TABLE IF EXISTS `organisation_process`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `organisation_process` (
  `process_id` tinyint(10) NOT NULL AUTO_INCREMENT,
  `check_list` tinyint(2) NOT NULL COMMENT '0-Inactive,1-Active',
  `organisation_details` tinyint(2) NOT NULL COMMENT '0-Inactive,1-Active',
  `address_bank` tinyint(2) NOT NULL COMMENT '0-Inactive,1-Active',
  `director` tinyint(2) NOT NULL COMMENT '0-Inactive,1-Active',
  `account_info` tinyint(2) NOT NULL COMMENT '0-Inactive,1-Active',
  `audit_accounts` tinyint(2) NOT NULL COMMENT '0-Inactive,1-Active',
  `manage_accounts` tinyint(2) NOT NULL COMMENT '0-Inactive,1-Active',
  `support_documents` tinyint(2) NOT NULL COMMENT '0-Inactive,1-Active',
  `application_payment` tinyint(2) NOT NULL COMMENT '0-Inactive,1-Active',
  `application_success` tinyint(2) NOT NULL COMMENT '0-Inactive,1-Active',
  PRIMARY KEY (`process_id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `organisation_process_relation`
--

DROP TABLE IF EXISTS `organisation_process_relation`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `organisation_process_relation` (
  `relation_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `user_id` bigint(40) NOT NULL,
  `register_name` tinyint(2) NOT NULL,
  `trade_name` tinyint(2) NOT NULL,
  `register_no` tinyint(2) NOT NULL,
  `vat_no` tinyint(2) NOT NULL,
  `share_capital` tinyint(2) NOT NULL,
  `website` tinyint(2) NOT NULL,
  `reg_address` tinyint(2) NOT NULL,
  `primary_address` tinyint(2) NOT NULL,
  `billing_address` tinyint(2) NOT NULL,
  `bank_name` tinyint(2) NOT NULL,
  `bank_address` tinyint(2) NOT NULL,
  `sort_code` tinyint(2) NOT NULL,
  `iban_no` tinyint(2) NOT NULL,
  `swift_code` varchar(20) NOT NULL,
  `home_address` tinyint(2) NOT NULL,
  `home_phone` tinyint(2) NOT NULL,
  `mobile_phone` tinyint(2) NOT NULL,
  `percent_owned` tinyint(2) NOT NULL,
  `email_address` tinyint(2) NOT NULL,
  `turnover` tinyint(2) NOT NULL,
  `avg_invoice` tinyint(2) NOT NULL,
  `ledger_balance` tinyint(2) NOT NULL,
  `fiscal_year` tinyint(2) NOT NULL,
  `finance_relationship` tinyint(2) NOT NULL,
  `audit_account` tinyint(2) NOT NULL,
  `manage_account` tinyint(2) NOT NULL,
  `profit` tinyint(2) NOT NULL,
  `balance_sheet` tinyint(2) NOT NULL,
  `debtor_ledger` tinyint(2) NOT NULL,
  `photo_id` tinyint(2) NOT NULL,
  `status` tinyint(2) NOT NULL COMMENT '0-Inactive,1-Active',
  `utility_bill` tinyint(2) NOT NULL,
  `bank_account_no` varchar(50) NOT NULL,
  PRIMARY KEY (`relation_id`)
) ENGINE=MyISAM AUTO_INCREMENT=358 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `organisation_tax_payments`
--

DROP TABLE IF EXISTS `organisation_tax_payments`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `organisation_tax_payments` (
  `organisation_tax_payment_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `organisation_id` bigint(40) NOT NULL,
  `organisation_tax_type` varchar(255) NOT NULL,
  `organisation_tax_due` date NOT NULL,
  `organisation_tax_start` date NOT NULL,
  `organisation_tax_end` date NOT NULL,
  `organisation_tax_recipt` text NOT NULL,
  `organisation_tax_amount` double NOT NULL,
  `organisation_tax_recived` date NOT NULL,
  PRIMARY KEY (`organisation_tax_payment_id`),
  KEY `organisation_id` (`organisation_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `organisation_trade_documents_relation`
--

DROP TABLE IF EXISTS `organisation_trade_documents_relation`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `organisation_trade_documents_relation` (
  `organisation_id` int(11) NOT NULL,
  `document_type_id` int(11) NOT NULL,
  `event` tinyint(4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `organisation_users`
--

DROP TABLE IF EXISTS `organisation_users`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `organisation_users` (
  `temp_user_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `temp_reg_id` bigint(20) DEFAULT NULL,
  `parent_id` bigint(20) DEFAULT NULL,
  `first_name` varchar(255) NOT NULL,
  `last_name` varchar(255) NOT NULL,
  `organisation_name` varchar(255) NOT NULL,
  `country_id` bigint(20) NOT NULL,
  `email` varchar(255) NOT NULL,
  `status` tinyint(4) NOT NULL COMMENT '0-Not reg,1-Reg',
  `verification_code` varchar(255) NOT NULL,
  `result` varchar(255) NOT NULL,
  `csr` longblob NOT NULL,
  `public_key` longblob NOT NULL,
  `created_at` datetime NOT NULL,
  `modified_at` datetime NOT NULL,
  PRIMARY KEY (`temp_user_id`),
  KEY `temp_reg_id` (`temp_reg_id`,`parent_id`,`country_id`,`status`)
) ENGINE=MyISAM AUTO_INCREMENT=123 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `originator_detr_reserves_daily`
--

DROP TABLE IF EXISTS `originator_detr_reserves_daily`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `originator_detr_reserves_daily` (
  `user_id` smallint(10) unsigned DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `currency_id` tinyint(3) unsigned DEFAULT NULL,
  `reserve_due` float(10,2) DEFAULT '0.00',
  `reserve_due_eur` float(10,2) DEFAULT '0.00',
  `reserve_total` float(10,2) DEFAULT '0.00',
  `reserve_total_eur` float(10,2) DEFAULT '0.00',
  `etr_outstanding` float(10,2) DEFAULT '0.00',
  `etr_outstanding_eur` float(10,2) DEFAULT '0.00',
  `trailing_eur` float(10,2) DEFAULT '0.00',
  `discounts_eur` float(10,2) DEFAULT '0.00',
  `closing_position` float(10,2) DEFAULT '0.00',
  `closing_position_eur` float(10,2) DEFAULT '0.00',
  `currency_rate` float(10,4) DEFAULT '0.0000',
  KEY `Index 1` (`user_id`,`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `originator_notes`
--

DROP TABLE IF EXISTS `originator_notes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `originator_notes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `originator_id` int(11) NOT NULL,
  `text` text NOT NULL,
  `created_at` datetime NOT NULL,
  `created_by` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1775 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `originator_rpa_details`
--

DROP TABLE IF EXISTS `originator_rpa_details`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `originator_rpa_details` (
  `org_rpa_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `userName` varchar(255) NOT NULL,
  `companyName` varchar(255) NOT NULL,
  `phone_country` varchar(5) NOT NULL,
  `phone_code` varchar(3) NOT NULL,
  `phoneNo` varchar(10) NOT NULL,
  `email` varchar(255) NOT NULL,
  `workingCapital` varchar(255) NOT NULL,
  `created_at` datetime NOT NULL,
  `modified_at` datetime NOT NULL,
  PRIMARY KEY (`org_rpa_id`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `originator_rsa`
--

DROP TABLE IF EXISTS `originator_rsa`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `originator_rsa` (
  `org_rsa_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `address_id` bigint(40) NOT NULL,
  `organisation_name` varchar(250) NOT NULL,
  `first_name` varchar(250) NOT NULL,
  `last_name` varchar(250) NOT NULL,
  `job_title` varchar(250) NOT NULL,
  `nacec` varchar(250) NOT NULL,
  `naced` varchar(250) NOT NULL,
  `description` text NOT NULL,
  `key` varchar(150) NOT NULL,
  `key_confirmed` varchar(150) NOT NULL,
  `year_end` varchar(200) NOT NULL,
  `org_response` text NOT NULL,
  `site_settings` text NOT NULL,
  `issue_date` datetime NOT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '0' COMMENT '0-Regd,1-Approved,2-Rejected,3-Confirmed,4-Originator,5-Reapplied',
  `created_at` datetime NOT NULL,
  `modified_at` datetime NOT NULL,
  `comments` text,
  PRIMARY KEY (`org_rsa_id`)
) ENGINE=MyISAM AUTO_INCREMENT=262 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `originator_rsa_debtor`
--

DROP TABLE IF EXISTS `originator_rsa_debtor`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `originator_rsa_debtor` (
  `org_rsa_debtor_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `org_rsa_id` bigint(40) NOT NULL,
  `org_rsa_details_id` bigint(40) NOT NULL,
  `debtor` varchar(200) NOT NULL,
  `total_revenue_year` varchar(200) NOT NULL,
  `country` int(5) NOT NULL,
  `country_post` int(5) NOT NULL,
  `company_number` varchar(100) NOT NULL,
  `incorporation_date` date NOT NULL,
  `nacec` varchar(250) NOT NULL,
  `naced` varchar(250) NOT NULL,
  `todays_rating` varchar(50) NOT NULL,
  `todays_limit` varchar(50) NOT NULL,
  `rating_fee` decimal(6,2) NOT NULL,
  `api_response` text NOT NULL,
  `approved_date` date NOT NULL,
  `status` tinyint(2) NOT NULL DEFAULT '0',
  `created_at` datetime NOT NULL,
  `modified_at` datetime NOT NULL,
  PRIMARY KEY (`org_rsa_debtor_id`)
) ENGINE=MyISAM AUTO_INCREMENT=150 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `originator_rsa_debtor_rejected_log`
--

DROP TABLE IF EXISTS `originator_rsa_debtor_rejected_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `originator_rsa_debtor_rejected_log` (
  `rejected_log_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `org_rsa_debtor_id` bigint(40) NOT NULL,
  `rejected_date` date NOT NULL,
  PRIMARY KEY (`rejected_log_id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `originator_rsa_details`
--

DROP TABLE IF EXISTS `originator_rsa_details`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `originator_rsa_details` (
  `org_rsa_details_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `org_rsa_id` bigint(40) NOT NULL,
  `avg_payment_day` int(11) NOT NULL,
  `provided_by` varchar(250) NOT NULL,
  `credit_from` varchar(250) NOT NULL,
  `invoice_value` double NOT NULL,
  `invoice_consignmen` tinyint(2) NOT NULL,
  `mgr_first_name` varchar(250) NOT NULL,
  `mgr_last_name` varchar(250) NOT NULL,
  `bk_first_name` varchar(250) NOT NULL,
  `bk_last_name` varchar(250) NOT NULL,
  `overdraft_limit` int(11) NOT NULL,
  `capital_facility` int(11) NOT NULL,
  `account_software` varchar(250) NOT NULL,
  `stage_payment` tinyint(2) NOT NULL,
  `credit_insurance` tinyint(2) NOT NULL,
  `credit_insurer` varchar(255) NOT NULL,
  `turn_over` double NOT NULL,
  `invoice_margin` varchar(5) NOT NULL,
  `created_at` datetime NOT NULL,
  `modified_at` datetime NOT NULL,
  PRIMARY KEY (`org_rsa_details_id`)
) ENGINE=MyISAM AUTO_INCREMENT=262 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `originator_users`
--

DROP TABLE IF EXISTS `originator_users`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `originator_users` (
  `temp_user_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `temp_reg_id` bigint(20) DEFAULT NULL,
  `originator_id` bigint(20) NOT NULL,
  `first_name` varchar(255) NOT NULL,
  `last_name` varchar(255) NOT NULL,
  `organisation_name` varchar(255) NOT NULL,
  `country_id` bigint(20) NOT NULL,
  `email` varchar(255) NOT NULL,
  `status` tinyint(4) NOT NULL COMMENT '0-Not reg,1-Reg',
  `verification_code` varchar(255) NOT NULL,
  `result` varchar(255) NOT NULL,
  `created_at` datetime NOT NULL,
  `modified_at` datetime NOT NULL,
  PRIMARY KEY (`temp_user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `orpa`
--

DROP TABLE IF EXISTS `orpa`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `orpa` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `originator_id` int(11) NOT NULL,
  `reference` varchar(15) DEFAULT NULL,
  `friendly_name` varchar(200) DEFAULT NULL,
  `orpa_date` date NOT NULL,
  `expected_date` date DEFAULT NULL,
  `predicted_amount` decimal(10,2) DEFAULT NULL,
  `margin_percent` decimal(4,2) DEFAULT NULL,
  `margin_amount` decimal(10,2) DEFAULT NULL,
  `deposit_percent` decimal(4,2) DEFAULT NULL,
  `deposit_amount` decimal(10,2) DEFAULT NULL COMMENT '= (predicted_amount - margin_amount)*deposit_percent%',
  `deposit_paid` tinyint(1) DEFAULT '0',
  `amount` decimal(10,2) DEFAULT NULL,
  `status` tinyint(4) DEFAULT '1' COMMENT '1 - Created, 2 - Submitted for approval, 3 - Authorised, 4 - Rejected',
  `description` text NOT NULL,
  `file_support` varchar(255) NOT NULL,
  `created_at` datetime DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `modified_at` datetime DEFAULT NULL,
  `modified_by` int(11) DEFAULT NULL,
  `authorised_at` datetime DEFAULT NULL,
  `authorised_by` int(11) DEFAULT NULL,
  `d_etr_sell_rate` decimal(6,3) DEFAULT NULL,
  `d_etr_purchase_discount` double DEFAULT NULL,
  `c_etr_sell_rate` decimal(6,3) DEFAULT NULL,
  `c_etr_early_payment_discount` double DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `reference` (`reference`)
) ENGINE=InnoDB AUTO_INCREMENT=1451 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `orpa_amount_update_log`
--

DROP TABLE IF EXISTS `orpa_amount_update_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `orpa_amount_update_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  `count` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1127 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `orpa_deposit_change_history`
--

DROP TABLE IF EXISTS `orpa_deposit_change_history`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `orpa_deposit_change_history` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `date` datetime NOT NULL,
  `orpa_id` int(11) NOT NULL,
  `deposit_percent` decimal(4,2) NOT NULL,
  `user_id` int(11) NOT NULL,
  `user_type` varchar(10) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2000 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `orpa_margin_change_history`
--

DROP TABLE IF EXISTS `orpa_margin_change_history`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `orpa_margin_change_history` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `date` datetime NOT NULL,
  `orpa_id` int(11) NOT NULL,
  `margin_percent` decimal(4,2) NOT NULL,
  `user_id` int(11) NOT NULL,
  `user_type` varchar(10) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1631 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `orpa_po`
--

DROP TABLE IF EXISTS `orpa_po`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `orpa_po` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `orpa_id` int(11) NOT NULL,
  `debtor_id` int(11) NOT NULL,
  `amount` decimal(10,2) DEFAULT NULL,
  `po_file` varchar(255) NOT NULL,
  `po_no` varchar(255) NOT NULL,
  `po_date` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2747 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `override_180_day_rule_history`
--

DROP TABLE IF EXISTS `override_180_day_rule_history`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `override_180_day_rule_history` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `type` varchar(45) NOT NULL,
  `entity_id` int(11) NOT NULL,
  `value` tinyint(1) NOT NULL,
  `changed_by` int(11) NOT NULL,
  `changed_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10123 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `owner_details`
--

DROP TABLE IF EXISTS `owner_details`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `owner_details` (
  `owner_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `organisation_id` bigint(40) NOT NULL,
  `contact_id` bigint(40) NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`owner_id`),
  KEY `organization_id` (`organisation_id`)
) ENGINE=InnoDB AUTO_INCREMENT=561 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `owners_business_details`
--

DROP TABLE IF EXISTS `owners_business_details`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `owners_business_details` (
  `business_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `organisation_id` bigint(40) NOT NULL,
  `owner_id` bigint(40) NOT NULL,
  `primary_contact_name` varchar(255) NOT NULL,
  `business_name` varchar(255) NOT NULL,
  `duns_no` varchar(255) NOT NULL,
  `first_name` varchar(255) NOT NULL,
  `middle_name` varchar(255) NOT NULL,
  `last_name` varchar(255) NOT NULL,
  `job_title` varchar(255) NOT NULL,
  `work_address_id` bigint(40) NOT NULL,
  `percent_owned` int(2) NOT NULL,
  `website` varchar(255) DEFAULT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`business_id`),
  KEY `organization_id` (`organisation_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `partner`
--

DROP TABLE IF EXISTS `partner`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `partner` (
  `partner_id` int(50) NOT NULL AUTO_INCREMENT,
  `partner_reference` varchar(50) NOT NULL,
  `partner_name` varchar(50) NOT NULL,
  `partner_email` varchar(50) NOT NULL,
  `api_key` varchar(255) NOT NULL,
  `partner_phone` int(50) NOT NULL,
  `partner_address` text NOT NULL,
  `postcode` varchar(50) NOT NULL,
  `city` varchar(50) NOT NULL,
  `state` varchar(50) NOT NULL,
  `country` varchar(50) NOT NULL,
  `status` varchar(50) NOT NULL COMMENT '1-Active,2-Suspend',
  PRIMARY KEY (`partner_id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `payment_gateways`
--

DROP TABLE IF EXISTS `payment_gateways`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `payment_gateways` (
  `payment_gateway_id` int(5) NOT NULL AUTO_INCREMENT,
  `payment_gateway_name` varchar(255) NOT NULL,
  `payment_gateway_username` varchar(250) DEFAULT NULL,
  `payment_gateway_password` varchar(250) DEFAULT NULL,
  `payment_gateway_key` varchar(250) DEFAULT NULL,
  `payment_gateway_accno` varchar(250) DEFAULT NULL,
  `payment_gateway_accid` varchar(50) DEFAULT NULL,
  `payment_gateway_status` tinyint(3) NOT NULL COMMENT '1-Active,2-Inactive',
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(10) NOT NULL,
  PRIMARY KEY (`payment_gateway_id`),
  UNIQUE KEY `payment_gateway_name` (`payment_gateway_name`),
  KEY `modified_by` (`modified_by`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `processing_commissions`
--

DROP TABLE IF EXISTS `processing_commissions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `processing_commissions` (
  `pc_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `eur_eur` decimal(6,2) DEFAULT NULL,
  `gbp_eur` decimal(6,2) DEFAULT NULL,
  `usd_eur` decimal(6,2) DEFAULT NULL,
  `usd_usd` decimal(6,2) DEFAULT NULL,
  `gbp_gbp` decimal(6,2) DEFAULT NULL,
  `processing_id` varchar(31) CHARACTER SET utf8mb4 DEFAULT NULL,
  `posted_date` date DEFAULT NULL,
  `user_id` smallint(20) unsigned DEFAULT NULL,
  `is_drp` mediumint(8) unsigned DEFAULT NULL,
  PRIMARY KEY (`pc_id`),
  UNIQUE KEY `Index 3` (`posted_date`,`user_id`,`is_drp`),
  KEY `processing_id` (`user_id`,`posted_date`),
  KEY `is_drp` (`is_drp`)
) ENGINE=InnoDB AUTO_INCREMENT=170907 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `promotional_code`
--

DROP TABLE IF EXISTS `promotional_code`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `promotional_code` (
  `promotional_code_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `promotional_code_name` varchar(200) NOT NULL,
  `promotional_code_code` varchar(20) NOT NULL,
  `promotional_code_discount` int(10) NOT NULL,
  `valid_from` date NOT NULL,
  `valid_to` date NOT NULL,
  `promotional_code_per_user` int(10) NOT NULL,
  `promotional_code_status` int(2) NOT NULL DEFAULT '1' COMMENT '1-Active,2-Inactive',
  `created_at` datetime NOT NULL,
  `created_by` bigint(20) NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`promotional_code_id`),
  KEY `created_by` (`created_by`),
  KEY `modified_by` (`modified_by`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `promotional_code_history`
--

DROP TABLE IF EXISTS `promotional_code_history`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `promotional_code_history` (
  `promotional_code_history_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `user_id` bigint(40) NOT NULL,
  `prmotional_code_id` bigint(40) NOT NULL,
  `discount_amount` double NOT NULL,
  `used_date` datetime NOT NULL,
  `entered_code` varchar(50) NOT NULL,
  PRIMARY KEY (`promotional_code_history_id`),
  KEY `prmotional_code_id` (`prmotional_code_id`)
) ENGINE=InnoDB AUTO_INCREMENT=77 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prospects`
--

DROP TABLE IF EXISTS `prospects`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prospects` (
  `prospect_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `pr_no` bigint(20) NOT NULL,
  `pr_date` date NOT NULL,
  `pr_type` int(2) NOT NULL,
  `pr_organisation` varchar(255) NOT NULL,
  `pr_tradeus` varchar(255) NOT NULL,
  `pr_website` varchar(255) NOT NULL,
  `pr_contact1_firstname` varchar(255) NOT NULL,
  `pr_contact1_lastname` varchar(255) NOT NULL,
  `pr_contact1_title` varchar(255) NOT NULL,
  `pr_contact2_firstname` varchar(255) NOT NULL,
  `pr_contact2_lastname` varchar(255) NOT NULL,
  `pr_contact2_title` varchar(255) NOT NULL,
  `pr_contact3_firstname` varchar(255) NOT NULL,
  `pr_contact3_lastname` varchar(255) NOT NULL,
  `pr_contact3_title` varchar(255) NOT NULL,
  `pr_result` int(2) NOT NULL,
  `pr_agent` bigint(20) NOT NULL,
  `pr_username` varchar(255) NOT NULL,
  `pr_password` varchar(255) NOT NULL,
  `pr_question` text NOT NULL,
  `pr_answer` text NOT NULL,
  `pr_address_id` bigint(40) NOT NULL,
  `pr_nacec` int(11) NOT NULL,
  `pr_naced` int(11) NOT NULL,
  `pr_description` text NOT NULL,
  `pr_paymentdays` varchar(255) NOT NULL,
  `pr_customer1` varchar(255) NOT NULL,
  `pr_revenue1` varchar(255) NOT NULL,
  `pr_customer2` varchar(255) NOT NULL,
  `pr_revenue2` varchar(255) NOT NULL,
  `pr_customer3` varchar(255) NOT NULL,
  `pr_revenue3` varchar(255) NOT NULL,
  `pr_customer4` varchar(255) NOT NULL,
  `pr_revenue4` varchar(255) NOT NULL,
  `pr_customer5` varchar(255) NOT NULL,
  `pr_revenue5` varchar(255) NOT NULL,
  `pr_overdraft` varchar(255) NOT NULL,
  `created_at` datetime NOT NULL,
  `created_by` bigint(20) NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  `pr_status` int(2) NOT NULL,
  `comments` text,
  PRIMARY KEY (`prospect_id`)
) ENGINE=MyISAM AUTO_INCREMENT=180 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `prospects_old`
--

DROP TABLE IF EXISTS `prospects_old`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `prospects_old` (
  `contact_id` bigint(40) NOT NULL,
  `no` bigint(40) NOT NULL,
  `date` date NOT NULL,
  `type` varchar(100) NOT NULL,
  `organisation_id` bigint(40) NOT NULL,
  `website` varchar(50) NOT NULL,
  `director` varchar(100) NOT NULL,
  `phone_country` varchar(5) NOT NULL,
  `phone_area` varchar(5) NOT NULL,
  `phone_code` varchar(5) NOT NULL,
  `directdial_country` varchar(5) NOT NULL,
  `directdial_area` varchar(5) NOT NULL,
  `directdial_code` varchar(5) NOT NULL,
  `result` varchar(50) NOT NULL,
  `agent` bigint(40) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `rating_agency`
--

DROP TABLE IF EXISTS `rating_agency`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `rating_agency` (
  `rating_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `r_name` varchar(250) NOT NULL,
  `r_long` varchar(250) NOT NULL,
  `r_medium` varchar(250) NOT NULL,
  `r_short` varchar(250) NOT NULL,
  `created_date` datetime NOT NULL,
  `modified_date` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`rating_id`),
  KEY `r_name` (`r_name`,`r_long`,`r_medium`,`r_short`)
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `repurchase_history`
--

DROP TABLE IF EXISTS `repurchase_history`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `repurchase_history` (
  `invoice_id` mediumint(9) unsigned DEFAULT NULL,
  `old_investor_id` mediumint(9) unsigned DEFAULT NULL,
  `new_investor_id` mediumint(9) unsigned DEFAULT NULL,
  `repurchase_date` datetime DEFAULT NULL,
  KEY `Index 1` (`invoice_id`,`old_investor_id`,`new_investor_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `risk_credit`
--

DROP TABLE IF EXISTS `risk_credit`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `risk_credit` (
  `risk_credit_id` smallint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` smallint(20) unsigned NOT NULL,
  `organisation_id` smallint(20) unsigned NOT NULL,
  `debtor_id` mediumint(20) unsigned NOT NULL,
  `procurement_limit` int(10) NOT NULL,
  `provider1_credit_limit` varchar(10) DEFAULT NULL,
  `provider1_risk_score` varchar(10) DEFAULT NULL,
  `provider2_credit_limit` varchar(10) DEFAULT NULL,
  `provider2_risk_score` varchar(10) DEFAULT NULL,
  `provider3_credit_limit` varchar(20) DEFAULT NULL,
  `provider3_risk_score` varchar(20) DEFAULT NULL,
  `provider4_credit_limit` varchar(20) NOT NULL,
  `provider4_risk_score` varchar(20) NOT NULL,
  `provider5_credit_limit` varchar(20) DEFAULT NULL,
  `provider5_risk_score` varchar(20) DEFAULT NULL,
  `provider6_credit_limit` varchar(20) DEFAULT NULL,
  `provider6_risk_score` varchar(20) DEFAULT NULL,
  `company_status` varchar(255) NOT NULL,
  `company_type` varchar(255) NOT NULL,
  `provider1_credit_limit_modified_at` datetime NOT NULL,
  `provider1_credit_limit_modified_by` tinyint(10) unsigned NOT NULL,
  `provider1_risk_score_modified_at` datetime NOT NULL,
  `provider1_risk_score_modified_by` tinyint(10) unsigned NOT NULL,
  `provider2_credit_limit_modified_at` datetime NOT NULL,
  `provider2_credit_limit_modified_by` tinyint(10) unsigned NOT NULL,
  `provider2_risk_score_modified_at` datetime NOT NULL,
  `provider2_risk_score_modified_by` tinyint(10) unsigned NOT NULL,
  `provider3_credit_limit_modified_at` datetime NOT NULL,
  `provider3_credit_limit_modified_by` tinyint(10) unsigned NOT NULL,
  `provider3_risk_score_modified_at` datetime NOT NULL,
  `provider3_risk_score_modified_by` tinyint(10) unsigned NOT NULL,
  `provider4_credit_limit_modified_at` datetime NOT NULL,
  `provider4_credit_limit_modified_by` tinyint(10) unsigned NOT NULL,
  `provider4_risk_score_modified_at` datetime NOT NULL,
  `provider4_risk_score_modified_by` tinyint(10) unsigned NOT NULL,
  `provider5_credit_limit_modified_at` datetime NOT NULL,
  `provider5_credit_limit_modified_by` tinyint(10) unsigned NOT NULL,
  `provider5_risk_score_modified_at` datetime NOT NULL,
  `provider5_risk_score_modified_by` tinyint(10) unsigned NOT NULL,
  `provider6_credit_limit_modified_at` datetime NOT NULL,
  `provider6_credit_limit_modified_by` tinyint(10) unsigned NOT NULL,
  `provider6_risk_score_modified_at` datetime NOT NULL,
  `provider6_risk_score_modified_by` tinyint(10) unsigned NOT NULL,
  `risk_factor` decimal(5,2) NOT NULL,
  `stress_factor` decimal(5,2) NOT NULL,
  `payment_time` int(5) NOT NULL,
  `zscore` decimal(5,2) NOT NULL,
  `address_id` bigint(20) DEFAULT NULL,
  `name` varchar(250) NOT NULL,
  `founded` varchar(250) NOT NULL,
  `last_filling` year(4) NOT NULL,
  `filling_year` year(4) NOT NULL,
  `share_capital` varchar(100) NOT NULL,
  `type1` varchar(50) NOT NULL,
  `type2` varchar(50) NOT NULL,
  `company_number` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`risk_credit_id`),
  KEY `user_id` (`user_id`,`organisation_id`),
  KEY `debtor_id` (`debtor_id`),
  KEY `IDX_risk_credit_organisation_id` (`organisation_id`),
  KEY `IDX_risk_terms` (`provider1_credit_limit`,`provider1_risk_score`,`provider2_credit_limit`,`provider2_risk_score`,`provider3_credit_limit`,`provider3_risk_score`,`provider4_credit_limit`,`provider4_risk_score`,`provider5_credit_limit`,`provider5_risk_score`,`provider6_credit_limit`,`provider6_risk_score`)
) ENGINE=InnoDB AUTO_INCREMENT=5943 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `risk_credit_document`
--

DROP TABLE IF EXISTS `risk_credit_document`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `risk_credit_document` (
  `risk_credit_document_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `risk_credit_id` bigint(20) NOT NULL,
  `provider1_document_path` varchar(255) NOT NULL,
  `provider1_document_published_date` date NOT NULL,
  `provider1_document_modified_at` datetime NOT NULL,
  `provider1_document_modified_by` bigint(20) NOT NULL,
  `provider2_document_path` varchar(255) NOT NULL,
  `provider2_document_published_date` date NOT NULL,
  `provider2_document_modified_at` datetime NOT NULL,
  `provider2_document_modified_by` bigint(20) NOT NULL,
  `provider3_document_path` varchar(255) NOT NULL,
  `provider3_document_published_date` date NOT NULL,
  `provider3_document_modified_at` datetime NOT NULL,
  `provider3_document_modified_by` bigint(20) NOT NULL,
  `provider4_document_path` varchar(255) NOT NULL,
  `provider4_document_published_date` date NOT NULL,
  `provider4_document_modified_at` datetime NOT NULL,
  `provider4_document_modified_by` bigint(20) NOT NULL,
  `provider5_document_path` varchar(255) NOT NULL,
  `provider5_document_published_date` date NOT NULL,
  `provider5_document_modified_at` datetime NOT NULL,
  `provider5_document_modified_by` bigint(20) NOT NULL,
  `provider6_document_path` varchar(255) NOT NULL,
  `provider6_document_published_date` date NOT NULL,
  `provider6_document_modified_at` datetime NOT NULL,
  `provider6_document_modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`risk_credit_document_id`),
  KEY `risk_credit_id` (`risk_credit_id`),
  KEY `provider2_document_modified_by` (`provider2_document_modified_by`),
  KEY `provider1_document_modified_by` (`provider1_document_modified_by`)
) ENGINE=InnoDB AUTO_INCREMENT=4942 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `risk_credit_purchase_history`
--

DROP TABLE IF EXISTS `risk_credit_purchase_history`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `risk_credit_purchase_history` (
  `risk_credit_purchase_history_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `risk_credit_document_id` bigint(40) NOT NULL,
  `user_id` bigint(40) NOT NULL,
  `provider1_document_status` tinyint(3) NOT NULL COMMENT '1-Purchased,2-Not Purchased',
  `provider2_document_status` tinyint(3) NOT NULL COMMENT '1-Purchased,2-Not Purchased',
  `provider1_document_purchased_date` datetime NOT NULL,
  `provider2_document_purchased_date` datetime NOT NULL,
  PRIMARY KEY (`risk_credit_purchase_history_id`),
  KEY `risk_credit_document_id` (`risk_credit_document_id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `rva_call_list`
--

DROP TABLE IF EXISTS `rva_call_list`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `rva_call_list` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `rva_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3558 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `rva_mail`
--

DROP TABLE IF EXISTS `rva_mail`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `rva_mail` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `rva_id` int(10) unsigned DEFAULT NULL,
  `debtor_id` mediumint(8) unsigned DEFAULT NULL,
  `date` datetime DEFAULT NULL,
  `type` smallint(6) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8591 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `rva_response`
--

DROP TABLE IF EXISTS `rva_response`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `rva_response` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `rva_id` int(10) unsigned DEFAULT NULL,
  `date` date DEFAULT NULL,
  `amount` double DEFAULT NULL,
  `note` text,
  `created_at` datetime DEFAULT NULL,
  `created_by` tinyint(3) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1683 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `sales_types`
--

DROP TABLE IF EXISTS `sales_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `sales_types` (
  `type_id` int(5) NOT NULL AUTO_INCREMENT,
  `type_name` varchar(50) NOT NULL,
  `type_store_method` varchar(50) NOT NULL COMMENT 'to choose which fields refer',
  `status` int(2) NOT NULL DEFAULT '1',
  PRIMARY KEY (`type_id`),
  KEY `type_id` (`type_id`),
  KEY `type_name` (`type_name`,`type_store_method`,`status`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `salesforce_mapping`
--

DROP TABLE IF EXISTS `salesforce_mapping`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `salesforce_mapping` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `type` varchar(50) NOT NULL,
  `salesforce_value` varchar(255) NOT NULL,
  `credebt_value` varchar(255) DEFAULT NULL,
  `credebt_entity_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=917 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `search_saved`
--

DROP TABLE IF EXISTS `search_saved`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `search_saved` (
  `save_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `sort1` int(4) NOT NULL DEFAULT '0',
  `sort2` int(4) NOT NULL DEFAULT '0',
  `sort3` int(4) NOT NULL DEFAULT '0',
  `sort4` int(4) NOT NULL DEFAULT '0',
  `sort5` int(4) NOT NULL DEFAULT '0',
  `sort6` int(4) NOT NULL DEFAULT '0',
  `sort7` int(4) NOT NULL DEFAULT '0',
  `sort8` int(4) NOT NULL DEFAULT '0',
  `sort9` int(4) NOT NULL DEFAULT '0',
  `window` int(10) NOT NULL DEFAULT '1',
  `window_m` int(10) NOT NULL DEFAULT '1',
  `window_p` int(10) NOT NULL DEFAULT '1',
  `order1` int(4) NOT NULL DEFAULT '0',
  `order2` int(4) NOT NULL DEFAULT '0',
  `order3` int(4) NOT NULL DEFAULT '0',
  `order4` int(4) NOT NULL DEFAULT '0',
  `order5` int(4) NOT NULL DEFAULT '0',
  `order6` int(4) NOT NULL DEFAULT '0',
  `order7` int(4) NOT NULL DEFAULT '0',
  `order8` int(4) NOT NULL DEFAULT '0',
  `order9` int(4) NOT NULL DEFAULT '0',
  `user_id` bigint(40) NOT NULL,
  `admin_id` int(10) NOT NULL,
  PRIMARY KEY (`save_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `search_terms`
--

DROP TABLE IF EXISTS `search_terms`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `search_terms` (
  `search_id` int(11) NOT NULL AUTO_INCREMENT,
  `search_title` varchar(100) NOT NULL,
  `search_type` int(2) NOT NULL DEFAULT '1',
  `investor` int(2) NOT NULL DEFAULT '1',
  `trader` int(2) NOT NULL DEFAULT '1',
  `ordering` int(5) NOT NULL DEFAULT '0',
  `published` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`search_id`),
  KEY `search_title` (`search_title`,`search_type`,`investor`,`trader`,`ordering`,`published`)
) ENGINE=MyISAM AUTO_INCREMENT=77 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `sfws_api_log`
--

DROP TABLE IF EXISTS `sfws_api_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `sfws_api_log` (
  `request_id` varchar(50) NOT NULL,
  `request_date` datetime NOT NULL,
  `referrer` varchar(255) NOT NULL,
  `request_url` varchar(255) NOT NULL,
  `request_method` varchar(255) NOT NULL,
  `request_data` text NOT NULL,
  `response_code` int(11) NOT NULL,
  `response_data` text NOT NULL,
  UNIQUE KEY `request_id` (`request_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `shopping_cart`
--

DROP TABLE IF EXISTS `shopping_cart`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `shopping_cart` (
  `shopping_cart_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `user_id` bigint(40) NOT NULL,
  `product_id` int(10) DEFAULT '0',
  `risk_credit_document_id` bigint(40) NOT NULL,
  `risk_credit_document_provider` tinyint(2) NOT NULL COMMENT '1- provider1,2- provider2',
  `product_value` double NOT NULL,
  `shopping_cart_date` datetime NOT NULL,
  `payment_status` tinyint(2) NOT NULL DEFAULT '2' COMMENT '1-Completed,2- Not completed',
  `transaction_id` bigint(40) NOT NULL,
  `cart_session` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY (`shopping_cart_id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `shopping_products`
--

DROP TABLE IF EXISTS `shopping_products`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `shopping_products` (
  `product_id` int(10) NOT NULL,
  `product_name` varchar(255) NOT NULL,
  `product_description` text NOT NULL,
  `product_value` double(10,2) NOT NULL,
  `product_value1` double(10,2) NOT NULL,
  `product_status` tinyint(3) NOT NULL,
  `modified_by` bigint(10) NOT NULL,
  `modified_on` datetime NOT NULL,
  PRIMARY KEY (`product_id`),
  KEY `modified_by` (`modified_by`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `site_settings`
--

DROP TABLE IF EXISTS `site_settings`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `site_settings` (
  `site_setting_id` tinyint(3) NOT NULL AUTO_INCREMENT,
  `site_title` varchar(255) NOT NULL,
  `site_url` varchar(255) NOT NULL,
  `meta_tags` text NOT NULL,
  `support_mail` text NOT NULL,
  `max_singletrade_value` double NOT NULL,
  `min_singletrade_value` double NOT NULL,
  `total_blocksale_value` double NOT NULL,
  `debtor_total_trade_value` double NOT NULL,
  `trader_total_credit_value` double NOT NULL,
  `trader_total_credit_period` int(10) NOT NULL COMMENT 'in number of days',
  `vat_tax_percentage` int(5) NOT NULL,
  `global_risk_multiplier` double NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(10) NOT NULL,
  `pro_code` int(100) NOT NULL,
  `auction_start` time NOT NULL,
  `auction_end` time NOT NULL,
  `w_start` int(11) DEFAULT '1',
  `w_end` int(11) DEFAULT '7',
  `sweepin` time NOT NULL,
  `sweepout` time NOT NULL,
  `ie_date_closed` text,
  `uk_date_closed` text,
  `inv_floor_status` int(3) NOT NULL DEFAULT '0',
  `cheatsheet` text NOT NULL,
  `cheatsheet1` text NOT NULL,
  `max_maturity_days` int(10) NOT NULL,
  `processing_fee` decimal(6,2) NOT NULL,
  `posting_fee` decimal(6,2) NOT NULL,
  `trade_commission` decimal(6,2) NOT NULL,
  `credit_limit_margin` double NOT NULL,
  `no_trade_starting_price` double NOT NULL,
  `minimum_offer` double NOT NULL,
  `maximum_offer` double NOT NULL,
  `maximum_bid` double NOT NULL,
  `cdp_cost` double NOT NULL,
  `trades_clear_date` datetime NOT NULL,
  `rsatrades_clear_date` datetime NOT NULL,
  `debtor_limit` double NOT NULL,
  `debtor_value` double NOT NULL,
  `debtor_avg` double NOT NULL,
  `purchase_payment` decimal(6,2) NOT NULL,
  `arrangement_fee` decimal(6,2) NOT NULL,
  `rating_fee` decimal(6,2) NOT NULL,
  `max_edso` int(4) DEFAULT NULL,
  `tar_value` decimal(6,3) unsigned DEFAULT '3.000',
  `rebate_refund` tinyint(3) unsigned NOT NULL DEFAULT '180',
  `exchange_fee` decimal(5,4) unsigned NOT NULL DEFAULT '0.0625',
  `bank_transfer` tinyint(3) unsigned NOT NULL DEFAULT '50',
  `debxcomission` decimal(5,4) unsigned NOT NULL DEFAULT '0.1250',
  `instalment_periods` tinyint(3) unsigned NOT NULL DEFAULT '30',
  `investment_leverage` decimal(5,4) unsigned NOT NULL DEFAULT '0.9863',
  `entries_per_page` smallint(5) unsigned NOT NULL DEFAULT '100',
  `target_split` decimal(10,4) DEFAULT '1.2000',
  `trade_limit_level` smallint(4) DEFAULT '0',
  `bank_holidays` text,
  `max_payment_discount` decimal(6,2) NOT NULL COMMENT 'Maximum Early Payment Discount (%)',
  `orpa_margin` decimal(6,2) NOT NULL COMMENT 'Optimum ORPA margin',
  `orpa_deposit_percent` decimal(6,2) NOT NULL COMMENT 'ORPA deposit percent',
  `default_rav` int(11) NOT NULL COMMENT 'Originator RAV%',
  `creditsafe_username` varchar(50) NOT NULL,
  `creditsafe_password` varchar(50) NOT NULL,
  `creditsafe_islive` tinyint(4) NOT NULL DEFAULT '0',
  `credit_limit_excess` decimal(6,2) NOT NULL DEFAULT '0.00',
  `ldc_premium` double(6,3) NOT NULL DEFAULT '0.000',
  `agent_commission` double(6,3) NOT NULL DEFAULT '0.000',
  PRIMARY KEY (`site_setting_id`),
  KEY `modified_by` (`modified_by`),
  KEY `auction_start` (`auction_start`,`auction_end`,`w_start`,`w_end`,`inv_floor_status`,`max_maturity_days`,`processing_fee`,`posting_fee`,`cdp_cost`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `smb_customers`
--

DROP TABLE IF EXISTS `smb_customers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `smb_customers` (
  `smb_customer_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `customer_id` bigint(40) NOT NULL,
  `debtor_id` bigint(40) NOT NULL,
  `user_id` bigint(40) NOT NULL,
  PRIMARY KEY (`smb_customer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `smb_temp_invoice`
--

DROP TABLE IF EXISTS `smb_temp_invoice`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `smb_temp_invoice` (
  `smb_temp_invoice_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `user_id` bigint(40) NOT NULL,
  `debtor_id` bigint(40) NOT NULL,
  `po_id` varchar(255) NOT NULL,
  `smb_invoice_id` bigint(40) NOT NULL,
  `status` tinyint(5) NOT NULL COMMENT '1-New,2-Published,3-Closed',
  `invoice_id` bigint(40) NOT NULL,
  `created_date` datetime NOT NULL,
  PRIMARY KEY (`smb_temp_invoice_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `spool_batches`
--

DROP TABLE IF EXISTS `spool_batches`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `spool_batches` (
  `id` bigint(10) NOT NULL,
  `date` datetime DEFAULT NULL,
  `type` varchar(32) DEFAULT NULL,
  `accepted` int(2) DEFAULT '0',
  `spool_id` bigint(20) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `spool_fees`
--

DROP TABLE IF EXISTS `spool_fees`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `spool_fees` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `originator_id` bigint(20) DEFAULT NULL,
  `amount` double DEFAULT NULL,
  `comment` varchar(100) DEFAULT NULL,
  `batch_id` bigint(20) DEFAULT NULL,
  `date` datetime DEFAULT NULL,
  `type` varchar(32) DEFAULT NULL,
  `subtype` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `INDEX_spool_fees_batch_id` (`batch_id`),
  KEY `INDEX_spool_fees_amount` (`amount`)
) ENGINE=InnoDB AUTO_INCREMENT=10051 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `spool_files`
--

DROP TABLE IF EXISTS `spool_files`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `spool_files` (
  `id` bigint(10) NOT NULL AUTO_INCREMENT,
  `date` datetime DEFAULT NULL,
  `content` text,
  `accepted` int(2) DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1840 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `spool_transactions`
--

DROP TABLE IF EXISTS `spool_transactions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `spool_transactions` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `type` varchar(100) DEFAULT NULL,
  `accepted` int(2) DEFAULT '0',
  `batch_id` bigint(20) DEFAULT NULL,
  `account_from` varchar(32) DEFAULT NULL,
  `bank_to` varchar(32) DEFAULT NULL,
  `account_to` varchar(32) DEFAULT NULL,
  `currency` varchar(3) DEFAULT NULL,
  `source` varchar(32) DEFAULT NULL,
  `source_id` bigint(10) DEFAULT NULL,
  `transaction_id` bigint(10) DEFAULT NULL,
  `amount` double DEFAULT NULL,
  `sources` text,
  `originator_id` bigint(20) NOT NULL,
  `etr_type` varchar(3) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `INDEX_batch_id` (`batch_id`),
  KEY `INDEX_amount` (`amount`),
  KEY `originator_id_INDEX` (`originator_id`)
) ENGINE=InnoDB AUTO_INCREMENT=320554 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `state_master`
--

DROP TABLE IF EXISTS `state_master`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `state_master` (
  `state_id` smallint(100) unsigned NOT NULL,
  `country_id` tinyint(25) unsigned NOT NULL,
  `state_name` varchar(200) NOT NULL COMMENT 'State Name',
  `modified_by` tinyint(40) unsigned DEFAULT NULL COMMENT 'user_id from user_registration Table',
  `modified_at` datetime DEFAULT NULL COMMENT 'State modified date',
  PRIMARY KEY (`state_id`),
  KEY `country_id` (`country_id`),
  KEY `modified_by` (`modified_by`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `statement_reports`
--

DROP TABLE IF EXISTS `statement_reports`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `statement_reports` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `type` enum('debtor','creditor') NOT NULL DEFAULT 'debtor',
  `date` date NOT NULL,
  `path` varchar(255) NOT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15802 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `statements`
--

DROP TABLE IF EXISTS `statements`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `statements` (
  `transaction_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `reference_id` varchar(40) NOT NULL,
  `manual_transaction_id` mediumint(20) unsigned NOT NULL,
  `bulk_id` smallint(40) unsigned NOT NULL,
  `originator_id` smallint(40) unsigned NOT NULL,
  `trade_id` bigint(40) NOT NULL,
  `invoice_repurchase_id` bigint(40) NOT NULL,
  `investor_id` varchar(40) NOT NULL,
  `currency` tinyint(50) unsigned NOT NULL DEFAULT '0',
  `event` date NOT NULL,
  `reference` varchar(50) NOT NULL,
  `description` varchar(50) NOT NULL,
  `etr_value` double(10,2) NOT NULL,
  `etr_expected` date NOT NULL,
  `etr_balance` double(10,2) NOT NULL,
  `investment_debit` double(10,2) NOT NULL,
  `investment_credit` double(10,2) NOT NULL,
  `investment_balance` double(10,2) NOT NULL,
  `cumulative_balance` double(10,2) NOT NULL,
  `reserve_on` tinyint(4) unsigned NOT NULL COMMENT '0-not reserved,1-reserved',
  `status` tinyint(2) unsigned NOT NULL COMMENT '0-EFT, 1-CSH, 2-ETRPURCHASED, 3-ETRBLOCKPURCHASED,4-ETRBUYOUT,5-ETRSETTLED,6-ETROFFSET,7-ETRREPURCHASE',
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`transaction_id`),
  KEY `reference_id` (`reference_id`,`manual_transaction_id`,`bulk_id`,`originator_id`,`investor_id`,`status`),
  KEY `Index 3` (`manual_transaction_id`),
  KEY `Index 4` (`manual_transaction_id`)
) ENGINE=MyISAM AUTO_INCREMENT=10663 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `storages`
--

DROP TABLE IF EXISTS `storages`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `storages` (
  `name` varchar(64) NOT NULL,
  `description` varchar(255) NOT NULL,
  `driver` varchar(64) NOT NULL DEFAULT 'local',
  `config` varchar(1024) DEFAULT NULL,
  PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `temp_export`
--

DROP TABLE IF EXISTS `temp_export`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `temp_export` (
  `organisation_reference_id` bigint(40) NOT NULL,
  `organisation_name` varchar(255) NOT NULL DEFAULT '',
  `debtor_reference_id` bigint(50) NOT NULL,
  `debtor_name` varchar(200) NOT NULL DEFAULT '',
  `trade_reference_id` bigint(40) NOT NULL,
  `traded_date` date DEFAULT NULL,
  `payment_date` date DEFAULT NULL,
  `reserves_paid` varchar(1) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',
  `currency_code` varchar(3) DEFAULT '0',
  `face_value` double NOT NULL,
  `debtor_id` mediumint(20) unsigned NOT NULL DEFAULT '0',
  `rdso` int(7) DEFAULT NULL,
  `edso` int(7) NOT NULL DEFAULT '0',
  `adso` bigint(80) DEFAULT NULL,
  `sr` decimal(10,7) DEFAULT NULL,
  `pp` double DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `temp_organisation_details`
--

DROP TABLE IF EXISTS `temp_organisation_details`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `temp_organisation_details` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `organisation_name` varchar(255) NOT NULL,
  `organisation_address_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `temp_reg_customers`
--

DROP TABLE IF EXISTS `temp_reg_customers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `temp_reg_customers` (
  `customer_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `customer_name1` varchar(255) NOT NULL,
  `customer_name2` varchar(255) NOT NULL,
  `customer_name3` varchar(255) NOT NULL,
  `customer_name4` varchar(255) NOT NULL,
  `customer_name5` varchar(255) NOT NULL,
  `customer_name6` varchar(255) NOT NULL,
  `customer_name7` varchar(255) NOT NULL,
  `customer_name8` varchar(255) NOT NULL,
  `customer_name9` varchar(255) NOT NULL,
  `customer_name10` varchar(255) NOT NULL,
  `reg_id` bigint(40) NOT NULL,
  `created` datetime NOT NULL,
  PRIMARY KEY (`customer_id`)
) ENGINE=MyISAM AUTO_INCREMENT=541 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `temp_registration`
--

DROP TABLE IF EXISTS `temp_registration`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `temp_registration` (
  `temp_reg_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `ref_id` varchar(40) DEFAULT NULL,
  `rsa_id` bigint(40) NOT NULL,
  `username` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `old_pass` varchar(50) DEFAULT NULL,
  `old_email` varchar(50) DEFAULT NULL,
  `old_username` varchar(50) DEFAULT NULL,
  `password_expire_date` date DEFAULT NULL,
  `first_name` varchar(255) NOT NULL,
  `middle_name` varchar(50) DEFAULT NULL,
  `last_name` varchar(255) NOT NULL,
  `job_title` varchar(255) NOT NULL,
  `register_type` tinyint(4) NOT NULL,
  `organization_name` varchar(255) NOT NULL,
  `organization_address_id` bigint(40) NOT NULL,
  `secret_question_id` bigint(20) NOT NULL,
  `secret_answer` varchar(255) NOT NULL,
  `user_type` int(50) NOT NULL,
  `nace_group_id` int(10) DEFAULT NULL,
  `nace_id` bigint(10) DEFAULT NULL,
  `desc` varchar(255) DEFAULT NULL,
  `user_id` smallint(40) unsigned DEFAULT NULL,
  `doj` date NOT NULL,
  `verification_code` varchar(200) NOT NULL,
  `ipaddress` varchar(50) NOT NULL,
  `csr` longblob,
  `public_key` longblob,
  `result` text,
  `payment_id` int(2) DEFAULT '0',
  `payment_status` int(2) DEFAULT '0',
  `status` int(5) NOT NULL DEFAULT '3' COMMENT '0-Registration Submitted, 1-Payment Made, 2-Invited Trader, 3-Activated, 4-Authorised, 5-Suspended, 6-Terminated',
  `confirm` int(5) NOT NULL,
  `permission` int(5) NOT NULL DEFAULT '1' COMMENT '1 No Sell/Buy, 2 Sell/buy, 3 Temp No Access to Trade Floor, 4 Prmt No Access to Trade Floor',
  `interface` int(5) NOT NULL DEFAULT '4' COMMENT '1 Trader, 2 Investor, 3 Partner, 4 Applicant',
  `dp_type` tinyint(2) NOT NULL COMMENT '0-Deposit,1-Pension',
  `dp_organisation` bigint(40) NOT NULL,
  `confirm_type` tinyint(10) NOT NULL COMMENT '0-Online,1-Manual',
  `partner_id` int(50) NOT NULL,
  `partner_hashkey` varchar(100) NOT NULL,
  `created_at` datetime NOT NULL,
  `modified_at` datetime NOT NULL,
  `currency_id` tinyint(3) unsigned NOT NULL,
  `email` varchar(250) DEFAULT NULL,
  `apply_id` varchar(250) DEFAULT NULL,
  `verified` tinyint(1) DEFAULT '0',
  `certificate` mediumblob,
  `certificate_name` varchar(255) DEFAULT NULL,
  `uged_d` varchar(250) DEFAULT NULL,
  `uged_c` varchar(250) DEFAULT NULL,
  `accounting_software_id` int(11) DEFAULT NULL,
  `idf_st` varchar(255) DEFAULT NULL,
  `idf_r` varchar(255) DEFAULT NULL,
  `upload_idf` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`temp_reg_id`),
  KEY `secret_question_id` (`secret_question_id`),
  KEY `nace_group_id` (`nace_group_id`),
  KEY `nace_id` (`nace_id`),
  KEY `ref_id` (`ref_id`,`username`,`organization_address_id`,`user_type`,`doj`,`status`)
) ENGINE=InnoDB AUTO_INCREMENT=2210 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `temp_retailer`
--

DROP TABLE IF EXISTS `temp_retailer`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `temp_retailer` (
  `retailer_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `temp_reg_id` varchar(25) NOT NULL DEFAULT 'NULL',
  `pasport` varchar(255) NOT NULL,
  `bill` varchar(255) NOT NULL,
  `signed_rpa` varchar(255) NOT NULL,
  `created_by` bigint(40) NOT NULL,
  `created_at` datetime NOT NULL,
  `modified_at` datetime NOT NULL,
  `quote_rate` decimal(5,3) NOT NULL,
  `rate_status` tinyint(2) NOT NULL COMMENT '1-Approve,2-Confirm',
  `file_bank_statement` varchar(255) CHARACTER SET utf8 NOT NULL,
  `file_cheque` varchar(255) CHARACTER SET utf8 NOT NULL,
  `personal_identity` varchar(255) NOT NULL,
  PRIMARY KEY (`retailer_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1227 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `temp_rffffff`
--

DROP TABLE IF EXISTS `temp_rffffff`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `temp_rffffff` (
  `organisation_reference_id` bigint(40) DEFAULT NULL,
  `organisation_name` varchar(255) DEFAULT NULL,
  `debtor_reference_id` bigint(50) DEFAULT NULL,
  `IF(dd.trade_name="", dd.debtor_name, dd.trade_name)` varchar(200) DEFAULT NULL,
  `trade_reference_id` bigint(40) NOT NULL,
  `actual_date` date NOT NULL,
  `Traded_Date` date DEFAULT NULL,
  `Reconciled_Date` longtext CHARACTER SET latin1,
  `expected_date` date NOT NULL,
  `invoice_no` varchar(100) NOT NULL,
  `Face_Value` double NOT NULL DEFAULT '0',
  `currency_code` varchar(3) DEFAULT '0',
  `Discount` double(8,6) DEFAULT NULL,
  `Sell_Rate` decimal(15,9) DEFAULT NULL,
  `EDSO` int(7) NOT NULL DEFAULT '0',
  `EDSO_New` int(7) NOT NULL DEFAULT '0',
  `RDSO` int(7) DEFAULT NULL,
  `ADSO` longtext CHARACTER SET utf8mb4,
  `ADSO_New` longtext CHARACTER SET utf8mb4,
  `Commision` double DEFAULT NULL,
  `Commision_New` double DEFAULT NULL,
  `Status` varchar(11) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',
  `rca` mediumint(40) unsigned DEFAULT '0',
  `icp` mediumint(40) unsigned DEFAULT '0',
  `invoice_id` mediumint(20) unsigned NOT NULL DEFAULT '0',
  `icp_amount` decimal(10,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `terms_table`
--

DROP TABLE IF EXISTS `terms_table`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `terms_table` (
  `id` int(100) NOT NULL AUTO_INCREMENT,
  `inv_reg` text CHARACTER SET utf8 NOT NULL,
  `tr_reg` text CHARACTER SET utf8 NOT NULL,
  `inter_reg` text CHARACTER SET utf8 NOT NULL,
  `ret_reg` text CHARACTER SET utf8 NOT NULL,
  `inv_app_form` text CHARACTER SET utf8 NOT NULL,
  `tr_app_form` longtext CHARACTER SET utf8 NOT NULL,
  `ret_inv_contract` text NOT NULL,
  `etr_loan_terms` text NOT NULL,
  `combined_master` longtext,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `trade_document_types`
--

DROP TABLE IF EXISTS `trade_document_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `trade_document_types` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `active` tinyint(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `trader_account_details`
--

DROP TABLE IF EXISTS `trader_account_details`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `trader_account_details` (
  `trader_account_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `organisation_id` bigint(40) NOT NULL,
  `user_id` bigint(20) NOT NULL,
  `fiscal_year_enddate` date NOT NULL,
  `annual_revenue` double NOT NULL,
  `debtors_balance` double NOT NULL,
  `average_invoice_value` double NOT NULL,
  `primary_bank` varchar(200) NOT NULL,
  `payment_terms` varchar(200) NOT NULL,
  `financing_relationship` text NOT NULL,
  `bill_allowance` varchar(255) NOT NULL,
  `bill_coustomer_pay_work` varchar(255) NOT NULL,
  `bill_invoice_system` varchar(255) NOT NULL,
  `bill_sell_consignment` varchar(255) NOT NULL,
  `bill_warranty` varchar(255) NOT NULL,
  `bill_return_rights` varchar(255) NOT NULL,
  `bill_other_details` varchar(255) NOT NULL,
  `risk_report_one` varchar(50) NOT NULL,
  `credit_limit_one` varchar(50) NOT NULL,
  `risk_report_two` varchar(50) NOT NULL,
  `credit_limit_two` varchar(50) NOT NULL,
  `report` text NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`trader_account_id`),
  KEY `trader_id` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=352 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `trader_balance_details`
--

DROP TABLE IF EXISTS `trader_balance_details`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `trader_balance_details` (
  `trader_balance_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `orgainsation_id` bigint(40) NOT NULL,
  `account_year` year(4) NOT NULL,
  `date_of_preperation` date NOT NULL,
  `attached_accounts` text NOT NULL,
  `audited` tinyint(3) NOT NULL COMMENT '1-Yes,2-No',
  `modified_by` bigint(20) NOT NULL,
  `modified_at` datetime NOT NULL,
  PRIMARY KEY (`trader_balance_id`),
  KEY `orgainzation_id` (`orgainsation_id`),
  KEY `modified_by` (`modified_by`)
) ENGINE=InnoDB AUTO_INCREMENT=403 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `trader_balancet_sheet`
--

DROP TABLE IF EXISTS `trader_balancet_sheet`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `trader_balancet_sheet` (
  `trader_balance_sheet_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `trader_balance_id` bigint(40) NOT NULL,
  `tangible_assets` double NOT NULL,
  `debtors` double NOT NULL,
  `cash` double NOT NULL,
  `stock` double NOT NULL,
  `falling_due_one_year` double NOT NULL,
  `falling_due_other_years` int(11) NOT NULL,
  `liablities` int(11) NOT NULL,
  `share_capital` int(11) NOT NULL,
  `profit_loss` int(11) NOT NULL,
  `fixed_assets` int(11) NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`trader_balance_sheet_id`),
  KEY `audited_account_id` (`trader_balance_id`)
) ENGINE=InnoDB AUTO_INCREMENT=405 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `trader_bank_ledger`
--

DROP TABLE IF EXISTS `trader_bank_ledger`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `trader_bank_ledger` (
  `trader_bank_ledger_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `trader_bank_ledger_master_id` bigint(40) NOT NULL,
  `account_label_id` bigint(10) NOT NULL,
  `trader_bank_ledger_number` int(11) NOT NULL,
  `trader_bank_ledger_date` date NOT NULL,
  `trader_bank_ledger_credit` double NOT NULL,
  `trader_bank_ledger_debit` double NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`trader_bank_ledger_id`),
  KEY `bank_account_statement_id` (`trader_bank_ledger_master_id`),
  KEY `account_label_id` (`account_label_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `trader_bank_ledger_master`
--

DROP TABLE IF EXISTS `trader_bank_ledger_master`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `trader_bank_ledger_master` (
  `trader_bank_ledger_master_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `organisation_id` bigint(40) NOT NULL,
  `created_at` datetime NOT NULL,
  `created_by` bigint(20) NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`trader_bank_ledger_master_id`),
  KEY `organization_id` (`organisation_id`),
  KEY `created_by` (`created_by`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `trader_calculator`
--

DROP TABLE IF EXISTS `trader_calculator`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `trader_calculator` (
  `trader_calculator_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) NOT NULL,
  `first_name` varchar(255) NOT NULL,
  `last_name` varchar(50) NOT NULL,
  `nace_id` int(50) NOT NULL,
  `nace_gp` int(50) NOT NULL,
  `email_address` varchar(255) NOT NULL,
  `organisation_name` varchar(50) NOT NULL,
  `phone_number_country` int(5) NOT NULL,
  `phone_number_code` int(5) NOT NULL,
  `phone_number` int(10) NOT NULL,
  `annual_turnover` double NOT NULL,
  `current_credit_facilities` double NOT NULL,
  `desired_credit_facilities` double NOT NULL,
  `avg_invoice_value` double NOT NULL,
  `avg_payment_cycle` int(5) NOT NULL,
  PRIMARY KEY (`trader_calculator_id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `trader_creditors_ledger`
--

DROP TABLE IF EXISTS `trader_creditors_ledger`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `trader_creditors_ledger` (
  `trader_creditors_ledger_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `trader_creditors_ledger_master_id` bigint(40) NOT NULL,
  `account_label_id` bigint(10) NOT NULL,
  `trader_creditors_ledger_number` int(11) NOT NULL,
  `trader_creditors_ledger_date` date NOT NULL,
  `trader_creditors_ledger_credit` double NOT NULL,
  `trader_creditors_ledger_debit` double NOT NULL,
  PRIMARY KEY (`trader_creditors_ledger_id`),
  KEY `creditor_account_report_id` (`trader_creditors_ledger_master_id`),
  KEY `account_label_id` (`account_label_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `trader_creditors_ledger_master`
--

DROP TABLE IF EXISTS `trader_creditors_ledger_master`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `trader_creditors_ledger_master` (
  `trader_creditors_ledger_master_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `organisation_id` bigint(40) NOT NULL,
  `created_at` datetime NOT NULL,
  `created_by` bigint(20) NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`trader_creditors_ledger_master_id`),
  KEY `organization_id` (`organisation_id`),
  KEY `created_by` (`created_by`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `trader_debtor_manager`
--

DROP TABLE IF EXISTS `trader_debtor_manager`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `trader_debtor_manager` (
  `trader_debtor_manager_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `trader_id` bigint(20) NOT NULL,
  `debtor_id` bigint(20) NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`trader_debtor_manager_id`),
  KEY `trader_id` (`trader_id`),
  KEY `debtor_id` (`debtor_id`),
  KEY `modified_by` (`modified_by`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `trader_debtors_ledger`
--

DROP TABLE IF EXISTS `trader_debtors_ledger`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `trader_debtors_ledger` (
  `trader_debtors_ledger_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `trader_debtors_ledger_master_id` bigint(40) NOT NULL,
  `account_label_id` bigint(10) NOT NULL,
  `trader_debtors_ledger_number` int(11) NOT NULL,
  `trader_debtors_ledger_date` date NOT NULL,
  `trader_debtors_ledger_credit` double NOT NULL,
  `trader_debtors_ledger_debit` double NOT NULL,
  `trader_debtor_ledger_document_path` varchar(255) NOT NULL,
  PRIMARY KEY (`trader_debtors_ledger_id`),
  KEY `debtor_account_report_id` (`trader_debtors_ledger_master_id`),
  KEY `account_label_id` (`account_label_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `trader_debtors_ledger_master`
--

DROP TABLE IF EXISTS `trader_debtors_ledger_master`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `trader_debtors_ledger_master` (
  `trader_debtors_ledger_master_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `organisation_id` bigint(40) NOT NULL,
  `created_at` datetime NOT NULL,
  `created_by` bigint(20) NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`trader_debtors_ledger_master_id`),
  KEY `organization_id` (`organisation_id`),
  KEY `created_by` (`created_by`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `trader_global_setting`
--

DROP TABLE IF EXISTS `trader_global_setting`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `trader_global_setting` (
  `trader_global_setting_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `trader_id` bigint(20) NOT NULL,
  `thirtyday_reserve_percentage` int(5) NOT NULL,
  `minimum_advance_percentage` int(11) NOT NULL,
  `debx_status` tinyint(3) NOT NULL COMMENT '1-Active,2-Inactive',
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`trader_global_setting_id`),
  KEY `trader_id` (`trader_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `trader_profit_loss`
--

DROP TABLE IF EXISTS `trader_profit_loss`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `trader_profit_loss` (
  `trader_profit_loss_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `trader_profit_loss_master_id` bigint(40) NOT NULL,
  `turnover` int(11) NOT NULL,
  `sales_cost` int(11) NOT NULL,
  `sales_expense` int(11) NOT NULL,
  `general_expense` int(11) NOT NULL,
  `hire_lease` int(11) NOT NULL,
  `rent` int(11) NOT NULL,
  `administration_expense` int(11) NOT NULL,
  `wages_salary` int(11) NOT NULL,
  `social_security_cost` int(11) NOT NULL,
  `pension_insurance` int(11) NOT NULL,
  `depriciation` int(11) NOT NULL,
  `interest_payable` int(11) NOT NULL,
  `corporation_tax` int(11) NOT NULL,
  `brought_forward` int(11) NOT NULL,
  `signed_document_path` varchar(255) NOT NULL,
  PRIMARY KEY (`trader_profit_loss_id`),
  KEY `profit_account_id` (`trader_profit_loss_master_id`)
) ENGINE=InnoDB AUTO_INCREMENT=505 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `trader_profit_loss_master`
--

DROP TABLE IF EXISTS `trader_profit_loss_master`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `trader_profit_loss_master` (
  `trader_profit_loss_master_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `orgainsation_id` bigint(40) NOT NULL,
  `account_year` year(4) NOT NULL,
  `date_of_preperation` date NOT NULL,
  `audited` tinyint(4) NOT NULL COMMENT '1-Yes,2-No',
  `modified_by` bigint(20) NOT NULL,
  `modified_at` datetime NOT NULL,
  `source` varchar(50) NOT NULL DEFAULT 'step5',
  PRIMARY KEY (`trader_profit_loss_master_id`),
  KEY `orgainzation_id` (`orgainsation_id`),
  KEY `modified_by` (`modified_by`)
) ENGINE=InnoDB AUTO_INCREMENT=505 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `trader_settings`
--

DROP TABLE IF EXISTS `trader_settings`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `trader_settings` (
  `trader_setting_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `trader_id` bigint(10) NOT NULL,
  `debt_collection_service_status` tinyint(3) NOT NULL COMMENT '1-Active,2-Inactive',
  `auto_trade_status` tinyint(3) NOT NULL COMMENT '1-Active,2-Inactive',
  `debx_auto_trade_status` tinyint(3) NOT NULL COMMENT '1-Active,2-Inactive',
  `max_advance` double NOT NULL,
  `min_thirty_reserve` int(10) NOT NULL,
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`trader_setting_id`),
  UNIQUE KEY `trader_id` (`trader_id`),
  KEY `modified_by` (`modified_by`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `transaction_detail`
--

DROP TABLE IF EXISTS `transaction_detail`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `transaction_detail` (
  `transaction_detail_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `transaction_id` bigint(40) NOT NULL,
  `payment_gatway_id` int(5) DEFAULT NULL,
  `transaction_return_id` varchar(50) NOT NULL,
  `promotional_code_id` bigint(40) DEFAULT NULL,
  `cart_session_id` bigint(40) DEFAULT NULL,
  `currency_id` int(10) NOT NULL,
  `order_id` bigint(40) DEFAULT NULL,
  `transaction_date` date NOT NULL,
  PRIMARY KEY (`transaction_detail_id`),
  UNIQUE KEY `transaction_id` (`transaction_id`),
  KEY `payment_gatway_id` (`payment_gatway_id`),
  KEY `promotional_code_id` (`promotional_code_id`),
  KEY `currency_id` (`currency_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `transaction_logs`
--

DROP TABLE IF EXISTS `transaction_logs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `transaction_logs` (
  `log_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `transaction_id` bigint(20) NOT NULL,
  `invoice_id` bigint(20) NOT NULL,
  `admin_user_id` int(5) NOT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`log_id`)
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `transaction_relations`
--

DROP TABLE IF EXISTS `transaction_relations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `transaction_relations` (
  `parent_transaction_id` int(11) DEFAULT NULL,
  `transaction_id` int(11) NOT NULL,
  UNIQUE KEY `trans_relation_index` (`parent_transaction_id`,`transaction_id`),
  KEY `transaction_id` (`transaction_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `transaction_types`
--

DROP TABLE IF EXISTS `transaction_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `transaction_types` (
  `transaction_id` tinyint(3) unsigned DEFAULT NULL,
  `type_id` tinyint(3) unsigned DEFAULT NULL COMMENT '1 - investor transactions, 2 - manual transactions',
  `transaction_name` varchar(100) DEFAULT NULL,
  `bogui_active` tinyint(3) unsigned DEFAULT '1',
  `is_subtype` tinyint(3) unsigned DEFAULT '0',
  KEY `Index 1` (`transaction_id`,`type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `transactions`
--

DROP TABLE IF EXISTS `transactions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `transactions` (
  `transaction_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `transaction_reference_id` bigint(40) DEFAULT NULL,
  `temp_reg_id` bigint(40) DEFAULT NULL,
  `user_id` bigint(20) DEFAULT NULL,
  `org_id` bigint(40) DEFAULT NULL,
  `transaction_amount` double NOT NULL,
  `vat_amount` double NOT NULL,
  `transaction_code` varchar(20) NOT NULL,
  `transaction_for` varchar(255) NOT NULL,
  `product_id` int(10) DEFAULT NULL,
  `invoice_id` bigint(20) DEFAULT NULL,
  `transaction_date` datetime NOT NULL,
  `status` int(2) NOT NULL DEFAULT '0',
  PRIMARY KEY (`transaction_id`),
  KEY `user_id` (`user_id`),
  KEY `product_id` (`product_id`),
  KEY `invoice_id` (`invoice_id`),
  KEY `temp_reg_id` (`temp_reg_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `trp_requests`
--

DROP TABLE IF EXISTS `trp_requests`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `trp_requests` (
  `request_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `requested_at` datetime NOT NULL,
  `requested_by` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `completed` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `completed_at` datetime DEFAULT NULL,
  `file_name` varchar(180) NOT NULL,
  `status` tinyint(3) unsigned NOT NULL,
  `status_message` varchar(100) NOT NULL,
  `is_weekly` date DEFAULT NULL,
  `source_data` varchar(250) DEFAULT NULL,
  `params` mediumtext,
  `error` text,
  `version` tinyint(4) NOT NULL DEFAULT '1',
  PRIMARY KEY (`request_id`)
) ENGINE=InnoDB AUTO_INCREMENT=606 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `user_auth`
--

DROP TABLE IF EXISTS `user_auth`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user_auth` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `token` varchar(250) NOT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=48374 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `user_login`
--

DROP TABLE IF EXISTS `user_login`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user_login` (
  `user_id` smallint(20) unsigned NOT NULL AUTO_INCREMENT,
  `username` varchar(200) NOT NULL,
  `user_password` varchar(200) NOT NULL,
  `user_type` tinyint(5) NOT NULL COMMENT '1-Dealer,2-Investor,3-Trader,4-Broker',
  `user_status` tinyint(5) NOT NULL DEFAULT '0' COMMENT '0-New,1-Active,2-Inactive',
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  `consent_status` int(11) NOT NULL DEFAULT '0',
  `consent_success_date` datetime DEFAULT NULL,
  `consent_request` int(11) NOT NULL DEFAULT '0',
  `access_token` varchar(255) NOT NULL,
  `certificate` mediumblob,
  `certificate_name` varchar(255) DEFAULT NULL,
  `consent_signature` text,
  `certificate_expired_date` date DEFAULT NULL,
  `certificate_password_hash` varchar(255) DEFAULT NULL,
  `certificate_receive_link_hash` varchar(255) DEFAULT NULL,
  `certificate_order_number` int(11) DEFAULT NULL,
  PRIMARY KEY (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2113 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `user_notification_setting`
--

DROP TABLE IF EXISTS `user_notification_setting`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user_notification_setting` (
  `user_notification_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) NOT NULL,
  `organisation_id` bigint(40) NOT NULL,
  `trading_open` tinyint(3) NOT NULL COMMENT '1-Active,2-Inactive',
  `trading_day` tinyint(3) NOT NULL COMMENT '1-Active,2-Inactive',
  `four_hour_close` tinyint(3) NOT NULL COMMENT '1-Active,2-Inactive',
  `one_hour_close` tinyint(3) NOT NULL COMMENT '1-Active,2-Inactive',
  `thirty_min_close` tinyint(3) NOT NULL COMMENT '1-Active,2-Inactive',
  `fifteen_min_close` tinyint(3) NOT NULL COMMENT '1-Active,2-Inactive',
  `stalled` tinyint(3) NOT NULL COMMENT '1-Active,2-Inactive',
  `won` tinytext NOT NULL COMMENT '1-Active,2-Inactive',
  `lost` tinyint(3) NOT NULL COMMENT '1-Active,2-Inactive',
  `mail_format` int(2) NOT NULL DEFAULT '0',
  `modified_at` datetime NOT NULL,
  `modified_by` bigint(20) NOT NULL,
  PRIMARY KEY (`user_notification_id`),
  UNIQUE KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `user_sessions`
--

DROP TABLE IF EXISTS `user_sessions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user_sessions` (
  `uid` int(10) NOT NULL AUTO_INCREMENT,
  `user_id` varchar(64) NOT NULL DEFAULT '',
  `hostname` varchar(128) NOT NULL DEFAULT '',
  `logged_time` datetime NOT NULL,
  `modified_time` datetime NOT NULL,
  PRIMARY KEY (`uid`)
) ENGINE=MyISAM AUTO_INCREMENT=142482 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `webservice_sellrate`
--

DROP TABLE IF EXISTS `webservice_sellrate`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `webservice_sellrate` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `fromname` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `phone` varchar(255) NOT NULL,
  `perline` varchar(255) NOT NULL,
  `business` varchar(255) NOT NULL,
  `annualTurnover` varchar(255) NOT NULL,
  `pushio_appid` varchar(255) NOT NULL,
  `pushio_secret` varchar(255) NOT NULL,
  `deviceid` varchar(100) NOT NULL,
  `pushio_uid` varchar(255) NOT NULL,
  `pushio_apikey` varchar(255) NOT NULL,
  `mail_status` int(11) NOT NULL COMMENT '0 - sent, 1 - not sent',
  `created_at` datetime NOT NULL,
  `modified_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `website_contact`
--

DROP TABLE IF EXISTS `website_contact`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `website_contact` (
  `website_contact_id` bigint(40) NOT NULL AUTO_INCREMENT,
  `full_name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `direct_dial_country` int(5) NOT NULL,
  `direct_dial_code` int(5) NOT NULL,
  `direct_dial_number` int(5) NOT NULL,
  `organisation_name` varchar(255) NOT NULL,
  `enquiry_about` varchar(255) NOT NULL,
  `message` text NOT NULL,
  `website_contact_date` datetime NOT NULL,
  `status` varchar(50) NOT NULL,
  PRIMARY KEY (`website_contact_id`)
) ENGINE=InnoDB AUTO_INCREMENT=92 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping routines for database 'exchange'
--
/*!50003 DROP FUNCTION IF EXISTS `bcETR_FS_Calculations` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` FUNCTION `bcETR_FS_Calculations`(
							 `ret_type` TINYINT(1), 
							 `expected_date` DATE,
                             `issue_date` DATE,
                             `payment_date` DATE,
                             `system_date` DATE,
                             `reserve` DOUBLE(10, 2),
                             `face_value` DOUBLE,
                             `sr` DOUBLE(4, 3),
                             `pp` DOUBLE(5, 3),
                             `trade_comission` DOUBLE(7, 4),
                             `override_180_day_rule` TINYINT(1),
                             `face_value_charge` DOUBLE(5, 3),
                             `credebt_facility_type` VARCHAR(20),
                             `face_value_charge_applied` TINYINT(1),
                             `ldc_premium` DOUBLE(6, 3),
                             `agent_commission` DOUBLE(6, 3)) RETURNS decimal(20,10)
BEGIN
    SET
		@edso = IFNULL(DATEDIFF(DATE(expected_date), DATE(issue_date)), 0),
        @rdso = DATEDIFF(IF(reserve IS NOT NULL AND payment_date <= system_date, payment_date, system_date),
                         DATE(issue_date)),
        @adso = IF(@edso > @rdso, @edso, @rdso),
        @sr = sr * 100 / (100 - agent_commission),
		@pp = face_value * pp / 100,
		@face_value_charge = face_value_charge * 100 / (100 - agent_commission),
		@ldc_premium = face_value * ldc_premium / 100,
		@dc = IF(face_value_charge > 0 AND face_value_charge_applied = 1,
			(face_value * @face_value_charge / 100) + trade_comission + @ldc_premium,
			IF(reserve IS NOT NULL, reserve, face_value * @sr / 100 / 30 * @edso) + trade_comission + @ldc_premium),
		@ldc_reserve_8330 = IF(face_value_charge  > 0 AND face_value_charge_applied = 1,
			0.00,
			IF(@adso > @edso, face_value * @sr / 100 / 30 * (@adso - @edso), 0.00));
	IF (ret_type=1) THEN 
		RETURN @dc;
	ELSEIF (ret_type=2) THEN 
		RETURN @ldc_reserve_8330;
	ELSE
		RETURN 0.00;
    END IF;
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP FUNCTION IF EXISTS `dETR_FS_Calculations` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` FUNCTION `dETR_FS_Calculations`(
							 `ret_type` TINYINT(1), 
							 `expected_date` DATE,
                             `issue_date` DATE,
                             `payment_date` DATE,
                             `system_date` DATE,
                             `reserve` DOUBLE(10, 2),
                             `face_value` DOUBLE,
                             `sr` DOUBLE(4, 3),
                             `pp` DOUBLE(5, 3),
                             `trade_comission` DOUBLE(7, 4),
                             `override_180_day_rule` TINYINT(1),
                             `face_value_charge` DOUBLE(5, 3),
                             `credebt_facility_type` VARCHAR(20),
                             `face_value_charge_applied` TINYINT(1),
                             `ldc_premium` DOUBLE(6, 3),
                             `agent_commission` DOUBLE(6, 3)) RETURNS decimal(20,10)
BEGIN
    SET
		@mm = 180,
        @edso = IFNULL(DATEDIFF(DATE(expected_date), DATE(issue_date)), 0),
        @rdso = DATEDIFF(IF(reserve IS NOT NULL AND payment_date <= system_date, payment_date, system_date),
                         DATE(issue_date)),
        @adso = IF(@edso > @rdso, @edso, @rdso),
        @sr = sr * 100 / (100 - agent_commission),
		@pp = face_value * pp / 100,
		@face_value_charge = face_value_charge * 100 / (100 - agent_commission),
		@dc = IF(face_value_charge > 0 AND face_value_charge_applied = 1,
			face_value * @face_value_charge / 100,
			face_value * @sr / 100 / 30 * LEAST(@edso,@mm)),
		@ldc_reserve_3132 = IF(face_value_charge > 0 AND face_value_charge_applied = 1,
			face_value - @pp - face_value * @face_value_charge / 100,
			face_value - (face_value * @sr / 100 / 30 * @mm) - @pp),
		@edso_reserve = IF(face_value_charge > 0 AND face_value_charge_applied = 1,
			0.00,
			IF(@edso >= @mm, 0, (face_value * @sr / 100 / 30) * (@mm - @edso))),
		@ldc_accruals_1701 = IF(face_value_charge > 0 AND face_value_charge_applied = 1,
			0.00,
			IF(override_180_day_rule > 0,
				IF(@adso > @edso AND (LEAST(face_value * @sr / 100 / 30 * (@adso - @edso), @ldc_reserve_3132 + @edso_reserve) >= @ldc_reserve_3132 + @edso_reserve), 
					face_value * @sr / 100 / 30 * (@adso - @edso) - (@ldc_reserve_3132 + @edso_reserve), 0.00),
				IF(@adso > @mm,(face_value * @sr / 100 / 30) * (@adso - LEAST(@edso, @mm)), 0.00))),
		@ldc_reserve_8330 = IF(face_value_charge > 0 AND face_value_charge_applied = 1,
			0.00,
			IF(override_180_day_rule > 0,
				IF(@adso > @edso, LEAST(face_value * @sr / 100 / 30 * (@adso - @edso), @ldc_reserve_3132 + @edso_reserve), 0), /* + @ldc_accruals_1701 */
				IF(@adso > @edso OR @adso >= @mm,
					IF(@adso >= @mm, @ldc_reserve_3132, 0.00) + IF(@edso >= @mm, 0.00, face_value * @sr / 100 / 30 * (LEAST(@adso, @mm) - @edso)), 0.00))), /* + @ldc_accruals_1701 */
		@ldc_premium = IF(face_value * ldc_premium / 100 > @ldc_reserve_3132 + @edso_reserve + trade_comission, 0.00, face_value * ldc_premium / 100),
		@reserveOutstanding_8320 = @ldc_reserve_3132 + @edso_reserve - @ldc_reserve_8330, /* + @ldc_accruals_1701 */
		@trade_commission = IF(@reserveOutstanding_8320 - @ldc_premium <= trade_comission, 0.00, trade_comission),
		@reserveOutstanding_BO = @ldc_reserve_3132 + @edso_reserve - @ldc_reserve_8330 - @ldc_premium - @trade_commission; /* + @ldc_accruals_1701 */
	IF (ret_type=1) THEN 
		RETURN @dc;
	ELSEIF (ret_type=2) THEN 
		RETURN @ldc_reserve_3132;
	ELSEIF (ret_type=3) THEN 
		RETURN @edso_reserve;
	ELSEIF (ret_type=4) THEN 
		RETURN @ldc_reserve_8330;
	ELSEIF (ret_type=5) THEN 
		RETURN @ldc_accruals_1701;
	ELSEIF (ret_type=6) THEN 
		IF (reserve IS NOT NULL AND (system_date = CURDATE() OR system_date >= payment_date)) THEN 
			RETURN 0.0;
		ELSE
			RETURN @reserveOutstanding_8320;
		END IF;
	ELSEIF (ret_type=7) THEN 
		IF (reserve IS NOT NULL AND (system_date = CURDATE() OR system_date >= payment_date)) THEN
			RETURN 0.00;
		ELSE
			RETURN @reserveOutstanding_BO;
		END IF;
	ELSEIF (ret_type=8) THEN 
		IF (reserve IS NOT NULL AND (system_date = CURDATE() OR system_date >= payment_date)) THEN
			RETURN reserve;
		ELSE
			RETURN @reserveOutstanding_BO;
		END IF;
	ELSE
		RETURN 0.00;
    END IF;
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP FUNCTION IF EXISTS `getReserve` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` FUNCTION `getReserve`(`expected_date` DATE,
                             `issue_date` DATE,
                             `payment_date` DATE,
                             `system_date` DATE,
                             `reserve` DOUBLE(10, 2),
                             `face_value` DOUBLE,
                             `sr` DOUBLE(4, 3),
                             `pp` DOUBLE(5, 3),
                             `trade_comission` DOUBLE(7, 4),
                             `override_180_day_rule` TINYINT(1),
                             `face_value_charge` DOUBLE(5, 3),
                             `credebt_facility_type` VARCHAR(20),
                             `face_value_charge_applied` TINYINT(1),
                             `ldc_premium` DOUBLE(6, 3),
                             `agent_commission` DOUBLE(6, 3)) RETURNS decimal(20,10)
BEGIN
    SET
        @edso = IFNULL(DATEDIFF(DATE(expected_date), DATE(issue_date)), 0),
        @rdso = DATEDIFF(IF(reserve IS NOT NULL AND payment_date <= system_date, payment_date, system_date),
                         DATE(issue_date)),
        @adso = IF(@edso > @rdso, @edso, @rdso),
        @sr = sr * 100 / (100 - agent_commission),
        @face_value_charge = face_value_charge * 100 / (100 - agent_commission);
    IF (reserve IS NOT NULL AND (system_date = CURDATE() OR system_date >= payment_date)) THEN
        RETURN reserve;
    ELSEIF (`face_value_charge_applied` = 1) THEN
        RETURN face_value - face_value * pp / 100 - face_value * @face_value_charge / 100 -
               face_value * ldc_premium / 100 - trade_comission;
    ELSEIF (@adso >= 180 AND override_180_day_rule = 0) THEN
        RETURN face_value * @sr / 100 * 12 * (180 - @adso) / 360 - face_value * ldc_premium / 100 - trade_comission;
    ELSE
        RETURN face_value - face_value * @sr / 100 * 12 * 180 / 360 - face_value * pp / 100 +
               face_value * @sr / 100 * 12 * (180 - @adso) / 360 - face_value * ldc_premium / 100 - trade_comission;
    END IF;
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP FUNCTION IF EXISTS `getReserveOs` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` FUNCTION `getReserveOs`(`expected_date` DATE, 
							`issue_date` DATE, 
							`payment_date` DATE, 
							`system_date` DATE, 
							`reserve` DOUBLE(10,2), 
							`face_value` DOUBLE, 
							`sr` DOUBLE(4,3), 
							`pp` DOUBLE(5,3), 
							`trade_comission` DOUBLE(7,4), 
							`override_180_day_rule` TINYINT(1), 
							`face_value_charge` DOUBLE(5,3), 
							`credebt_facility_type` VARCHAR(20), 
							`face_value_charge_applied` TINYINT(1), 
							`ldc_premium` DOUBLE(6,3), 
							`agent_commission` DOUBLE(6,3)) RETURNS decimal(20,10)
BEGIN 
    SET
        @edso = IFNULL(DATEDIFF(DATE(expected_date), DATE(issue_date)), 0),
        @rdso = DATEDIFF(IF(reserve IS NOT NULL AND payment_date <= system_date, payment_date, system_date),
                         DATE(issue_date)),
        @adso = IF(@edso > @rdso, @edso, @rdso),
        @sr = sr * 100 / (100 - agent_commission),
        @face_value_charge = face_value_charge * 100 / (100 - agent_commission);
    IF (reserve IS NOT NULL AND payment_date <= system_date) THEN 
        RETURN 0;
    ELSEIF (`face_value_charge_applied` = 1) THEN
        RETURN face_value - face_value * pp / 100 - face_value * @face_value_charge / 100 -
               face_value * ldc_premium / 100 - trade_comission;
    ELSEIF (@adso >= 180 AND override_180_day_rule = 0) THEN
        RETURN 0;
    ELSE
		SET @retReserveOs = face_value - face_value * @sr / 100 * 12 * 180 / 360 - face_value * pp / 100 +
               face_value * @sr / 100 * 12 * (180 - @adso) / 360 - face_value * ldc_premium / 100 - trade_comission;
		IF (@retReserveOs < 0) THEN
			RETURN 0;
		ELSE
			RETURN @retReserveOs;
		END IF;
    END IF;
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2022-02-16 14:26:21