/**Begin D:\datamodel\pdm\PDM_UPGRADE_1.3\PDM_UPGRADE_1.3\PDM_UPGRADE\log\0515\RIM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INVOICE_UNCHECK') 
 CREATE TABLE T_RIM_INVOICE_UNCHECK (
FID BIGINT DEFAULT 0 NOT NULL,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL,
FINVOICE_CODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_NO NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_DATE DATETIME,
FINVOICE_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTAL_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTAL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSALER_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FSALER_TAX_NO NVARCHAR(20) DEFAULT ' ' NOT NULL,
FBUYER_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FBUYER_TAX_NO NVARCHAR(20) DEFAULT ' ' NOT NULL,
FCHECK_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FCHECK_TIME DATETIME,
FCHECK_TIMES INT DEFAULT 0 NOT NULL,
FEXPENSE_STATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEXPENSE_TIME DATETIME,
FEXPENSE_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FVOUCH_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEXPENSE_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACCOUNT_TIME DATETIME,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FORG_ID BIGINT DEFAULT 0 NOT NULL,
FACCOUNT_DATE DATETIME,
FRESOURCE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FDELETE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FUPDATE_TIME DATETIME,
FCREATER BIGINT DEFAULT 0 NOT NULL,
FAUTHENTICATE_FLAG NVARCHAR(2) DEFAULT ' ' NOT NULL,
FAUTHENTICATE_TIME DATETIME,
FSELECT_TIME DATETIME,
FTAX_PERIOD DATETIME,
FEFFECTIVE_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEDUCTION_PURPOSE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMANAGE_STATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCHECK_RESULT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCHECK_CODE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FFILE_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPAGE_NO INT DEFAULT 0 NOT NULL,
FCOLLECT_TYPE NVARCHAR(10) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INVOICE_FILE') 
 CREATE TABLE T_RIM_INVOICE_FILE (
FID BIGINT DEFAULT 0 NOT NULL,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FFILE_HASH NVARCHAR(100) DEFAULT ' ' NOT NULL,
FORIGINAL_TYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPDF_URL NVARCHAR(300) DEFAULT ' ' NOT NULL,
FOFD_URL NVARCHAR(300) DEFAULT ' ' NOT NULL,
FIMAGE_URL NVARCHAR(300) DEFAULT ' ' NOT NULL,
FSNAPSHOT_URL NVARCHAR(300) DEFAULT ' ' NOT NULL,
FICON_URL NVARCHAR(300) DEFAULT ' ' NOT NULL,
FROTATION_ANGLE INT DEFAULT 0 NOT NULL,
FREGION NVARCHAR(35) DEFAULT ' ' NOT NULL,
FPIXEL NVARCHAR(20) DEFAULT ' ' NOT NULL,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FUPDATE_TIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_SELECT_ACCOUNT') 
 CREATE TABLE T_RIM_SELECT_ACCOUNT (
FID BIGINT DEFAULT 0 NOT NULL,
FBATCH_NO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FEFFECTIVE_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEDUCTION_PURPOSE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FHANDLE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FUPDATE_TIME DATETIME,
FSELECT_RESULT NVARCHAR(2) DEFAULT ' ' NOT NULL,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL,
FINVOICE_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTAL_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSALER_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FSALER_TAX_NO NVARCHAR(20) DEFAULT ' ' NOT NULL,
FINVOICE_CODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_NO NVARCHAR(32) DEFAULT ' ' NOT NULL,
FMANAGE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FSELECT_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATER BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INVOICE_HIS') 
 CREATE TABLE T_RIM_INVOICE_HIS (
FID BIGINT DEFAULT 0 NOT NULL,
FDATA_TABLE NVARCHAR(36) DEFAULT ' ' NOT NULL,
FDATA_PK NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOLD_VALUE NVARCHAR(400) DEFAULT ' ' NOT NULL,
FFIELD_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNEW_VALUE NVARCHAR(400) DEFAULT ' ' NOT NULL,
FTRACEID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOPERATE_TYPE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATER BIGINT DEFAULT 0 NOT NULL,
FCREATE_TIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_COLLECT_ORG') 
 CREATE TABLE T_RIM_INV_COLLECT_ORG (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FCOLLECT_ORG BIGINT DEFAULT 0 NOT NULL,
FCOLLECT_ORG_USER BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_COLLECT_USER') 
 CREATE TABLE T_RIM_INV_COLLECT_USER (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FCOLLECT_USER BIGINT DEFAULT 0 NOT NULL,
FCOLLECT_USER_ORG BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INVOICE_SUM') 
 CREATE TABLE T_RIM_INVOICE_SUM (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FINPUT_INVOICE_TYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FRECEIVED_COUNT INT DEFAULT 0 NOT NULL,
FUNRECEIVE_COUNT INT DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUM_COUNT INT DEFAULT 0 NOT NULL,
FUNCERTIFIED_COUNT INT DEFAULT 0 NOT NULL,
FCERTIFIED_COUNT INT DEFAULT 0 NOT NULL,
FTAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTAL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCREATE_DATE DATETIME,
FDATA_DATE_TIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_AIR_ITEM') 
 CREATE TABLE T_RIM_INV_AIR_ITEM (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FENTRY_FLIGHT_NUM NVARCHAR(32) DEFAULT ' ' NOT NULL,
FENTRY_DEPARTURE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FENTRY_DESTINATION NVARCHAR(32) DEFAULT ' ' NOT NULL,
FENTRY_SEAT_GRADE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FENTRY_CARRIER NVARCHAR(32) DEFAULT ' ' NOT NULL,
FENTRY_DATE DATETIME,
FENTRY_TIME NVARCHAR(10) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_AIR') 
 CREATE TABLE T_RIM_INV_AIR (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FPRINT_NUM NVARCHAR(32) DEFAULT ' ' NOT NULL,
FCUSTOMER_NAME NVARCHAR(32) DEFAULT ' ' NOT NULL,
FCUSTOMER_ID_NO NVARCHAR(25) DEFAULT ' ' NOT NULL,
FAIR_NUM NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAIRPORT_CONSTRUCTION_FEE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFUEL_SURCHARGE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTAL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOTHER_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTAL_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAX_RATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINSURANCE_PREMIUM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICE_DATE DATETIME,
FISSUE_DATE DATETIME,
FFILLING_UNIT NVARCHAR(100) DEFAULT ' ' NOT NULL,
FETICKET_NO NVARCHAR(32) DEFAULT ' ' NOT NULL,
FAGENT_CODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FENDORSEMENT NVARCHAR(32) DEFAULT ' ' NOT NULL,
FPLACE_OF_DEPARTURE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FDESTINATION NVARCHAR(32) DEFAULT ' ' NOT NULL,
FCARRIER NVARCHAR(32) DEFAULT ' ' NOT NULL,
FFLIGHT_NUM NVARCHAR(32) DEFAULT ' ' NOT NULL,
FSEAT_GRADE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FAIR_TIME NVARCHAR(10) DEFAULT ' ' NOT NULL,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTAX_ORG BIGINT DEFAULT 0 NOT NULL,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL,
FORG_ID BIGINT DEFAULT 0 NOT NULL,
FRESOURCE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FEXPENSE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FORIGINAL_STATE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FACCOUNT_DATE DATETIME,
FTRANSPORT_DEDUCTION NVARCHAR(2) DEFAULT ' ' NOT NULL,
FAUTHENTICATE_TIME DATETIME,
FTAX_PERIOD DATETIME,
FEFFECTIVE_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEDUCTION_FLAG NVARCHAR(2) DEFAULT ' ' NOT NULL,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_CUSTOM') 
 CREATE TABLE T_RIM_INV_CUSTOM (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FINVOICE_DATE DATETIME,
FCUSTOM_DECLARATION_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDEPT_NAME NVARCHAR(80) DEFAULT ' ' NOT NULL,
FDEPT_ACCOUNT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDEPT_BANK NVARCHAR(58) DEFAULT ' ' NOT NULL,
FDECLARE_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTOTAL_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAPPLY_DEPT_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCONTRACT_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTRANS_TOOL_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPAY_LIMIT_DATE DATETIME,
FDEAL_GOODS_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FGET_OFFICE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMODE_TRADE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUDGET_ACCOUNT_CODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCODE_COLLECTION_TREASURY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDELIVERY_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAUTHENTICATE_FLAG NVARCHAR(2) DEFAULT ' ' NOT NULL,
FAUTHENTICATE_TIME DATETIME,
FSELECT_TIME DATETIME,
FTAX_PERIOD DATETIME,
FEFFECTIVE_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEDUCTION_PURPOSE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FDEDUCTION_FLAG NVARCHAR(2) DEFAULT ' ' NOT NULL,
FMANAGE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FRESOURCE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FEXPENSE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FORIGINAL_STATE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FACCOUNT_DATE DATETIME,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL,
FORG_ID BIGINT DEFAULT 0 NOT NULL,
FTAX_ORG BIGINT DEFAULT 0 NOT NULL,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_CUSTOM_ITEM') 
 CREATE TABLE T_RIM_INV_CUSTOM_ITEM (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FGOODS_NAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FUNIT_PRICE INT DEFAULT 0 NOT NULL,
FNUM INT DEFAULT 0 NOT NULL,
FTAX_RATE INT DEFAULT 0 NOT NULL,
FUNIT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXNO_INFO NVARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_GENERAL') 
 CREATE TABLE T_RIM_INV_GENERAL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FINVOICE_CODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_NO NVARCHAR(32) DEFAULT ' ' NOT NULL,
FBUYER_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FBUYER_TAX_NO NVARCHAR(20) DEFAULT ' ' NOT NULL,
FCHECK_CODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FSALER_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FSALER_TAX_NO NVARCHAR(20) DEFAULT ' ' NOT NULL,
FTOTAL_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTAL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPAYEE NVARCHAR(20) DEFAULT ' ' NOT NULL,
FREVIEWER NVARCHAR(20) DEFAULT ' ' NOT NULL,
FDRAWER NVARCHAR(20) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(300) DEFAULT ' ' NOT NULL,
FENTRANCE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FEXIT NVARCHAR(32) DEFAULT ' ' NOT NULL,
FTIME NVARCHAR(10) DEFAULT ' ' NOT NULL,
FPLACE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_DATE DATETIME,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTAX_ORG BIGINT DEFAULT 0 NOT NULL,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL,
FORG_ID BIGINT DEFAULT 0 NOT NULL,
FRESOURCE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FEXPENSE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FORIGINAL_STATE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FACCOUNT_DATE DATETIME,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_MOTOR') 
 CREATE TABLE T_RIM_INV_MOTOR (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FBUYER_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FBUYER_CARDNO NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBUYER_TAX_NO NVARCHAR(20) DEFAULT ' ' NOT NULL,
FSALER_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FSALER_TAX_NO NVARCHAR(20) DEFAULT ' ' NOT NULL,
FSALER_ACCOUNT NVARCHAR(150) DEFAULT ' ' NOT NULL,
FSALER_PHONE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSALER_ADDRESS NVARCHAR(150) DEFAULT ' ' NOT NULL,
FSALER_BANK_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FVEHICLE_TYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBRAND_MODEL NVARCHAR(80) DEFAULT ' ' NOT NULL,
FPRODUCING_AREA NVARCHAR(30) DEFAULT ' ' NOT NULL,
FMACHINE_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FORIGINAL_INVOICE_CODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FORIGINAL_INVOICE_NO NVARCHAR(32) DEFAULT ' ' NOT NULL,
FCERTIFICATE_NUM NVARCHAR(32) DEFAULT ' ' NOT NULL,
FIMPORT_CERTIFICATE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FCOMMODITY_INSPECTION_NUM NVARCHAR(32) DEFAULT ' ' NOT NULL,
FENGINE_NUM NVARCHAR(60) DEFAULT ' ' NOT NULL,
FVEHICLE_IDENTIFICATION_CODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FOVER_TAX_CODE NVARCHAR(20) DEFAULT ' ' NOT NULL,
FTAX_AUTHORITY_CODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTAX_AUTHORITY_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTAX_RATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTAL_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICE_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTAL_TON NVARCHAR(50) DEFAULT ' ' NOT NULL,
FLIMITE_PEOPLE BIGINT DEFAULT 0 NOT NULL,
FPROXY_MARK NVARCHAR(4) DEFAULT ' ' NOT NULL,
FDRAWER NVARCHAR(20) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(300) DEFAULT ' ' NOT NULL,
FINVOICE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FINVALID_DATE DATETIME,
FTOTAL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCHECK_CODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTAX_ORG BIGINT DEFAULT 0 NOT NULL,
FORG_ID BIGINT DEFAULT 0 NOT NULL,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL,
FRESOURCE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FEXPENSE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FORIGINAL_STATE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FACCOUNT_DATE DATETIME,
FAUTHENTICATE_FLAG NVARCHAR(2) DEFAULT ' ' NOT NULL,
FAUTHENTICATE_TIME DATETIME,
FSELECT_TIME DATETIME,
FTAX_PERIOD DATETIME,
FEFFECTIVE_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEDUCTION_PURPOSE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FDEDUCTION_FLAG NVARCHAR(2) DEFAULT ' ' NOT NULL,
FMANAGE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FINVOICE_CODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_NO NVARCHAR(32) DEFAULT ' ' NOT NULL,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FINVOICE_DATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_ORDINARY') 
 CREATE TABLE T_RIM_INV_ORDINARY (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FINVOICE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FINVALID_DATE DATETIME,
FTOTAL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCHECK_CODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTAX_ORG BIGINT DEFAULT 0 NOT NULL,
FORG_ID BIGINT DEFAULT 0 NOT NULL,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL,
FRESOURCE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FEXPENSE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FORIGINAL_STATE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FACCOUNT_DATE DATETIME,
FSPLIT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTRANSPORT_DEDUCTION NVARCHAR(2) DEFAULT ' ' NOT NULL,
FAUTHENTICATE_TIME DATETIME,
FTAX_PERIOD DATETIME,
FEFFECTIVE_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEDUCTION_FLAG NVARCHAR(2) DEFAULT ' ' NOT NULL,
FINVOICE_CODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_NO NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_DATE DATETIME,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FSALER_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FSALER_TAX_NO NVARCHAR(20) DEFAULT ' ' NOT NULL,
FSALER_ADDRESS_PHONE NVARCHAR(150) DEFAULT ' ' NOT NULL,
FSALER_ACCOUNT NVARCHAR(150) DEFAULT ' ' NOT NULL,
FBUYER_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FBUYER_TAX_NO NVARCHAR(20) DEFAULT ' ' NOT NULL,
FBUYER_ADDRESS_PHONE NVARCHAR(150) DEFAULT ' ' NOT NULL,
FBUYER_ACCOUNT NVARCHAR(150) DEFAULT ' ' NOT NULL,
FINVOICE_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTAL_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(300) DEFAULT ' ' NOT NULL,
FMACHINE_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPROXY_MARK NVARCHAR(4) DEFAULT ' ' NOT NULL,
FDRAWER NVARCHAR(20) DEFAULT ' ' NOT NULL,
FREVIEWER NVARCHAR(20) DEFAULT ' ' NOT NULL,
FPAYEE NVARCHAR(20) DEFAULT ' ' NOT NULL,
FTYPE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FORIGINAL_INVOICE_CODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FORIGINAL_INVOICE_NO NVARCHAR(32) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_ORDINARY_ITEM') 
 CREATE TABLE T_RIM_INV_ORDINARY_ITEM (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FGOODS_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FGOODS_CODE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSPEC_MODEL NVARCHAR(30) DEFAULT ' ' NOT NULL,
FUNIT_PRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNUM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAX_RATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT NVARCHAR(20) DEFAULT ' ' NOT NULL,
FDETAIL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDISCOUNT_TYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FZEROTAXRATE_FLAG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPREFERENTIAL_POLICY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FVAT_EXCEPTION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FVERSION_NO NVARCHAR(16) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_OTHER') 
 CREATE TABLE T_RIM_INV_OTHER (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FTOTAL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(300) DEFAULT ' ' NOT NULL,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTAX_ORG BIGINT DEFAULT 0 NOT NULL,
FORG_ID BIGINT DEFAULT 0 NOT NULL,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL,
FRESOURCE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FEXPENSE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FORIGINAL_STATE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FACCOUNT_DATE DATETIME,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_QUOTA') 
 CREATE TABLE T_RIM_INV_QUOTA (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FINVOICE_CODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_NO NVARCHAR(32) DEFAULT ' ' NOT NULL,
FSALER_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FSALER_TAX_NO NVARCHAR(20) DEFAULT ' ' NOT NULL,
FTOTAL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(300) DEFAULT ' ' NOT NULL,
FPLACE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTAX_ORG BIGINT DEFAULT 0 NOT NULL,
FORG_ID BIGINT DEFAULT 0 NOT NULL,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL,
FRESOURCE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FEXPENSE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FORIGINAL_STATE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FACCOUNT_DATE DATETIME,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_SPECIAL') 
 CREATE TABLE T_RIM_INV_SPECIAL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FINVOICE_CODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_NO NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_DATE DATETIME,
FCHECK_CODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSALER_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FSALER_TAX_NO NVARCHAR(20) DEFAULT ' ' NOT NULL,
FSALER_ADDRESS_PHONE NVARCHAR(150) DEFAULT ' ' NOT NULL,
FSALER_ACCOUNT NVARCHAR(150) DEFAULT ' ' NOT NULL,
FBUYER_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FBUYER_TAX_NO NVARCHAR(20) DEFAULT ' ' NOT NULL,
FBUYER_ADDRESS_PHONE NVARCHAR(150) DEFAULT ' ' NOT NULL,
FBUYER_ACCOUNT NVARCHAR(150) DEFAULT ' ' NOT NULL,
FINVOICE_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTAL_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTAL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(300) DEFAULT ' ' NOT NULL,
FMACHINE_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPROXY_MARK NVARCHAR(4) DEFAULT ' ' NOT NULL,
FDRAWER NVARCHAR(20) DEFAULT ' ' NOT NULL,
FREVIEWER NVARCHAR(20) DEFAULT ' ' NOT NULL,
FPAYEE NVARCHAR(20) DEFAULT ' ' NOT NULL,
FINVOICE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORIGINAL_INVOICE_CODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FORIGINAL_INVOICE_NO NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVALID_DATE DATETIME,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTAX_ORG BIGINT DEFAULT 0 NOT NULL,
FORG_ID BIGINT DEFAULT 0 NOT NULL,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL,
FRESOURCE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FEXPENSE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FORIGINAL_STATE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FACCOUNT_DATE DATETIME,
FSPLIT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAUTHENTICATE_FLAG NVARCHAR(2) DEFAULT ' ' NOT NULL,
FAUTHENTICATE_TIME DATETIME,
FSELECT_TIME DATETIME,
FTAX_PERIOD DATETIME,
FEFFECTIVE_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEDUCTION_PURPOSE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FDEDUCTION_FLAG NVARCHAR(2) DEFAULT ' ' NOT NULL,
FMANAGE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_SPECIAL_ITEM') 
 CREATE TABLE T_RIM_INV_SPECIAL_ITEM (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FGOODS_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FGOODS_CODE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSPEC_MODEL NVARCHAR(30) DEFAULT ' ' NOT NULL,
FUNIT_PRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNUM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAX_RATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT NVARCHAR(20) DEFAULT ' ' NOT NULL,
FDETAIL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDISCOUNT_TYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FZEROTAXRATE_FLAG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPREFERENTIAL_POLICY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FVAT_EXCEPTION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FVERSION_NO NVARCHAR(16) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_TAX_PROOF') 
 CREATE TABLE T_RIM_INV_TAX_PROOF (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FBUYER_TAX_NO NVARCHAR(20) DEFAULT ' ' NOT NULL,
FBUYER_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FTOTAL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAX_PAID_PROOF_NO NVARCHAR(20) DEFAULT ' ' NOT NULL,
FTAX_AUTHORITY_NAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FINVOICE_DATE DATETIME,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTAX_ORG BIGINT DEFAULT 0 NOT NULL,
FORG_ID BIGINT DEFAULT 0 NOT NULL,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL,
FRESOURCE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FEXPENSE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FORIGINAL_STATE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FACCOUNT_DATE DATETIME,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_TAXI') 
 CREATE TABLE T_RIM_INV_TAXI (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FINVOICE_CODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_NO NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_DATE DATETIME,
FLICENSE_NUMBER NVARCHAR(20) DEFAULT ' ' NOT NULL,
FTIME_GET_ON NVARCHAR(10) DEFAULT ' ' NOT NULL,
FTIME_GET_OFF NVARCHAR(10) DEFAULT ' ' NOT NULL,
FPLACE NVARCHAR(20) DEFAULT ' ' NOT NULL,
FTOTAL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMILEAGE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTAX_ORG BIGINT DEFAULT 0 NOT NULL,
FORG_ID BIGINT DEFAULT 0 NOT NULL,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL,
FRESOURCE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FEXPENSE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FORIGINAL_STATE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FACCOUNT_DATE DATETIME,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_TOLL') 
 CREATE TABLE T_RIM_INV_TOLL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINVOICE_CODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_NO NVARCHAR(32) DEFAULT ' ' NOT NULL,
FORIGINAL_INVOICE_CODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FORIGINAL_INVOICE_NO NVARCHAR(32) DEFAULT ' ' NOT NULL,
FMACHINE_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINVOICE_DATE DATETIME,
FBUYER_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FBUYER_TAX_NO NVARCHAR(20) DEFAULT ' ' NOT NULL,
FBUYER_ADDRESS_PHONE NVARCHAR(120) DEFAULT ' ' NOT NULL,
FBUYER_ACCOUNT NVARCHAR(120) DEFAULT ' ' NOT NULL,
FSALER_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FSALER_TAX_NO NVARCHAR(20) DEFAULT ' ' NOT NULL,
FSALER_ACCOUNT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSALER_ADDRESS_PHONE NVARCHAR(120) DEFAULT ' ' NOT NULL,
FINVOICE_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTAL_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTAL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPROXY_MARK NVARCHAR(4) DEFAULT ' ' NOT NULL,
FDRAWER NVARCHAR(20) DEFAULT ' ' NOT NULL,
FREVIEWER NVARCHAR(20) DEFAULT ' ' NOT NULL,
FPAYEE NVARCHAR(20) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(300) DEFAULT ' ' NOT NULL,
FINVOICE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FINVALID_DATE DATETIME,
FCHECK_CODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTAX_ORG BIGINT DEFAULT 0 NOT NULL,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL,
FORG_ID BIGINT DEFAULT 0 NOT NULL,
FRESOURCE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FEXPENSE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FORIGINAL_STATE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FACCOUNT_DATE DATETIME,
FAUTHENTICATE_FLAG NVARCHAR(2) DEFAULT ' ' NOT NULL,
FAUTHENTICATE_TIME DATETIME,
FSELECT_TIME DATETIME,
FTAX_PERIOD DATETIME,
FEFFECTIVE_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEDUCTION_PURPOSE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FDEDUCTION_FLAG NVARCHAR(2) DEFAULT ' ' NOT NULL,
FMANAGE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_TOLL_ITEM') 
 CREATE TABLE T_RIM_INV_TOLL_ITEM (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FGOODS_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FGOODS_CODE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSPEC_MODEL NVARCHAR(20) DEFAULT ' ' NOT NULL,
FUNIT_PRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVEH_PLATE NVARCHAR(20) DEFAULT ' ' NOT NULL,
FSTART_DATE DATETIME,
FEND_DATE DATETIME,
FNUM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAX_RATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT NVARCHAR(20) DEFAULT ' ' NOT NULL,
FDETAIL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDISCOUNT_TYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FZEROTAXRATE_FLAG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPREFERENTIAL_POLICY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FVAT_EXCEPTION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FVERSION_NO NVARCHAR(16) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_TRAIN') 
 CREATE TABLE T_RIM_INV_TRAIN (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FSEQUENCE_NO NVARCHAR(32) DEFAULT ' ' NOT NULL,
FTRAIN_NUM NVARCHAR(16) DEFAULT ' ' NOT NULL,
FINVOICE_DATE DATETIME,
FTOTAL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSEAT_GRADE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FSTATION_GET_ON NVARCHAR(16) DEFAULT ' ' NOT NULL,
FSTATION_GET_OFF NVARCHAR(16) DEFAULT ' ' NOT NULL,
FPASSENGER_NAME NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTAX_RATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTOTAL_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTRAIN_TIME NVARCHAR(10) DEFAULT ' ' NOT NULL,
FTAX_ORG BIGINT DEFAULT 0 NOT NULL,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL,
FORG_ID BIGINT DEFAULT 0 NOT NULL,
FRESOURCE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FEXPENSE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FORIGINAL_STATE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FACCOUNT_DATE DATETIME,
FTRANSPORT_DEDUCTION NVARCHAR(2) DEFAULT ' ' NOT NULL,
FAUTHENTICATE_TIME DATETIME,
FTAX_PERIOD DATETIME,
FEFFECTIVE_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEDUCTION_FLAG NVARCHAR(2) DEFAULT ' ' NOT NULL,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_TRANSPORT') 
 CREATE TABLE T_RIM_INV_TRANSPORT (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FSEQUENCE_NO NVARCHAR(32) DEFAULT ' ' NOT NULL,
FTRAIN_NUM NVARCHAR(16) DEFAULT ' ' NOT NULL,
FINVOICE_DATE DATETIME,
FTOTAL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSEAT_GRADE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FSTATION_GET_ON NVARCHAR(16) DEFAULT ' ' NOT NULL,
FSTATION_GET_OFF NVARCHAR(16) DEFAULT ' ' NOT NULL,
FPASSENGER_NAME NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTAX_RATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTOTAL_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTIME NVARCHAR(10) DEFAULT ' ' NOT NULL,
FRESOURCE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FEXPENSE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FORIGINAL_STATE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FACCOUNT_DATE DATETIME,
FTRANSPORT_DEDUCTION NVARCHAR(2) DEFAULT ' ' NOT NULL,
FAUTHENTICATE_TIME DATETIME,
FTAX_PERIOD DATETIME,
FEFFECTIVE_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEDUCTION_FLAG NVARCHAR(2) DEFAULT ' ' NOT NULL,
FINVOICE_CODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_NO NVARCHAR(32) DEFAULT ' ' NOT NULL,
FORG_ID BIGINT DEFAULT 0 NOT NULL,
FTAX_ORG BIGINT DEFAULT 0 NOT NULL,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FINSURANCE_PREMIUM DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_USEDCAR') 
 CREATE TABLE T_RIM_INV_USEDCAR (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FINVOICE_CODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_NO NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_DATE DATETIME,
FBUYER_PHONE_NUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBUYER_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FBUYER_ID_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBUYER_ADDRESS NVARCHAR(120) DEFAULT ' ' NOT NULL,
FSALER_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FSALER_PHONE_NUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSALER_ID_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSALER_ADDRESS NVARCHAR(120) DEFAULT ' ' NOT NULL,
FLICENSE_PLATE_NUMBER NVARCHAR(20) DEFAULT ' ' NOT NULL,
FREGISTRATION_NUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FVEHICLE_TYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FVEHICLE_IDENTIFICATION_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBAND_MODEL NVARCHAR(30) DEFAULT ' ' NOT NULL,
FVEHICLE_MANAGEMENT_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTOTAL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAUCTION_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAUCTION_PHONE_NUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FAUCTION_ADDRESS NVARCHAR(120) DEFAULT ' ' NOT NULL,
FAUCTION_TAXPAYER_ID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FAUCTION_BANK_ACCOUT NVARCHAR(100) DEFAULT ' ' NOT NULL,
FMARKET_NAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FMARKET_PHONE_NUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FMARKET_ADDRESS NVARCHAR(120) DEFAULT ' ' NOT NULL,
FMARKET_TAXPAYER_ID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FMARKET_BANK_ACCOUT NVARCHAR(100) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(300) DEFAULT ' ' NOT NULL,
FINVOICE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FISSUING_OFFICE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDRAWER NVARCHAR(20) DEFAULT ' ' NOT NULL,
FCHECK_CODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMACHINE_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTAX_ORG BIGINT DEFAULT 0 NOT NULL,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL,
FORG_ID BIGINT DEFAULT 0 NOT NULL,
FRESOURCE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FEXPENSE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FORIGINAL_STATE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FACCOUNT_DATE DATETIME,
FAUTHENTICATE_FLAG NVARCHAR(2) DEFAULT ' ' NOT NULL,
FAUTHENTICATE_TIME DATETIME,
FSELECT_TIME DATETIME,
FTAX_PERIOD DATETIME,
FEFFECTIVE_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEDUCTION_PURPOSE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FDEDUCTION_FLAG NVARCHAR(2) DEFAULT ' ' NOT NULL,
FMANAGE_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INVOICE') 
 CREATE TABLE T_RIM_INVOICE (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FINVOICE_CODE NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_NO NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_DATE DATETIME,
FINVOICE_STATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINVOICE_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTAL_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTAL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSALER_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FSALER_TAX_NO NVARCHAR(20) DEFAULT ' ' NOT NULL,
FBUYER_NAME NVARCHAR(120) DEFAULT ' ' NOT NULL,
FBUYER_TAX_NO NVARCHAR(20) DEFAULT ' ' NOT NULL,
FAUTHENTICATE_FLAG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FAUTHENTICATE_TIME DATETIME,
FSELECT_TIME DATETIME,
FTAX_PERIOD DATETIME,
FEFFECTIVE_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEDUCTION_PURPOSE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDEDUCTION_FLAG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMANAGE_STATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCHECK_STATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCHECK_TIME DATETIME,
FCHECK_TIMES INT DEFAULT 0 NOT NULL,
FEXPENSE_STATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEXPENSE_TIME DATETIME,
FEXPENSE_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FVOUCH_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEXPENSE_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORIGINAL_STATE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORIGINAL_TIME DATETIME,
FACCOUNT_TIME DATETIME,
FACCOUNT_DATE DATETIME,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FRESOURCE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDELETE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINVOICE_INFO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FIS_REVISE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL,
FTAX_ORG BIGINT DEFAULT 0 NOT NULL,
FISVOUCHER NVARCHAR(2) DEFAULT ' ' NOT NULL,
FORG_ID BIGINT DEFAULT 0 NOT NULL,
FCOLLECT_TYPE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_EXPENSE') 
 CREATE TABLE T_RIM_EXPENSE (
FID BIGINT DEFAULT 0 NOT NULL,
FEXPENSE_NUM NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEXPENSE_ID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FREIMBURSING_ID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FEXPENSE_TYPE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FINVOICE_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXPENSE_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAPPROVE_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCREATOR_ID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATOR_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATOR_PHONE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATOR_EMAIL NVARCHAR(50) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(300) DEFAULT ' ' NOT NULL,
FRESOURCE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FUPDATE_TIME DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_VERIFY') 
 CREATE TABLE T_RIM_VERIFY (
FID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBASE_CONFIG NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FSENSITIVE_WORD NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FBLACK_LIST NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FCUSTOM_CONFIG NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FCREATER BIGINT DEFAULT 0 NOT NULL,
FMODIFIER BIGINT DEFAULT 0 NOT NULL,
FCREATE_TIME DATETIME,
FUPDATE_TIME DATETIME,
FSTATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FBILL_TYPE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FSCOPE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FSEQUENCE_TYPE NVARCHAR(2) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_VERIFY_ENTRY') 
 CREATE TABLE T_RIM_VERIFY_ENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FORG BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_VOUCH_RELATION') 
 CREATE TABLE T_RIM_VOUCH_RELATION (
FID BIGINT DEFAULT 0 NOT NULL,
FVOUCH_ID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FVOUCH_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILL_TYPE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FBILL_ID NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_VOUCH') 
 CREATE TABLE T_RIM_VOUCH (
FID BIGINT DEFAULT 0 NOT NULL,
FVOUCH_ID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FVOUCH_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FVOUCH_DATE DATETIME,
FBUSINESS_DATE DATETIME,
FACCOUNT_DATE DATETIME,
FVOUCH_TYPE NVARCHAR(20) DEFAULT ' ' NOT NULL,
FRESOURCE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FUPDATE_TIME DATETIME,
FCREATER BIGINT DEFAULT 0 NOT NULL,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_EXPENSE_RELATION') 
 CREATE TABLE T_RIM_EXPENSE_RELATION (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRY_ID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FRESOURCE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FEXPENSE_ID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FDEDUCTION_FLAG NVARCHAR(2) DEFAULT ' ' NOT NULL,
FDEDUCTION_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXPENSE_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCREATE_TIME DATETIME,
FCHECK_STATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(2) DEFAULT ' ' NOT NULL,
FEXPENSE_NUM NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_COVER_RELATION') 
 CREATE TABLE T_RIM_COVER_RELATION (
FID BIGINT DEFAULT 0 NOT NULL,
FEXPENSE_ID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FRESOURCE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FCOVER_ID NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_COVER') 
 CREATE TABLE T_RIM_COVER (
FID BIGINT DEFAULT 0 NOT NULL,
FCOVER_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCOVER_URL NVARCHAR(150) DEFAULT ' ' NOT NULL,
FSNAPSHOT_URL NVARCHAR(150) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FUPDATE_TIME DATETIME,
FRESOURCE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FCOVER_TYPE NVARCHAR(10) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_ATTACH') 
 CREATE TABLE T_RIM_ATTACH (
FID BIGINT DEFAULT 0 NOT NULL,
FATTACH_NO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FATTACH_URL NVARCHAR(200) DEFAULT ' ' NOT NULL,
FICON_URL NVARCHAR(200) DEFAULT ' ' NOT NULL,
FATTACH_NAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(300) DEFAULT ' ' NOT NULL,
FORIGINAL_NAME NVARCHAR(200) DEFAULT ' ' NOT NULL,
FSNAPSHOT_URL NVARCHAR(200) DEFAULT ' ' NOT NULL,
FUSER BIGINT DEFAULT 0 NOT NULL,
FCREATE_TIME DATETIME,
FUPDATE_TIME DATETIME,
FATTACH_TYPE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FATTACH_HASH_VALUE NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_ATTACH_RELATION') 
 CREATE TABLE T_RIM_ATTACH_RELATION (
FID BIGINT DEFAULT 0 NOT NULL,
FATTACH_ID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FRELATION_TYPE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FRELATION_ID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEXPENSE_ID NVARCHAR(50) DEFAULT ' ' NOT NULL
);

/**End D:\datamodel\pdm\PDM_UPGRADE_1.3\PDM_UPGRADE_1.3\PDM_UPGRADE\log\0515\RIM_table.sql **/
