ALTER TABLE `billing_item_pricelists` CHANGE `account` `debit_account` VARCHAR(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, CHANGE `account_id` `debit_account_id` INT NOT NULL;
ALTER TABLE `billing_item_pricelists` ADD `credit_account` VARCHAR(250) NOT NULL AFTER `debit_account_id`, ADD `credit_account_id` INT NOT NULL AFTER `credit_account`;
ALTER TABLE `billing_item_pricelists` ADD INDEX(`credit_account`);
ALTER TABLE `billing_item_pricelists` ADD INDEX(`credit_account_id`);
ALTER TABLE `billing_item_pricelists` ADD INDEX(`pricemode`);

ALTER TABLE `accounting_accounts` ADD `parent` VARCHAR(250) NOT NULL AFTER `subtype`, ADD `parent_id` INT NOT NULL AFTER `parent`, ADD `level` INT NOT NULL AFTER `parent_id`;
ALTER TABLE `accounting_accounts` ADD INDEX(`parent`);
ALTER TABLE `accounting_accounts` ADD INDEX(`parent_id`);
ALTER TABLE `accounting_accounts` ADD INDEX(`level`);
ALTER TABLE `accounting_accounts` ADD `ledger` INT NOT NULL AFTER `currency`, ADD `deposit` INT NOT NULL AFTER `ledger`, ADD `withdraw` INT NOT NULL AFTER `deposit`, ADD `extra` INT NOT NULL AFTER `withdraw`;
ALTER TABLE `accounting_accounts` ADD INDEX(`ledger`);
ALTER TABLE `accounting_accounts` ADD INDEX(`deposit`);
ALTER TABLE `accounting_accounts` ADD INDEX(`withdraw`);
ALTER TABLE `accounting_accounts` ADD INDEX(`channel`);

DELETE FROM `accounting_accounts` WHERE `accounting_accounts`.`id` = 4;
DELETE FROM `accounting_accounts` WHERE `accounting_accounts`.`id` = 5;
DELETE FROM `accounting_accounts` WHERE `accounting_accounts`.`id` = 6;
DELETE FROM `accounting_accounts` WHERE `accounting_accounts`.`id` = 7;
DELETE FROM `accounting_accounts` WHERE `accounting_accounts`.`id` = 8;
DELETE FROM `accounting_accounts` WHERE `accounting_accounts`.`id` = 9;
DELETE FROM `accounting_accounts` WHERE `accounting_accounts`.`id` = 10;
DELETE FROM `accounting_accounts` WHERE `accounting_accounts`.`id` = 11;
DELETE FROM `accounting_accounts` WHERE `accounting_accounts`.`id` = 12;

-- UPDATE `accounting_accounts` SET `id` = '4' WHERE `accounting_accounts`.`id` = 1;
-- UPDATE `accounting_accounts` SET `id` = '1' WHERE `accounting_accounts`.`id` = 2;
-- UPDATE `accounting_accounts` SET `id` = '2' WHERE `accounting_accounts`.`id` = 13;
-- UPDATE `accounting_accounts` SET `id` = '3' WHERE `accounting_accounts`.`id` = 15;
-- UPDATE `accounting_accounts` SET `id` = '5' WHERE `accounting_accounts`.`id` = 14;
-- UPDATE `accounting_accounts` SET `id` = '6' WHERE `accounting_accounts`.`id` = 16;

UPDATE `accounting_accounts` SET `name` = 'GEPG Account' WHERE `accounting_accounts`.`code` = 'GEPG'; 
UPDATE `accounting_accounts` SET `name` = 'NMB Account' WHERE `accounting_accounts`.`code` = 'NMB';
UPDATE `accounting_accounts` SET `name` = 'CRDB Account' WHERE `accounting_accounts`.`code` = 'CRDB';
UPDATE `accounting_accounts` SET `name` = 'NHIF Account' WHERE `accounting_accounts`.`code` = 'NHIF';
UPDATE `accounting_accounts` SET `name` = 'CASH Account' WHERE `accounting_accounts`.`code` = 'CASH';

UPDATE `billing_item_pricelists` SET `debit_account` = '', `debit_account_id` = 0, `credit_account` = '', `credit_account_id` = 0;
ALTER TABLE `billing_item_pricelists` ADD `opd_debit_account_id` INT NOT NULL AFTER `debit_account_id`, ADD `ipd_debit_account_id` INT NOT NULL AFTER `opd_debit_account_id`;
ALTER TABLE `billing_item_pricelists` ADD `opd_credit_account_id` INT NOT NULL AFTER `credit_account_id`, ADD `ipd_credit_account_id` INT NOT NULL AFTER `opd_credit_account_id`;
ALTER TABLE `billing_item_pricelists` ADD INDEX(`opd_debit_account_id`);
ALTER TABLE `billing_item_pricelists` ADD INDEX(`ipd_debit_account_id`);
ALTER TABLE `billing_item_pricelists` ADD INDEX(`opd_credit_account_id`);
ALTER TABLE `billing_item_pricelists` ADD INDEX(`ipd_credit_account_id`);