/
Historico_250. Migração de Programações

Historico_250. Migração de Programações

Como buscar do Protheus


--LISTA DE USUFRUTOS
select ria_mat    MATRICULA,
       ria_pd     VERBA,
       RIA_DTINPA DATA_INICIO_PERIODO_AQUISITIVO,
       RIA_DATINI INICIO,
       RIA_DATFIM FIM,
       RIA_NRDGOZ DIAS_GOZO,
       RIA_STATUS STATUS,
       ria_obs    OBSERVACAO,
       ria_suspen DIAS_SUSPENSOS,
       ria_nrport GEDOC,
       RA_CATFUNC CATEGORIA_FUNCIONAL
from ria010
INNER JOIN SRA010 ON RA_MAT = RIA010.RIA_MAT AND SRA010.D_E_L_E_T_ = ' '
where ria010.D_E_L_E_T_ = ' ' AND RIA_NRDGOZ > 0 AND RIA_STATUS <> '1';

-- LISTA DE INDENIZADOS
select ria_mat    MATRICULA,
       ria_pd     VERBA,
       RIA_DTINPA DATA_INICIO_PERIODO_AQUISITIVO,
       RIA_DATINI INICIO,
       RIA_DATFIM FIM,
       RIA_NRDIND DIAS_INDENIZADOS,
       RIA_STATUS STATUS,
       ria_obs    OBSERVACAO,
       ria_nrport GEDOC,
       RA_CATFUNC CATEGORIA_FUNCIONAL
from ria010
INNER JOIN SRA010 ON RA_MAT = RIA010.RIA_MAT AND SRA010.D_E_L_E_T_ = ' '
where ria010.D_E_L_E_T_ = ' ' AND RIA010.RIA_NRDIND > 0 AND RIA_STATUS <> '1';



--Status protheus 

0 - Programado 
1 - Cancelado
2 - Suspenso 
3 - Retificado
4 - Quitado


Como zerar programações e direitos Athenas

--DELETE FROM dayoff_activity_modifieds;
--DELETE FROM dayoff_usufruct;
--DELETE FROM dayoff_activity;

1. Como gravar no Athenas


dayoff_activityPADRÃO/USUFRUTOQUANDO FOR INDENIZADOOBSERVAÇÃO
idGerado automaticamente

created_at                    
Data hora atual

modified_at                   
Data hora atual

immediate_authorization_at    
NULL

mediate_authorization_at      
NULL

admin_authorization_at        
NULL

homologation_at               
NULL

status4


4 - HOMOLOGADO 7 - VENDIDO


ACT_ST_CREATED = 1
ACT_ST_AUTHORIZED = 2
ACT_ST_AUTHORIZED_M = 6
ACT_ST_NOT_AUTHORIZED = 3
ACT_ST_HOMOLOGATED = 4
ACT_ST_CANCELED = 5
ACT_ST_SOLD = 7


ACTIVITY_STATUS_CHOICE = {
    ACT_ST_CREATED'CRIADO',
    ACT_ST_AUTHORIZED'AUTORIZADO',
    ACT_ST_AUTHORIZED_M'AUTORIZADO CHEFE MEDIATO',
    ACT_ST_NOT_AUTHORIZED'NÃO AUTORIZADO',
    ACT_ST_HOMOLOGATED'HOMOLOGADO',
    ACT_ST_CANCELED'CANCELADO',
    ACT_ST_SOLD'VENDIDO'
}

type_of_activity              
1 - MARCACAO
7 - VENDA


ACT_BOOK = 1
ACT_CHANGE = 2
ACT_SUSPEND = 3
ACT_INTERRUPT = 4
ACT_INDEMNIFY = 5
ACT_SELL = 7


ACTIVITY_TYPE_CHOICE = {
    ACT_BOOK'MARCAÇÃO',  # usuario validar quando não estiver autorizado
    ACT_CHANGE'ALTERAÇÃO',  # usuario validar quando não estiver autorizado
    ACT_SUSPEND'SUSPENSÃO',
    ACT_INTERRUPT'INTERRUPÇÃO',
    ACT_INDEMNIFY'INDENIZAÇÃO',  # ação do admin/athenas
    ACT_SELL'VENDA',  # pedido do usuário, solicitação de venda # usuario validar quando não estiver autorizado
}

