UPDATE VS4TSO Set TSODCountryOrigin ='Thailand'
GO
ALTER TABLE VS4TSO ADD
	TSODTransportDesc money NULL,
	TSODDuty money NULL,
	TSODBaseIncoType smallint NULL,
	TSODDiscountText nvarchar(30) NULL,
	TSODDepositText nvarchar(30) NULL,
	TSODWTAXBase money NULL,
	TSODVATType smallint NULL,
	TSODTotal money NULL,
	TSODTotalInRate money NULL,
	TSODNetTotal money NULL
GO
UPDATE VS4TSO Set TSODBaseIncoType =TSODIncoType where TSODBaseIncoType is null
GO
UPDATE VS4TSO Set TSODTransportDesc=0 where TSODTransportDesc is null
GO
UPDATE VS4TSO Set TSODDuty=0 where TSODDuty is null
GO

UPDATE VS4TSO Set TSODWTAXBase=TSODTaxBase ,TSODVATType=TSODDepositVAT,TSODTotal=TSODGrandTotalVAT, TSODTotalInRate=TSODFirstPayment, TSODNetTotal=TSODWTAXRate
GO

UPDATE VS4TSO SET TSODDepositText=replace(''+convert(char(20),round(TSODDepositRate,2)),' ','') where TSODDepositRate > 0
GO
UPDATE VS4TSO SET TSODDepositText=TSODDepositText+'%' WHERE TSODDepositText<>''
GO

UPDATE VS4TSO SET TSODDiscountText=replace(''+convert(char(20),round(TSODDiscountPC,2)),' ','') where TSODDiscountPC > 0
GO
UPDATE VS4TSO SET TSODDiscountText=TSODDiscountText+'%' WHERE TSODDiscountText<>''
GO
UPDATE VS4TSO SET TSODDiscountText=TSODDiscountText+'+'+replace(''+convert(char(20),round(TSODDiscountFix,2)),' ','') where TSODDiscountFix > 0
GO

UPDATE VS4TSO Set TSODFlag2=TSODIncoType
GO
ALTER TABLE VS4TSO
	DROP COLUMN TSODIncoType,TSODBaseIncoType
GO
ALTER TABLE VS4TSO ADD
	TSODIncoType nvarchar(3) NULL,
	TSODBaseIncoType nvarchar(3) NULL
GO
UPDATE VS4TSO Set TSODIncoType='FOB' WHERE TSODFlag2=0
GO
UPDATE VS4TSO Set TSODIncoType='CIF' WHERE TSODFlag2=1
GO
UPDATE VS4TSO Set TSODIncoType='CFR' WHERE TSODFlag2=2
GO
UPDATE VS4TSO Set TSODIncoType='EXW' WHERE TSODFlag2=3
GO
UPDATE VS4TSO Set TSODBaseIncoType =TSODIncoType where TSODBaseIncoType is null
GO