TEXT TO cCmdBddVfac NOSHOW TEXTMERGE 


CREATE TABLE IF NOT EXISTS cxc (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  referencia varchar(30),
  fecha date,
  vence date,
  total double default 0,
  saldo double default 0,
  cuota int default 1,
  idcustomer int,
  idsalesman int,
  idinvoice int,
  idcuota int,
  idcc int,
  idcp int
);
--CREATE INDEX IF NOT EXISTS icxc ON cxc (idcustomer);


CREATE TABLE IF NOT EXISTS item (
  id varchar(12) PRIMARY KEY,
  name varchar(100) DEFAULT '',
  note text,
  noteunidad varchar(30),
  partnumber varchar(20) DEFAULT '',
  codigo2 varchar(20) DEFAULT '',
  price double DEFAULT 0,
  priceb double DEFAULT 0,
  pricec double DEFAULT 0,
  priced double DEFAULT 0,
  pricee double DEFAULT 0,
  idbrand varchar(8) default '',
  idgrupo varchar(9) default '',
  idsupplier varchar(12) default '',
  unidadescaja int DEFAULT 0,
  descEsp double DEFAULT 0,
  PromDesc double DEFAULT 0,
  PorcDesc1 double DEFAULT 0,
  PorcDesc2 double DEFAULT 0,
  PorcDesc3 double DEFAULT 0,
  PorcDesc4 double DEFAULT 0,
  PorcDesc5 double DEFAULT 0,
  iva int DEFAULT 0,
  isservice int default 0,
  tipo varchar(2) default '',    
  stock double DEFAULT 0,
  stkbod double DEFAULT 0
 );

CREATE TABLE IF NOT EXISTS customer (
  id integer PRIMARY KEY ,
  ruc varchar(20),
  name varchar(140),
  comercio varchar(140),
  address varchar(200),
  city varchar(40),
  email varchar(100),
  phone varchar(20),
  pvp numeric(1) DEFAULT 1,
  codigo varchar(20),
  opcionpvp integer,
  idsalesman integer,
  idzona integer,
  notas text,
  estado text,
  tipoclie integer,
  visitado integer,
  ruta integer,
  edicion integer,
  cupo numeric,
  secuencia numeric,
  horavisita text,
  saldo double,
  tipocliente int,
  diascredito int,
  idvisita int,
  longitud,
  latitud
  ) ;
  
--CREATE INDEX IF NOT EXISTS iruc ON customer (ruc);
--CREATE INDEX IF NOT EXISTS iidsalesman ON customer (idsalesman);

CREATE TABLE IF NOT EXISTS usuario (
  id varchar(8) PRIMARY KEY ,
  name varchar(60),
  login varchar(20),
  password varchar(20) ,
  clave varchar(20),
  nombre_empresa varchar (80),
  telf_empresa varchar (80),
  web_empresa varchar (80),
  direcc_empresa varchar (80),
  url_logo varchar (80),
  nro_lin_ped int,
  stock_linea int,
  lcontrol_stock int,
  control_cupos int,
  cambia_pvp int,
  crea_cliente int,
  venta_en_linea int,
  sincroniza_linea int,   
  tiempo_sincronizacion int,
  nota1 varchar(80),
  nota2 varchar(80),
  nota3 varchar(80),  
  idsalesman varchar(8),
  idcc varchar(10),
  idcp varchar(10),
  iddepartuser varchar(8),
  idemploy varchar(12),
  emailuser varchar(50),
  seriepv varchar(6),
  idbodega varchar(8)
);


