0% found this document useful (0 votes)
207 views8 pages

Xbase Source Code in PHC

This document describes a routine to process pay slips that would have negative or positive values but have absences for the entire processed period. It validates the employee's absence processing code, loads absences into a cursor and compares absence hours to working hours. If equal, it redistributes bonus amounts across absence lines. Otherwise, it clears pay slip header fields and recalculates totals without PHC functions.

Uploaded by

Luis Coelho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
207 views8 pages

Xbase Source Code in PHC

This document describes a routine to process pay slips that would have negative or positive values but have absences for the entire processed period. It validates the employee's absence processing code, loads absences into a cursor and compares absence hours to working hours. If equal, it redistributes bonus amounts across absence lines. Otherwise, it clears pay slip header fields and recalculates totals without PHC functions.

Uploaded by

Luis Coelho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 8

********************************************************************************

*******************************
*
*
* DESCRIO DA ROTINA: EVENTO PARA PROCESSAR RECIBOS QUE IRIAM TER VALOR NEGATIVO OU
POSITIVO MAS QUE TM
*
*
FALTAS NA TOTALIDADE DO PERIODO PROCESSADO
*
* AUTOR: LUIS COELHO
*
* DATA: 2014/03/13
*
*
*
* PROJECTO (S/N)? N
*
* QUEM PEDIU? DR. VITOR AGUIAR
*
*
*
********************************************************************************
*******************************
*
*
* PRESSUPOSTOS:
*
*
*
*
*
********************************************************************************
*******************************
* OBSERVAES: VALIDAR O CDIGO DE PROCESSAMENTO DE FALTAS DO FUNCIONRIO (U_PROCFALTAS)
*
*
*
*
*
********************************************************************************
*******************************
xTemFaltas = .f.
select pr
TEXT TO m.msql TEXTMERGE NOSHOW
select hsemana, hdia, u_codprocf, diai, mesi, diaf, mesf, no
from pe (nolock) inner join u_procfaltas as pf (nolock) on (pe.u_codproc
f = pf.codigo)
where pe.no=<< astr(pr.no) >> and pf.anoproc = << astr(year(pr.data)) >>
and pf.mesproc = << astr(month(pr.data)) >>
ENDTEXT
u_sqlexec(m.msql, 'crpe')
xValorAbono = 0
*********************************************
*
*

* CRIAMOS O CURSOR DE FALTAS PARA DEPOIS AS *


* COMPARARMOS COM O PERIODO TOTAL DE FALTAS *
*
*
*********************************************
create cursor crFaltas (qtt n(10,2), valorunit n(12,2), valortotal n(12,2))

