Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Novas regras de apuração do subsídio #300

Merged
merged 24 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
adc8d47
add DATA_SUBSIDIO_V10_INICIO
akaBotelho Nov 5, 2024
969c003
add regras resolucao 3777/2024
akaBotelho Nov 5, 2024
3073114
Merge branch 'main' into staging/novas-regras-apuracao
mergify[bot] Nov 5, 2024
ba38095
registra flow
akaBotelho Nov 5, 2024
8393f7e
add changelog
akaBotelho Nov 5, 2024
60b11fa
Merge branch 'staging/novas-regras-apuracao' of https://github.com/pr…
akaBotelho Nov 5, 2024
8426414
Update queries/models/dashboard_subsidio_sppo/CHANGELOG.md
eng-rodrigocunha Nov 5, 2024
2426e7c
Merge branch 'main' into staging/novas-regras-apuracao
mergify[bot] Nov 6, 2024
17f32db
Merge branch 'main' into staging/novas-regras-apuracao
mergify[bot] Nov 6, 2024
98533fb
Merge branch 'main' into staging/novas-regras-apuracao
mergify[bot] Nov 7, 2024
cb3d119
Merge branch 'main' into staging/novas-regras-apuracao
mergify[bot] Nov 7, 2024
2722038
Merge branch 'main' into staging/novas-regras-apuracao
mergify[bot] Nov 11, 2024
b831052
ajuste nas regras
akaBotelho Nov 25, 2024
9312ee7
Merge branch 'main' into staging/novas-regras-apuracao
akaBotelho Nov 25, 2024
6150231
Merge branch 'main' into staging/novas-regras-apuracao
mergify[bot] Nov 25, 2024
22204a9
corrige regras, add indicador_circular, versao e datetime_ultima_atua…
akaBotelho Nov 25, 2024
5abee4f
Merge branch 'staging/novas-regras-apuracao' of https://github.com/pr…
akaBotelho Nov 25, 2024
b8c6fd8
Merge branch 'main' into staging/novas-regras-apuracao
mergify[bot] Nov 25, 2024
fabad29
altera changelog e corrige logica circular
akaBotelho Nov 25, 2024
6ee39dd
Merge branch 'staging/novas-regras-apuracao' of https://github.com/pr…
akaBotelho Nov 25, 2024
4fdbf20
Merge branch 'main' into staging/novas-regras-apuracao
mergify[bot] Nov 25, 2024
8c67439
Merge branch 'main' into staging/novas-regras-apuracao
mergify[bot] Nov 26, 2024
1352f9f
remove coluna indicador_circular
akaBotelho Nov 26, 2024
0d19e6c
Merge branch 'staging/novas-regras-apuracao' of https://github.com/pr…
akaBotelho Nov 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions queries/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ vars:
DATA_SUBSIDIO_V8_INICIO: "2024-07-20"
# Feature Apuração por faixa horária
DATA_SUBSIDIO_V9_INICIO: "2024-08-16"
# Feature Apuração por novas faixas horárias (RESOLUÇÃO SMTR 3777/2024)
DATA_SUBSIDIO_V10_INICIO: "2024-11-01"
# valor_subsidio: "`rj-smtr-dev.projeto_subsidio_sppo.valor_subsidio`"
DATA_SUBSIDIO_V11_INICIO: "2024-11-06"

Expand Down
6 changes: 6 additions & 0 deletions queries/models/dashboard_subsidio_sppo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog - dashboard_subsidio_sppo

## [7.0.6] - 2024-11-05

### Alterado

