-- 采购合同管理
DROP TABLE IF EXISTS `purch_contract_management`;
CREATE TABLE `purch_contract_management` (
                                             `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
                                             `business_number` varchar(50) NOT NULL COMMENT '业务编号',
                                             `supplier_id` bigint(20) DEFAULT NULL COMMENT '供应商Id',
                                             `contract_status` bigint(20) unsigned DEFAULT '0' COMMENT '合同状态 已创建、已录入、已审核、已签署、签署已审核、已驳回、已变更、已完成',
                                             `is_change` tinyint(1) DEFAULT '0' COMMENT '是否发生变更标识、默认为否',
                                             `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                             `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同管理';

-- 采购合同基本信息
DROP TABLE IF EXISTS `purch_contract_basic_info`;
CREATE TABLE `purch_contract_basic_info` (
                                             `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
                                             `contract_number` varchar(50) DEFAULT NULL COMMENT '合同编号',
											 `contract_name` varchar(50) DEFAULT NULL COMMENT '合同名称',
                                             `contract_period` int(10) DEFAULT NULL COMMENT '采购合同期限',
											 `repurch_method` bigint(20) DEFAULT NULL COMMENT '回购方式',
                                             `contract_plan_amount_type` bigint(20) DEFAULT NULL COMMENT '合同约定金额类型',
                                             `contract_plan_amount` decimal(17,2) DEFAULT '0.00' COMMENT '合同约定金额',
                                             `check_operator` varchar(32) DEFAULT NULL COMMENT '验收经办人',
                                             `settlement_operator` varchar(32) DEFAULT NULL COMMENT '结算经办人',
											 `purch_contract_management_id` bigint(20) NOT NULL COMMENT '采购合同管理Id',
                                             `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                             `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同基本信息';

-- 采购合同付款条件
DROP TABLE IF EXISTS `purch_contract_payment_condition`;
CREATE TABLE `purch_contract_payment_condition` (
                                                    `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
                                                    `serial_number` smallint(5) unsigned DEFAULT '0' COMMENT '序号',
                                                    `payment_condition` varchar(2000) DEFAULT NULL COMMENT '付款条件',
                                                    `purch_contract_basic_info_id` bigint(20) NOT NULL COMMENT '采购合同基本信息表Id',
                                                    `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                                    `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同付款条件';

-- 采购合同结算周期
DROP TABLE IF EXISTS `purch_contract_settle_cycle`;
CREATE TABLE `purch_contract_settle_cycle` (
                                              `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
                                              `delivery_date` varchar(500) DEFAULT NULL COMMENT '发货时间',
                                              `sign_date` varchar(500) DEFAULT NULL COMMENT '签收时间',
                                              `first_settle_date` datetime DEFAULT NULL COMMENT '第一次结算时间',
                                              `settle_cycle_method` bigint(20) DEFAULT NULL COMMENT '结算周期方式',
                                              `settle_cycle` int(10) DEFAULT NULL COMMENT '结算周期',
                                              `plan_payback_days` int(10) DEFAULT NULL COMMENT '约定回款时间',
											  `settle_min_amount` decimal(17,2) DEFAULT NULL COMMENT '结算最低差额',
                                              `purch_contract_basic_info_id` bigint(20) NOT NULL COMMENT '采购合同基本信息表Id',
                                              `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                              `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同结算周期';

-- 采购合同质保金信息
DROP TABLE IF EXISTS `purch_contract_retention_info`;
CREATE TABLE `purch_contract_retention_info` (
                                                 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
                                                 `is_retention` tinyint(1) DEFAULT NULL COMMENT '是否有质保金，0:无 1:有',
                                                 `retention_percent` decimal(17,2) DEFAULT NULL COMMENT '质保金比例',
                                                 `is_limit` tinyint(1) DEFAULT NULL COMMENT '质保金是否有上限，0:无 1:有',
                                                 `retention_limit` decimal(17,2) DEFAULT NULL COMMENT '质保金上限',
                                                 `release_method` bigint(20) DEFAULT NULL COMMENT '质保金释放方式',
                                                 `release_date` datetime DEFAULT NULL COMMENT '释放日期',
												 `release_days` int(10) DEFAULT NULL COMMENT '释放天数',
                                                 `purch_contract_basic_info_id` bigint(20) NOT NULL COMMENT '采购合同基本信息表Id',
                                                 `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                                 `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同质保金信息';

-- 采购合同价格规则
DROP TABLE IF EXISTS `purch_contract_price_rule`;
CREATE TABLE `purch_contract_price_rule` (
                                                 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
                                                 `accrual_margin_calc_method` bigint(20) DEFAULT NULL COMMENT '利差计算方式',
                                                 `trade_platform_offer` decimal(17,2) DEFAULT NULL COMMENT '贸易平台报价',
												 `factoring_offer` decimal(17,2) DEFAULT NULL COMMENT '保理报价',
												 `monthlyinterest_rate` decimal(17,3) DEFAULT NULL COMMENT '月利率',
												 `factoring_finance_deadline` int(10) DEFAULT NULL COMMENT '预估保理融资期限',
												 `differ_amount` decimal(17,2) DEFAULT NULL COMMENT '差额',
                                                 `purch_contract_basic_info_id` bigint(20) NOT NULL COMMENT '采购合同基本信息表Id',
                                                 `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                                 `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同价格规则';

-- 采购合同应收账款有效期
DROP TABLE IF EXISTS `purch_contract_ar_exp`;
CREATE TABLE `purch_contract_ar_exp` (
                                                 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
												 `start_date` varchar(50) DEFAULT NULL COMMENT '开始日期',
												 `end_date` varchar(50) DEFAULT NULL COMMENT '结束日期',
                                                 `purch_contract_basic_info_id` bigint(20) NOT NULL COMMENT '采购合同基本信息表Id',
                                                 `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                                 `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同应收账款有效期';

-- 采购合同货物信息
DROP TABLE IF EXISTS `purch_contract_goods_info`;
CREATE TABLE `purch_contract_goods_info` (
                                                 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
												 `goods_code` int(10)  NOT NULL COMMENT '货物编号',
												 `sales_contract_goods_info_id` bigint(20)  NOT NULL COMMENT '销售合同货物信息ID',
												 `is_clear_price` tinyint(1) DEFAULT NULL COMMENT '是否明确单价，0:否 1:是',
												 `purch_price` varchar(50) DEFAULT NULL COMMENT '采购单价',
												 `remark` varchar(200) DEFAULT NULL COMMENT '备注',
                                                 `quantity` decimal(17,3) DEFAULT NULL COMMENT '数量',
                                                 `purch_contract_basic_info_id` bigint(20) NOT NULL COMMENT '采购合同基本信息表Id',
                                                 `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                                 `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同货物信息';

-- 20211027
-- 采购合同补充信息
DROP TABLE IF EXISTS `purch_contract_replenish_info`;
CREATE TABLE `purch_contract_replenish_info` (
                                                 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
												 `project_amount_category` bigint(20) DEFAULT NULL COMMENT '工程量类别',
												 `goods_price_settle_method` varchar(100) DEFAULT NULL COMMENT '货物单价结算方式',
                                                 `purch_contract_basic_info_id` bigint(20) NOT NULL COMMENT '采购合同基本信息表Id',
                                                 `purch_contract_approval_id` bigint(20) NOT NULL COMMENT '采购合同审核表Id',
                                                 `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                                 `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同补充信息';

-- 采购合同增值税要求
DROP TABLE IF EXISTS `purch_contract_vat_info`;
CREATE TABLE `purch_contract_vat_info` (
                                                 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
												 `price_comment` varchar(50) DEFAULT NULL COMMENT '价款说明',
												 `tax_rate` decimal(17,2) DEFAULT NULL COMMENT '税率',
												 `receipt_type` varchar(50) DEFAULT NULL COMMENT '发票类型',
												 `open_cycle` varchar(50) DEFAULT NULL COMMENT '开票周期',
												 `open_bank` varchar(50) DEFAULT NULL COMMENT '发票开户行',
												 `receipt_account` varchar(50) DEFAULT NULL COMMENT '发票账号',
												 `receipt_remark` varchar(500) DEFAULT NULL COMMENT '发票备注',
                                                 `purch_contract_basic_info_id` bigint(20) NOT NULL COMMENT '采购合同基本信息表Id',
                                                 `purch_contract_approval_id` bigint(20) NOT NULL COMMENT '采购合同审核表Id',
                                                 `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                                 `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同增值税要求';

-- 采购合同质量与验收
DROP TABLE IF EXISTS `purch_contract_quality_accept`;
CREATE TABLE `purch_contract_quality_accept` (
                                                 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
												 `accept_criteria` varchar(500) DEFAULT NULL COMMENT '验收标准',
												 `quality_criteria` varchar(500) DEFAULT NULL COMMENT '质量标准',
                                                 `purch_contract_basic_info_id` bigint(20) NOT NULL COMMENT '采购合同基本信息表Id',
                                                 `purch_contract_approval_id` bigint(20) NOT NULL COMMENT '采购合同审核表Id',
                                                 `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                                 `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同质量与验收';

-- 采购合同结算与付款
DROP TABLE IF EXISTS `purch_contract_settle_payment`;
CREATE TABLE `purch_contract_settle_payment` (
                                                 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
												 `settle_method` varchar(2) DEFAULT NULL COMMENT '结算方式',
												 `payment_method` varchar(2) DEFAULT NULL COMMENT '付款方式',
                                                 `purch_contract_basic_info_id` bigint(20) NOT NULL COMMENT '采购合同基本信息表Id',
                                                 `purch_contract_approval_id` bigint(20) NOT NULL COMMENT '采购合同审核表Id',
                                                 `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                                 `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同结算与付款';

-- 采购合同交货规定
DROP TABLE IF EXISTS `purch_contract_deliver_clause`;
CREATE TABLE `purch_contract_deliver_clause` (
                                                 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
												 `deliver_site` varchar(50) DEFAULT NULL COMMENT '交货地点',
												 `deliver_method` varchar(50) DEFAULT NULL COMMENT '交货方式',
												 `deliver_date` varchar(50) DEFAULT NULL COMMENT '交货日期',
												 `transport_premium` varchar(50) DEFAULT NULL COMMENT '运输及保险费',
                                                 `purch_contract_basic_info_id` bigint(20) NOT NULL COMMENT '采购合同基本信息表Id',
                                                 `purch_contract_approval_id` bigint(20) NOT NULL COMMENT '采购合同审核表Id',
                                                 `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                                 `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同交货规定';

-- 采购合同需方收货人
DROP TABLE IF EXISTS `purch_contract_buyer_receiver`;
CREATE TABLE `purch_contract_buyer_receiver` (
                                                 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
												 `name` varchar(50) DEFAULT NULL COMMENT '姓名',
												 `certno` varchar(50) DEFAULT NULL COMMENT '身份证号',
												 `contact` varchar(50) DEFAULT NULL COMMENT '联系方式',
                                                 `purch_contract_basic_info_id` bigint(20) NOT NULL COMMENT '采购合同基本信息表Id',
                                                 `purch_contract_approval_id` bigint(20) NOT NULL COMMENT '采购合同审核表Id',
                                                 `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                                 `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同需方收货人';

-- 采购合同供货商发货人
DROP TABLE IF EXISTS `purch_contract_seller_sender`;
CREATE TABLE `purch_contract_seller_sender` (
                                                 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
												 `name` varchar(50) DEFAULT NULL COMMENT '姓名',
												 `certno` varchar(50) DEFAULT NULL COMMENT '身份证号',
												 `contact` varchar(50) DEFAULT NULL COMMENT '联系方式',
                                                 `purch_contract_basic_info_id` bigint(20) NOT NULL COMMENT '采购合同基本信息表Id',
                                                 `purch_contract_approval_id` bigint(20) NOT NULL COMMENT '采购合同审核表Id',
                                                 `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                                 `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同供货商发货人';

-- 采购合同供货商责任
DROP TABLE IF EXISTS `purch_contract_seller_blame`;
CREATE TABLE `purch_contract_seller_blame` (
                                                 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
												 `penalty_rate` decimal(17,2) DEFAULT NULL COMMENT '供货商违约金比例',
                                                 `purch_contract_basic_info_id` bigint(20) NOT NULL COMMENT '采购合同基本信息表Id',
                                                 `purch_contract_approval_id` bigint(20) NOT NULL COMMENT '采购合同审核表Id',
                                                 `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                                 `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同供货商责任';


-- 采购合同违约条款
DROP TABLE IF EXISTS `purch_contract_punish_clause`;
CREATE TABLE `purch_contract_punish_clause` (
                                                 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
												 `contract_compensate_rate` decimal(17,2) DEFAULT NULL COMMENT '合同补偿金比例',
												 `contract_penalty_rate` decimal(17,2) DEFAULT NULL COMMENT '合同违约金比例',
                                                 `purch_contract_basic_info_id` bigint(20) NOT NULL COMMENT '采购合同基本信息表Id',
                                                 `purch_contract_approval_id` bigint(20) NOT NULL COMMENT '采购合同审核表Id',
                                                 `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                                 `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同违约条款';


-- 采购合同其他条款
DROP TABLE IF EXISTS `purch_contract_other_clause`;
CREATE TABLE `purch_contract_other_clause` (
                                                 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
												 `serial_number` smallint(5) unsigned DEFAULT '0' COMMENT '序号',
                                                 `payment_condition` varchar(2000) DEFAULT NULL COMMENT '付款条件',
                                                 `purch_contract_basic_info_id` bigint(20) NOT NULL COMMENT '采购合同基本信息表Id',
                                                 `purch_contract_approval_id` bigint(20) NOT NULL COMMENT '采购合同审核表Id',
                                                 `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                                 `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同其他条款';

-- 20211027
-- 采购合同电子合同信息
DROP TABLE IF EXISTS `purch_contract_electronic_info`;
CREATE TABLE `purch_contract_electronic_info` (
                                                 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
												 `certify_link` varchar(1024) DEFAULT NULL COMMENT '认证链接',
												 `certify_status` tinyint(1) DEFAULT NULL COMMENT '认证状态',
												 `contract_link` varchar(1024) DEFAULT NULL COMMENT '合同链接',
												 `sign_status` tinyint(1) DEFAULT NULL COMMENT '签署状态',
                                                 `purch_contract_basic_info_id` bigint(20) NOT NULL COMMENT '采购合同基本信息表Id',
                                                 `purch_contract_sign_confirm_id` bigint(20) NOT NULL COMMENT '采购合同签署确认表Id',
                                                 `fdd_customer_id` varchar(50) DEFAULT NULL COMMENT '二网在法大大上的客户编号',
                                                 `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                                 `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同电子合同信息';


-- 采购合同审核表
DROP TABLE IF EXISTS `purch_contract_approval`;
CREATE TABLE `purch_contract_approval` (
                                           `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                                           `purch_contract_basic_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '采购合同基本信息表Id',
                                           `approval_comment` varchar(3000) COLLATE utf8_bin DEFAULT '' COMMENT '审批意见',
                                           `approval_conclusion` varchar(50) COLLATE utf8_bin DEFAULT '' COMMENT '审批结论',
                                           `auditor_id` bigint(20) unsigned DEFAULT '0' COMMENT '审核人Id',
                                           `user_create` varchar(50) COLLATE utf8_bin DEFAULT '' COMMENT '创建人',
                                           `user_modified` varchar(50) COLLATE utf8_bin 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同审核表';

-- 采购合同签署确认表
DROP TABLE IF EXISTS `purch_contract_sign_confirm`;
CREATE TABLE `purch_contract_sign_confirm` (
                                               `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                                               `purch_contract_basic_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '采购合同基本信息表Id',
                                               `assignee_id` bigint(20) unsigned DEFAULT '0' COMMENT '处理人ID',
                                               `conclusion` varchar(50) COLLATE utf8_bin DEFAULT '' COMMENT '结论',
                                               `veto_reason` varchar(350) COLLATE utf8_bin DEFAULT '' COMMENT '否决原因',
                                               `remark` varchar(3000) COLLATE utf8_bin DEFAULT '' COMMENT '备注',
                                               `fdd_customer_id` varchar(50) DEFAULT NULL COMMENT '二网在法大大上的客户编号',
                                               `user_create` varchar(50) COLLATE utf8_bin DEFAULT '' COMMENT '创建人',
                                               `user_modified` varchar(50) COLLATE utf8_bin 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同签署确认表';

-- 采购合同签署审核表
DROP TABLE IF EXISTS `purch_contract_final_approval`;
CREATE TABLE `purch_contract_final_approval` (
                                                 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                                                 `purch_contract_basic_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '采购合同基本信息表Id',
                                                 `approval_comment` varchar(3000) COLLATE utf8_bin DEFAULT '' COMMENT '审批意见',
                                                 `approval_conclusion` varchar(50) COLLATE utf8_bin DEFAULT '' COMMENT '审批结论',
                                                 `auditor_id` bigint(20) unsigned DEFAULT '0' COMMENT '审核人Id',
                                                 `user_create` varchar(50) COLLATE utf8_bin DEFAULT '' COMMENT '创建人',
                                                 `user_modified` varchar(50) COLLATE utf8_bin 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`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='采购合同签署审核表';

-- 添加采购合同状态字典项
INSERT INTO `t_dictionary` (name, parentId, code, value, gradation, gmt_create, gmt_modified)
VALUES ('采购合同状态', null, 'purchContractStatus', null, '1',  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 = 'purchContractStatus'), 'purch_contract_create', null, '0', 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 = 'purchContractStatus'), 'purch_contract_input', null, '1', 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 = 'purchContractStatus'), 'purch_contract_first_approval', null, '2', 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 = 'purchContractStatus'), 'purch_contract_overrule', null, '3', 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 = 'purchContractStatus'), 'purch_contract_sign', null, '4', 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 = 'purchContractStatus'), 'purch_contract_confirm', null, '5', 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 = 'purchContractStatus'), 'purch_contract_wait_change', 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 = 'purchContractStatus'), 'purch_contract_change', null, '7', NOW(), NOW());

-- 采购合同信息附件中间表
DROP TABLE IF EXISTS `purch_contract_info_file_ref`;
CREATE TABLE `purch_contract_info_file_ref` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `purch_contract_id` bigint(20) unsigned DEFAULT '0' COMMENT '采购合同信息的ID',
  `file_id` bigint(20) unsigned DEFAULT '0' COMMENT '附件的ID',
  `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`)
) ENGINE=InnoDB AUTO_INCREMENT=971 DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='采购合同信息附件中间表';


-- 添加采购合同--采购合同回购方式
INSERT INTO `t_dictionary` (name, parentId, code, value, gradation, gmt_create, gmt_modified)
VALUES ('采购合同回购方式', null, 'purchContractRepurchMethod', null, '1',  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 = 'purchContractRepurchMethod'), 'purchContractRepurchMethod_interestBeforeCapital', null, '0', 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 = 'purchContractRepurchMethod'), 'purchContractRepurchMethod_capitalOnly', null, '1', NOW(), NOW());


-- 添加采购合同--采购合同利差计算方式
INSERT INTO `t_dictionary` (name, parentId, code, value, gradation, gmt_create, gmt_modified)
VALUES ('采购合同利差计算方式', null, 'purchAccrualMarginCalcMethod', null, '1',  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 = 'purchAccrualMarginCalcMethod'), 'purchAccrualMarginCalcMethod_fixedInterest', null, '0', 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 = 'purchAccrualMarginCalcMethod'), 'purchAccrualMarginCalcMethod_fixedAmount', null, '1', NOW(), NOW());

-- 添加采购合同--采购合同工程量类别
INSERT INTO `t_dictionary` (name, parentId, code, value, gradation, gmt_create, gmt_modified)
VALUES ('采购合同工程量类别', null, 'purchProjectAmountCategory', null, '1',  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 = 'purchProjectAmountCategory'), 'purchProjectAmountCategory_estimateAmount', null, '0', 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 = 'purchProjectAmountCategory'), 'purchProjectAmountCategory_fixedAmount', null, '1', NOW(), NOW());

-- 2021年10月18日19:35

-- 采购发票信息表
DROP TABLE IF EXISTS `purch_invoice_info`;
CREATE TABLE `purch_invoice_info` (
                                             `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
											 `invoice_number` varchar(50) NOT NULL COMMENT '发票单号',
                                             `business_number` varchar(50) NOT NULL COMMENT '业务编号',
											 `supplier_id` bigint(20) DEFAULT NULL COMMENT '供应商Id',
											 `invoice_date` datetime DEFAULT NULL COMMENT '发票日期',
											 `invoice_amount` decimal(17,2) DEFAULT '0.00' COMMENT '发票金额',
											 `invoice_type` bigint(20) DEFAULT NULL COMMENT '发票类型',
											 `amount_kind` bigint(20) DEFAULT NULL COMMENT '金额种类',
											 `invoice_status` bigint(20) unsigned DEFAULT '0' COMMENT '发票状态 已创建、已退回、已驳回、已通过',
                                             `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                             `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB  AUTO_INCREMENT=1  DEFAULT CHARSET=utf8 COMMENT='采购发票信息表';

-- 采购发票信息表历史
DROP TABLE IF EXISTS `purch_invoice_info_history`;
CREATE TABLE `purch_invoice_info_history` (
                                      `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
                                      `invoice_number` varchar(50) NOT NULL COMMENT '发票单号',
                                      `business_number` varchar(50) NOT NULL COMMENT '业务编号',
                                      `supplier_id` bigint(20) DEFAULT NULL COMMENT '供应商Id',
                                      `invoice_date` datetime DEFAULT NULL COMMENT '发票日期',
                                      `invoice_amount` decimal(17,2) DEFAULT '0.00' COMMENT '发票金额',
                                      `invoice_type` bigint(20) DEFAULT NULL COMMENT '发票类型',
                                      `amount_kind` bigint(20) DEFAULT NULL COMMENT '金额种类',
                                      `invoice_status` bigint(20) unsigned DEFAULT '0' COMMENT '发票状态 已创建、已退回、已驳回、已通过',
                                      `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                      `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB  AUTO_INCREMENT=1  DEFAULT CHARSET=utf8 COMMENT='采购发票信息表';

-- 采购发票附件表
DROP TABLE IF EXISTS `purch_invoice_file`;
CREATE TABLE `purch_invoice_file` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `purch_invoice_info_id` bigint(20) NOT NULL COMMENT '采购发票信息表Id',
  `file_storage_id` bigint(20) unsigned DEFAULT '0' COMMENT '附件的ID',
  `file_type` varchar(50) DEFAULT '' COMMENT '附件类型',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='采购发票-采购发票附件表';

-- 采购发票附件表历史
DROP TABLE IF EXISTS `purch_invoice_file_history`;
CREATE TABLE `purch_invoice_file_history` (
                                      `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                                      `purch_invoice_info_id` bigint(20) NOT NULL COMMENT '采购发票信息表Id',
                                      `file_storage_id` bigint(20) unsigned DEFAULT '0' COMMENT '附件的ID',
                                      `file_type` varchar(50) DEFAULT '' COMMENT '附件类型',
                                      PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='采购发票-采购发票附件表';

-- 采购发票货物信息表
DROP TABLE IF EXISTS `purch_invoice_goods`;
CREATE TABLE `purch_invoice_goods` (
                                             `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
											 `purch_invoice_info_id` bigint(20) NOT NULL COMMENT '采购发票信息表Id',
											 `invoice_number` varchar(50) NOT NULL COMMENT '发票单号',
                                             `business_number` varchar(50) NOT NULL COMMENT '业务编号',
											 `amount_kind` bigint(20) DEFAULT NULL COMMENT '金额种类',
											 `acceptance_business_goods_id` bigint(20) DEFAULT NULL COMMENT '验收单货物Id',
											 `goods_code` int(10)  DEFAULT NULL COMMENT '货物编号',
											 `goods_name` varchar(50) DEFAULT NULL COMMENT '货物名称',
											 `model_number` varchar(50) DEFAULT NULL COMMENT '货物型号',
											 `units` varchar(10) DEFAULT NULL COMMENT '货物单位',
											 `quantity` decimal(17,3) DEFAULT NULL COMMENT '货物数量',
											 `unit_price` decimal(17,2) DEFAULT NULL COMMENT '采购单价',
											 `total_price` decimal(17,2) DEFAULT NULL COMMENT '采购总价',
											 `supplier_id` bigint(20) DEFAULT NULL COMMENT '供应商Id',
											 `invoiced_quantity` decimal(17,3) DEFAULT NULL COMMENT '已开票数量',
											 `open_quantity` decimal(17,3) DEFAULT NULL COMMENT '开票数量',
											 `open_amount` decimal(17,2) DEFAULT NULL COMMENT '开票金额',
                                             `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                             `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB  AUTO_INCREMENT=1  DEFAULT CHARSET=utf8 COMMENT='采购发票货物信息表';

-- 采购发票货物信息表历史
DROP TABLE IF EXISTS `purch_invoice_goods_history`;
CREATE TABLE `purch_invoice_goods_history` (
                                       `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
                                       `purch_invoice_info_id` bigint(20) NOT NULL COMMENT '采购发票信息表Id',
                                       `invoice_number` varchar(50) NOT NULL COMMENT '发票单号',
                                       `business_number` varchar(50) NOT NULL COMMENT '业务编号',
                                       `amount_kind` bigint(20) DEFAULT NULL COMMENT '金额种类',
                                       `acceptance_business_goods_id` bigint(20) DEFAULT NULL COMMENT '验收单货物Id',
                                       `goods_code` int(10)  DEFAULT NULL COMMENT '货物编号',
                                       `goods_name` varchar(50) DEFAULT NULL COMMENT '货物名称',
                                       `model_number` varchar(50) DEFAULT NULL COMMENT '货物型号',
                                       `units` varchar(10) DEFAULT NULL COMMENT '货物单位',
                                       `quantity` decimal(17,3) DEFAULT NULL COMMENT '货物数量',
                                       `unit_price` decimal(17,2) DEFAULT NULL COMMENT '采购单价',
                                       `total_price` decimal(17,2) DEFAULT NULL COMMENT '采购总价',
                                       `supplier_id` bigint(20) DEFAULT NULL COMMENT '供应商Id',
                                       `invoiced_quantity` decimal(17,3) DEFAULT NULL COMMENT '已开票数量',
                                       `open_quantity` decimal(17,3) DEFAULT NULL COMMENT '开票数量',
                                       `open_amount` decimal(17,2) DEFAULT NULL COMMENT '开票金额',
                                       `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                       `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB  AUTO_INCREMENT=1  DEFAULT CHARSET=utf8 COMMENT='采购发票货物信息表';


-- 采购发票审核表
DROP TABLE IF EXISTS `purch_invoice_approval`;
CREATE TABLE `purch_invoice_approval` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `purch_invoice_info_id` bigint(20) NOT NULL COMMENT '采购发票信息表Id',
  `approval_comment` varchar(3000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '' COMMENT '审批意见',
  `approval_conclusion` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '' COMMENT '审批结论',
  `auditor_id` bigint(20) unsigned DEFAULT '0' COMMENT '审核人Id',
  `user_create` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '' COMMENT '创建人',
  `user_modified` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin 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`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT='采购发票审核表';

-- 销售发票信息表
DROP TABLE IF EXISTS `sale_invoice_info`;
CREATE TABLE `sale_invoice_info` (
                                             `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
											 `invoice_number` varchar(50) NOT NULL COMMENT '发票单号',
                                             `business_number` varchar(50) NOT NULL COMMENT '业务编号',
											 `invoice_date` datetime DEFAULT NULL COMMENT '发票日期',
											 `invoice_amount` decimal(17,2) DEFAULT '0.00' COMMENT '发票金额-货物开票金额总和',
											 `purchaser_id` bigint(20) DEFAULT NULL COMMENT '公司名称-业务买方名称',
											 `tax_identify_no` varchar(64) DEFAULT NULL COMMENT '纳税识别号',
											 `address` varchar(512) DEFAULT NULL COMMENT '地址',
											 `phone` varchar(64) DEFAULT NULL COMMENT '电话',
											 `account_bank_name` varchar(512) DEFAULT NULL COMMENT '开户行名称',
											 `account_number` varchar(64) DEFAULT NULL COMMENT '开户账号',
											 `invoice_type` bigint(20) DEFAULT NULL COMMENT '发票类型',
											 `amount_kind` bigint(20) DEFAULT NULL COMMENT '金额种类',
											 `invoice_status` bigint(20) unsigned DEFAULT '0' COMMENT '发票状态 已创建、已退回、已驳回、已通过',
                                             `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                             `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB  AUTO_INCREMENT=1  DEFAULT CHARSET=utf8 COMMENT='销售发票信息表';

-- 销售发票信息表历史
DROP TABLE IF EXISTS `sale_invoice_info_history`;
CREATE TABLE `sale_invoice_info_history` (
                                     `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
                                     `invoice_number` varchar(50) NOT NULL COMMENT '发票单号',
                                     `business_number` varchar(50) NOT NULL COMMENT '业务编号',
                                     `invoice_date` datetime DEFAULT NULL COMMENT '发票日期',
                                     `invoice_amount` decimal(17,2) DEFAULT '0.00' COMMENT '发票金额-货物开票金额总和',
                                     `purchaser_id` bigint(20) DEFAULT NULL COMMENT '公司名称-业务买方名称',
                                     `tax_identify_no` varchar(64) DEFAULT NULL COMMENT '纳税识别号',
                                     `address` varchar(512) DEFAULT NULL COMMENT '地址',
                                     `phone` varchar(64) DEFAULT NULL COMMENT '电话',
                                     `account_bank_name` varchar(512) DEFAULT NULL COMMENT '开户行名称',
                                     `account_number` varchar(64) DEFAULT NULL COMMENT '开户账号',
                                     `invoice_type` bigint(20) DEFAULT NULL COMMENT '发票类型',
                                     `amount_kind` bigint(20) DEFAULT NULL COMMENT '金额种类',
                                     `invoice_status` bigint(20) unsigned DEFAULT '0' COMMENT '发票状态 已创建、已退回、已驳回、已通过',
                                     `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                     `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB  AUTO_INCREMENT=1  DEFAULT CHARSET=utf8 COMMENT='销售发票信息表';


-- 销售发票货物信息表
DROP TABLE IF EXISTS `sale_invoice_goods`;
CREATE TABLE `sale_invoice_goods` (
                                             `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
											 `sale_invoice_info_id` bigint(20) NOT NULL COMMENT '销售发票信息表Id',
											 `invoice_number` varchar(50) NOT NULL COMMENT '发票单号',
                                             `business_number` varchar(50) NOT NULL COMMENT '业务编号',
											 `amount_kind` bigint(20) DEFAULT NULL COMMENT '金额种类',
											 `acceptance_business_goods_id` bigint(20) DEFAULT NULL COMMENT '验收单货物Id',
											 `goods_code` int(10)  DEFAULT NULL COMMENT '货物编号',
											 `goods_name` varchar(50) DEFAULT NULL COMMENT '货物名称',
											 `model_number` varchar(50) DEFAULT NULL COMMENT '货物型号',
											 `units` varchar(10) DEFAULT NULL COMMENT '货物单位',
											 `quantity` decimal(17,3) DEFAULT NULL COMMENT '货物数量',
											 `unit_price` decimal(17,2) DEFAULT NULL COMMENT '销售单价',
											 `total_price` decimal(17,2) DEFAULT NULL COMMENT '销售总价',
											 `supplier_id` bigint(20) DEFAULT NULL COMMENT '供应商Id',
											 `invoiced_quantity` decimal(17,3) DEFAULT NULL COMMENT '已开票数量',
											 `open_quantity` decimal(17,3) DEFAULT NULL COMMENT '开票数量',
											 `open_amount` decimal(17,2) DEFAULT NULL COMMENT '开票金额',
                                             `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                             `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB  AUTO_INCREMENT=1  DEFAULT CHARSET=utf8 COMMENT='销售发票货物信息表';

-- 销售发票货物信息表历史
DROP TABLE IF EXISTS `sale_invoice_goods_history`;
CREATE TABLE `sale_invoice_goods_history` (
                                      `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
                                      `sale_invoice_info_id` bigint(20) NOT NULL COMMENT '销售发票信息表Id',
                                      `invoice_number` varchar(50) NOT NULL COMMENT '发票单号',
                                      `business_number` varchar(50) NOT NULL COMMENT '业务编号',
                                      `amount_kind` bigint(20) DEFAULT NULL COMMENT '金额种类',
                                      `acceptance_business_goods_id` bigint(20) DEFAULT NULL COMMENT '验收单货物Id',
                                      `goods_code` int(10)  DEFAULT NULL COMMENT '货物编号',
                                      `goods_name` varchar(50) DEFAULT NULL COMMENT '货物名称',
                                      `model_number` varchar(50) DEFAULT NULL COMMENT '货物型号',
                                      `units` varchar(10) DEFAULT NULL COMMENT '货物单位',
                                      `quantity` decimal(17,3) DEFAULT NULL COMMENT '货物数量',
                                      `unit_price` decimal(17,2) DEFAULT NULL COMMENT '销售单价',
                                      `total_price` decimal(17,2) DEFAULT NULL COMMENT '销售总价',
                                      `supplier_id` bigint(20) DEFAULT NULL COMMENT '供应商Id',
                                      `invoiced_quantity` decimal(17,3) DEFAULT NULL COMMENT '已开票数量',
                                      `open_quantity` decimal(17,3) DEFAULT NULL COMMENT '开票数量',
                                      `open_amount` decimal(17,2) DEFAULT NULL COMMENT '开票金额',
                                      `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                      `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB  AUTO_INCREMENT=1  DEFAULT CHARSET=utf8 COMMENT='销售发票货物信息表';

-- 销售发票审核表
DROP TABLE IF EXISTS `sale_invoice_approval`;
CREATE TABLE `sale_invoice_approval` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `sale_invoice_info_id` bigint(20) NOT NULL COMMENT '销售发票信息表Id',
  `approval_comment` varchar(3000) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '' COMMENT '审批意见',
  `approval_conclusion` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '' COMMENT '审批结论',
  `auditor_id` bigint(20) unsigned DEFAULT '0' COMMENT '审核人Id',
  `user_create` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '' COMMENT '创建人',
  `user_modified` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin 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`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT='销售发票审核表';

-- 销售发票附件表
DROP TABLE IF EXISTS `sales_invoice_file`;
CREATE TABLE `sales_invoice_file` (
                                      `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                                      `sales_invoice_info_id` bigint(20) NOT NULL COMMENT '销售发票信息表Id',
                                      `file_storage_id` bigint(20) unsigned DEFAULT '0' COMMENT '附件的ID',
                                      `file_type` varchar(50) DEFAULT '' COMMENT '附件类型',
                                      PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='销售发票-销售发票附件表';

-- 销售发票附件表历史
DROP TABLE IF EXISTS `sales_invoice_file_history`;
CREATE TABLE `sales_invoice_file_history` (
                                              `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
                                              `sales_invoice_info_id` bigint(20) NOT NULL COMMENT '销售发票信息表Id',
                                              `file_storage_id` bigint(20) unsigned DEFAULT '0' COMMENT '附件的ID',
                                              `file_type` varchar(50) DEFAULT '' COMMENT '附件类型',
                                              PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='销售发票-销售发票附件表';

-- 添加销售发票状态字典项
INSERT INTO `t_dictionary` (name, parentId, code, value, gradation, gmt_create, gmt_modified)
VALUES ('销售发票状态', null, 'SaleInvoiceStatus', null, '1',  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 = 'SaleInvoiceStatus'), 'sale_invoice_create', null, '0', 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 = 'SaleInvoiceStatus'), 'sale_invoice_back', null, '1', 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 = 'SaleInvoiceStatus'), 'sale_invoice_overrule', null, '2', 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 = 'SaleInvoiceStatus'), 'sale_invoice_pass', null, '3', NOW(), NOW());


-- 添加采购发票状态字典项
INSERT INTO `t_dictionary` (name, parentId, code, value, gradation, gmt_create, gmt_modified)
VALUES ('采购发票状态', null, 'PurchInvoiceStatus', null, '1',  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 = 'PurchInvoiceStatus'), 'purch_invoice_create', null, '0', 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 = 'PurchInvoiceStatus'), 'purch_invoice_back', null, '1', 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 = 'PurchInvoiceStatus'), 'purch_invoice_overrule', null, '2', 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 = 'PurchInvoiceStatus'), 'purch_invoice_pass', null, '3', NOW(), NOW());


-- 添加发票类型字典项
INSERT INTO `t_dictionary` (name, parentId, code, value, gradation, gmt_create, gmt_modified)
VALUES ('发票类型', null, 'invoiceType', null, '1',  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 = 'invoiceType'), 'invoice_type_general', null, '0', 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 = 'invoiceType'), 'invoice_type_special', null, '1', NOW(), NOW());

-- 添加金额种类字典项
INSERT INTO `t_dictionary` (name, parentId, code, value, gradation, gmt_create, gmt_modified)
VALUES ('金额种类', null, 'amountKind', null, '1',  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 = 'amountKind'), 'amount_kind_payment', null, '0', 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 = 'amountKind'), 'amount_kind_discount', null, '1', 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 = 'amountKind'), 'amount_kind_capital', null, '2', NOW(), NOW());

-- 现金流管理

-- 银行卡信息设置表
DROP TABLE IF EXISTS `bank_card_info_set`;
CREATE TABLE `bank_card_info_set` (
                                             `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
											 `company_belong` bigint(20) NOT NULL COMMENT '公司归属',
                                             `bank_name` varchar(256) NOT NULL COMMENT '银行名称',
											 `bank_account` varchar(64) NOT NULL COMMENT '银行卡号',
											 `effective_date` datetime DEFAULT NULL COMMENT '生效日期',
											 `begin_value` decimal(17,2) DEFAULT '0.00' COMMENT '期初数值',
											 `currency` bigint(20) DEFAULT NULL COMMENT '币种',
											 `info_status` varchar(2) DEFAULT NULL COMMENT '状态:1,启用;0,禁用',
											 `remark` varchar(512) DEFAULT NULL COMMENT '备注',
                                             `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                             `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB  AUTO_INCREMENT=1  DEFAULT CHARSET=utf8 COMMENT='银行卡信息设置表';

-- 现金流管理基础信息表
DROP TABLE IF EXISTS `cash_flow_manage_base_info`;
CREATE TABLE `cash_flow_manage_base_info` (
                                             `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
											 `purchaser_id` bigint(20) NOT NULL COMMENT '买方名称',
											 `business_name` varchar(50) NOT NULL COMMENT '业务名称',
                                             `business_number` varchar(50) NOT NULL COMMENT '业务编号',
											 `entry_out_type` varchar(2) DEFAULT NULL COMMENT '出入账类型:1,入账;2,出账',
											 `cash_type` bigint(20) DEFAULT NULL COMMENT '类型：现金、票据贴现、保理利息、保理本金、质保金、折扣率等等',
                                             `currency` bigint(20) DEFAULT NULL COMMENT '币种',
											 `amount` decimal(17,2) DEFAULT '0.00' COMMENT '金额',
											 `cash_status` varchar(2) DEFAULT NULL COMMENT '状态 入账：1,已创建、2,已分配;出账：3,待处理、4,已完成',
											 `supplier_id` bigint(20) DEFAULT NULL COMMENT '供应商Id',
                                             `platform_id` bigint(20) DEFAULT NULL COMMENT '贸易平台Id',
											 `contract_number` varchar(50) DEFAULT NULL COMMENT '采购合同编号',
											 `cash_date` datetime DEFAULT NULL COMMENT '日期',
											 `remark` varchar(50) DEFAULT NULL COMMENT '备注',
                                             `ledger_account_basic_info_id` bigint(20) DEFAULT NULL COMMENT '对应分账管理基本信息表Id',
											 `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                             `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB  AUTO_INCREMENT=1  DEFAULT CHARSET=utf8 COMMENT='现金流管理基础信息表';


-- 现金流管理入账信息表
DROP TABLE IF EXISTS `cash_flow_manage_entry_info`;
CREATE TABLE `cash_flow_manage_entry_info` (
                                             `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
											 `cash_flow_manage_base_info_id` bigint(20) NOT NULL COMMENT '现金流管理基础信息表Id',
											 `entry_party` varchar(2) DEFAULT NULL COMMENT '入账方:1,买家;2,卖家',
											 `company_belong` bigint(20) DEFAULT NULL COMMENT '归属公司',
											 `bank_name` varchar(256) NOT NULL COMMENT '银行名称',
											 `bank_account` varchar(64) NOT NULL COMMENT '银行卡号',
											 `bill_amount` decimal(17,2) DEFAULT '0.00' COMMENT '票据金额',
											 `curr_executor` varchar(50) DEFAULT NULL COMMENT '当前执行人',
											 `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                             `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB  AUTO_INCREMENT=1  DEFAULT CHARSET=utf8 COMMENT='现金流管理入账信息表';

-- 现金流管理入账信息附件表
DROP TABLE IF EXISTS `cash_flow_manage_entry_file`;
CREATE TABLE `cash_flow_manage_entry_file` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `cash_flow_manage_entry_info_id` bigint(20) NOT NULL COMMENT '现金流管理入账信息表Id',
  `file_storage_id` bigint(20) unsigned DEFAULT '0' COMMENT '附件的ID',
  `file_type` varchar(50) DEFAULT '' COMMENT '附件类型',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='现金流管理入账信息附件表';

-- 现金流管理出账信息表
DROP TABLE IF EXISTS `cash_flow_manage_out_info`;
CREATE TABLE `cash_flow_manage_out_info` (
                                             `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
											 `cash_flow_manage_base_info_id` bigint(20) NOT NULL COMMENT '现金流管理基础信息表Id',
											 `loan_date` datetime DEFAULT NULL COMMENT '此次放款日期',
											 `loan_amount` decimal(17,2) DEFAULT '0.00' COMMENT '此次放款金额',
											 `from_company_belong` bigint(20) DEFAULT NULL COMMENT '打款账户--归属公司',
                                             `from_bank_name` varchar(256) NOT NULL COMMENT '打款账户--银行名称',
                                             `from_bank_account` varchar(64) NOT NULL COMMENT '打款账户--银行卡号',
                                             `to_company_belong` bigint(20) DEFAULT NULL COMMENT '收款账户--归属公司',
                                             `to_bank_name` varchar(256) NOT NULL COMMENT '收款账户--银行名称',
                                             `to_bank_account` varchar(64) NOT NULL COMMENT '收款账户--银行卡号',
											 `curr_executor` varchar(50) DEFAULT NULL COMMENT '当前执行人',
                                             `file_text` mediumtext COMMENT '附件富文本',
											 `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
                                             `user_modified` varchar(50) DEFAULT NULL 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`)
) ENGINE=InnoDB  AUTO_INCREMENT=1  DEFAULT CHARSET=utf8 COMMENT='现金流管理出账信息表';

-- 添加现金流管理入账类型字典项
INSERT INTO `t_dictionary` (name, parentId, code, value, gradation, gmt_create, gmt_modified)
VALUES ('现金流管理-入账类型', null, 'cashFlowEntryType', null, '1',  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 = 'cashFlowEntryType'), 'entryType_cash', null, '0', 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 = 'cashFlowEntryType'), 'entryType_bills_discounted', null, '1', NOW(), NOW());

-- 添加现金流管理出账类型字典项
INSERT INTO `t_dictionary` (name, parentId, code, value, gradation, gmt_create, gmt_modified)
VALUES ('现金流管理-出账类型', null, 'cashFlowOutType', null, '1',  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_factoring_principal_interest', null, '0', 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_discount', null, '1', 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_funds_used_cost', null, '2', 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_retention_amount', null, '3', NOW(), NOW());

