/*
Created		20/01/2009
Modified		15/09/2009
Project		ATS Vertical
Model		
Company		Landix Sistemas
Author		Keila Rodrigues e Tiago Morais
Version		01.00.00
Database		Firebird 
*/

Create Table TMVSEQP  (
	CDEQP Varchar(25) NOT NULL,
	CDCNX Varchar(25) NOT NULL,
	CDUNID Varchar(25) NOT NULL,
	CDPAI Varchar(25) NOT NULL,
	DSNOME Varchar(20),
	IDCRG Char(1) Default '1' NOT NULL,
 Primary Key (CDEQP)
);

Create Table TMVSPARAMGL  (
	CDRGST Varchar(25) NOT NULL,
	CDUSU Varchar(25) NOT NULL,
	CDTPVD Varchar(25) NOT NULL,
	DSSMTP Varchar(256),
	DSEMRT Varchar(256),
	DSEMTI Varchar(50),
	DSEMCF Varchar(256),
	DSTPAU Varchar(25),
	DSEMUS Varchar(50),
	DSEMSN Varchar(50),
	DSLMHS Varchar(256),
	DSLMUS Varchar(50),
	DSLMSH Varchar(50),
	DSLMSC Varchar(50),
	NULMPT Integer,
	IDLMAU Char(1) Default '0' NOT NULL,
	IDLMHS Char(1) Default '0' NOT NULL,
	NUDICR Integer Default 0 NOT NULL,
	IDTPCR Char(1) Default '0' NOT NULL,
	NRDNFP Integer Default 0 NOT NULL,
	IDLMLO Char(1) Default '0',
	HRVC1 Char(8),
	HRVC2 Char(8),
	HRVC3 Char(8),
	HRVC4 Char(8),
	HRVC5 Char(8),
	HRVCA1 Char(8),
	HRVCA2 Char(8),
	HRVCA3 Char(8),
	HRVCA4 Char(8),
	HRVCA5 Char(8),
	NUVERS Varchar(8),
	DTCRG Date Default '01/01/1900' NOT NULL,
	QTCOTA Decimal(15,4) Default 0,
	DSEMP Varchar(25),
	IDMSG Char(1) Default '0',
	IDMUR Char(1) Default '0',
	NUDRPD Integer Default 0 NOT NULL,
	DTHRVC Timestamp,
	IDVLCA Char(1) Default '0',
 Primary Key (CDRGST)
);

Create Table TMVSPARAM  (
	CDPRFL Varchar(25) NOT NULL,
	IDPDBL Char(1) Default '0' NOT NULL,
	NRDINA Integer Default 0 NOT NULL,
	IDDCMX Char(1) Default '0' NOT NULL,
	IDPERF Char(1) Default '0' NOT NULL,
	NUVALI Integer Default 0,
	IDDBCR Char(1) Default '0' NOT NULL,
	IDPDLC Char(1) Default '0' NOT NULL,
	IDVIND Char(1) Default '0',
	IDEMMS Char(1) Default '0',
	IDESTV Char(1) Default '0',
	PCDSMX Decimal(15,4) Default 0 NOT NULL,
	IDTRPP Char(1) Default '0',
 Primary Key (CDPRFL)
);

Create Table TMVSCBPEDRETORNO  (
	CDPED Varchar(25) NOT NULL,
	CDMW Varchar(39) NOT NULL,
	CDCL Varchar(25) NOT NULL,
	CDRET Varchar(25) NOT NULL,
	DTPED Timestamp NOT NULL,
	VLPED Decimal(15,4) Default 0 NOT NULL,
	DTPROC Timestamp NOT NULL,
	DSMSG Varchar(300),
 Primary Key (CDPED)
);

Create Table TMVSITPEDRETORNO  (
	CDPED Varchar(25) NOT NULL,
	CDPROD Varchar(25) NOT NULL,
	QTDVND Decimal(15,4) Default 0 NOT NULL,
	QTDATE Decimal(15,4) Default 0,
	QTFALT Decimal(15,4) Default 0,
	DSMSG Varchar(300),
 Primary Key (CDPED,CDPROD)
);

Create Table TMVSSTSRETORNO  (
	CDRET Integer NOT NULL,
	IDSTS Char(1),
	DSMSG Varchar(300),
 Primary Key (CDRET)
);

