Commit inicial: fuentes MBS ERP (Genero 6) + .gitignore + docs/SETUP_PC_MBS.md
This commit is contained in:
@@ -0,0 +1,323 @@
|
||||
{-------------------------------------------------------------------------------
|
||||
PROGRAMA : VEPRRP055
|
||||
OBJETIVO : Ordenes de producion x áreas
|
||||
PROGRAMADOR : Valentin Rodriguez.
|
||||
FECHA REALIZACION : Enero 11,2019
|
||||
-------------------------------------------------------------------------------}
|
||||
|
||||
SCHEMA "smarmotech"
|
||||
GLOBALS
|
||||
DEFINE datos RECORD
|
||||
fecha_inicial DATE,
|
||||
fecha_final DATE,
|
||||
modo_plantilla CHAR(1)
|
||||
END RECORD,
|
||||
usuarios VARCHAR(20),
|
||||
clave VARCHAR(20),
|
||||
selec STRING,
|
||||
selec2 STRING,
|
||||
pcompanias RECORD LIKE companias.*,
|
||||
idx int,
|
||||
cg LIKE prtb00013.cod_grupo,
|
||||
ct LIKE prtb00013.cod_tipo,
|
||||
cs LIKE prtb00013.cod_sec,
|
||||
cn LIKE prtb00013.cod_n,
|
||||
nc LIKE prtb00012.num_oc,
|
||||
cantidadPend,
|
||||
valorPend,
|
||||
valorOrd,
|
||||
valorCot FLOAT
|
||||
|
||||
DEFINE ordenesProd RECORD
|
||||
equipo LIKE seg0008.nombre,
|
||||
vendedor LIKE seg0000.nombre,
|
||||
cotizacion_no LIKE prtb00012.cotizacion_no,
|
||||
num_oc LIKE prtb00012.num_oc,
|
||||
producto LIKE prtb00002.descripcion,
|
||||
precio LIKE prtb00013.precio,
|
||||
tasa LIKE cgtb00084.tasa,
|
||||
descuento LIKE prtb00013.precio,
|
||||
cantidad_ordenada LIKE prtb00013.cantidad,
|
||||
cod_grupo LIKE prtb00013.cod_grupo,
|
||||
cod_tipo LIKE prtb00013.cod_tipo,
|
||||
cod_sec LIKE prtb00013.cod_sec,
|
||||
cod_n LIKE prtb00013.cod_n,
|
||||
cantidad_despachada LIKE iptb00006.cantidad_2
|
||||
END RECORD
|
||||
END GLOBALS
|
||||
|
||||
MAIN
|
||||
DEFER INTERRUPT
|
||||
CALL ARG_VAL(1) RETURNING usuarios
|
||||
CALL ARG_VAL(2) RETURNING clave
|
||||
CONNECT TO "smarmotech" USER usuarios USING clave
|
||||
|
||||
SELECT * INTO pcompanias.* FROM companias
|
||||
CALL OrdenProducionXareas()
|
||||
END MAIN
|
||||
|
||||
FUNCTION OrdenProducionXareas()
|
||||
DEFINE handler om.SaxDocumentHandler, -- return value from fgl_report_commitCurrentSettings()
|
||||
r_filename STRING, -- filename of Report Design Document including .4rp extension
|
||||
r_output STRING, -- output format option
|
||||
preview INTEGER, -- TRUE/FALSE, to set preview option
|
||||
criterio STRING
|
||||
|
||||
OPEN WINDOW HOME_FRM WITH FORM 'vefmrp055'
|
||||
DIALOG ATTRIBUTE(UNBUFFERED)
|
||||
INPUT BY NAME datos .*
|
||||
|
||||
AFTER FIELD fecha_inicial
|
||||
IF datos.fecha_inicial IS NULL THEN
|
||||
CALL fgl_winmessage("INFO", "DEBE INDICAR UNA FECHA INICIAL DE BUSQUEDA", "INFO")
|
||||
NEXT FIELD fecha_inicial
|
||||
END IF
|
||||
|
||||
AFTER FIELD fecha_final
|
||||
IF datos.fecha_final IS NULL THEN
|
||||
CALL fgl_winmessage("INFO", "DEBE INDICAR UNA FECHA FINAL DE BUSQUEDA", "INFO")
|
||||
NEXT FIELD fecha_final
|
||||
END IF
|
||||
|
||||
IF datos.fecha_final < datos.fecha_inicial THEN
|
||||
CALL fgl_winmessage("INFO", "LA FECHA FINAL DEBE SER MAS RECIENTE A LA INICIAL", "INFO")
|
||||
NEXT FIELD fecha_final
|
||||
END IF
|
||||
END INPUT
|
||||
|
||||
CONSTRUCT criterio ON c.cod_n, c.cod_grupo, c.cod_tipo, c.cod_sec, a.num_oc, a.cerrada, g.depto, a.sec_vend
|
||||
FROM cod_n, cod_grupo, cod_tipo, cod_sec, orden, cerrada, equipos, kvendedor
|
||||
BEFORE CONSTRUCT
|
||||
CALL cequipos()
|
||||
CALL cvendedor(usuarios)
|
||||
ON ACTION mostrar
|
||||
LET selec = "select g.nombre, '('+cast(x.num_emp as varchar(6))+')'+ISNULL(rtrim(x.nom1_emp),' ')+isnull(rtrim(x.apell1_emp),' '), a.cotizacion_no, a.num_oc,
|
||||
'('+cast(c.cod_n as varchar(5))+cast(c.cod_grupo as varchar(5))+cast(c.cod_tipo as varchar(5))+cast(c.cod_sec as varchar(5))+')' +' '+ ISNULL(h.descrip_esp,' '),
|
||||
c.precio, i.tasa, c.descuento, SUM(c.cantidad), c.cod_grupo, c.cod_tipo, c.cod_sec, c.cod_n
|
||||
from prtb00013 c
|
||||
inner join prtb00012 a on a.num_oc = c.num_oc
|
||||
inner join adtb00003 x on x.num_emp = a.sec_vend
|
||||
inner join seg0000 f on a.sec_vend = f.sec_vend
|
||||
inner join seg0008 g on f.depto = g.depto
|
||||
inner join iptb00002 h on c.cod_n = h.cod_n and c.cod_grupo = h.cod_grupo and c.cod_tipo = h.cod_tipo and c.cod_sec = h.cod_sec
|
||||
inner join cgtb00084 i on a.tipo_cliente = i.tipo_cliente and a.ventas = i.ventas
|
||||
inner join prdtable j on i.mes = j.mes and i.ano = j.ano
|
||||
where " , criterio CLIPPED, " and ","
|
||||
i.ano between year('", datos.fecha_inicial USING "mm/dd/yyyy" ,"') and year('", datos.fecha_final USING "mm/dd/yyyy" ,"') and
|
||||
i.mes between month('", datos.fecha_inicial USING "mm/dd/yyyy" ,"') and month('", datos.fecha_final USING "mm/dd/yyyy" ,"') and
|
||||
a.fecha_oc between '", datos.fecha_inicial USING "mm/dd/yyyy" , "' and '",datos.fecha_final USING "mm/dd/yyyy","' and
|
||||
a.fecha_oc BETWEEN j.fecha_inicio AND j.fecha_corte and
|
||||
a.status_t is null
|
||||
group by g.nombre, f.nombre, x.num_emp, x.nom1_emp, x.apell1_emp, a.cotizacion_no, a.num_oc, c.cod_n, c.cod_grupo, c.cod_tipo,
|
||||
c.cod_sec, h.descrip_esp, c.precio, i.tasa, c.descuento
|
||||
"
|
||||
|
||||
PREPARE comando FROM selec
|
||||
DECLARE ordenes CURSOR FOR comando
|
||||
|
||||
LET r_filename ="veprrp055.4rp"
|
||||
LET idx = 1
|
||||
|
||||
FOREACH ordenes INTO ordenesProd.*
|
||||
CALL getCantidadDespachada(ordenesProd.cod_grupo, ordenesProd.cod_tipo, ordenesProd.cod_sec, ordenesProd.cod_n, ordenesProd.num_oc) RETURNING ordenesProd.cantidad_despachada
|
||||
|
||||
LET valorCot = (ordenesProd.precio - ((ordenesProd.descuento * ordenesProd.precio)/100)) * ordenesProd.tasa
|
||||
LET valorOrd = valorCot * ordenesProd.cantidad_ordenada
|
||||
LET cantidadPend = ordenesProd.cantidad_ordenada + ordenesProd.cantidad_despachada
|
||||
LET valorPend = cantidadPend * valorCot
|
||||
|
||||
|
||||
IF idx = 1 THEN
|
||||
IF fgl_report_loadCurrentSettings(r_filename) THEN
|
||||
|
||||
LET preview=1
|
||||
CALL seleccionarsalida() RETURNING r_output -- load the .4rp file
|
||||
CALL fgl_report_selectDevice(r_output) -- changing default
|
||||
CALL fgl_report_selectPreview(preview) -- changing default
|
||||
LET handler = fgl_report_commitCurrentSettings() -- commit changes
|
||||
ELSE
|
||||
CALL fgl_winmessage("INFO", "NO HAY REGISTROS EN ESTE RANGO DE FECHA Y CON LOS PARAMETROS INDICADOS", "INFO")
|
||||
NEXT FIELD fecha_final
|
||||
END IF
|
||||
LET idx = 2
|
||||
|
||||
START REPORT ordenes_prod_rpt TO XML HANDLER HANDLER
|
||||
|
||||
END IF
|
||||
|
||||
OUTPUT TO REPORT ordenes_prod_rpt(ordenesProd.*, datos.*, valorCot, valorOrd, cantidadPend, valorPend)
|
||||
|
||||
END FOREACH
|
||||
|
||||
IF idx > 1 THEN
|
||||
FINISH REPORT ordenes_prod_rpt
|
||||
END IF
|
||||
END CONSTRUCT
|
||||
|
||||
ON ACTION CANCEL
|
||||
CALL msg(2)
|
||||
LET INT_FLAG = FALSE
|
||||
EXIT PROGRAM
|
||||
END DIALOG
|
||||
CLOSE WINDOW HOME_FRM
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION getCantidadDespachada(cg, ct, cs, cn, nc)
|
||||
|
||||
DEFINE cg LIKE prtb00013.cod_grupo,
|
||||
ct LIKE prtb00013.cod_tipo,
|
||||
cs LIKE prtb00013.cod_sec,
|
||||
cn LIKE prtb00013.cod_n,
|
||||
nc LIKE prtb00012.num_oc,
|
||||
cantidad_despachada LIKE iptb00006.cantidad_2
|
||||
SELECT isnull(SUM(a.cantidad_2),0)
|
||||
INTO cantidad_despachada
|
||||
FROM iptb00006 a
|
||||
WHERE a.cod_grupo = cg AND
|
||||
a.cod_tipo = ct AND
|
||||
a.cod_sec = cs AND
|
||||
a.cod_n = cn AND
|
||||
a.num_oc = nc AND
|
||||
a.cod_mov IN (30,31,55,56,12,13) AND
|
||||
a.status_t IS NULL
|
||||
|
||||
RETURN cantidad_despachada
|
||||
END FUNCTION
|
||||
|
||||
REPORT ordenes_prod_rpt(x, y, Vcot, Vorden, canPend, Vpend)
|
||||
|
||||
DEFINE x RECORD
|
||||
equipo LIKE seg0008.nombre,
|
||||
vendedor LIKE seg0000.nombre,
|
||||
cotizacion_no LIKE prtb00012.cotizacion_no,
|
||||
num_oc LIKE prtb00012.num_oc,
|
||||
producto LIKE prtb00002.descripcion,
|
||||
precio LIKE prtb00013.precio,
|
||||
tasa LIKE cgtb00084.tasa,
|
||||
descuento LIKE prtb00013.precio,
|
||||
cantidad_ordenada LIKE prtb00013.cantidad,
|
||||
cod_grupo LIKE prtb00013.cod_grupo,
|
||||
cod_tipo LIKE prtb00013.cod_tipo,
|
||||
cod_sec LIKE prtb00013.cod_sec,
|
||||
cod_n LIKE prtb00013.cod_n,
|
||||
cantidad_despachada LIKE iptb00006.cantidad_2
|
||||
END RECORD,
|
||||
canPend,
|
||||
cantidadPendiente,
|
||||
Vcot,
|
||||
Vpend,
|
||||
Vorden FLOAT
|
||||
|
||||
DEFINE y RECORD
|
||||
fecha_inicial DATE,
|
||||
fecha_final DATE,
|
||||
modo_plantilla CHAR(1)
|
||||
END RECORD,
|
||||
fecha_reporte char(30),
|
||||
fecha char(30),
|
||||
valorCotizacion NUMERIC(10,2),
|
||||
|
||||
--VARIABLES DE TOTALES POR ORDEN
|
||||
totalOrden,
|
||||
totalOrdenOrdenada,
|
||||
totalOrdenDespachada,
|
||||
totalOrdenCanPendiente,
|
||||
totalOrdenValPendiente,
|
||||
|
||||
--VARIABLES DE TOTALES POR VENDEDOR
|
||||
totalOrdenVendor,
|
||||
totalVendordenada,
|
||||
totalVendorValorPendiente,
|
||||
totalVendorPendiente,
|
||||
totalVendorDespachada,
|
||||
|
||||
--VARIABLES DE TOTALES POR EQUIPO
|
||||
totalCantidadOrden,
|
||||
totalCantidadOrdenada,
|
||||
totalCantidadDespachada,
|
||||
totalCantidadPendiente,
|
||||
totalValorPendiente,
|
||||
|
||||
--VARIABLES DE TOTALES PARA TOTALES GENERALES
|
||||
totalGenValorOrden,
|
||||
totalGenValorPendiente,
|
||||
totalGenGenCantidadOrdenada,
|
||||
totalGenCantidadDespachada,
|
||||
totalGenCantidadPendiente FLOAT
|
||||
|
||||
ORDER BY x.equipo,x.vendedor
|
||||
|
||||
FORMAT
|
||||
|
||||
BEFORE GROUP OF x.equipo
|
||||
LET totalCantidadOrdenada = 0
|
||||
LET valorCotizacion = 0
|
||||
|
||||
BEFORE GROUP OF x.vendedor
|
||||
LET totalOrdenVendor = 0
|
||||
LET totalVendordenada = 0
|
||||
LET totalVendorPendiente = 0
|
||||
LET totalVendorDespachada = 0
|
||||
PRINTX x.vendedor
|
||||
|
||||
BEFORE GROUP OF x.num_oc
|
||||
LET totalOrdenOrdenada = 0
|
||||
LET totalOrdenDespachada = 0
|
||||
LET totalOrdenCanPendiente = 0
|
||||
LET totalOrdenValPendiente = 0
|
||||
|
||||
ON EVERY ROW
|
||||
|
||||
LET fecha_reporte = today USING "mm/dd/yyyy"
|
||||
LET fecha = y.fecha_inicial USING "mm/dd/yyyy",'--',y.fecha_final USING "mm/dd/yyyy"
|
||||
LET cantidadPendiente = x.cantidad_ordenada + x.cantidad_despachada
|
||||
|
||||
PRINTX x.equipo, x.cotizacion_no, x.num_oc, x.producto ,x.tasa,
|
||||
x.descuento, x.cantidad_ordenada, x.cod_grupo, x.cod_tipo,
|
||||
x.cod_sec, x.cod_n, x.cantidad_despachada ,cantidadPendiente,
|
||||
Vpend, Vcot,Vorden, pcompanias.nombre, fecha_reporte, fecha,
|
||||
y.modo_plantilla
|
||||
|
||||
AFTER GROUP OF x.equipo
|
||||
LET totalCantidadOrden = GROUP SUM(Vorden)
|
||||
LET totalCantidadOrdenada = GROUP SUM(x.cantidad_ordenada)
|
||||
LET totalCantidadDespachada = GROUP SUM(x.cantidad_despachada)
|
||||
LET totalCantidadPendiente = GROUP SUM(cantidadPendiente)
|
||||
LET totalValorPendiente = GROUP SUM(Vpend)
|
||||
|
||||
PRINTX totalCantidadOrden, totalValorPendiente, totalCantidadDespachada,
|
||||
totalCantidadPendiente, totalCantidadOrdenada
|
||||
|
||||
AFTER GROUP OF x.vendedor
|
||||
LET totalOrdenVendor = GROUP SUM(Vorden)
|
||||
LET totalVendordenada = GROUP SUM(x.cantidad_ordenada)
|
||||
LET totalVendorDespachada = GROUP SUM(x.cantidad_despachada)
|
||||
LET totalVendorPendiente = GROUP SUM(cantidadPendiente)
|
||||
LET totalVendorValorPendiente = GROUP SUM(Vpend)
|
||||
|
||||
PRINTX totalOrdenVendor, totalVendordenada, totalVendorDespachada,
|
||||
totalVendorPendiente, totalVendorValorPendiente
|
||||
|
||||
AFTER GROUP OF x.num_oc
|
||||
LET totalOrden = GROUP SUM(Vorden)
|
||||
LET totalOrdenOrdenada = GROUP SUM(x.cantidad_ordenada)
|
||||
LET totalOrdenDespachada = GROUP SUM(x.cantidad_despachada)
|
||||
LET totalOrdenCanPendiente = GROUP SUM(cantidadPendiente)
|
||||
LET totalOrdenValPendiente = GROUP SUM(Vpend)
|
||||
|
||||
PRINTX totalOrden ,totalOrdenOrdenada, totalOrdenDespachada,
|
||||
totalOrdenCanPendiente, totalOrdenValPendiente
|
||||
|
||||
ON LAST ROW
|
||||
LET totalGenValorOrden = SUM(Vorden)
|
||||
LET totalGenGenCantidadOrdenada = SUM(x.cantidad_ordenada)
|
||||
LET totalGenCantidadDespachada = SUM(x.cantidad_despachada)
|
||||
LET totalGenValorPendiente = SUM(Vpend)
|
||||
LET totalGenCantidadPendiente = SUM(cantidadPendiente)
|
||||
|
||||
PRINTX totalGenValorOrden, totalGenGenCantidadOrdenada,
|
||||
totalGenCantidadDespachada, totalGenValorPendiente,
|
||||
totalGenCantidadPendiente
|
||||
|
||||
END REPORT
|
||||
|
||||
Reference in New Issue
Block a user