-- 成本中心专项添加成本中心字段sql脚本

-- 折旧汇总添加成本中心字段 T_FA_DEPREENTRY_D_SUM   FTOTALCOSTCENTERID
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_DEPREENTRY_D_SUM' AND KSQL_COL_NAME ='FTOTALCOSTCENTRERID')
ALTER TABLE T_FA_DEPREENTRY_D_SUM ADD (FTOTALCOSTCENTRERID BIGINT DEFAULT 0 NOT NULL );

-- 折旧明细添加成本中心字段 T_FA_DEPREDETAILENTRY   FCOSTCENTERID
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_DEPREDETAILENTRY' AND KSQL_COL_NAME ='FCOSTCENTRERID')
ALTER TABLE T_FA_DEPREDETAILENTRY ADD (FCOSTCENTRERID BIGINT DEFAULT 0 NOT NULL );

-- 资产调入单 T_FA_DISPTBILLENTRY 调入成本中心 FINCOSTCENTERID 字段
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_DISPTBILLENTRY' AND KSQL_COL_NAME ='FINCOSTCENTRERID')
ALTER TABLE T_FA_DISPTBILLENTRY ADD (FINCOSTCENTRERID BIGINT DEFAULT 0 NOT NULL );

-- 实物卡片
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_CARD_REAL' AND KSQL_COL_NAME ='FCOSTCENTRERID')
ALTER TABLE T_FA_CARD_REAL ADD (FCOSTCENTRERID BIGINT DEFAULT 0 NOT NULL );

-- 采购转固单、工程转固单添加字段成本中心
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_PURCHASEBILLENTRY' AND KSQL_COL_NAME IN ('FCOSTCENTRERID'))
ALTER TABLE T_FA_PURCHASEBILLENTRY ADD (FCOSTCENTRERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_ASSETINFOADDENTRY' AND KSQL_COL_NAME IN ('FCOSTCENTRERID'))
ALTER TABLE T_FA_ASSETINFOADDENTRY ADD (FCOSTCENTRERID BIGINT DEFAULT 0 NOT NULL );

