xBase source code in PHC

October 19, 2017 | Author: Luis Coelho | Category: N/A
Share Embed Donate


Short Description

xBase language used in ERP PHC....

Description

******************************************************************************** ******************************* * * * DESCRIÇÃO DA ROTINA: EVENTO PARA PROCESSAR RECIBOS QUE IRIAM TER VALOR NEGATIVO OU POSITIVO MAS QUE TÊM * * FALTAS NA TOTALIDADE DO PERIODO PROCESSADO * * AUTOR: LUIS COELHO * * DATA: 2014/03/13 * * * * PROJECTO (S/N)? N * * QUEM PEDIU? DR. VITOR AGUIAR * * * ******************************************************************************** ******************************* * * * PRESSUPOSTOS: * * * * * ******************************************************************************** ******************************* * OBSERVAÇÕES: VALIDAR O CÓDIGO DE PROCESSAMENTO DE FALTAS DO FUNCIONÁRIO (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=> and pf.anoproc = > and pf.mesproc = > 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 REMUNERAÇÕES 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 NÃO TEM UMA ÚNICA FALTA SAI DA ROTINA * * * ******************************************** if xTemFaltas = .f. return .t. endif ************************************************************************ * * * VAMOS VALIDAR OS DIAS E HORAS ÚTEIS DO INTERVALO DO CÓDIGO 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 CÓDIGO DE FALTAS SÃO 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 NÃO TIVERMOS VALORES DE ABONOS, * * LIMPAMOS AS LINHAS DE DESCONTOS * * * ************************************** if xValor = 0 then select prde goto top scan delete endscan endif ********************************************************************** * * * SE NÃO HOUVER NENHUM ABONO, ENTÃO LIMPAMOS OS VALORES DO CABEÇALHO * * DO RECIBO E NÃO RECALCULAMOS PELAS FUNÇÕES 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

******************************* * * * CÁLCULO 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 MÊS DO PROCESSAMENTO * * * **************************************************************** if used('crprre') then fecha('crprre') endif duplicursor('prre', 'crprre') xTemDeZerar = .f.

*********************************************** * * * VAMOS VALIDAR A DATA REFERÊNCIA 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 ******************************* * * * CÁLCULO 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 NÃO EXISTIR NENHUM DESCONTO , * * ENTÃO NÃO DEVERIA DESCONTAR NADA MESMO COM OUTRAS DATAS * * * ************************************************************************ ******* select prde if reccount('prde') = 0 then xTemdeZerar = .t. endif endif ************************************************ * * * REPOMOS AGORA AS DATAS REFERÊNCIA 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, ENTÃO 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

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF