
/** 销售合同-基本信息表-新增合同名称字段 **/
ALTER TABLE sales_contract_basic_info ADD `contract_name` varchar(100) NOT NULL COMMENT '合同名称';
ALTER TABLE sales_contract_basic_info_history ADD `contract_name` varchar(100) NOT NULL COMMENT '合同名称';
UPDATE sales_contract_basic_info SET contract_name = '销售合同';
UPDATE sales_contract_basic_info_history SET contract_name = '销售合同';

ALTER TABLE sales_contract_basic_info MODIFY COLUMN `contract_period` varchar(100) DEFAULT '' COMMENT '合同期限';
ALTER TABLE sales_contract_basic_info_history MODIFY COLUMN `contract_period` varchar(100) DEFAULT '' COMMENT '合同期限';

ALTER TABLE sales_contract_settle_info ADD `receivable_type` bigint(20) DEFAULT NULL COMMENT '应收账款种类';
ALTER TABLE sales_contract_settle_info_history ADD `receivable_type` bigint(20) DEFAULT NULL COMMENT '应收账款种类';

/** 字典表新增-应收账款种类 **/
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`)VALUES('应收账款种类', NULL, 'receivableType', NULL, 0);
INSERT INTO `t_dictionary` (`name`, `parentId` , `code`, `value`, `gradation`)VALUES('货款', (select t.id from t_dictionary t where code = 'receivableType'), 'goodsCharge', NULL, 0);
INSERT INTO `t_dictionary` (`name`, `parentId` , `code`, `value`, `gradation`)VALUES('预付款', (select t.id from t_dictionary t where code = 'receivableType'), 'advanceCharge', NULL, 1);

UPDATE sales_contract_settle_info SET receivable_type = (SELECT id FROM t_dictionary t where t.`code` = 'goodsCharge' );
UPDATE sales_contract_settle_info_history SET receivable_type = (SELECT id FROM t_dictionary t where t.`code` = 'goodsCharge' );

/** 销售合同-补充信息表（历史）-新增字段 **/
ALTER TABLE sales_contract_supplement_info ADD `is_approval` tinyint(1) DEFAULT NULL COMMENT '是否需要审核， 1:是,0:否';
ALTER TABLE sales_contract_supplement_info ADD `is_add_goods` tinyint(1) DEFAULT NULL COMMENT '是否新增货物， 1:是,0:否';
ALTER TABLE sales_contract_supplement_info_history ADD `is_approval` tinyint(1) DEFAULT NULL COMMENT '是否需要审核， 1:是,0:否';
ALTER TABLE sales_contract_supplement_info_history ADD `is_add_goods` tinyint(1) DEFAULT NULL COMMENT '是否新增货物， 1:是,0:否';
ALTER TABLE sales_contract_supplement_info ADD  `remark` varchar(100) DEFAULT '' COMMENT '说明';
ALTER TABLE sales_contract_supplement_info_history ADD  `remark` varchar(100) DEFAULT '' COMMENT '说明';
/** 销售合同-货物信息-货物数量修改到小数点后四位 **/
ALTER TABLE sales_contract_goods_info MODIFY `quantity` decimal(17,4) DEFAULT NULL COMMENT '数量';
ALTER TABLE sales_contract_goods_info_history MODIFY `quantity` decimal(17,4) DEFAULT NULL COMMENT '数量';
/** 销售合同-补充货物信息-货物数量修改到小数点后四位 **/
ALTER TABLE sales_contract_supplement_goods_info MODIFY `quantity` decimal(17,4) DEFAULT NULL COMMENT '数量';
ALTER TABLE sales_contract_supplement_goods_info_history MODIFY `quantity` decimal(17,4) DEFAULT NULL COMMENT '数量';
DROP TABLE IF EXISTS `sales_contract_return_bond`;
/** 新增保证金退还表 **/
DROP TABLE IF EXISTS `sales_contract_return_bond`;
CREATE TABLE `sales_contract_return_bond` (
    `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `sales_contract_management_id` bigint(20) NOT NULL COMMENT '销售合同管理Id',
    `return_type` tinyint(1) NOT NULL COMMENT '保证金退还形式 1:退还 0:其他',
    `remark` varchar(300) DEFAULT NULL COMMENT '说明',
    `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
    `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
    `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) COMMENT='销售合同-保证金退还表';
/** 销售合同-基础信息表及历史表-货物数量修改到小数点后四位 **/
ALTER TABLE sales_contract_basic_info MODIFY `contract_plan_amount` decimal(17,4) DEFAULT '0.0000' COMMENT '合同约定金额';
ALTER TABLE sales_contract_basic_info_history MODIFY `contract_plan_amount` decimal(17,4) DEFAULT '0.0000' COMMENT '合同约定金额';

/**新增-贸易平台-开票信息表**/
DROP TABLE IF EXISTS `trading_platform_invoice_info`;
CREATE TABLE `trading_platform_invoice_info` (
    `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `trading_platform_id` bigint(20) NOT NULL COMMENT '贸易平台Id',
    `platform_name` varchar(200) DEFAULT NULL COMMENT '贸易平台名称',
    `social_credit_code` varchar(200) DEFAULT NULL COMMENT '纳税识别号',
    `address` varchar(200) DEFAULT NULL COMMENT '地址',
    `phone_number` varchar(200) DEFAULT NULL COMMENT '电话',
    `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
    `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
    `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) COMMENT='贸易平台-开票信息表';

## 新增核心企业开票信息表
DROP TABLE IF EXISTS `invoice_customer_info`;
CREATE TABLE `invoice_customer_info` (
    `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `customer_id` bigint(20) NOT NULL COMMENT '核心企业Id',
    `enterprise_name` varchar(200) DEFAULT NULL COMMENT '公司名称',
    `social_credit_code` varchar(200) DEFAULT NULL COMMENT '纳税识别号',
    `address` varchar(200) DEFAULT NULL COMMENT '地址',
    `phone_number` varchar(200) DEFAULT NULL COMMENT '电话',
    `account_bank_name` varchar(200) DEFAULT NULL COMMENT '开户行名称',
    `account_number` varchar(200) DEFAULT NULL COMMENT '开户行名称',
    `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
    `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
    `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) COMMENT='发票管理-核心企业开票信息表';

## 新增现金流-入账信息表
ALTER TABLE `cash_flow_manage_entry_info` ADD COLUMN `file_text` mediumtext COMMENT '附件富文本';
/** 验收单货物信息表及历史表-增加（修改）字段 **/
ALTER TABLE acceptance_goods_info ADD `sales_price` decimal(17,4) DEFAULT NULL COMMENT '销售单价';
ALTER TABLE acceptance_his_goods_info ADD `sales_price` decimal(17,4) DEFAULT NULL COMMENT '销售单价';
ALTER TABLE acceptance_goods_info MODIFY COLUMN `goods_quantity` decimal(17,4) DEFAULT NULL COMMENT '数量';
ALTER TABLE acceptance_his_goods_info MODIFY COLUMN `goods_quantity` decimal(17,4) DEFAULT NULL COMMENT '数量';
/** 验收单基础信息表-修改状态备注 **/
ALTER TABLE acceptance_basic_info MODIFY COLUMN `acceptance_status` bigint(20) DEFAULT NULL COMMENT '状态: 已创建、已录入、已驳回、已审核';
/** 验收单基础信息表-增加业务名称 **/
ALTER TABLE acceptance_basic_info ADD `business_name` varchar(50) DEFAULT '' COMMENT '业务名称';
ALTER TABLE acceptance_his_info ADD `business_name` varchar(50) DEFAULT '' COMMENT '业务名称';
ALTER TABLE  acceptance_basic_info MODIFY COLUMN `expected_settlement_date` datetime DEFAULT NULL COMMENT '预估结算日期 ';
ALTER TABLE  acceptance_his_info MODIFY COLUMN `expected_settlement_date` datetime DEFAULT NULL COMMENT '预估结算日期 ';
UPDATE  t_dictionary SET CODE = 'acceptance_sheet_entry' WHERE CODE = 'acceptance_sheet_create';
INSERT INTO `t_dictionary` (`name`, `parentId` , `code`, `value`, `gradation`)VALUES('已创建',
 (select t.id from t_dictionary t where code = 'acceptanceSheetStatus'), 'acceptance_sheet_create', NULL, 0);

/** 验收单基础信息（历史）表历史数据刷新 **/
UPDATE acceptance_his_info t
INNER JOIN business_basic_info t1 ON t.business_number = t1.business_number
SET t.business_name = t1.business_name
WHERE t.business_number = t1.business_number;

UPDATE acceptance_basic_info t
INNER JOIN business_basic_info t1 ON t.business_number = t1.business_number
SET t.business_name = t1.business_name
WHERE t.business_number = t1.business_number;
/** 销售合同全部列表-退还保证金按钮权限 **/
INSERT INTO `t_permission`( `parentId`, `cname`, `ename`, `gradation`, `moduleName`,`user_create`, `user_modified`, `gmt_create`, `gmt_modified`)
VALUES ((SELECT t.id FROM t_permission t WHERE ename = 'salesContractManagement'), '保证金退还', 'returnBond', 1, '销售合同管理', NULL, NULL, now(), now());
INSERT INTO `t_permission`( `parentId`, `cname`, `ename`, `gradation`, `moduleName`,`user_create`, `user_modified`, `gmt_create`, `gmt_modified`)
VALUES ( (SELECT t.id FROM t_permission t WHERE ename = 'platformManagement'), '开票信息维护', 'editInvoiceInfo', 4, '平台管理', NULL, NULL, now(), now());

/** 结算单基础信息表-新增-业务编号字段 **/
ALTER TABLE settlement_basic_info ADD `business_name` varchar(50) DEFAULT '' COMMENT '业务名称';
ALTER TABLE settlement_his_info ADD `business_name` varchar(50) DEFAULT '' COMMENT '业务名称';

-- 分账货款分配表增加字段
ALTER TABLE `ledger_fund_goods_assign` ADD COLUMN `financing_management_fee` decimal(17,2) DEFAULT '0.00' COMMENT '融资管理费';
ALTER TABLE `ledger_fund_goods_assign` ADD COLUMN `financing_overdue_interest` decimal(17,2) DEFAULT '0.00' COMMENT '逾期利息';
ALTER TABLE `ledger_fund_goods_assign` ADD COLUMN `refund_interest` decimal(17,2) DEFAULT NULL COMMENT '应退利息';
ALTER TABLE `ledger_fund_goods_assign` ADD COLUMN `refund_management_fee` decimal(17,2) DEFAULT NULL COMMENT '应退管理费';

/** 结算单状态修改 **/
UPDATE  t_dictionary SET CODE = 'bill_entry' WHERE CODE = 'bill_create';
INSERT INTO `t_dictionary` (`name`, `parentId` , `code`, `value`, `gradation`)VALUES('已创建',
 (select t.id from t_dictionary t where code = 'billStatus'), 'bill_create', NULL, 1);

-- 底层基础信息（历史）表-新增-业务名称字段
ALTER TABLE underlying_basic_info ADD `business_name` varchar(50) DEFAULT '' COMMENT '业务名称';
ALTER TABLE underlying_his_info ADD `business_name` varchar(50) DEFAULT '' COMMENT '业务名称';

-- 底层基础信息（历史）表-修改-合同金额保留小数点后四位
ALTER TABLE underlying_basic_info MODIFY COLUMN `contract_amount` decimal(17,4) DEFAULT NULL COMMENT '合同金额';
ALTER TABLE underlying_his_info MODIFY COLUMN `contract_amount` decimal(17,4) DEFAULT NULL COMMENT '合同金额';

-- 底层货物信息（历史）表-修改-金额保留到小数点后四位
ALTER TABLE underlying_goods_info MODIFY COLUMN `sales_price` decimal(17,4) DEFAULT NULL COMMENT '销售单价';
ALTER TABLE underlying_goods_info MODIFY COLUMN `sales_total_price` decimal(17,4) DEFAULT NULL COMMENT '销售总价';
ALTER TABLE underlying_goods_info MODIFY COLUMN `purchase_price` decimal(17,4) DEFAULT NULL COMMENT '采购单价';
ALTER TABLE underlying_goods_info MODIFY COLUMN `purchase_total_price` decimal(17,4) DEFAULT NULL COMMENT '采购总价';
ALTER TABLE underlying_goods_info MODIFY COLUMN `purchase_guarantee_money` decimal(17,4) DEFAULT NULL COMMENT '采购质保金';
ALTER TABLE underlying_goods_info MODIFY COLUMN `sales_guarantee_money` decimal(17,4) DEFAULT NULL COMMENT '销售质保金';

ALTER TABLE underlying_his_goods_info MODIFY COLUMN `sales_price` decimal(17,4) DEFAULT NULL COMMENT '销售单价';
ALTER TABLE underlying_his_goods_info MODIFY COLUMN `sales_total_price` decimal(17,4) DEFAULT NULL COMMENT '销售总价';
ALTER TABLE underlying_his_goods_info MODIFY COLUMN `purchase_price` decimal(17,4) DEFAULT NULL COMMENT '采购单价';
ALTER TABLE underlying_his_goods_info MODIFY COLUMN `purchase_total_price` decimal(17,4) DEFAULT NULL COMMENT '采购总价';
ALTER TABLE underlying_his_goods_info MODIFY COLUMN `purchase_guarantee_money` decimal(17,4) DEFAULT NULL COMMENT '采购质保金';
ALTER TABLE underlying_his_goods_info MODIFY COLUMN `sales_guarantee_money` decimal(17,4) DEFAULT NULL COMMENT '销售质保金';

-- 底层管理-应收账款（历史）信息表-修改-数量/金额保留到小数点后四位
ALTER TABLE underlying_accounts_receivable_info MODIFY COLUMN `goods_quantity` decimal(17,4) DEFAULT NULL COMMENT '数量';
ALTER TABLE underlying_accounts_receivable_info MODIFY COLUMN  `accounts_receivable_amount` decimal(17,4) DEFAULT NULL COMMENT '应收账款金额';
ALTER TABLE underlying_accounts_receivable_info MODIFY COLUMN `net_accounts_receivable_amount` decimal(17,4) DEFAULT NULL COMMENT '应收账款净额';

ALTER TABLE underlying_his_accounts_receivable_info MODIFY COLUMN `goods_quantity` decimal(17,4) DEFAULT NULL COMMENT '数量';
ALTER TABLE underlying_his_accounts_receivable_info MODIFY COLUMN  `accounts_receivable_amount` decimal(17,4) DEFAULT NULL COMMENT '应收账款金额';
ALTER TABLE underlying_his_accounts_receivable_info MODIFY COLUMN `net_accounts_receivable_amount` decimal(17,4) DEFAULT NULL COMMENT '应收账款净额';

-- 底层管理-新增-底层状态字典项
UPDATE  t_dictionary SET CODE = 'mortgage_entry' WHERE CODE = 'mortgage_create';
INSERT INTO `t_dictionary` (`name`, `parentId` , `code`, `value`, `gradation`)VALUES('已创建',
 (select t.id from t_dictionary t where code = 'mortgageStatus'), 'mortgage_create', NULL, 4);

-- 结算单管理-历史数据刷新
UPDATE settlement_his_info t
INNER JOIN business_basic_info t1 ON t.business_number = t1.business_number
SET t.business_name = t1.business_name
WHERE t.business_number = t1.business_number;

UPDATE settlement_basic_info t
INNER JOIN business_basic_info t1 ON t.business_number = t1.business_number
SET t.business_name = t1.business_name
WHERE t.business_number = t1.business_number;

-- 底层管理-历史数据刷新
UPDATE underlying_his_info t
INNER JOIN business_basic_info t1 ON t.business_number = t1.business_number
SET t.business_name = t1.business_name
WHERE t.business_number = t1.business_number;

UPDATE underlying_basic_info t
INNER JOIN business_basic_info t1 ON t.business_number = t1.business_number
SET t.business_name = t1.business_name
WHERE t.business_number = t1.business_number;

/**  **/
ALTER TABLE settlement_goods_info MODIFY COLUMN `sales_price` decimal(17,4) DEFAULT NULL COMMENT '销售单价';
ALTER TABLE settlement_his_goods_info MODIFY COLUMN `sales_price` decimal(17,4) DEFAULT NULL COMMENT '销售单价';

ALTER TABLE settlement_goods_info MODIFY COLUMN `sales_total_price` decimal(17,4) DEFAULT NULL COMMENT '销售总价';
ALTER TABLE settlement_his_goods_info MODIFY COLUMN `sales_total_price` decimal(17,4) DEFAULT NULL COMMENT '销售总价';

ALTER TABLE settlement_goods_info MODIFY COLUMN `sales_guarantee_money` decimal(17,4) DEFAULT NULL COMMENT '销售质保金';
ALTER TABLE settlement_his_goods_info MODIFY COLUMN `sales_guarantee_money` decimal(17,4) DEFAULT NULL COMMENT '销售质保金';

ALTER TABLE settlement_goods_info MODIFY COLUMN `purchase_price` decimal(17,4) DEFAULT NULL COMMENT '采购单价';
ALTER TABLE settlement_his_goods_info MODIFY COLUMN `purchase_price` decimal(17,4) DEFAULT NULL COMMENT '采购单价';

ALTER TABLE settlement_goods_info MODIFY COLUMN `purchase_total_price` decimal(17,4) DEFAULT NULL COMMENT '采购总价';
ALTER TABLE settlement_his_goods_info MODIFY COLUMN `purchase_total_price` decimal(17,4) DEFAULT NULL COMMENT '采购总价';

ALTER TABLE settlement_goods_info MODIFY COLUMN `purchase_guarantee_money` decimal(17,4) DEFAULT NULL COMMENT '采购质保金';
ALTER TABLE settlement_his_goods_info MODIFY COLUMN `purchase_guarantee_money` decimal(17,4) DEFAULT NULL COMMENT '采购质保金';

ALTER TABLE underlying_goods_info MODIFY COLUMN `sales_guarantee_money` decimal(17,4) DEFAULT NULL COMMENT '销售质保金';
ALTER TABLE underlying_his_goods_info MODIFY COLUMN `sales_guarantee_money` decimal(17,4) DEFAULT NULL COMMENT '销售质保金';

-- 所有模块下载按钮权限
INSERT INTO `t_permission`( `parentId`, `cname`, `ename`, `gradation`, `moduleName`,`user_create`, `user_modified`, `gmt_create`, `gmt_modified`)
VALUES ( (SELECT t.id FROM t_permission t WHERE ename = 'salesContractManagement'), '下载', 'downloadAllSalesContractFile', 2, '销售合同管理', NULL, NULL, now(), now());
INSERT INTO `t_permission`( `parentId`, `cname`, `ename`, `gradation`, `moduleName`,`user_create`, `user_modified`, `gmt_create`, `gmt_modified`)
VALUES ( (SELECT t.id FROM t_permission t WHERE ename = 'purchContractManagement'), '下载', 'downloadAllPurchFile', 2, '采购合同管理', NULL, NULL, now(), now());
INSERT INTO `t_permission`( `parentId`, `cname`, `ename`, `gradation`, `moduleName`,`user_create`, `user_modified`, `gmt_create`, `gmt_modified`)
VALUES ( (SELECT t.id FROM t_permission t WHERE ename = 'acceptanceManagement'), '下载', 'downloadAllAcceptanceFile', 4, '验收单管理', NULL, NULL, now(), now());
INSERT INTO `t_permission`( `parentId`, `cname`, `ename`, `gradation`, `moduleName`,`user_create`, `user_modified`, `gmt_create`, `gmt_modified`)
VALUES ( (SELECT t.id FROM t_permission t WHERE ename = 'billManagement'), '下载', 'downloadAllSettlementFile', 5, '结算单管理', NULL, NULL, now(), now());
INSERT INTO `t_permission`( `parentId`, `cname`, `ename`, `gradation`, `moduleName`,`user_create`, `user_modified`, `gmt_create`, `gmt_modified`)
VALUES ( (SELECT t.id FROM t_permission t WHERE ename = 'underlyingManagement'), '下载', 'downloadAllUnderlyingFile', 4, '底层管理', NULL, NULL, now(), now());
INSERT INTO `t_permission`( `parentId`, `cname`, `ename`, `gradation`, `moduleName`,`user_create`, `user_modified`, `gmt_create`, `gmt_modified`)
VALUES ( (SELECT t.id FROM t_permission t WHERE ename = 'invoiceManagement'), '下载', 'downloadAllInvoiceFile', 4, '发票管理', NULL, NULL, now(), now());
INSERT INTO `t_permission`( `parentId`, `cname`, `ename`, `gradation`, `moduleName`,`user_create`, `user_modified`, `gmt_create`, `gmt_modified`)
VALUES ( (SELECT t.id FROM t_permission t WHERE ename = 'businessManagement'), '下载', 'downloadAllBusinessFile', 6, '业务管理', NULL, NULL, now(), now());

-- 分账管理-货款分配表新增字段
ALTER TABLE `ledger_fund_goods_assign` ADD COLUMN `to_assigned_amount` decimal(17,2) DEFAULT '0.00' COMMENT '待分配金额';
ALTER TABLE `ledger_fund_goods_assign` ADD COLUMN `goods_assign_id` bigint(20) DEFAULT NULL COMMENT '货物分配Id';
ALTER TABLE `ledger_fund_goods_assign` ADD COLUMN `latest_coll_date` datetime DEFAULT NULL COMMENT '最近一期本金回款日期（如果没有回款取放款日期）';
ALTER TABLE `ledger_fund_goods_assign` ADD COLUMN `last_plan_date` datetime DEFAULT NULL COMMENT '最后一期计划本金收款日期';
ALTER TABLE `ledger_fund_goods_assign` ADD COLUMN `pay_coll_basic_id` bigint(20) DEFAULT NULL COMMENT '账后基础表Id';
ALTER TABLE `ledger_fund_goods_assign` ADD COLUMN `returned_amount` decimal(17,2) DEFAULT '0.00' COMMENT '待回款金额（本金）';
ALTER TABLE `ledger_fund_goods_assign` ADD COLUMN `is_submit` tinyint(1) DEFAULT 1 COMMENT '是否提交';

-- 分账管理-账后收放款计划分配表
ALTER TABLE `ledger_plan_factoring_assign` ADD COLUMN `plan_date` datetime DEFAULT NULL COMMENT '实际分配日期，精确到年月日' after `amount_type`;

-- 企业信息管理-删除权限
INSERT INTO `t_permission`( `parentId`, `cname`, `ename`, `gradation`, `moduleName`,`user_create`, `user_modified`, `gmt_create`, `gmt_modified`)
VALUES ( (SELECT t.id FROM t_permission t WHERE ename = 'supplier'), '删除', 'deleteSupplier', 4, '供应商', NULL, NULL, now(), now());

INSERT INTO `t_permission`( `parentId`, `cname`, `ename`, `gradation`, `moduleName`,`user_create`, `user_modified`, `gmt_create`, `gmt_modified`)
VALUES ( (SELECT t.id FROM t_permission t WHERE ename = 'enterpriese'), '删除', 'deleteEnterprise', 2, '核心企业', NULL, NULL, now(), now());

-- 添加现金流管理出账类型字典项
INSERT INTO `t_dictionary` (name, parentId, code, value, gradation, gmt_create, gmt_modified)
VALUES ('保理融资管理费', (SELECT t.id from t_dictionary t where t.code = 'cashFlowOutType'), 'outType_financing_management_fee', null, '6', NOW(), NOW());
INSERT INTO `t_dictionary` (name, parentId, code, value, gradation, gmt_create, gmt_modified)
VALUES ('保理融资逾期利息', (SELECT t.id from t_dictionary t where t.code = 'cashFlowOutType'), 'outType_financing_overdue_interest', null, '7', NOW(), NOW());


-- 发票货物信息开票数量保留位数修改
ALTER TABLE invoice_goods_info MODIFY `open_quantity` decimal(17,4) DEFAULT NULL COMMENT '开票数量';
ALTER TABLE invoice_his_goods_info MODIFY `open_quantity` decimal(17,4) DEFAULT NULL COMMENT '开票数量';

-- 贸理通3.1遗留  验收单和现金流删除权限

INSERT INTO `t_permission`( `parentId`, `cname`, `ename`, `gradation`, `moduleName`,`user_create`, `user_modified`, `gmt_create`, `gmt_modified`)
VALUES ( (SELECT t.id FROM t_permission t WHERE ename = 'acceptanceManagement'), '删除', 'deleteAcceptance', 5, '验收单管理', NULL, NULL, now(), now());

INSERT INTO `t_permission`( `parentId`, `cname`, `ename`, `gradation`, `moduleName`,`user_create`, `user_modified`, `gmt_create`, `gmt_modified`)
VALUES ( (SELECT t.id FROM t_permission t WHERE ename = 'recashflowManage'), '删除', 'deleteRecashflow', 3, '现金流管理', NULL, NULL, now(), now());

-- 销售合同历史数据处理
UPDATE sales_contract_supplement_info
SET is_approval = 1
WHERE
 is_approval is NULL