***************************************************************************
*
*
* PERCORREMOS AS LINHAS DE REMUNERAES PARA VALIDARMOS SE EXISTEM FALTAS *
*
*
***************************************************************************
select prre
goto top
scan
xCm = PRRE.CR
u_sqlexec("select cm, cmdesc, u_ofaltas, u_bmedica, u_ferias, codbase fr
om cm6 (nolock) where cm6.cm = " + astr(prre.cr), 'crcm6')
select crcm6
*****************************************************************
*
*
* VAMOS CARREGAR AS FALTAS NUM CURSOR E OS ABONOS NUMA VARIAVEL *
*
*
*****************************************************************
if crcm6.u_ofaltas = .t. or crcm6.u_bmedica = .t.
select crFaltas
append blank
replace crFaltas.qtt with prre.rqtt
replace crFaltas.valorunit with prre.ervu
replace crFaltas.valortotal with prre.ere
xTemFaltas = .t.
else
if crcm6.codbase = .t.
xValorAbono = xValorAbono + prre.ere
endif
endif
select prre
endscan
********************************************
*
*
* SE NO TEM UMA NICA FALTA SAI DA ROTINA *
*
*
********************************************
if xTemFaltas = .f.
return .t.
endif
************************************************************************
*
*
* VAMOS VALIDAR OS DIAS E HORAS TEIS DO INTERVALO DO CDIGO DE FALTAS *
*
*
************************************************************************
select crpe

if crpe.mesi = 12 then
xDataInicial = ctod(right('00' + astr(crpe.diai), 2) + '.' + right('00'
+ astr(crpe.mesi), 2) + '.' + right('0000' + astr(year(pr.data)-1), 4))
else
xDataInicial = ctod(right('00' + astr(crpe.diai), 2) + '.' + right('00'
+ astr(crpe.mesi), 2) + '.' + right('0000' + astr(year(pr.data)), 4))
endif
xDataFinal = ctod(right('00' + astr(crpe.diaf), 2) + '.' + right('00' + astr(crp
e.mesf), 2) + '.' + right('0000' + astr(year(pr.data)), 4))
select pr
xDiasUteis = u_diasuteis(xDataInicial, xDataFinal, pr.no)
select crpe
xHorasUteis = xDiasUteis * crpe.hdia
xHorasFalta = 0
********************************************************************************
********
*
*
* VALIDAR SE AS HORAS TEIS DO INTERVALO DO CDIGO DE FALTAS SO IGUAIS AOS DAS FALTAS
*
*
*
********************************************************************************
********
select crFaltas
goto top
scan
xHorasFalta = xHorasFalta + crFaltas.qtt
endscan
xRestante = round(xValorABono, 2)
if xHorasFalta == xHorasUteis then
xValorUnit = -(xValorAbono / xHorasFalta)
select prre
goto top
scan
xCm = PRRE.CR
u_sqlexec("select cm, cmdesc, u_ofaltas, u_bmedica, u_ferias fro
m cm6 (nolock) where cm6.cm = " + astr(prre.cr), 'crcm6')
select crcm6
if crcm6.u_ofaltas = .t. or crcm6.u_bmedica = .t.
if xRestante >= abs(prre.rqtt * xValorUnit)
replace prre.ervu with round(xValorUnit, 2)
replace prre.ere with round(xValorUnit * prre.rq
tt, 2)
xRestante = xRestante + round((xValorUnit * prre

.rqtt), 2)
else
replace prre.ervu with - round((xRestante / prre
.rqtt), 2)
replace prre.ere with - xRestante
xRestante = 0
endif
endif
select prre
endscan
************************************************************************
*****
*
*
* SE AINDA EXISTIR VALOR RESTANTE, VAMOS ATRIBUIR PRIMEIRA LINHA DE FALT
A *
*
*
************************************************************************
*****
if xRestante > 0 then
select prre
goto top
scan
xCm = PRRE.CR
u_sqlexec("select cm, cmdesc, u_ofaltas, u_bmedica, u_fe
rias from cm6 (nolock) where cm6.cm = " + astr(prre.cr), 'crcm6')
select crcm6
if crcm6.u_ofaltas = .t. or crcm6.u_bmedica = .t.
replace prre.ere with prre.ere - xRestante
replace prre.ervu with round(prre.ere / prre.rqt
t, 2)
xRestante = 0
exit
endif
select prre
endscan
endif
endif

***************************************
*
*
* CALCULAMOS O VALOR TOTAL DAS LINHAS *
*
*
***************************************
xValor = 0
select prre
goto top
scan
xValor = xValor + prre.ere

endscan
**************************************
*
*
* SE NO TIVERMOS VALORES DE ABONOS, *
* LIMPAMOS AS LINHAS DE DESCONTOS
*
*
*
**************************************
if xValor = 0 then
select prde
goto top
scan
delete
endscan
endif
**********************************************************************
*
*
* SE NO HOUVER NENHUM ABONO, ENTO LIMPAMOS OS VALORES DO CABEALHO *
* DO RECIBO E NO RECALCULAMOS PELAS FUNES DO PHC
*
*
*
**********************************************************************
if xValor = 0 then
select PR
replace PR.EFCTVALOR with 0
replace PR.EFGCTVALOR with 0
replace PR.EFGCTVALREEMB with 0
replace PR.EHETT with 0
replace PR.ELIQUIDO with 0
replace PR.ESSEVALOR with 0
replace PR.ESSHEXTRA with 0
replace PR.ESUBSIDIO with 0
replace PR.ETTDESC with 0
replace PR.ETTNSUJ with 0
replace PR.ETTSUJ with 0
replace PR.ETTSUJCX with 0
replace PR.EVALORJAEMTB with 0
replace PR.EVALOROL with 0
replace
replace
replace
replace
replace
replace
replace
replace
replace
replace
replace
replace
replace
replace

PR.FCTVALOR with 0
PR.FGCTVALOR with 0
PR.FGCTVALREEMB with 0
PR.HETT with 0
PR.LIQUIDO with 0
PR.SSEVALOR with 0
PR.SSHEXTRA with 0
PR.SUBSIDIO with 0
PR.TTDESC with 0
PR.TTNSUJ with 0
PR.TTSUJ with 0
PR.TTSUJCX with 0
PR.VALORJAEMTB with 0
PR.VALOROL with 0

return .t.
else

*******************************
*
*
* CLCULO DE TOTAIS DO RECIBO *
*
*
*******************************
m.mxsujirs=0
m.mvirs=0
Declare a_diff(1),a_mesano(1),a_dtsuj(1)
a_dtsuj=0
a_mesano=0
a_diff=0
Do prantirs With pr.no,pr.data,m.eur_def
Do prproc
Do prprocf
endif

****************************************************************
*
*
* VALIDAMOS AGORA SE O TOTAL DE ABONOS ESTARIA SUJEITO
*
* A IRS E SS CASO ESTIVESSEM AS FALTAS NO MS DO PROCESSAMENTO *
*
*
****************************************************************
if used('crprre') then
fecha('crprre')
endif
duplicursor('prre', 'crprre')
xTemDeZerar = .f.

***********************************************
*
*
* VAMOS VALIDAR A DATA REFERNCIA DO ORD.BASE *
*
*
***********************************************
select prre
goto top
locate for prre.cr = 1
if found() then
xData = prre.dtref
select prre
goto top
scan
replace prre.dtref with xData
endscan
*******************************
*
*
* CLCULO DE TOTAIS DO RECIBO *
*
*
*******************************
m.mxsujirs=0

m.mvirs=0
Declare a_diff(1),a_mesano(1),a_dtsuj(1)
a_dtsuj=0
a_mesano=0
a_diff=0
Do prantirs With pr.no,pr.data,m.eur_def
Do prproc
Do prprocf
************************************************************************
*******
*
*
* SE TODOS OS ABONOS ESTIVEREM MESMA DATA E SE NO EXISTIR NENHUM DESCONTO
, *
* ENTO NO DEVERIA DESCONTAR NADA MESMO COM OUTRAS DATAS
*
*
*
************************************************************************
*******
select prde
if reccount('prde') = 0 then
xTemdeZerar = .t.
endif
endif
************************************************
*
*
* REPOMOS AGORA AS DATAS REFERNCIA DAS LINHAS *
*
*
************************************************
select prre
goto top
scan
select crprre
locate for crprre.prrestamp = prre.prrestamp
if found() then
replace prre.dtref with crprre.dtref
endif
select prre
endscan
***************************************************
*
*
* SE TEM DE ZERAR, ENTO APAGA TODOS OS DESCONTOS *
*
*
***************************************************
if xTemDeZerar then
select prde
scan
delete
endscan
select PR
replace PR.EFCTVALOR with 0

endif

replace
replace
replace
replace
replace
replace
replace
replace
replace
replace
replace
replace
replace

PR.EFGCTVALOR with 0
PR.EFGCTVALREEMB with 0
PR.EHETT with 0
PR.ELIQUIDO with 0
PR.ESSEVALOR with 0
PR.ESSHEXTRA with 0
PR.ESUBSIDIO with 0
PR.ETTDESC with 0
PR.ETTNSUJ with 0
PR.ETTSUJ with 0
PR.ETTSUJCX with 0
PR.EVALORJAEMTB with 0
PR.EVALOROL with 0

replace
replace
replace
replace
replace
replace
replace
replace
replace
replace
replace
replace
replace
replace

PR.FCTVALOR with 0
PR.FGCTVALOR with 0
PR.FGCTVALREEMB with 0
PR.HETT with 0
PR.LIQUIDO with 0
PR.SSEVALOR with 0
PR.SSHEXTRA with 0
PR.SUBSIDIO with 0
PR.TTDESC with 0
PR.TTNSUJ with 0
PR.TTSUJ with 0
PR.TTSUJCX with 0
PR.VALORJAEMTB with 0
PR.VALOROL with 0

You might also like