justification                 
""

days_in_cache                 
DIAS_GOZO
DIAS_INDENIZADOS

days_out_cache                
0

days_left_cache               
0

note                          
false

authorized_immediate          
true

authorized_mediate            
true

authorized                    
true

authorized_at
NULL

homologated                   
true

canceled                      
false

scale_homologation            
false

acquisition_period_id         

Para buscar o periodo aquisitivo correspondente:

RF_PDsub_type_of_usufruct
S25(Férias)

Se servidor CATEGORIA_FUNCIONAL not in ('0','1') então 9000

Se servidor CATEGORIA_FUNCIONAL in ('0','1') então 9001

S67(DISPENSA ELEITORAL)9004
S68(PLANTAO)9007 → 9005
D82(GRATIFICACAO PLANTAO)9005
S58(RECESSO-ESTAGIARIO)9010
S59(BS LICENCA PREMIO)9009
S60(BS FER COMP-MEMBRO)9008
S69(CONCURSO ESTAGIARIO)9012
S81(FOLGA COMPENSATORIA)9006 → 9007
S83(RECESSO FORENSE)9002
S85(CONCURSO PROM SUBSTI)9011


select *
from dayoff_configuration
inner join dayoff_groupperiod on dayoff_configuration.id = dayoff_groupperiod.configuration_id
inner join dayoff_acquisitionperiod on dayoff_groupperiod.id = dayoff_acquisitionperiod.group_period_id
where sub_type_of_usufruct = ?sub_type_of_usufruct ? and dayoff_acquisitionperiod.start_date_acquisition = ?PROTHEUS:DATA_INICIO_PERIODO_AQUISITIVO?


sub_type_of_usufruct

9000 - Férias Regulamentares

9001 - Férias Individuais

9002 - Recesso Forense

9003 - Folga de Aniversário

9004 - Folga Eleitoral

9005 - Plantão (Servidores)

9006 - <vago>

9007 - Folgas Compensatórias de Membros

9008 - Férias Compensatórias de Membros

9009- Licença Prêmio

9010 - Recesso de Estagiário

9011 - Concurso Promotor Substituto

9012 - Concurso de Estagiários

immediate_authorization_by_id
1

annotation_id
NULL

created_by_id1

homologation_by_id1

immediate_authorization_by_id
NULL

mediate_authorization_by_id    
NULL

modified_by_id1

Tabela dayoff_usufruct


id

ID gerado automaticamente

created_atData hora atual

modified_atData hora atual

status44096

USUFRUCT_STATUS_CHOICE = {
    USU_NEW"Inclusão solicitada",
    USU_AUTORIZED_CI"Autorizado",
    USU_HOMOLOGATED"Homologado",  # CRIAR AFASTAMENTO
    USU_CHANGED"Alterado",  # APAGAR AFASTAMENTO
    USU_CHANGING"Alteração solicitada",
    USU_INTERRUPTED"Interrompido",  # ALTERAR AFASTAMENTO
    USU_SUSPENDED"Suspenso",  # APAGAR AFASTAMENTO
    USU_ENJOYING"Em fruição",
    USU_ENJOYED"Usufruído",
    USU_NOT_AUTHORIZED"Não autorizado",
    USU_SUBSTITUTE"Substituto",
    USU_SOLD"Vendido",
    USU_CANCELED"Cancelado"
}

USU_NEW = 1
USU_AUTORIZED_CI = 2
USU_HOMOLOGATED = 4
USU_CHANGING = 8
USU_CHANGED = 16
USU_INTERRUPTED = 32
USU_SUSPENDED = 64
USU_ENJOYING = 128
USU_ENJOYED = 256
USU_NOT_AUTHORIZED = 512
USU_SUBSTITUTE = 1024
USU_CANCELED = 2048
USU_SOLD = 4096

start_dateINICIONULL
end_dateFIMNULL
daysDIAS_GOZO
DIAS_INDENIZADOS

from_scalefalse

activity_idid da activity gerada

created_by_id1

modified_by_id1

departure_id

Buscar em afastamentos o id do afastamento:


