Files
MBS/PROYECTO/ccdir/ccprrp022.4gl
T

436 lines
15 KiB
Plaintext

{
-------------------------------------------------------------------------------
PROGRAMA : CCPRRP022
OBJETIVO : Relacion de Ventas sin compania
PROGRAMADOR : Ing. Juan Soto
FECHA REALIZACION : Noviembre 2, 1993.
-------------------------------------------------------------------------------
}
GLOBALS "ccprgb000.4gl"
DEFINE idx_1, idx_2, idx_3 SMALLINT
DEFINE fecha_inicial, fecha_final DATE
DEFINE salir, salir2, salir3, tipo_venta CHAR(1)
DEFINE selec5, selec6 CHAR(1500)
DEFINE tot_gen RECORD
tot_1 DECIMAL(10,2),
tot_2 DECIMAL(10,2),
tot_3 DECIMAL(10,2),
tot_4 DECIMAL(10,2),
tot_5 DECIMAL(10,2)
END RECORD
DEFINE ventas RECORD
compania SMALLINT,
factura INTEGER,
fecha_factura DATE,
tipo_cliente SMALLINT,
sec_cliente SMALLINT,
monto_bruto DECIMAL(10,2),
monto_desc DECIMAL(10,2),
monto_itbi DECIMAL(10,2),
monto_neto DECIMAL(10,2),
prima DECIMAL(10,2),
status_t CHAR(1)
END RECORD
DEFINE desc_ft RECORD
cod_n SMALLINT,
cod_grupo SMALLINT,
cod_tipo SMALLINT,
cod_sec SMALLINT,
porc DECIMAL(10,2)
END RECORD
DEFINE det_ft RECORD
cod_n SMALLINT,
cod_grupo SMALLINT,
cod_tipo SMALLINT,
cod_sec SMALLINT,
valor DECIMAL(10,2)
END RECORD
DEFINE monto_desc DECIMAL(10,2)
DEFINE monto_ft DECIMAL(10,2)
FUNCTION ccprrp022()
WHENEVER ERROR CONTINUE
OPTIONS
FORM LINE 8,
ERROR LINE 23,
COMMENT LINE 21
OPEN FORM ccfmrp022 FROM "ccfmrp022"
DISPLAY FORM ccfmrp022
CALL pantalla()
DISPLAY "ccprrp022" AT 4,3
DISPLAY "Relacion de Ventas Sin Compania" AT 6,24
LET tipo_papel = 1
CALL msgrp000(tipo_papel)
INPUT BY NAME fecha_inicial,fecha_final,tipo_venta
AFTER FIELD fecha_inicial
IF fecha_inicial is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD fecha_inicial
END IF
BEFORE FIELD fecha_final
LET fecha_final = today
AFTER FIELD fecha_final
IF fecha_final is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD fecha_final
END IF
IF fecha_final < fecha_inicial THEN
LET numero_msg = 86
CALL msg(numero_msg)
NEXT FIELD fecha_final
END IF
AFTER FIELD tipo_venta
IF tipo_venta is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD tipo_venta
END IF
IF tipo_venta != "1" AND
tipo_venta != "2" THEN
LET numero_msg = 7
CALL msg(numero_msg)
NEXT FIELD tipo_venta
END IF
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = false
RETURN
END IF
IF fecha_inicial is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD fecha_inicial
END IF
IF fecha_final is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD fecha_final
END IF
IF fecha_final < fecha_inicial THEN
LET numero_msg = 86
CALL msg(numero_msg)
NEXT FIELD fecha_final
END IF
IF tipo_venta is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD tipo_venta
END IF
IF tipo_venta != "1" AND
tipo_venta != "2" THEN
LET numero_msg = 7
CALL msg(numero_msg)
NEXT FIELD tipo_venta
END IF
EXIT INPUT
END INPUT
#CONSTRUCT criterio ON a.cod_cia FROM cod_cia
IF tipo_venta = "1" THEN
LET selec3 =
"SELECT a.cod_cia,a.num_doc,a.fecha_orig,a.tipo_cliente,a.sec_cliente, ",
" d.sub_total,d.monto_desc,d.monto_itbi,a.valor,d.porc_itbi, ",
" a.status_t ",
"FROM cctb00001 a, vetb00002 d ",
"WHERE a.num_doc = d.factura and a.cod_cia = d.cod_cia and a.cod_cia IS NULL",
" AND a.fecha_orig between ? and ? and a.tipo_doc = 'FT' and ",
criterio clipped," ORDER BY 2,3 "
ELSE
LET selec3 =
"SELECT a.cod_cia,a.num_doc,a.fecha_orig,a.tipo_cliente,a.sec_cliente, ",
" b.sub_total,b.monto_desc,b.monto_itbi,a.valor,b.prima_us,a.status_t ",
"FROM cctb00001 a, vetb00002 b ",
"WHERE a.num_doc = d.factura and a.cod_cia = d.cod_cia and a.cod_cia IS NULL",
" AND a.fecha_orig between ? and ? and a.tipo_doc = 'FE' and ",
criterio clipped," ORDER BY 2,3 "
END IF
DISPLAY "<< Buscando Informacion ... Espere Por Favor. >>" AT 19,14
ATTRIBUTE (REVERSE,BOLD)
PREPARE ventas_locales FROM selec4
DECLARE lfacturas CURSOR FOR ventas_locales
OPEN lfacturas USING fecha_inicial, fecha_final
DISPLAY " " AT 19,14
START REPORT ventas_ft1 TO "relac"
DISPLAY " " AT 19,14
DISPLAY "<< Reporte Generandose ... Por Favor Espere. >>"
AT 19,14 ATTRIBUTE (REVERSE)
# Procesa las ventas de exportacion
LET salir = "N"
LET idx_1 = 1
WHILE salir = "N"
FETCH lfacturas INTO ventas.*
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 ventas.status_t = "E" THEN
LET ventas.monto_bruto = 0
LET ventas.monto_desc = 0
LET ventas.monto_itbi = 0
LET ventas.monto_neto = 0
LET ventas.prima = 0
END IF
LET idx_1 = idx_1 + 1
OUTPUT TO REPORT ventas_ft1(ventas.*)
END WHILE
FINISH REPORT ventas_ft1
DISPLAY BY NAME tot_gen.*
PROMPT "Desea Imprimir Reporte [S/N]...?" FOR CHAR opt
LET opt = UPSHIFT(opt)
IF opt = "S" THEN
RUN "cat relac|$DBPRINT"
END IF
CLEAR SCREEN
RUN "type C:\\archivo > %USPRINT%" END FUNCTION
REPORT ventas_ft1(x)
DEFINE x RECORD
compania SMALLINT,
factura INTEGER,
fecha_factura DATE,
tipo_cliente SMALLINT,
sec_cliente SMALLINT,
monto_bruto DECIMAL(10,2),
monto_desc DECIMAL(10,2),
monto_itbi DECIMAL(10,2),
monto_neto DECIMAL(10,2),
prima DECIMAL(10,2),
status_t CHAR(1)
END RECORD
DEFINE tot_1,tot_2,tot_3,tot_4,tot_5 DECIMAL(10,2)
DEFINE descuento DECIMAL(10,2)
DEFINE valor_factura DECIMAL(10,2)
DEFINE doble_on CHAR(2)
DEFINE doble_off CHAR(2)
DEFINE negrillas_on CHAR(2)
DEFINE negrillas_off CHAR(2)
DEFINE comp_on CHAR(2)
DEFINE comp_off CHAR(2)
DEFINE doce CHAR(2)
DEFINE normal CHAR(2)
DEFINE normall CHAR(3)
DEFINE comprimido CHAR(3)
DEFINE hora CHAR(5)
OUTPUT
TOP MARGIN 0
LEFT MARGIN 0
BOTTOM MARGIN 2
FORMAT
PAGE HEADER
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 15
LET comp_off = ASCII 18
LET comprimido = ASCII 031
LET doce = ASCII 27, ASCII 77
LET normal = ASCII 27, ASCII 80
LET normall = ASCII 030
LET hora = time
LET lj = (133 - LENGTH(p_companias.nombre CLIPPED))/2
PRINT COLUMN 1, comprimido
PRINT COLUMN 1, "ccprrp022",
COLUMN lj, p_companias.nombre CLIPPED,
COLUMN 126, "Pag. ",pageno using "###"
PRINT COLUMN 51, "Sistema de Cuentas por Cobrar",
COLUMN 124, today using "dd/mm/yyyy"
IF tipo_venta = "1" THEN
PRINT COLUMN 43, " Relacion de Ventas Sin Compania Locales",
COLUMN 129, hora
ELSE
PRINT COLUMN 43, " Relacion de Ventas Sin Compania Exportacion",
COLUMN 129, hora
END IF
PRINT COLUMN 53, "Del ", fecha_inicial using "dd/mm/yy",
" Al ", fecha_final using "dd/mm/yy"
SKIP 1 LINES
IF tipo_venta = "2" THEN
SKIP 1 LINE
PRINT COLUMN 1,
"--------------------------------------------------",
"--------------------------------------------------",
"-------------------------------------"
PRINT COLUMN 1, "Factura",
COLUMN 11, "Fecha",
COLUMN 20, "C l i e n t e",
COLUMN 68, "Monto US$",
COLUMN 83, "Otros US$",
COLUMN 98, "Total US$",
COLUMN 117, "Prima",
COLUMN 128, "Monto RD$"
PRINT COLUMN 1,
"--------------------------------------------------",
"--------------------------------------------------",
"-------------------------------------"
ELSE
PRINT COLUMN 1,
"--------------------------------------------------",
"--------------------------------------------------",
"----------------------------------"
PRINT COLUMN 128, "Valor a"
PRINT COLUMN 1, "Factura",
COLUMN 11, "Fecha",
COLUMN 20, "C l i e n t e",
COLUMN 66, "Monto RD$",
COLUMN 81, "Descuento",
COLUMN 97, "Neto RD$",
COLUMN 115, "ITBIS",
COLUMN 129, "Cobrar"
PRINT COLUMN 1,
"--------------------------------------------------",
"--------------------------------------------------" ,
"----------------------------------"
END IF
ON EVERY ROW
LET nom_cli = NULL
IF x.status_t IS NULL THEN
SELECT nombre INTO nom_cli FROM vetb00004
WHERE tipo_cliente = x.tipo_cliente and sec_cliente = x.sec_cliente and
status_t is null
IF nom_cli IS NULL THEN
LET nom_cli = "Cliente no existe. Verifique"
END IF
ELSE
LET nom_cli = "NULA"
END IF
IF tipo_venta = "2" THEN
PRINT COLUMN 1, x.factura using "######",
COLUMN 9, x.fecha_factura using "dd/mm/yy",
COLUMN 20, x.tipo_cliente using "&&","-",
x.sec_cliente using "&&&&"," ", nom_cli clipped,
COLUMN 62, x.monto_bruto using "####,###,###.##",
COLUMN 74, x.monto_desc using "####,###,###.##",
COLUMN 86, x.monto_neto using "####,###,###.##",
COLUMN 98, x.monto_neto*(x.prima-1) using "####,###,###.##",
COLUMN 110, x.monto_neto + (x.monto_neto * (x.prima - 1))
using "####,###,###.##"
END IF
IF tipo_venta = "1" THEN
PRINT COLUMN 1,x.factura using "######",
COLUMN 9,x.fecha_factura using "dd/mm/yy",
COLUMN 20,x.tipo_cliente using "&&","-",
x.sec_cliente using "&&&&"," ", nom_cli clipped,
COLUMN 60,x.monto_bruto using "####,###,###.##",
COLUMN 71,x.monto_desc using "####,###,###.##",
COLUMN 82,x.monto_bruto-x.monto_desc using "####,###,###.##",
COLUMN 93,x.monto_itbi using "####,###,###.##",
COLUMN 104,x.monto_neto using "####,###,###.##"
END IF
ON LAST ROW
IF tipo_venta = "1" THEN
SKIP 1 LINE
PRINT COLUMN 33, "Total General Ventas ---> ",
COLUMN 60, SUM(x.monto_bruto) using "####,###,###.##",
COLUMN 71, SUM(x.monto_desc) using "####,###,###.##",
COLUMN 82, SUM(x.monto_bruto - x.monto_desc)
using "####,###,###.##",
COLUMN 93, SUM(x.monto_itbi) using "####,###,###.##",
COLUMN 104, SUM(x.monto_neto) using "####,###,###.##"
LET tot_1 = SUM(x.monto_bruto)
LET tot_2 = SUM(x.monto_desc)
LET tot_3 = SUM(x.monto_bruto - x.monto_desc)
LET tot_4 = SUM(x.monto_itbi)
LET tot_5 = SUM(x.monto_neto)
END IF
IF tipo_venta = "2" THEN
SKIP 1 LINE
PRINT COLUMN 34, "Total General Ventas ---> ",
COLUMN 62, SUM(x.monto_bruto) using "####,###,###.##",
COLUMN 74, SUM(x.monto_desc) using "####,###,###.##",
COLUMN 86, SUM(x.monto_neto) using "####,###,###.##",
COLUMN 98, SUM(x.monto_neto * (x.prima - 1))
using "####,###,###.##",
COLUMN 110, SUM
(x.monto_neto + (x.monto_neto * (x.prima - 1)))
using "####,###,###.##"
LET tot_1 = SUM(x.monto_bruto)
LET tot_2 = SUM(x.monto_desc)
LET tot_3 = SUM(x.monto_neto)
LET tot_4 = SUM(x.monto_neto * (x.prima -1))
LET tot_5 = SUM(x.monto_neto + (x.monto_neto * (x.prima - 1)))
END IF
LET tot_gen.tot_1 = tot_1
LET tot_gen.tot_2 = tot_2
LET tot_gen.tot_3 = tot_3
LET tot_gen.tot_4 = tot_4
LET tot_gen.tot_5 = tot_5
PRINT normall
END REPORT