/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MAL_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MAL_ORDER_XY') 
 CREATE TABLE T_MAL_ORDER_XY (
FID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FPORDERID VARCHAR(80) DEFAULT ' ' NOT NULL,
FORDERID VARCHAR(80) DEFAULT ' ' NOT NULL,
FSUBMITSTATE CHAR(1) DEFAULT ' ' NOT NULL,
FSTATE CHAR(1) DEFAULT ' ' NOT NULL,
FORDERSTATE CHAR(1) DEFAULT ' ' NOT NULL,
FFREIGHT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERNAKEDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICESTATE CHAR(1) DEFAULT ' ' NOT NULL,
FINVOICEID VARCHAR(50) DEFAULT ' ' NOT NULL,
FINVOICECODE VARCHAR(80) DEFAULT ' ' NOT NULL,
FINVOICEDATE DATETIME,
FINVOICETAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICETAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICETAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICEADDRESS VARCHAR(1000) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FCURRID BIGINT DEFAULT 0 NOT NULL,
FMARKID NVARCHAR(255) DEFAULT ' ' NOT NULL,
FINVOICETYPE CHAR(10) DEFAULT ' ' NOT NULL,
FINVOICERESULT NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MAL_ORDERENTRY_XY') 
 CREATE TABLE T_MAL_ORDERENTRY_XY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FGOODSID BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNAKEDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPACKAGEID VARCHAR(80) DEFAULT ' ' NOT NULL,
FSENDNO VARCHAR(80) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MAL_PRICEADJUSTENTRY' AND KSQL_COL_NAME ='FTAXRATEID') 
 ALTER TABLE T_MAL_PRICEADJUSTENTRY ADD (FTAXRATEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MAL_ORDERENTRY' AND KSQL_COL_NAME ='FTAXRATEID') 
 ALTER TABLE T_MAL_ORDERENTRY ADD (FTAXRATEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MAL_PROD' AND KSQL_COL_NAME ='FTAXRATEID') 
 ALTER TABLE T_MAL_PROD ADD (FTAXRATEID BIGINT DEFAULT 0 NOT NULL );

/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MAL_table.sql **/