select movimentacaopessoal_ptr_id
from afastamento_baselicencaafast
inner join rh_movpessoal rm on afastamento_baselicencaafast.movimentacaopessoal_ptr_id = rm.id
inner join rh_servidor on rm.servidor_id = rh_servidor.id
where matricula = 6564 and data_inicio = '?INICIO?' and data_fim = '?FIM?';

NULL




















Rascunho
select
    status,
    start_date_acquisition,
    end_date_acquisition,
    start_date_fruition,
    days,
    suspended_days,
    description,
    group_period_id,
    employee_id
from dayoff_acquisitionperiod;


INSERT INTO public.dayoff_groupperiod (created_at, modified_at, created_by_id, modified_by_id, title, period, start_date_book, start_date_fruition, year_reference, blocked, configuration_id)
VALUES
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2022-01-01', '2022-01-01', 2021, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2021-01-01', '2021-01-01', 2020, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2020-01-01', '2020-01-01', 2019, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2019-01-01', '2019-01-01', 2018, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2018-01-01', '2018-01-01', 2017, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2017-01-01', '2017-01-01', 2016, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2016-01-01', '2016-01-01', 2015, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2015-01-01', '2015-01-01', 2014, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2014-01-01', '2014-01-01', 2013, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2013-01-01', '2013-01-01', 2012, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2012-01-01', '2012-01-01', 2011, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2011-01-01', '2011-01-01', 2010, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2010-01-01', '2010-01-01', 2009, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2009-01-01', '2009-01-01', 2008, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2008-01-01', '2008-01-01', 2007, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2007-01-01', '2007-01-01', 2006, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2006-01-01', '2006-01-01', 2005, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2005-01-01', '2005-01-01', 2004, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2004-01-01', '2004-01-01', 2003, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2003-01-01', '2003-01-01', 2002, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2002-01-01', '2002-01-01', 2001, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '2001-01-01', '2001-01-01', 2000, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '1999-01-01', '1999-01-01', 1998, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '1997-01-01', '1997-01-01', 1996, false, 10),
(now(), now(), 1,1, 'FERIAS REGULAMENTARES ', 1, '1991-01-01', '1991-01-01', 1990, false, 10)
;





select from rh_servidor where id = '631274'-- 006402
select from dayoff_configuration where type_of_usufruct = '4'-- tipo eleicoes
select from dayoff_groupperiod where configuration_id = '4';
select
    start_date_acquisition INICIO_PERIODO_AQUISITIVO,
    end_date_acquisition   FIM_PERIODO_AQUISITIVO,
    days TOTAL,
    booked_days_cache DIAS_AGENDADOS,
    days_to_enjoy_cache SALDO,
    suspended_days DIAS_SUSPENSOS
from dayoff_acquisitionperiod
where
    group_period_id in ('19','4','17','18'and
    employee_id = '631274' and
    status not in (1, 4, 12);



ria_status

0 = Programado
1 = Cancelado
2 = Suspenso
3 = Retificado
4 = Quitado



INSERT INTO public.dayoff_acquisitionperiod

(indemnified, note, pendency, continuous_period,blocked,automatic_created, real_days_cache, booked_days_cache, days_to_enjoy_cache, paid_days_cache, days_not_booked_cache, paid_without_payroll, created_at,modified_at,status,start_date_acquisition,end_date_acquisition,start_date_fruition,days,suspended_days,created_by_id,employee_id,group_period_id,modified_by_id)

VALUES (false,  false, false, false, false, false, 30, 0,30, 0,30, false, now(),now(),2,'2013-02-13','2014-02-12','2014-01-01', 30,  0,  1, 627393, 41, 1);

Related content

Historico_300. Migração de afastamentos
Historico_300. Migração de afastamentos
More like this
Historico_02- Intranet
Historico_02- Intranet
More like this
Historico_200. Migração de dias de direito
Historico_200. Migração de dias de direito
More like this
Historico_03- Aposentados
Historico_03- Aposentados
More like this
Historico_Sistemas a serem Migrados
Historico_Sistemas a serem Migrados
More like this
Historico_400. Migração de Dados Bancários
Historico_400. Migração de Dados Bancários
More like this