CxC: ccprrp018/003/001 con reporte Genero, ccprrp052 y ccprmt002 corregidos

- ccprrp018: agrega MAIN, GROUP BY por nombre, y reemplaza la salida Excel/DDE
  (G:\ESTADO.XLS, DEL G:\ESTADOS) por un reporte Genero (ccprrp018.4rp); carga con
  un solo INSERT...SELECT en tabla temporal.
- ccprrp003: reemplaza el REPORT de texto con codigos de impresora por
  ccprrp003.4rp; agrega por cliente en una consulta (DATEDIFF, mismas reglas).
- ccprrp001: agrega MAIN, GROUP BY por nombre, reporte Genero (ccprrp001.4rp) y
  registra el formulario ccfmrp001 en FORMULARIOS_CC (faltaba, -1110).
- ccprrp052: la validacion del campo Orden estaba al reves.
- ccprmt002: cctb00002.fecha es datetime en SQL Server; el formulario, la variable
  global relacion (ccprgb000) y el CONSTRUCT la manejan como DATE; corrige que
  eLiminar mostrara exito sin actualizar filas.
- mbsERP.4pw: registra los .4rp, libgre y ccfmrp001 (sin credenciales).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-07 15:23:22 -04:00
co-authored by Claude Sonnet 5.5
parent b52ccfae7f
commit 539af7f912
11 changed files with 654 additions and 477 deletions
+144 -5
View File
@@ -44,6 +44,20 @@ GLOBALS "ccprgb000.4gl"
CALL ccprrp003()
END MAIN
FUNCTION ccprrp003()
DEFINE sql_ag STRING, lit_corte STRING
DEFINE ag RECORD
tc, sc SMALLINT,
nom CHAR(30),
c1, c2, c3, c4, c5, tot DECIMAL(14,2)
END RECORD
DEFINE fila3 RECORD
grupo SMALLINT,
empresa STRING,
titulo STRING,
cliente STRING,
c1, c2, c3, c4, c5, total DECIMAL(14,2),
pct DECIMAL(8,2)
END RECORD
# WHENEVER ERROR CONTINUE
@@ -157,8 +171,20 @@ LABEL atras:
START REPORT reporte3 TO archivo
}
CALL seleccionarsalida() RETURNING r_output
CALL configureoutput(r_output) RETURNING handler
START REPORT reporte3 TO XML HANDLER HANDLER
CALL configureoutput3(r_output) RETURNING handler
IF handler IS NULL THEN
CALL fgl_winmessage("ERROR","No se pudo cargar ccprrp003.4rp","stop")
RETURN
END IF
CREATE TEMP TABLE s3
(
tipo_cliente SMALLINT,
sec_cliente SMALLINT,
nombre CHAR(30),
aplica_a INTEGER,
pendiente DECIMAL(12,2),
fecha_factura DATE
)
LET cmd = null
LET cmd = FGL_GETENV("FGLSPOOL")||"\\DATA.txt"
@@ -201,7 +227,11 @@ LET selec1 =
IF progreso > 50 THEN
LET progreso = 50
END IF
OUTPUT TO REPORT reporte3(doccli.*,tipo_venta,fecha_corte,valor_total)
IF doccli.fecha_factura IS NULL OR doccli.fecha_factura = MDY(12,31,1899) THEN
LET doccli.fecha_factura = MDY(1,1,2001)
END IF
INSERT INTO s3 VALUES (doccli.tipo_cliente, doccli.sec_cliente, doccli.nombre,
doccli.aplica_a, doccli.pendiente, doccli.fecha_factura)
OUTPUT TO REPORT reporte33(doccli.*,tipo_venta,fecha_corte,valor_total)
DISPLAY progreso TO progreso
@@ -250,7 +280,11 @@ LET selec3 =
LET progreso = 95
END IF
OUTPUT TO REPORT reporte3(doccli.*,tipo_venta,fecha_corte,valor_total)
IF doccli.fecha_factura IS NULL OR doccli.fecha_factura = MDY(12,31,1899) THEN
LET doccli.fecha_factura = MDY(1,1,2001)
END IF
INSERT INTO s3 VALUES (doccli.tipo_cliente, doccli.sec_cliente, doccli.nombre,
doccli.aplica_a, doccli.pendiente, doccli.fecha_factura)
OUTPUT TO REPORT reporte33(doccli.*,tipo_venta,fecha_corte,valor_total)
DISPLAY progreso TO progreso
@@ -259,7 +293,46 @@ LET selec3 =
LET progreso = 100
DISPLAY progreso to progreso
CALL ui.Interface.refresh()
FINISH REPORT reporte3
LET lit_corte = "CONVERT(DATE,'", fecha_corte USING "yyyy-mm-dd", "',23)"
LET sql_ag =
"SELECT tipo_cliente, sec_cliente, MAX(nombre), ",
" SUM(CASE WHEN DATEDIFF(day,fecha_factura,", lit_corte, ") <= 0 THEN pendiente ELSE 0 END), ",
" SUM(CASE WHEN DATEDIFF(day,fecha_factura,", lit_corte, ") BETWEEN 1 AND 30 THEN pendiente ELSE 0 END), ",
" SUM(CASE WHEN DATEDIFF(day,fecha_factura,", lit_corte, ") BETWEEN 31 AND 60 THEN pendiente ELSE 0 END), ",
" SUM(CASE WHEN DATEDIFF(day,fecha_factura,", lit_corte, ") BETWEEN 61 AND 90 THEN pendiente ELSE 0 END), ",
" SUM(CASE WHEN DATEDIFF(day,fecha_factura,", lit_corte, ") >= 91 THEN pendiente ELSE 0 END), ",
" SUM(pendiente) FROM s3 GROUP BY tipo_cliente, sec_cliente "
IF cero = "NO" THEN
LET sql_ag = sql_ag, " HAVING SUM(pendiente) <> 0 "
END IF
LET sql_ag = sql_ag, " ORDER BY tipo_cliente, sec_cliente "
START REPORT estado3 TO XML HANDLER handler
DECLARE c_ag CURSOR FROM sql_ag
FOREACH c_ag INTO ag.*
LET fila3.grupo = 1
LET fila3.empresa = p_companias.nombre CLIPPED
IF tipo_venta = "1" THEN
LET fila3.titulo = "Saldos por Antiguedad al ", fecha_corte USING "dd/mm/yyyy", " Valores en RD$"
ELSE
LET fila3.titulo = "Saldos por Antiguedad al ", fecha_corte USING "dd/mm/yyyy", " Valores en US$"
END IF
LET fila3.cliente = ag.tc USING "&&", "-", ag.sc USING "&&&&&", " ", ag.nom CLIPPED
LET fila3.c1 = ag.c1
LET fila3.c2 = ag.c2
LET fila3.c3 = ag.c3
LET fila3.c4 = ag.c4
LET fila3.c5 = ag.c5
LET fila3.total = ag.tot
IF valor_total IS NULL OR valor_total = 0 THEN
LET fila3.pct = 0
ELSE
LET fila3.pct = (ag.tot / valor_total) * 100
END IF
OUTPUT TO REPORT estado3(fila3.*)
END FOREACH
FINISH REPORT estado3
DROP TABLE s3
FINISH REPORT reporte33
CALL ui.Interface.frontCall("standard","getenv", ["CREDITO"], [dcmd] )
@@ -1061,4 +1134,70 @@ END FUNCTION
LET total_saldo = 0
END REPORT
FUNCTION configureoutput3(tipo_file)
DEFINE tipo_file CHAR(3)
IF NOT fgl_report_loadCurrentSettings("ccprrp003.4rp") THEN
RETURN NULL
END IF
CALL fgl_report_setPageMargins("0.5cm","0.5cm","0.5cm","0.5cm")
CALL fgl_report_selectDevice(tipo_file)
CALL fgl_report_configurexlsxdevice(null,null,null,false,false,null,1)
CALL fgl_report_selectPreview(TRUE)
RETURN fgl_report_commitCurrentSettings()
END FUNCTION
REPORT estado3(x)
DEFINE x RECORD
grupo SMALLINT,
empresa STRING,
titulo STRING,
cliente STRING,
c1, c2, c3, c4, c5, total DECIMAL(14,2),
pct DECIMAL(8,2)
END RECORD
DEFINE t30, t45, t60, tm60, tm120, tsaldo DECIMAL(14,2)
DEFINE ct30, ct45, ct60, ctm60, ctm120, ctsaldo DECIMAL(14,2)
ORDER EXTERNAL BY x.grupo
FORMAT
BEFORE GROUP OF x.grupo
LET t30 = 0
LET t45 = 0
LET t60 = 0
LET tm60 = 0
LET tm120 = 0
LET tsaldo = 0
LET ct30 = 0
LET ct45 = 0
LET ct60 = 0
LET ctm60 = 0
LET ctm120 = 0
LET ctsaldo = 0
PRINTX x.empresa, x.titulo
ON EVERY ROW
LET t30 = t30 + x.c1
LET t45 = t45 + x.c2
LET t60 = t60 + x.c3
LET tm60 = tm60 + x.c4
LET tm120 = tm120 + x.c5
LET tsaldo = tsaldo + x.total
IF x.c1 > 0 THEN LET ct30 = ct30 + x.c1 END IF
IF x.c2 > 0 THEN LET ct45 = ct45 + x.c2 END IF
IF x.c3 > 0 THEN LET ct60 = ct60 + x.c3 END IF
IF x.c4 > 0 THEN LET ctm60 = ctm60 + x.c4 END IF
IF x.c5 > 0 THEN LET ctm120 = ctm120 + x.c5 END IF
IF x.total > 0 THEN LET ctsaldo = ctsaldo + x.total END IF
PRINTX x.cliente, x.c1, x.c2, x.c3, x.c4, x.c5, x.total, x.pct
AFTER GROUP OF x.grupo
LET tot_gen2.total1 = t30
LET tot_gen2.total2 = t45
LET tot_gen2.total3 = t60
LET tot_gen2.total4 = tm60
LET tot_gen2.total5 = tsaldo
PRINTX t30, t45, t60, tm60, tm120, tsaldo,
ct30, ct45, ct60, ctm60, ctm120, ctsaldo
END REPORT