/*

CREATE TABLE IF NOT EXISTS brand (
  id varchar(8) PRIMARY KEY,
  name varchar(50) DEFAULT '',
  codigo varchar(20) DEFAULT ''
  ) ;

CREATE TABLE IF NOT EXISTS grupo (
  id varchar(9) PRIMARY KEY,
  name varchar(50) DEFAULT '',
  grupo varchar(20) DEFAULT ''
);


CREATE TABLE IF NOT EXISTS promodef (
    id 			VARCHAR(10) 	default '',
    name		VARCHAR(60) 	default '',
    codigo		VARCHAR(20) 	default '',
    estado		INTEGER(1) 		default 0,
    cantbase	DOUBLE 			default 0,
    cantprom	DOUBLE 			default 0,
    iditempromo	VARCHAR(12) 	default '',
    pda			NUMERIC(5,2)    default 0,
    pdb			NUMERIC(5,2)    default 0,
    pdc			NUMERIC(5,2)    default 0,
    pdd			NUMERIC(5,2)    default 0,
    pde			NUMERIC(5,2)    default 0
) ;




CREATE TABLE IF NOT EXISTS supplier (
  id varchar(12) PRIMARY KEY,
  ruc varchar(20),
  name varchar(140),
  comercio varchar(140),
  address varchar(200),
  city varchar(40),
  email varchar(100),
  phone varchar(20)
  ) ;
  
--CREATE INDEX IF NOT EXISTS iruc  ON supplier (ruc);

CREATE TABLE IF NOT EXISTS salesman(
  id varchar(8) PRIMARY KEY,
  name varchar(100),
  code varchar(10),
  login varchar(20),
  clave varchar(20) DEFAULT '1234',
  nota varchar(150)
 ) ;		



CREATE TABLE IF NOT EXISTS user (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  name varchar(20),
  pw varchar(20) ,
  role int default 0,
  formapago int default 11,
  iduser varchar(8)
 );






CREATE TABLE IF NOT EXISTS zonas (
  id varchar(9) PRIMARY KEY ,
  name varchar(100)
);

CREATE TABLE IF NOT EXISTS bodega (
  id varchar(8) PRIMARY KEY ,
  name varchar(100)
);

CREATE TABLE IF NOT EXISTS centercost (
  id varchar(10) PRIMARY KEY ,
  name varchar(100)
);	


CREATE TABLE IF NOT EXISTS contprod (
  id varchar(10) PRIMARY KEY ,
  name varchar(100)
) ;


CREATE TABLE IF NOT EXISTS prom2 (
	idItem			VARCHAR(12) 	default '',
	idItemProm		VARCHAR(12) 	default ''
) ;
	
--CREATE INDEX IF NOT EXISTS iItem ON prom2 (idItem);
--CREATE INDEX IF NOT EXISTS iItemProm ON prom2 (idItemProm);
	

CREATE TABLE IF NOT EXISTS ctrl_venta (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  idsalesman varchar(8),
  idgrupo varchar(12),
  mes varchar(6),
  venta double DEFAULT 0,
  budget double DEFAULT 0
) ;

CREATE TABLE IF NOT EXISTS role (
  id INTEGER PRIMARY KEY autoincrement,
  role1 varchar(40),
  role2 varchar(40),
  role3 varchar(40),
  role4 varchar(40)
  ) ;


CREATE TABLE IF NOT EXISTS msg (
  id INTEGER PRIMARY KEY,
  idfrom int(10) default 0,
  idto int(10) default 0,
  prio int default 0,
  msg text,
  tiempo datetime ,
  tleido datetime ,
  estado int default 0
) ;
--CREATE INDEX IF NOT EXISTS ifrom ON msg (idfrom);
--CREATE INDEX IF NOT EXISTS ito ON msg (idto);

CREATE TABLE IF NOT EXISTS data_fin (
  id INTEGER PRIMARY KEY,
  bdd varchar(30),
  periodo varchar(6),
  code varchar(25),
  name varchar(240),
  idcc varchar(10),
  idcp varchar(10),
  valor double DEFAULT 0
) ;

CREATE TABLE IF NOT EXISTS plan (
  id INTEGER PRIMARY KEY,
  code varchar(25),
  name varchar(240),
  istrans int default 0,
  apc int default 0
) ;

CREATE TABLE IF NOT EXISTS bank (
  id varchar(8) PRIMARY KEY,
  name varchar(100)
) ;

CREATE TABLE IF NOT EXISTS tipoventa (
  id varchar(8) PRIMARY KEY ,
  name varchar(50)
) ;

CREATE TABLE IF NOT EXISTS costeo (
  id INTEGER PRIMARY KEY,
  idcp varchar(10),
  periodo varchar(6)
) ;

CREATE TABLE IF NOT EXISTS costeodet (
  id INTEGER PRIMARY KEY,
  idcosteo int(10) NOT NULL ,
  idcc varchar(10),
  idcp varchar(10),
  peso double DEFAULT 0,
  valor double DEFAULT 0
  ) ;
 
--CREATE INDEX IF NOT EXISTS icosteo ON costeodet (idcosteo);


CREATE TABLE IF NOT EXISTS periodo (
  id INTEGER PRIMARY KEY,
  periodo varchar(06),
  nombre varchar(30)
);
*/
endtext

RETURN cCmdBddVfac