File: //www/exchange2/sql/archive/sql.sql
ALTER TABLE `manual_transactions_invoice` ADD INDEX `Index 2` (`transaction_id`);
ALTER TABLE `statements` ADD INDEX `Index 3` (`manual_transaction_id`);
ALTER TABLE `invoice_master` ADD INDEX `Index 8` (`manual_transaction_id`);
ALTER TABLE `invoice_reserve` ADD INDEX `Index 2` (`invoice_id`);
ALTER TABLE `prospects` ADD COLUMN `comments` TEXT NULL AFTER `pr_status`;
ALTER TABLE `originator_rsa` ADD COLUMN `comments` TEXT NULL AFTER `modified_at`;
ALTER TABLE `invoice_reserve` ADD INDEX `Index 3` (`invoice_id`, `manual_transaction_id`);
ALTER TABLE `manual_transactions_invoice` ADD INDEX `Index 2` (`transaction_id`);
ALTER TABLE `manual_transactions` ADD INDEX `Index 3` (`debtors`(200));
/*-Missed table and field for API-*/
CREATE TABLE `invoice_api_access` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`status` INT(11) UNSIGNED NULL DEFAULT NULL,
`user_id` INT(11) UNSIGNED NULL DEFAULT NULL,
`organisation_id` BIGINT(11) UNSIGNED NULL DEFAULT NULL,
`api_key` VARCHAR(100) NULL DEFAULT NULL,
`ip_address` VARCHAR(40) NULL DEFAULT NULL,
`params` TEXT NULL,
`created_at` DATETIME NULL DEFAULT NULL,
`created_by` INT(10) UNSIGNED NULL DEFAULT NULL,
`modified_at` DATETIME NULL DEFAULT NULL,
`modified_by` INT(10) UNSIGNED NULL DEFAULT NULL,
PRIMARY KEY (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
ROW_FORMAT=DEFAULT;
ALTER TABLE `invoice_api_data` ADD COLUMN `status` TINYINT(4) UNSIGNED NOT NULL DEFAULT '0';
/*-Missed table and field for API-*/
/**-- Add Sell rate for debtor--**/
ALTER TABLE `debtors_master` ADD COLUMN `purchase_price` DECIMAL(6,2) NULL DEFAULT '0.00' AFTER `credit_limit`;
ALTER TABLE `manual_transactions` CHANGE COLUMN `creditnote_ref` `transref_list` TEXT NOT NULL COMMENT 'ref=>manual_transaction_id ' AFTER `trailing_balance_amt`;
ALTER TABLE `manual_transactions_rejected` CHANGE COLUMN `creditnote_ref` `transref_list` TEXT NOT NULL COMMENT 'ref=>manual_transaction_id ' AFTER `trailing_balance_amt`;
ALTER TABLE `manual_transactions` CHANGE COLUMN `status` `status` TINYINT(10) NOT NULL COMMENT '0-Created,1-Authorised,2-Notified' AFTER `amendment_id`;
ALTER TABLE `manual_transactions` CHANGE COLUMN `reconcile_status` `reconcile_status` TINYINT(5) NOT NULL DEFAULT '0' COMMENT '0-non reconcile,1-reconcile' AFTER `status`;
ALTER TABLE `debtors_master` DROP COLUMN `purchase_price`;
ALTER TABLE `debtors_detail` ADD COLUMN `purchase_price` DECIMAL(6,2) NOT NULL DEFAULT '00.000' AFTER `credit_limit`;
ALTER TABLE `debtor_bank_details` ADD COLUMN `banking_url` VARCHAR(250) NOT NULL AFTER `post_code`;
ALTER TABLE `debtor_bank_details` ADD COLUMN `username` VARCHAR(250) NOT NULL AFTER `banking_url`;
ALTER TABLE `debtor_bank_details` ADD COLUMN `password` VARCHAR(250) NOT NULL AFTER `username`;
ALTER TABLE `debtor_bank_details` ADD COLUMN `passcode` VARCHAR(250) NOT NULL AFTER `password`;
ALTER TABLE `debtor_bank_details` ADD COLUMN `token_id` VARCHAR(250) NOT NULL AFTER `passcode`;
ALTER TABLE `debtor_bank_details` ADD COLUMN `helpline_number` VARCHAR(250) NOT NULL AFTER `token_id`;
ALTER TABLE `invoice_master` ADD INDEX `Debtor_id` (`debtor_id`);
ALTER TABLE `debtors_detail` ADD COLUMN `type` ENUM('debtor','creditor') NOT NULL DEFAULT 'debtor' AFTER `interface_added`;
ALTER TABLE `debtors_detail` ADD COLUMN `payment_discount` DOUBLE(4,2) UNSIGNED NOT NULL DEFAULT '0' AFTER `type`;
ALTER TABLE `debtors_master` ADD COLUMN `type` ENUM('debtor','creditor') NOT NULL DEFAULT 'debtor' AFTER `created_date`;
ALTER TABLE `debtors_master` ADD COLUMN `payment_discount` DOUBLE(4,2) UNSIGNED NOT NULL DEFAULT '0' AFTER `type`;
ALTER TABLE `invoice_master` ADD COLUMN `payment_discount` DOUBLE(4,2) NOT NULL DEFAULT '0' AFTER `reject_message`;
ALTER TABLE `invoice_api_access` CHANGE `ip_address` `ip_address` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;
//*changes staring 24.02.2015*//
ALTER TABLE `terms_table` ADD COLUMN `etr_loan_terms` TEXT NOT NULL AFTER `ret_inv_contract`;
//*27.02.2015*//
ALTER TABLE `trader_profit_loss_master` ADD COLUMN `source` VARCHAR(50) NOT NULL DEFAULT 'step5' AFTER `modified_at`;
ALTER TABLE `promotional_code_history` ADD COLUMN `entered_code` VARCHAR(50) NOT NULL AFTER `used_date`;
//*05.03.2015*//
ALTER TABLE `organisation_details` ADD COLUMN `created_at` DATETIME NOT NULL AFTER `modified_by`, ADD COLUMN `created_by` BIGINT NOT NULL AFTER `created_at`;
//*09.03.2015*//
ALTER TABLE `admin_users` DROP FOREIGN KEY `admin_users_ibfk_1`;
ALTER TABLE `contents` DROP FOREIGN KEY `contents_ibfk_1`;
ALTER TABLE `contents` ADD COLUMN `content_type` TINYINT UNSIGNED NULL DEFAULT '0' AFTER `modifed_at`;
ALTER TABLE `contents` ADD INDEX `content_type` (`content_type`);
ALTER TABLE `invoice_master` ADD COLUMN `is_auto_send` TINYINT NOT NULL DEFAULT '0.00' AFTER `payment_discount`;
//*17.07.2015*//
ALTER TABLE `invoice_master` ADD COLUMN `reserve` DOUBLE(10,2) NULL DEFAULT NULL AFTER `is_auto_send`;
UPDATE invoice_master
LEFT JOIN invoice_reserve ON invoice_reserve.invoice_id = invoice_master.invoice_id
SET invoice_master.reserve = invoice_reserve.reserve;
ALTER TABLE `invoice_master` ADD COLUMN `auto_allocated` TINYINT UNSIGNED NOT NULL DEFAULT '0' AFTER `reserve`;
ALTER TABLE `manual_transactions` ADD COLUMN `reserve_on` TINYINT(4) NOT NULL DEFAULT '0' AFTER `authorised_by`;
UPDATE invoice_master
LEFT JOIN manual_transactions ON manual_transactions.manual_transaction_id = invoice_master.manual_transaction_id
SET invoice_master.auto_allocated=1
WHERE manual_transactions.transaction_type IN (1,2,9) AND manual_transactions.specific_allocation=0;
DELETE FROM `statements` WHERE `transaction_id` IN (2192,5863,6258,6654,7538);
UPDATE manual_transactions
LEFT JOIN statements ON statements.manual_transaction_id = manual_transactions.manual_transaction_id
SET manual_transactions.reserve_on = statements.reserve_on;
UPDATE `manual_transactions` SET `transaction_date`='2014-01-29' WHERE `manual_transaction_id`=7251 LIMIT 1;
CREATE TABLE IF NOT EXISTS `originator_detr_reserves_daily` (
`user_id` INT(10) UNSIGNED NULL DEFAULT NULL,
`created_at` DATETIME NULL DEFAULT NULL,
`currency_id` TINYINT(3) UNSIGNED NULL DEFAULT NULL,
`reserve_due` FLOAT(10,2) NULL DEFAULT '0.00',
`reserve_total` FLOAT(10,2) NULL DEFAULT '0.00',
`etr_outstanding` FLOAT(10,2) NULL DEFAULT '0.00',
`closing_position` FLOAT(10,2) NULL DEFAULT '0.00',
INDEX `Index 1` (`user_id`, `created_at`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
ROW_FORMAT=DEFAULT;
ALTER TABLE `invoice_master` CHANGE COLUMN `invoice_status` `invoice_status` TINYINT(2) NOT NULL DEFAULT '1' COMMENT '0-Inactive:1-Published:2-frozen:3-Closed' AFTER `debx`, ADD INDEX `invoice_status` (`invoice_status`);
ALTER TABLE `invoice_master` CHANGE COLUMN `invoice_authorise` `invoice_authorise` TINYINT(5) NOT NULL DEFAULT '0' COMMENT '0-New:1-Contacted:2-Confirmed:3-Authorised' AFTER `revolving_status`, CHANGE COLUMN `draft` `draft` TINYINT(2) NOT NULL DEFAULT '0' AFTER `invoice_authorise`, CHANGE COLUMN `revolving_draft` `revolving_draft` TINYINT(2) NOT NULL DEFAULT '0' AFTER `instalment_draft`, CHANGE COLUMN `modified_by` `modified_by` TINYINT(20) UNSIGNED NOT NULL AFTER `modified_at`;
//* 27.08.2015*//
ALTER TABLE `invoice_master` ADD COLUMN `drp_id` BIGINT UNSIGNED NOT NULL DEFAULT '0' AFTER `auto_allocated`, ADD INDEX `DRP` (`drp_id`);
UPDATE invoice_master
LEFT JOIN manual_transactions ON manual_transactions.transaction_type=11 AND manual_transactions.debtors = invoice_master.debtor_id AND manual_transactions.originator_id = invoice_master.user_id AND FIND_IN_SET(invoice_master.invoice_id,manual_transactions.reference_to)>0
SET invoice_master.drp_id = manual_transactions.manual_transaction_id
WHERE invoice_master.reserve_on=1;
UPDATE originators_bank_accounts, organisation_details
SET originators_bank_accounts.organisation_id = organisation_details.organisation_id, originators_bank_accounts.user_id = organisation_details.user_id
WHERE originators_bank_accounts.long_id = organisation_details.organisation_reference_id;