Create Table TMVSITE  (
	CDPED Varchar(25) NOT NULL,
	CDPROD Varchar(25) NOT NULL,
	CDGRAD Varchar(25) NOT NULL,
	QTDVND Decimal(15,4) Default 0 NOT NULL,
	VLTAB Decimal(15,4) Default 0 NOT NULL,
	VLVEND Decimal(15,4) Default 0 NOT NULL,
	PCDSAC Decimal(15,4) Default 0 NOT NULL,
	VLPROD Decimal(15,4) Default 0,
 Primary Key (CDPED,CDPROD,CDGRAD)
);

Create Table TMVSCAB  (
	CDPED Varchar(25) NOT NULL,
	CDTPVD Varchar(25) NOT NULL,
	CDCNPG Varchar(25) NOT NULL,
	CDEQP Varchar(25) NOT NULL,
	CDCL Varchar(25) NOT NULL,
	DTCRIA Timestamp,
	DTALT Timestamp,
	DTFECH Timestamp,
	VLPED Decimal(15,4) Default 0 NOT NULL,
	DSOBS Varchar(127),
	NUPECL Varchar(25),
	DTPROC Timestamp NOT NULL,
	NUPROC Varchar(25) NOT NULL,
	IDEXP Char(1),
	DSMSEX Varchar(4000),
	IDSTS Char(1),
	CDMW Varchar(39) Default '0' NOT NULL,
 Primary Key (CDPED)
);

Create Table TMVSMNVCL  (
	CDINC Integer NOT NULL,
	CDCL Varchar(25) NOT NULL,
	CDMOT Varchar(25) NOT NULL,
	CDEQP Varchar(25) NOT NULL,
	DTMNV Timestamp NOT NULL,
	DTPROC Timestamp NOT NULL,
	NUPROC Varchar(25) NOT NULL,
	IDEXP Char(1),
	DSMSEX Varchar(4000),
	IDSTS Char(1) Default '0',
 Primary Key (CDINC)
);

Create Table TMVSVDCL  (
	CDEQP Varchar(25) NOT NULL,
	CDCL Varchar(25) NOT NULL,
	IDIAE Char(1),
 Primary Key (CDEQP)
);

Create Table TMVSCLIALT  (
	CDCL Varchar(25) NOT NULL,
	CDCID Varchar(25) NOT NULL,
	CDATIV Varchar(25) NOT NULL,
	CDCNPG Varchar(25) NOT NULL,
	CDEQP Varchar(25) NOT NULL,
	CDTPVD Varchar(25) NOT NULL,
	DSRAZ Varchar(40),
	DSFAN Varchar(40),
	DSCGCP Varchar(20),
	DSIERG Varchar(20),
	VLCRED Decimal(15,4),
	IDPFPJ Char(1),
	IDBLQ Char(1) Default '0',
	IDTITV Char(1) Default '0',
	NUDSIN Integer Default 0,
	DSOBS Varchar(40),
	DSENDP Varchar(40),
	DSBAIP Varchar(40),
	DSCEPP Varchar(10),
	DSTLPR Varchar(15),
	DSFAXP Varchar(15),
	DSENDC Varchar(40),
	DSBAIC Varchar(40),
	CDCIDC Varchar(25),
	DSCEPC Varchar(10),
	IDIAE Char(1),
	DSEDEN Varchar(60),
	CDCIDE Varchar(25),
	DSBAEN Varchar(30),
	NUCPEN Varchar(8),
	DTPROC Timestamp NOT NULL,
	NUPROC Varchar(25) NOT NULL,
	IDEXP Char(1),
	DSMSEX Varchar(4000),
 Primary Key (CDCL)
);

Create Table TMVSCTT  (
	CDCL Varchar(25) NOT NULL,
	DSCTT Varchar(30) NOT NULL,
	NRTCTT Varchar(15),
	DSEMAI Varchar(30),
	DSDEP Varchar(30),
	IDIAE Char(1) Default '0',
	DTPROC Timestamp NOT NULL,
	NUPROC Varchar(25) NOT NULL,
	IDEXP Char(1),
	DSMSEX Varchar(4000),
 Primary Key (CDCL,DSCTT)
);

Create Table TAFCTT  (
	COD_CLIENTE Varchar(25) NOT NULL,
	NOM_CONTATO Varchar(30) NOT NULL,
	NUM_TELEFONE Varchar(15),
	DES_EMAIL Varchar(30),
	IDIAE Char(1) Default '0',
	DSDEP Varchar(30),
	IMPORTADO Varchar(25) NOT NULL,
	DTPROC Timestamp NOT NULL,
	NUPROC Varchar(25) NOT NULL,
	MSG_IMPORTACAO Varchar(300),
 Primary Key (COD_CLIENTE,NOM_CONTATO)
);

