--------------------------------------------------------------------------
-- Play this script in PRUEBAS@VISANY to make it look like DESA@VISMAR
--                                                                      --
-- Please review the script before using it to make sure it won't       --
-- cause any unacceptable data loss.                                    --
--                                                                      --
-- PRUEBAS@VISANY Schema Extracted by User PRUEBAS 
-- DESA@VISMAR Schema Extracted by User DESA 

-- Difference : Column Order (No action taken) 

ALTER TABLE CXP_ENC_GEN_PAGO
MODIFY(COD_BANCO VARCHAR2(12 BYTE) NOT NULL);

ALTER TABLE CXP_ENC_GEN_PAGO
MODIFY(CUENTA  NOT NULL);

ALTER TABLE CXP_ENC_GEN_PAGO
MODIFY(MONTO  DEFAULT 0);

ALTER TABLE CXP_PARAMETRO
 ADD (TIPO_MOV_DEB  CHAR(2 BYTE));

ALTER TABLE CXP_PARAMETRO
 ADD (IND_CON_PEL  CHAR(1 BYTE)                     DEFAULT 'N'                   NOT NULL);

ALTER TABLE CXP_CREDITO
 ADD (COD_BANCO  VARCHAR2(12 BYTE));

--
-- CXP_OBLIG_VIEW  (View) 
--
CREATE OR REPLACE FORCE VIEW CXP_OBLIG_VIEW
(COD_CIA, SUCURSAL, TIP_DOC, NUM_DOC, NUM_PARTE, 
 COD_PROVEEDOR, FEC_VENCE, MON_PAGO, MON_SALDO, COD_MONEDA)
AS 
select o.cod_cia, o.sucursal, o.tip_doc, o.num_doc, 
       o.num_parte, m.cod_proveedor, o.fec_vence, 
       o.mon_pago, o.mon_saldo, m.cod_moneda
from   cxp_obligacion o, cxp_enc_movimiento m
where  o.cod_cia=m.cod_cia
  and  o.sucursal=m.sucursal
  and  o.tip_doc=m.tip_doc
  and  o.num_doc=m.num_doc
  and m.estado='A';

--
-- CXP_LIQUIDACION  (View) 
--
CREATE OR REPLACE FORCE VIEW CXP_LIQUIDACION
(COD_CIA, COD_PROVEEDOR, SUCURSAL, TIP_DOC, NUM_DOC, 
 SUCURSAL_REF, TIP_DOC_REF, NUM_DOC_REF, MON_PAGO, FEC_DOC, 
 NUM_ASIENTO, MON_DESCUENTO, INTERES, INT_MORA, COD_MONEDA, 
 DOC_REF)
AS 
select a.cod_cia, b.cod_proveedor, a.sucursal, a.tip_doc, 
       a.num_doc, a.sucursal_ref, a.tip_doc_ref, a.num_doc_ref, 
       a.mon_pago, b.fec_doc, b.num_asiento,  a.mon_descuento, a.interes, 
a.int_mora, b.cod_moneda, b.doc_ref
from CXP_DET_PAGO_NOTA a, CXP_ENC_PAGO_NOTA b
where a.cod_cia = b.cod_cia
  and a.sucursal = b.sucursal
  and a.tip_doc = b.tip_doc
  and a.num_doc = b.num_doc
  and b.estado = 'A'
  and b.tip_doc_ref is not null;

ALTER TABLE CXP_ASIENTO
 ADD CONSTRAINT CXP_ASIENTO_PK
 PRIMARY KEY
 (COD_CIA, SUCURSAL, TIP_DOC, COD_MONEDA, TIP_CAMBIO, COD_CTA, CCOSTO, DEBITOS, CREDITOS);

ALTER TABLE CXP_ENC_GEN_PAGO
 DROP CONSTRAINT CXP_ENC_GENPG_FOR_PAG_CK;
ALTER TABLE CXP_ENC_GEN_PAGO
 ADD CONSTRAINT CXP_ENC_GENPG_FOR_PAG_CK
 CHECK (ind_forma_pago in ('E','C','T','F'));

ALTER TABLE CXP_PARAMETRO
 ADD CONSTRAINT CXP_PARAMETRO_IND_CONPEL
 CHECK (ind_con_pel in ('S','N'));

ALTER TABLE CXP_ENC_PAGO_NOTA
 DROP CONSTRAINT CXP_ENC_PGNT_FOR_PAG_CK;
ALTER TABLE CXP_ENC_PAGO_NOTA
 ADD CONSTRAINT CXP_ENC_PGNT_FOR_PAG_CK
 CHECK (ind_forma_pago in ('E','C','T','F'));

_