- Altera regras do modelo `viagens_remuneradas` conforme Resolução SMTR N° 3777/2024 e MTR-MEM-2024/02465 (https://github.com/prefeitura-rio/pipelines_rj_smtr/pull/300)

## [7.0.5] - 2024-10-16

### Corrigido
Expand Down
41 changes: 38 additions & 3 deletions queries/models/dashboard_subsidio_sppo/viagens_remuneradas.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ WITH
faixa_horaria_fim,
partidas_total_planejada,
distancia_total_planejada AS km_planejada,
IF(sentido = "C", TRUE, FALSE) AS indicador_circular
FROM
{{ ref("viagem_planejada") }}
-- rj-smtr.projeto_subsidio_sppo.viagem_planejada
Expand Down Expand Up @@ -75,7 +76,8 @@ WITH
p.faixa_horaria_fim,
v.viagens_planejadas,
p.km_planejada,
IF(p.data >= DATE("{{ var("DATA_SUBSIDIO_V9_INICIO") }}"), p.partidas_total_planejada, v.partidas_ida + v.partidas_volta) AS viagens_planejadas_ida_volta
IF(p.data >= DATE("{{ var("DATA_SUBSIDIO_V9_INICIO") }}"), p.partidas_total_planejada, v.partidas_ida + v.partidas_volta) AS viagens_planejadas_ida_volta,
p.indicador_circular
FROM
planejado AS p
LEFT JOIN
Expand Down Expand Up @@ -160,8 +162,39 @@ WITH
)
-- 6. Flag de viagens que serão consideradas ou não para fins de remuneração (apuração de valor de subsídio) - RESOLUÇÃO SMTR Nº 3645/2023
SELECT
v.* EXCEPT(rn, datetime_partida, viagens_planejadas, viagens_planejadas_ida_volta, km_planejada, tipo_dia, consorcio, faixa_horaria_inicio, faixa_horaria_fim),
v.* EXCEPT(rn, datetime_partida, viagens_planejadas, viagens_planejadas_ida_volta, km_planejada, tipo_dia, consorcio, faixa_horaria_inicio, faixa_horaria_fim, indicador_circular),
CASE
WHEN v.data >= DATE("{{ var("DATA_SUBSIDIO_V10_INICIO") }}")
AND v.tipo_dia = "Dia Útil"
AND viagens_planejadas < 10
AND viagens_planejadas > 5
AND pof > 100
AND rn > (viagens_planejadas_ida_volta + IF(indicador_circular, 1, 2))
THEN FALSE
WHEN v.data >= DATE("{{ var("DATA_SUBSIDIO_V10_INICIO") }}")
AND v.tipo_dia = "Dia Útil"
AND viagens_planejadas >= 10
AND pof > 110
AND rn > viagens_planejadas_ida_volta*1.1
THEN FALSE
WHEN v.data >= DATE("{{ var("DATA_SUBSIDIO_V10_INICIO") }}")
AND v.tipo_dia = "Dia Útil"
AND viagens_planejadas <= 5
AND pof > 200
AND rn > viagens_planejadas_ida_volta*2
THEN FALSE
WHEN v.data >= DATE("{{ var("DATA_SUBSIDIO_V10_INICIO") }}")
AND v.tipo_dia != "Dia Útil"
AND viagens_planejadas < 5
AND pof > 100
AND rn > (viagens_planejadas_ida_volta + IF(indicador_circular, 1, 2))
THEN FALSE
WHEN v.data >= DATE("{{ var("DATA_SUBSIDIO_V10_INICIO") }}")
AND v.tipo_dia != "Dia Útil"
AND viagens_planejadas >= 5
AND pof > 120
AND rn > viagens_planejadas_ida_volta*1.2
THEN FALSE
WHEN v.data >= DATE("{{ var("DATA_SUBSIDIO_V3A_INICIO") }}")
AND v.tipo_dia = "Dia Útil"
AND viagens_planejadas > 10
Expand All @@ -184,7 +217,9 @@ SELECT
THEN NULL
ELSE
TRUE
END AS indicador_viagem_dentro_limite
END AS indicador_viagem_dentro_limite,
'{{ var("version") }}' AS versao,
CURRENT_DATETIME("America/Sao_Paulo") as datetime_ultima_atualizacao
FROM (
SELECT
v.*,
Expand Down
Loading