ALTER TABLE VS4TPS ADD
	TPSDDestination nvarchar(50) NULL,
	TPSDTransportDesc money NULL,
	TPSDDuty money NULL,
	TPSDBaseIncoType smallint NULL,
	TPSDDiscountText nvarchar(30) NULL,
	TPSDDepositText nvarchar(30) NULL,
	TPSDWTAXBase money NULL,
	TPSDVATType smallint NULL,
	TPSDTotal money NULL,
	TPSDTotalInRate money NULL,
	TPSDNetTotal money NULL
GO
UPDATE VS4TPS Set TPSDCountryOrigin = (Select TCouName2 FROM VS4TCountry WHERE TCouCode=(select tapntcouCode from vs4tap where tapncode=tpsdtapncode))
GO
UPDATE VS4TPS Set TPSDDestination ='Thailand'
GO
UPDATE VS4TPS Set TPSDBaseIncoType =TPSDIncoType where TPSDBaseIncoType is null
GO
UPDATE VS4TPS Set TPSDTransportDesc=0 where TPSDTransportDesc is null
GO
UPDATE VS4TPS Set TPSDDuty=0 where TPSDDuty is null
GO
UPDATE VS4TPS Set TPSDWTAXBase=TPSDTaxBase ,TPSDVATType=TPSDDepositVAT,TPSDTotal=TPSDGrandTotalVAT, TPSDTotalInRate=TPSDFirstPayment, TPSDNetTotal=TPSDWTAXRate
GO

UPDATE VS4TPS SET TPSDDepositText=replace(''+convert(char(20),round(TPSDDepositRate,2)),' ','') where TPSDDepositRate > 0
GO
UPDATE VS4TPS SET TPSDDepositText=TPSDDepositText+'%' WHERE TPSDDepositText<>''
GO

UPDATE VS4TPS SET TPSDDiscountText=replace(''+convert(char(20),round(TPSDDiscountPC,2)),' ','') where TPSDDiscountPC > 0
GO
UPDATE VS4TPS SET TPSDDiscountText=TPSDDiscountText+'%' WHERE TPSDDiscountText<>''
GO
UPDATE VS4TPS SET TPSDDiscountText=TPSDDiscountText+'+'+replace(''+convert(char(20),round(TPSDDiscountFix,2)),' ','') where TPSDDiscountFix > 0
GO


UPDATE VS4TPS Set TPSDFlag2=TPSDIncoType
GO
ALTER TABLE VS4TPS
	DROP COLUMN TPSDIncoType,TPSDBaseIncoType
GO
ALTER TABLE VS4TPS ADD
	TPSDIncoType nvarchar(3) NULL,
	TPSDBaseIncoType nvarchar(3) NULL
GO
UPDATE VS4TPS Set TPSDIncoType='FOB' WHERE TPSDFlag2=0
GO
UPDATE VS4TPS Set TPSDIncoType='CIF' WHERE TPSDFlag2=1
GO
UPDATE VS4TPS Set TPSDIncoType='CFR' WHERE TPSDFlag2=2
GO
UPDATE VS4TPS Set TPSDIncoType='EXW' WHERE TPSDFlag2=3
GO
UPDATE VS4TPS Set TPSDBaseIncoType =TPSDIncoType where TPSDBaseIncoType is null
GO