ALTER TABLE VS4TPO ADD
	TPODDestination nvarchar(50) NULL,
	TPODTransportDesc money NULL,
	TPODDuty money NULL,
	TPODBaseIncoType smallint NULL,
	TPODDiscountText nvarchar(30) NULL,
	TPODDepositText nvarchar(30) NULL,
	TPODWTAXBase money NULL,
	TPODVATType smallint NULL,
	TPODTotal money NULL,
	TPODTotalInRate money NULL,
	TPODNetTotal money NULL
GO
UPDATE VS4TPO Set TPODCountryOrigin = (Select TCouName2 FROM VS4TCountry WHERE TCouCode=(select tapntcouCode from vs4tap where tapncode=TPODtapncode))
GO
UPDATE VS4TPO Set TPODDestination ='Thailand'
GO
UPDATE VS4TPO Set TPODBaseIncoType =TPODIncoType where TPODBaseIncoType is null
GO
UPDATE VS4TPO Set TPODTransportDesc=0 where TPODTransportDesc is null
GO
UPDATE VS4TPO Set TPODDuty=0 where TPODDuty is null
GO
UPDATE VS4TPO Set TPODWTAXBase=TPODTaxBase ,TPODVATType=TPODDepositVAT,TPODTotal=TPODGrandTotalVAT, TPODTotalInRate=TPODFirstPayment, TPODNetTotal=TPODWTAXRate
GO

UPDATE VS4TPO SET TPODDepositText=replace(''+convert(char(20),round(TPODDepositRate,2)),' ','') where TPODDepositRate > 0
GO
UPDATE VS4TPO SET TPODDepositText=TPODDepositText+'%' WHERE TPODDepositText<>''
GO

UPDATE VS4TPO SET TPODDiscountText=replace(''+convert(char(20),round(TPODDiscountPC,2)),' ','') where TPODDiscountPC > 0
GO
UPDATE VS4TPO SET TPODDiscountText=TPODDiscountText+'%' WHERE TPODDiscountText<>''
GO
UPDATE VS4TPO SET TPODDiscountText=TPODDiscountText+'+'+replace(''+convert(char(20),round(TPODDiscountFix,2)),' ','') where TPODDiscountFix > 0
GO

UPDATE VS4TPO Set TPODFlag2=TPODIncoType
GO
ALTER TABLE VS4TPO
	DROP COLUMN TPODIncoType,TPODBaseIncoType
GO
ALTER TABLE VS4TPO ADD
	TPODIncoType nvarchar(3) NULL,
	TPODBaseIncoType nvarchar(3) NULL
GO
UPDATE VS4TPO Set TPODIncoType='FOB' WHERE TPODFlag2=0
GO
UPDATE VS4TPO Set TPODIncoType='CIF' WHERE TPODFlag2=1
GO
UPDATE VS4TPO Set TPODIncoType='CFR' WHERE TPODFlag2=2
GO
UPDATE VS4TPO Set TPODIncoType='EXW' WHERE TPODFlag2=3
GO
UPDATE VS4TPO Set TPODBaseIncoType =TPODIncoType where TPODBaseIncoType is null
GO