Create Table TAFITE  (
	COD_PEDIDO Varchar(25) NOT NULL,
	COD_PRODUTO Varchar(25) NOT NULL,
	COD_GRADE Varchar(25) NOT NULL,
	VLR_TABELA Decimal(15,4) Default 0 NOT NULL,
	VLR_VENDA Decimal(15,4) Default 0 NOT NULL,
	VLR_TOTPROD Decimal(15,4) Default 0,
	PER_DESCONTO Decimal(15,4) Default 0 NOT NULL,
	QTD_VENDA Decimal(15,4) Default 0 NOT NULL,
	QTDE_ATENDIDA Decimal(15,4) Default 0,
	QTDE_FALTA Decimal(15,4) Default 0,
	MSG_IMPORTACAO Varchar(300),
 Primary Key (COD_PEDIDO,COD_PRODUTO,COD_GRADE)
);

Create Table TAFCLIALT  (
	COD_CLIENTE Varchar(25) NOT NULL,
	COD_TIPOVENDA Varchar(25) NOT NULL,
	COD_CONDPGTO Varchar(25) NOT NULL,
	COD_RAMOATIV Varchar(25) NOT NULL,
	COD_VENDEDOR Varchar(25) NOT NULL,
	DES_RAZAO Varchar(40),
	DES_FANTASIA Varchar(40),
	NUM_CGCCPF Varchar(20),
	NUM_IERG Varchar(20),
	VLR_CREDITO Decimal(15,4),
	IDF_TIPPESSOA Char(1),
	IDF_BLOQUEIO Char(1) Default '0',
	IDF_TITULOS Char(1) Default '0',
	DES_OBS Varchar(40),
	COD_CIDPRIN Varchar(25),
	DES_ENDERECO Varchar(40),
	DES_BAIRRO Varchar(40),
	NUM_CEP Varchar(10),
	NUM_TELEFONE Varchar(15),
	NUM_FAX Varchar(15),
	COD_CIDCOB Varchar(25),
	DES_ENDERECOCOB Varchar(40),
	DES_BAIRROCOB Varchar(40),
	NUM_CEPCOB Varchar(10),
	COD_CIDENT Varchar(25),
	DES_ENDERECOENT Varchar(60),
	DES_BAIRROENT Varchar(30),
	NUM_CEPENT Varchar(8),
	IDIAE Char(1),
	MSG_IMPORTACAO Varchar(300),
	IMPORTADO Varchar(25) NOT NULL,
	DTPROC Timestamp NOT NULL,
	NUPROC Varchar(25) NOT NULL,
 Primary Key (COD_CLIENTE)
);

Create Table TAFMNVCL  (
	NUM_MOT_NVENDA Integer NOT NULL,
	COD_VENDEDOR Varchar(25) NOT NULL,
	COD_CLIENTE Varchar(25) NOT NULL,
	COD_MOTNVENDA Varchar(25) NOT NULL,
	DAT_INCLUSAO Timestamp NOT NULL,
	IMPORTADO Varchar(25) NOT NULL,
	DTPROC Timestamp NOT NULL,
	NUPROC Varchar(25) NOT NULL,
	MSG_IMPORTACAO Varchar(300),
 Primary Key (NUM_MOT_NVENDA)
);

Create Table TAFCAB  (
	COD_PEDIDO Varchar(25) NOT NULL,
	COD_VENDEDOR Varchar(25) NOT NULL,
	COD_CONDPAGTO Varchar(25) NOT NULL,
	COD_CLIENTE Varchar(25) NOT NULL,
	COD_TIPOVENDA Varchar(25) NOT NULL,
	DAT_HORACRIACAOPED Timestamp,
	DAT_HORAALTERPED Timestamp,
	DAT_HORAFECHPED Timestamp,
	VLR_TOTAL Decimal(15,4) Default 0 NOT NULL,
	DES_OBS Varchar(127),
	NUM_PEDCLI Varchar(25),
	CDMW Varchar(39) NOT NULL,
	IMPORTADO Varchar(25) NOT NULL,
	DTPROC Timestamp NOT NULL,
	NUPROC Varchar(25) NOT NULL,
	MSG_IMPORTACAO Varchar(300),
 Primary Key (COD_PEDIDO)
);

Create Table TMVSRET  (
	CDRET Varchar(25) NOT NULL,
	DSRET Varchar(30),
 Primary Key (CDRET)
);


