Commit inicial: fuentes MBS ERP (Genero 6) + .gitignore + docs/SETUP_PC_MBS.md
This commit is contained in:
@@ -0,0 +1,347 @@
|
||||
{
|
||||
PROGRAMA : VEPRMT025
|
||||
DESARROLLADO POR : ING. JUAN SOTO
|
||||
FECHA : 03/05/2019
|
||||
OBJETIVO : AGRUPAR CLIENTES A UNA CUENTA CORPORATIVA
|
||||
}
|
||||
|
||||
|
||||
GLOBALS
|
||||
DEFINE usuarios,clave VARCHAR(50),
|
||||
arr_lista DYNAMIC ARRAY OF RECORD
|
||||
grupo VARCHAR(100),
|
||||
limite_cr1 DEC(12,2),
|
||||
condiciones VARCHAR(60),
|
||||
estado VARCHAR(30),
|
||||
pcod_grupo INT,
|
||||
pdescripcion VARCHAR(100)
|
||||
|
||||
END RECORD,
|
||||
idx INT,curr,scr_l SMALLINT,
|
||||
pcondicion ui.ComboBox
|
||||
|
||||
|
||||
END GLOBALS
|
||||
MAIN
|
||||
DEFER INTERRUPT
|
||||
CALL ARG_VAL(1) RETURNING usuarios
|
||||
CALL ARG_VAL(2) RETURNING clave
|
||||
|
||||
CALL STARTLOG("vecorporativo.txt")
|
||||
CONNECT to "smarmotech" USER usuarios USING clave
|
||||
CALL corporacion()
|
||||
END MAIN
|
||||
|
||||
FUNCTION corporacion()
|
||||
DEFINE centra RECORD
|
||||
codigo_grupo INT,
|
||||
descripcion VARCHAR(100),
|
||||
tipo_grupo SMALLINT,
|
||||
limite_cr_grupo DEC(12,2),
|
||||
cond_pago INT
|
||||
END RECORD,
|
||||
secuencia INT,
|
||||
total_cr DEC(12,2)
|
||||
|
||||
DEFINE arr_entra DYNAMIC ARRAY OF RECORD
|
||||
idrow INT,
|
||||
tipo_cliente smallint,
|
||||
sec_cliente int,
|
||||
nombre VARCHAR(100),
|
||||
limite_cr_cliente DEC(12,2),
|
||||
tasa DEC(12,2),
|
||||
limite_cr_rd DEC(12,2),
|
||||
pventas CHAR(1),
|
||||
borrar CHAR(1)
|
||||
END RECORD,
|
||||
operacion CHAR(1)
|
||||
OPEN WINDOW sucursales AT 7,12 WITH FORM "vefmwd022"
|
||||
ATTRIBUTE (BORDER,FORM LINE FIRST + 2,COMMENT LINE LAST,MESSAGE LINE LAST)
|
||||
|
||||
CALL ui.Interface.LoadStyles("mbsStyle")
|
||||
DIALOG ATTRIBUTE(UNBUFFERED)
|
||||
DISPLAY ARRAY arr_lista TO s_lista.*
|
||||
BEFORE DISPLAY
|
||||
LET operacion = "M"
|
||||
CALL lista_grupos()
|
||||
ON ACTION desactivar
|
||||
CALL desactiva(arr_lista[arr_curr()].pcod_grupo)
|
||||
CALL lista_grupos()
|
||||
ON ACTION activar
|
||||
CALL activar(arr_lista[arr_curr()].pcod_grupo)
|
||||
CALL lista_grupos()
|
||||
AFTER DISPLAY
|
||||
|
||||
LET centra.codigo_grupo = arr_lista[arr_curr()].pcod_grupo
|
||||
LET centra.descripcion = arr_lista[arr_curr()].pdescripcion
|
||||
LET centra.limite_cr_grupo = arr_lista[arr_curr()].limite_cr1
|
||||
DECLARE busca_clientes CURSOR FOR
|
||||
SELECT a.idrow, a.tipo_cliente,a.sec_cliente,b.nombre,b.limite_credito,a.ventas,a.tasa,a.limite_cr_rd
|
||||
FROM vetb00052 a,vetb00004 b,vetb00060 c
|
||||
WHERE a.codigo_grupo = centra.codigo_grupo AND a.tipo_cliente = b.tipo_cliente AND
|
||||
a.sec_cliente = b.sec_cliente AND
|
||||
b.tipo_cliente = c.tipo_cliente
|
||||
|
||||
LET idx = 1
|
||||
FOREACH busca_clientes INTO arr_entra[idx].idrow, arr_entra[idx].tipo_cliente,arr_entra[idx].sec_cliente,
|
||||
arr_entra[idx].nombre,arr_entra[idx].limite_cr_cliente,
|
||||
arr_entra[idx].pventas,arr_entra[idx].tasa,arr_entra[idx].limite_cr_rd
|
||||
LET arr_entra[idx].borrar='N'
|
||||
LET idx = idx +1
|
||||
END FOREACH
|
||||
|
||||
END DISPLAY
|
||||
|
||||
INPUT BY NAME centra.* ATTRIBUTE(WITHOUT DEFAULTS)
|
||||
AFTER FIELD descripcion
|
||||
IF centra.descripcion IS NULL THEN
|
||||
CALL msg(16)
|
||||
NEXT FIELD descripcion
|
||||
END IF
|
||||
BEFORE INPUT
|
||||
{ IF operacion = "N" THEN
|
||||
|
||||
INITIALIZE centra.* TO NULL
|
||||
DISPLAY BY NAME centra.*
|
||||
CALL arr_entra.clear()
|
||||
END IF}
|
||||
IF centra.tipo_grupo IS NULL THEN
|
||||
LET centra.tipo_grupo = 1
|
||||
END IF
|
||||
IF centra.descripcion IS NULL AND operacion <> "N" THEN
|
||||
CALL fgl_winmessage("INFO","NO ESTAS ELIJIENDO UN GRUPO DE CLIENTES PARA MODIFICAR, FAVOR DE USAR LA OPCION <NUEVO> DEL MENU","INFO")
|
||||
EXIT PROGRAM
|
||||
END IF
|
||||
LET pcondicion = ui.combobox.forname("formonly.cond_pago")
|
||||
CALL ccondicion()
|
||||
AFTER FIELD limite_cr_grupo
|
||||
IF centra.limite_cr_grupo IS NULL THEN
|
||||
CALL msg(16)
|
||||
NEXT FIELD limite_cr_grupo
|
||||
END IF
|
||||
AFTER INPUT
|
||||
DECLARE buscate CURSOR FOR
|
||||
SELECT a.idrow,a.tipo_cliente,a.sec_cliente,b.nombre,b.limite_credito,c.ventas,
|
||||
a.tasa,a.limite_cr_rd
|
||||
FROM vetb00052 a,vetb00004 b,vetb00060 c
|
||||
WHERE a.tipo_cliente = b.tipo_cliente AND a.tipo_cliente = c.tipo_cliente AND
|
||||
a.sec_cliente = b.sec_cliente AND a.codigo_grupo = centra.codigo_grupo
|
||||
ORDER BY a.tipo_cliente,a.sec_cliente
|
||||
|
||||
LET idx = 1
|
||||
FOREACH buscate INTO arr_entra[idx].idrow,arr_entra[idx].tipo_cliente,arr_entra[idx].sec_cliente,
|
||||
arr_entra[idx].nombre,arr_entra[idx].limite_cr_cliente,
|
||||
arr_entra[idx].pventas,arr_entra[idx].tasa,arr_entra[idx].limite_cr_rd
|
||||
LET arr_entra[idx].borrar='N'
|
||||
LET idx = idx + 1
|
||||
END FOREACH
|
||||
|
||||
END INPUT
|
||||
|
||||
INPUT ARRAY arr_entra FROM s_datos.* ATTRIBUTE(WITHOUT DEFAULTS)
|
||||
BEFORE INPUT
|
||||
CALL DIALOG.setactionactive("delete",FALSE)
|
||||
|
||||
BEFORE ROW
|
||||
LET curr = arr_curr()
|
||||
LET scr_l = scr_line()
|
||||
AFTER FIELD sec_cliente
|
||||
IF arr_entra[curr].sec_cliente IS NOT NULL THEN
|
||||
SELECT a.nombre,a.limite_credito,b.ventas
|
||||
INTO arr_entra[curr].nombre,arr_entra[curr].limite_cr_cliente,arr_entra[curr].pventas
|
||||
FROM vetb00004 a,vetb00060 b
|
||||
WHERE a.tipo_cliente = arr_entra[curr].tipo_cliente AND
|
||||
a.sec_cliente = arr_entra[curr].sec_cliente AND
|
||||
a.tipo_cliente = b.tipo_cliente AND
|
||||
a.status_t IS NULL
|
||||
|
||||
IF STATUS = NOTFOUND THEN
|
||||
CALL msg(3)
|
||||
NEXT FIELD tipo_cliente
|
||||
END IF
|
||||
LET arr_entra[curr].borrar='N'
|
||||
DISPLAY arr_entra[curr].nombre TO s_datos[scr_l].nombre
|
||||
END IF
|
||||
AFTER FIELD limite_cr_cliente
|
||||
IF arr_entra[curr].limite_cr_cliente IS NOT NULL THEN
|
||||
IF arr_entra[curr].pventas = 1 THEN
|
||||
LET arr_entra[curr].tasa = 1
|
||||
ELSE
|
||||
SELECT a.prima INTO arr_entra[curr].tasa FROM vetb00019 a
|
||||
WHERE disponible = "S"
|
||||
END IF
|
||||
LET arr_entra[curr].limite_cr_rd = arr_entra[curr].tasa * arr_entra[curr].limite_cr_cliente
|
||||
|
||||
END IF
|
||||
ON ACTION guardar
|
||||
# LET total_cr = 0
|
||||
# FOR idx = 1 TO arr_Entra.getLength()
|
||||
# IF arr_entra[idx].nombre IS NOT NULL AND arr_entra[idx].borrar = 'N' THEN
|
||||
# LET total_cr = arr_entra[idx].limite_cr_rd + total_cr
|
||||
# END IF
|
||||
|
||||
# END FOR
|
||||
# IF total_cr <> centra.limite_cr_grupo THEN
|
||||
# CALL fgl_winmessage("INFO","LIMITE DE CREDITO CLIENTES DIFIERE DEL TOTAL","INFO")
|
||||
# NEXT FIELD limite_cr_grupo
|
||||
# END IF
|
||||
#LET centra.limite_cr_grupo = total_cr
|
||||
|
||||
IF operacion = "N" THEN
|
||||
SELECT MAX(a.codigo_grupo) INTO secuencia FROM vetb00054 a
|
||||
IF secuencia IS NULL THEN
|
||||
LET secuencia = 0
|
||||
END IF
|
||||
LET centra.codigo_grupo = secuencia + 1
|
||||
IF centra.limite_cr_grupo IS NULL THEN
|
||||
LET centra.limite_cr_grupo = 0
|
||||
END IF
|
||||
IF centra.tipo_grupo IS NULL THEN
|
||||
LET centra.tipo_grupo=1
|
||||
END IF
|
||||
|
||||
BEGIN WORK
|
||||
INSERT INTO vetb00054 (codigo_grupo,tipo_grupo,limite_cr_grupo,descripcion,us_crea,fech_crea,cond_pago)
|
||||
VALUES (centra.codigo_grupo,centra.tipo_grupo,centra.limite_cr_grupo,centra.descripcion,usuarios,getdate(),
|
||||
centra.cond_pago)
|
||||
|
||||
|
||||
FOR idx =1 TO arr_count()
|
||||
IF arr_entra[idx].sec_cliente IS NOT NULL THEN
|
||||
|
||||
IF arr_entra[idx].borrar = "S" THEN
|
||||
CALL borra_row(arr_entra[idx].idrow)
|
||||
END IF
|
||||
SELECT DISTINCT a.tipo_cliente FROM vetb00052 a WHERE a.tipo_cliente = arr_entra[idx].tipo_cliente AND
|
||||
a.sec_cliente = arr_entra[idx].sec_cliente AND
|
||||
a.codigo_grupo <> centra.codigo_grupo
|
||||
IF STATUS <> NOTFOUND THEN
|
||||
ROLLBACK WORK
|
||||
CALL fgl_winmessage("INFO","CLIENTE ESTA ASIGNADO A OTRO GRUPO, NO PUEDES ADICIONARLO A ESTE","INFO")
|
||||
NEXT FIELD tipo_cliente
|
||||
END IF
|
||||
|
||||
INSERT INTO vetb00052 (codigo_grupo,tipo_cliente,sec_cliente,centra.descripcion,us_crea,
|
||||
fech_crea,tasa,limite_cr_rd,ventas)
|
||||
VALUES (centra.codigo_grupo,arr_entra[idx].tipo_cliente,
|
||||
arr_entra[idx].sec_cliente,centra.descripcion,
|
||||
usuarios,getdate(),arr_entra[idx].tasa,arr_entra[idx].limite_cr_rd,
|
||||
arr_entra[idx].pventas)
|
||||
|
||||
# UPDATE vetb00004 SET limite_credito = arr_entra[idx].limite_cr_cliente
|
||||
# WHERE tipo_cliente = arr_entra[idx].tipo_cliente AND sec_cliente = arr_entra[idx].sec_cliente
|
||||
END IF
|
||||
END FOR
|
||||
|
||||
CALL msg(13)
|
||||
COMMIT WORK
|
||||
ELSE
|
||||
IF centra.tipo_grupo IS NULL THEN
|
||||
LET centra.tipo_grupo = 1
|
||||
END IF
|
||||
IF centra.limite_cr_grupo IS NULL THEN
|
||||
LET centra.limite_cr_grupo = 0
|
||||
END IF
|
||||
|
||||
BEGIN WORK
|
||||
|
||||
UPDATE vetb00054 SET cond_pago = centra.cond_pago,
|
||||
limite_cr_grupo = centra.limite_cr_grupo,
|
||||
descripcion = centra.descripcion,
|
||||
tipo_grupo = centra.tipo_grupo,
|
||||
us_mod = usuarios,
|
||||
fech_mod = getdate()
|
||||
WHERE codigo_grupo = centra.codigo_grupo
|
||||
|
||||
|
||||
|
||||
FOR idx =1 TO arr_count()
|
||||
IF arr_entra[idx].sec_cliente IS NOT NULL THEN
|
||||
IF arr_entra[idx].borrar = "S" THEN
|
||||
CALL borra_row(arr_entra[idx].idrow)
|
||||
ELSE
|
||||
SELECT DISTINCT a.tipo_cliente FROM vetb00052 a WHERE a.tipo_cliente = arr_entra[idx].tipo_cliente
|
||||
AND a.sec_cliente=arr_entra[idx].sec_cliente
|
||||
IF STATUS = NOTFOUND THEN
|
||||
SELECT a.tipo_cliente FROM vetb00052 a WHERE a.tipo_cliente = arr_entra[idx].tipo_cliente AND
|
||||
a.sec_cliente = arr_entra[idx].sec_cliente AND
|
||||
a.codigo_grupo <> centra.codigo_grupo
|
||||
IF STATUS <> NOTFOUND THEN
|
||||
ROLLBACK WORK
|
||||
CALL fgl_winmessage("INFO","CLIENTE ESTA ASIGNADO A OTRO GRUPO, NO PUEDES ADICIONARLO A ESTE","INFO")
|
||||
NEXT FIELD tipo_cliente
|
||||
END IF
|
||||
|
||||
INSERT INTO vetb00052 (codigo_grupo,tipo_cliente,sec_cliente,centra.descripcion,us_crea,
|
||||
fech_crea,ventas,tasa,limite_cr_rd)
|
||||
VALUES (centra.codigo_grupo,arr_entra[idx].tipo_cliente,
|
||||
arr_entra[idx].sec_cliente,centra.descripcion,
|
||||
usuarios,getdate(),arr_entra[idx].pventas,arr_entra[idx].tasa,arr_entra[idx].limite_cr_rd)
|
||||
ELSE
|
||||
UPDATE vetb00052 SET limite_cr_rd = arr_entra[idx].limite_cr_rd
|
||||
WHERE codigo_grupo = centra.codigo_grupo AND tipo_cliente = arr_entra[idx].tipo_cliente AND
|
||||
sec_cliente = arr_entra[idx].sec_cliente
|
||||
|
||||
END IF
|
||||
# UPDATE vetb00004 SET limite_credito = arr_entra[idx].limite_cr_cliente
|
||||
|
||||
# WHERE tipo_cliente = arr_entra[idx].tipo_cliente AND sec_cliente = arr_entra[idx].sec_cliente
|
||||
END IF
|
||||
END IF
|
||||
END FOR
|
||||
CALL msg(13)
|
||||
COMMIT WORK
|
||||
END IF
|
||||
CALL lista_grupos()
|
||||
END INPUT
|
||||
|
||||
ON ACTION nuevo
|
||||
|
||||
LET operacion = "N"
|
||||
CALL arr_entra.clear()
|
||||
INITIALIZE centra.* TO NULL
|
||||
NEXT FIELD descripcion
|
||||
ON ACTION CANCEL
|
||||
EXIT PROGRAM
|
||||
|
||||
END DIALOG
|
||||
CLOSE WINDOW sucursales
|
||||
END FUNCTION
|
||||
FUNCTION lista_grupos()
|
||||
CALL arr_lista.clear()
|
||||
DECLARE busca_grupos CURSOR FOR
|
||||
SELECT CAST(a.codigo_grupo AS varchar(12))+'-'+a.descripcion,a.limite_cr_GRUPO,b.descrip,
|
||||
a.status_t,a.codigo_grupo,a.descripcion
|
||||
|
||||
FROM vetb00054 a LEFT OUTER JOIN vetb00012 b ON a.cond_pago = b.cond_pago
|
||||
ORDER BY a.descripcion
|
||||
|
||||
LET idx = 1
|
||||
FOREACH busca_grupos INTO arr_lista[idx].*
|
||||
IF arr_lista[idx].estado IS NULL THEN
|
||||
LET arr_lista[idx].estado = 'ACTIVO'
|
||||
ELSE
|
||||
LET arr_lista[idx].estado = 'DESACTIVADO'
|
||||
END IF
|
||||
|
||||
LET idx = idx + 1
|
||||
END FOREACH
|
||||
|
||||
END FUNCTION
|
||||
FUNCTION borra_row(id1)
|
||||
DEFINE id1 INT
|
||||
DISPLAY "borrar ",id1
|
||||
DELETE FROM vetb00052 WHERE idrow = id1
|
||||
END FUNCTION
|
||||
FUNCTION desactiva(codigo_Grupo1)
|
||||
DEFINE codigo_grupo1 INT
|
||||
|
||||
UPDATE vetb00054 SET status_t = 'E',fech_mod = getdate() WHERE codigo_grupo = codigo_grupo1
|
||||
CALL fgl_winmessage("INFO","GRUPO DESACTIVADO","INFO")
|
||||
END FUNCTION
|
||||
FUNCTION activar(codigo_Grupo1)
|
||||
DEFINE codigo_grupo1 INT
|
||||
|
||||
UPDATE vetb00054 SET status_t = NULL,fech_mod = getdate() WHERE codigo_grupo = codigo_grupo1
|
||||
CALL fgl_winmessage("INFO","GRUPO ACTIVADO","INFO")
|
||||
END FUNCTION
|
||||
Reference in New Issue
Block a user