469 lines
17 KiB
Plaintext
469 lines
17 KiB
Plaintext
{-------------------------------------------------------------------------------
|
|
PROGRAMA : VEPRRP19
|
|
OBJETIVO : VENTAS DE VENDEDOR X PRODUCTO
|
|
PROGRAMADOR : Juan Fco. Soto
|
|
FECHA REALIZACION : Mayo 1997
|
|
DIRECTOR PROYECTO : ING. JOSE ALFREDO PAULINO
|
|
-------------------------------------------------------------------------------
|
|
}
|
|
GLOBALS "ccprgb000.4gl"
|
|
|
|
# Variables para la captura de la informacion del reporte
|
|
|
|
DEFINE fecha1,fecha2 DATE,
|
|
cod_cia,p_mes SMALLINT,
|
|
salir CHAR(1),
|
|
nombre_mes CHAR(10),
|
|
primera CHAR(1)
|
|
|
|
FUNCTION ccprrp019()
|
|
|
|
# Variables que toman los valores del query y a la vez estas mismas variables
|
|
# Asignan estos valores a otra que se imprimira posteriormente
|
|
|
|
DEFINE vendedor RECORD
|
|
sec_vend SMALLINT,
|
|
fecha_factura DATE,
|
|
factura INTEGER,
|
|
cond_pago SMALLINT,
|
|
cod_n SMALLINT,
|
|
cod_grupo SMALLINT,
|
|
cod_tipo SMALLINT,
|
|
cod_sec SMALLINT,
|
|
cantidad DECIMAL(12,3),
|
|
precio DECIMAL(10,2),
|
|
descrip_esp CHAR(27),
|
|
status_p CHAR(1),
|
|
porciento LIKE vetb00002.porc_desc,
|
|
codigo CHAR(7)
|
|
END RECORD
|
|
|
|
# Atrapa el error de run-time
|
|
|
|
# WHENEVER ERROR CONTINUE
|
|
# Especificaciones para el desplegue de errores y formulario.
|
|
# Reserva lineas para tales fines.
|
|
|
|
OPTIONS
|
|
FORM LINE 8,
|
|
ERROR LINE 23,
|
|
COMMENT LINE 21
|
|
OPEN FORM ccfmrp019 FROM "ccfmrp019"
|
|
DISPLAY FORM ccfmrp019
|
|
|
|
CALL pantalla()
|
|
|
|
DISPLAY "ccprrp019" AT 4,3
|
|
DISPLAY "Ventas X Vend. X PT" AT 6,30
|
|
|
|
## Tipo de papel necesario para imprimir el reporte
|
|
LET tipo_papel = 2
|
|
CALL msgrp000(tipo_papel)
|
|
|
|
# Entrada de datos para el reporte
|
|
|
|
INPUT BY NAME cod_cia,fecha1,fecha2
|
|
AFTER FIELD cod_cia
|
|
IF cod_cia IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_cia
|
|
END IF
|
|
|
|
END INPUT
|
|
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = false
|
|
RETURN
|
|
END IF
|
|
|
|
CONSTRUCT criterio ON a.sec_vend,b.cod_n,b.cod_grupo
|
|
FROM sec_vend,cod_n,cod_grupo
|
|
|
|
# Chequo de la cancelacion del programa con la variable global int_flag
|
|
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = false
|
|
RETURN
|
|
END IF
|
|
|
|
# Buscando las informaciones del reporte
|
|
|
|
DISPLAY " " AT 19,14
|
|
LET selec =
|
|
"SELECT a.sec_vend,a.fecha_factura,a.factura,a.cond_pago,b.cod_n, ",
|
|
" b.cod_grupo,b.cod_tipo,b.cod_sec,b.cantidad,b.precio, ",
|
|
" c.descrip_esp,b.status_t,a.porc_desc ",
|
|
"FROM vetb00003 b,vetb00002 a,iptb00002 c ",
|
|
"WHERE (b.cod_n = c.cod_n AND b.cod_grupo = c.cod_grupo AND ",
|
|
" b.cod_tipo = c.cod_tipo AND b.cod_sec = c.cod_sec AND ",
|
|
" b.factura=a.factura) AND (a.fecha_factura BETWEEN ? AND ?) AND ",
|
|
" (a.ventas = '1') AND (a.cod_cia = ?) AND ( ",criterio CLIPPED," )"
|
|
|
|
DISPLAY "Buscando Producto... Espere Por Favor" AT 19,14
|
|
|
|
PREPARE b_vende FROM selec
|
|
DECLARE c_vende CURSOR FOR b_vende
|
|
OPEN c_vende USING fecha1,fecha2,cod_cia
|
|
|
|
# Prepara al sistema operativo para recibir el reporte
|
|
|
|
START REPORT comision TO "C:\\archivo"
|
|
DISPLAY " " AT 19,14
|
|
DISPLAY "<< Reporte Generandose ... Por Favor Espere >>" AT 19,14
|
|
ATTRIBUTE (REVERSE)
|
|
|
|
# Loop para darle salida al Query hasta que la variable global status = 100
|
|
|
|
LET salir = "N"
|
|
WHILE salir != "S"
|
|
FETCH c_vende INTO vendedor.*
|
|
IF status = notfound THEN
|
|
LET salir = "S"
|
|
EXIT WHILE
|
|
END IF
|
|
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = false
|
|
RETURN
|
|
END IF
|
|
|
|
IF vendedor.sec_vend IS NULL THEN
|
|
LET vendedor.sec_vend = 0
|
|
END IF
|
|
IF vendedor.status_p is null THEN
|
|
LET vendedor.codigo = vendedor.cod_n USING "&",
|
|
vendedor.cod_grupo USING "&",
|
|
vendedor.cod_tipo USING "&&",
|
|
vendedor.cod_sec USING "&&&"
|
|
|
|
DISPLAY "DATOS: ", vendedor.sec_vend USING "&&&&","-",vendedor.codigo
|
|
AT 21,14
|
|
OUTPUT TO REPORT comision (vendedor.*)
|
|
END IF
|
|
END WHILE
|
|
FINISH REPORT comision
|
|
CLEAR SCREEN
|
|
RUN "type C:\\archivo > %USPRINT%" END FUNCTION
|
|
# Rutina de reporte
|
|
|
|
REPORT comision(x)
|
|
# Variable que toma el valor de la funcion que llamo a esta rutina
|
|
|
|
DEFINE x RECORD
|
|
sec_vend SMALLINT,
|
|
fecha_factura DATE,
|
|
factura INTEGER,
|
|
cond_pago SMALLINT,
|
|
cod_n SMALLINT,
|
|
cod_grupo SMALLINT,
|
|
cod_tipo SMALLINT,
|
|
cod_sec SMALLINT,
|
|
cantidad DECIMAL(12,3),
|
|
precio DECIMAL(10,2),
|
|
descrip_esp CHAR(27),
|
|
status_p CHAR(1),
|
|
porciento LIKE vetb00002.porc_desc,
|
|
codigo CHAR(7)
|
|
END RECORD
|
|
DEFINE descuentos,und_descuento,und_netas,ventas_netas,t_Desc,t_neto,tt_neto
|
|
DECIMAL(12,3),
|
|
precio_neto,precio_bruto,porciento DECIMAL(12,4)
|
|
|
|
# Esta variable toma el valor del nombre del mes para imprimirse
|
|
|
|
DEFINE nombre_vend, apellido_vend CHAR(30),
|
|
porc,porc_ventas DECIMAL(10,4)
|
|
#------------------------------------------------------------------
|
|
# Estas variables son constantes en todos los reportes de RAYOVAC
|
|
# para no estar definiendolas en cada momento.
|
|
# Estas variables son los caracteres ASCII para ser interpretados por
|
|
# el printer.
|
|
|
|
DEFINE doble_on,doble_off,negrillas_on,negrillas_off,comp_on,comp_off,
|
|
doce,normal CHAR(3)
|
|
|
|
#----------------------------------------------------------------------
|
|
# Esta variable es para asignarle la hora del dia e imprimir en HH:MM
|
|
|
|
DEFINE hora CHAR(5)
|
|
|
|
#-----------------------------------------------------------------------
|
|
# Variables totales del reporte
|
|
|
|
DEFINE total_vend,valor_pagar,t_total_vend,valor_pagar1,t_und_descuentos,
|
|
tt_und_descuentos,t_descuentos,tt_descuentos,total_pila,
|
|
t_und_neto,tt_und_neto DECIMAL(12,2)
|
|
|
|
# Definicion de salida del reporte, margenes.
|
|
|
|
OUTPUT
|
|
TOP MARGIN 0
|
|
LEFT MARGIN 9
|
|
BOTTOM MARGIN 4
|
|
#------------------------------------------------------------------------
|
|
|
|
ORDER BY x.sec_vend,x.factura
|
|
|
|
FORMAT
|
|
PAGE HEADER
|
|
# Asignaciones de los valores ASCII para la impresion
|
|
|
|
LET doble_on = ASCII 14
|
|
LET doble_off = ASCII 20
|
|
LET negrillas_on = ASCII 27, ASCII 69
|
|
LET negrillas_off = ASCII 27, ASCII 70
|
|
LET comp_on = ASCII 27,ASCII 15
|
|
LET comp_off = ASCII 18
|
|
LET doce = ASCII 27, ASCII 77
|
|
LET normal = ASCII 15
|
|
LET hora = time
|
|
|
|
# Funcion que busca los meses del ano
|
|
#--------------------------------------------------------------------------
|
|
|
|
LET lj = (157 - LENGTH(p_companias.nombre CLIPPED))/2
|
|
PRINT COLUMN 1, comp_on
|
|
PRINT COLUMN 1, "ccprrp019",
|
|
COLUMN lj, p_companias.nombre CLIPPED,
|
|
COLUMN 150, "Pag. ", pageno USING "###"
|
|
PRINT COLUMN 64, "Sistema de Cuentas por Cobrar",
|
|
COLUMN 150, today USING "dd/mm/yyyy"
|
|
PRINT COLUMN 58, "Relacion Ventas Por Vendedor Por Producto",
|
|
COLUMN 150, hora
|
|
|
|
PRINT COLUMN 52, doble_on,nombre_mes,doble_off
|
|
IF cod_cia = 1 THEN
|
|
PRINT COLUMN 1, "PRODUCTOS LOCALES "
|
|
ELSE
|
|
PRINT COLUMN 1, "IMPORTADOS"
|
|
END IF
|
|
|
|
PRINT COLUMN 1, "DESDE: ",fecha1 USING "dd/mm/yyyy",
|
|
" HASTA: ",fecha2 USING "dd/mm/yyyy"
|
|
|
|
PRINT COLUMN 1, "--------------------------------------------------",
|
|
"--------------------------------------------------",
|
|
"--------------------------------------------------",
|
|
"------------------"
|
|
|
|
PRINT COLUMN 1, "| |",
|
|
COLUMN 11, " |",
|
|
COLUMN 60, "| VENTAS BRUTAS |",
|
|
COLUMN 85, " |",
|
|
COLUMN 93, " |",
|
|
COLUMN 100, " DESCUENTOS |",
|
|
COLUMN 124, " VENTAS NETAS |",
|
|
COLUMN 148, " |",
|
|
COLUMN 159, " |"
|
|
|
|
PRINT COLUMN 1, "| |",
|
|
COLUMN 11, " |",
|
|
COLUMN 60, "|-----------------------|",
|
|
COLUMN 85, "PRECIO |",
|
|
COLUMN 93, "DESC. |",
|
|
COLUMN 101, "----------------------|",
|
|
COLUMN 124, "----------------------|"
|
|
|
|
PRINT COLUMN 1, "|FACTURA|",
|
|
COLUMN 11, "FECHA |",
|
|
COLUMN 18, "PRODUCTO ",
|
|
COLUMN 60, "| UNIDS.",
|
|
COLUMN 80, "RD$ |",
|
|
COLUMN 85, "NETO |",
|
|
COLUMN 93, "REAL |",
|
|
COLUMN 101, "UNIDS. ",
|
|
COLUMN 118, "RD$ |",
|
|
COLUMN 126, "UNDS.",
|
|
COLUMN 141, "RD$ |"
|
|
|
|
PRINT COLUMN 1, "--------------------------------------------------",
|
|
"--------------------------------------------------",
|
|
"--------------------------------------------------",
|
|
"------------------"
|
|
|
|
SKIP 1 LINE
|
|
BEFORE GROUP OF x.sec_vend
|
|
LET tt_und_neto = 0
|
|
LET tt_neto = 0
|
|
LET tt_descuentos = 0
|
|
LET tt_und_descuentos = 0
|
|
LET t_desc = 0
|
|
# Buscando del nombre del vendedor
|
|
|
|
IF x.sec_vend IS NOT NULL THEN
|
|
SELECT nom1_emp,apell1_emp INTO nombre_vend,apellido_vend
|
|
FROM adtb00003 WHERE num_emp = x.sec_vend
|
|
ELSE
|
|
LET nombre_vend = "NO EXISTE"
|
|
LET apellido_vend = " "
|
|
END IF
|
|
LET total_vend = 0
|
|
|
|
PRINT COLUMN 1, doble_on,"VENDEDOR : ", x.sec_vend," ",
|
|
nombre_vend clipped," ",apellido_vend clipped,
|
|
doble_off
|
|
|
|
SKIP 1 LINE
|
|
# Impresion detalle del reporte
|
|
|
|
BEFORE GROUP OF x.factura
|
|
LET t_neto = 0
|
|
LET t_und_descuentos = 0
|
|
LET t_und_neto = 0
|
|
LET primera = "S"
|
|
LET t_descuentos = 0
|
|
SKIP 1 LINE
|
|
LET total_pila = 0
|
|
|
|
IF t_total_vend is null THEN
|
|
LET t_total_vend = 0
|
|
END IF
|
|
|
|
ON EVERY ROW
|
|
|
|
LET valor_pagar = 0
|
|
IF x.porciento IS NOT NULL AND x.porciento <> 0 THEN
|
|
LET porciento = x.porciento /100
|
|
ELSE
|
|
LET porciento = 0
|
|
END IF
|
|
LET descuentos = (x.cantidad*x.precio) *
|
|
porciento
|
|
LET t_desc = t_desc + descuentos
|
|
IF cod_cia = 1 THEN
|
|
LET precio_bruto = (x.cantidad*x.precio) / x.cantidad
|
|
LET precio_neto = precio_bruto - porciento
|
|
LET und_descuento = descuentos / precio_neto
|
|
LET und_netas = x.cantidad - und_descuento
|
|
LET valor_pagar = und_netas * porc_ventas
|
|
END IF
|
|
IF cod_cia = "2" THEN
|
|
LET valor_pagar = ((x.cantidad * x.precio) - descuentos) *
|
|
porc_ventas
|
|
END IF
|
|
LET ventas_netas = (x.cantidad * x.precio) -
|
|
descuentos
|
|
# Para el vendedor que factura en la compania que usualmente es al contado
|
|
# se le paga el porciento por valores brutos vendidos
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
PRINT COLUMN 1, x.factura USING "&&&&&&",
|
|
COLUMN 9, x.fecha_factura USING "dd/mm/yyyy",
|
|
COLUMN 18, x.cod_n USING "&","-",
|
|
x.cod_grupo USING "&","-",
|
|
x.cod_tipo USING "&&","-",
|
|
x.cod_sec USING "&&&",
|
|
" ",x.descrip_esp CLIPPED;
|
|
IF cod_cia = "1" THEN
|
|
PRINT COLUMN 58, x.cantidad USING "###,###.###";
|
|
END IF
|
|
PRINT COLUMN 70, x.cantidad * x.precio USING "##,###,###.##";
|
|
IF cod_cia = "1" THEN
|
|
PRINT COLUMN 86, precio_neto using "##,###.##";
|
|
END IF
|
|
PRINT COLUMN 91, porciento using "##.###";
|
|
IF cod_cia = "1" THEN
|
|
PRINT COLUMN 99, und_descuento USING "###,###.###";
|
|
END IF
|
|
PRINT COLUMN 112, descuentos USING "###,###.##";
|
|
IF cod_cia = "1" THEN
|
|
PRINT COLUMN 125, und_netas USING "###,###.###";
|
|
END IF
|
|
PRINT COLUMN 137, ventas_netas USING "#,###,###.##"
|
|
|
|
# Esta es la acumulacion de lo que se le va ha pagar al vendedor
|
|
|
|
LET total_vend = valor_pagar + total_vend
|
|
LET total_pila = valor_pagar + total_pila
|
|
|
|
LET t_neto = t_neto + ventas_netas
|
|
LET t_und_neto = t_und_neto + und_netas
|
|
LET t_descuentos = t_descuentos + descuentos
|
|
LET t_und_descuentos = t_und_descuentos + und_descuento
|
|
LET primera = "N"
|
|
|
|
AFTER GROUP OF x.factura
|
|
|
|
PRINT COLUMN 1, negrillas_on
|
|
IF cod_cia = "1" THEN
|
|
PRINT COLUMN 58, "------------";
|
|
END IF
|
|
PRINT COLUMN 70, "-------------";
|
|
IF cod_cia = "1" THEN
|
|
PRINT COLUMN 97, "--------------";
|
|
END IF
|
|
PRINT COLUMN 112, "----------";
|
|
IF cod_cia = "1" THEN
|
|
PRINT COLUMN 125, "------------";
|
|
END IF
|
|
IF cod_cia = "1" THEN
|
|
PRINT COLUMN 137, "------------"
|
|
END IF
|
|
|
|
PRINT COLUMN 40, "Total Codigo ",
|
|
COLUMN 55, GROUP SUM(x.cantidad) USING "##,###,###.###",
|
|
COLUMN 70, GROUP SUM(x.precio*x.cantidad)
|
|
USING "##,###,###.##";
|
|
IF cod_cia = "1" THEN
|
|
PRINT COLUMN 97, t_und_descuentos USING "#,###,###.###";
|
|
END IF
|
|
PRINT COLUMN 112, t_descuentos USING "###,###.##";
|
|
IF cod_cia = "1" THEN
|
|
PRINT COLUMN 122, t_und_neto USING "##,###,###.###";
|
|
END IF
|
|
PRINT COLUMN 135, t_neto USING "#,###,###.##"
|
|
PRINT COLUMN 1, negrillas_off
|
|
|
|
LET tt_descuentos = tt_descuentos + t_descuentos
|
|
LET tt_neto = tt_neto + t_neto
|
|
LET tt_und_neto = tt_und_neto + t_und_neto
|
|
LET tt_und_descuentos = tt_und_descuentos + t_und_descuentos
|
|
AFTER GROUP OF x.sec_vend
|
|
|
|
PRINT COLUMN 1,negrillas_on
|
|
IF cod_cia = "1" THEN
|
|
PRINT COLUMN 55, "---------------";
|
|
END IF
|
|
PRINT COLUMN 70, "-------------";
|
|
IF cod_cia = "1" THEN
|
|
PRINT COLUMN 97, "---------------";
|
|
END IF
|
|
PRINT COLUMN 112, "---------------";
|
|
IF cod_cia = "1" THEN
|
|
PRINT COLUMN 123, "-----------";
|
|
END IF
|
|
IF cod_cia = "1" THEN
|
|
PRINT COLUMN 135, "------------"
|
|
END IF
|
|
|
|
PRINT COLUMN 40, "Total A Pagar: ";
|
|
IF cod_cia = "1" THEN
|
|
PRINT COLUMN 54, GROUP SUM(x.cantidad) USING "###,###,###.###";
|
|
END IF
|
|
PRINT COLUMN 70, GROUP SUM(x.precio*x.cantidad)
|
|
USING "##,###,###.##";
|
|
IF cod_cia = "1" THEN
|
|
PRINT COLUMN 97, tt_und_descuentos USING "#,###,###.###";
|
|
END IF
|
|
PRINT COLUMN 112, tt_descuentos USING "###,###.##";
|
|
IF cod_cia = "1" THEN
|
|
PRINT COLUMN 120, tt_und_neto USING "##,###,###.###";
|
|
END IF
|
|
PRINT COLUMN 135, tt_neto USING "#,###,###.##",
|
|
COLUMN 157, total_vend USING "##,###.##.###"
|
|
|
|
PRINT COLUMN 1,negrillas_off
|
|
|
|
LET t_total_vend = t_total_vend + total_vend
|
|
|
|
SKIP TO TOP OF PAGE
|
|
END REPORT
|