From dbf9a2ff80bff014bde8587599c27b9d94268f2a Mon Sep 17 00:00:00 2001 From: Joellensilva Date: Sat, 11 May 2024 22:01:59 -0300 Subject: [PATCH] =?UTF-8?q?adicionando=20f=C3=A9rias?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/summary.go | 3 ++- repo/database/dto/annuaISummary.go | 2 ++ repo/database/dto/generalMonthlyInfo.go | 3 +++ repo/database/postgres.go | 2 ++ repo/database/postgres_test.go | 7 +++++++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/models/summary.go b/models/summary.go index e3c63be..2b0ea2f 100644 --- a/models/summary.go +++ b/models/summary.go @@ -30,7 +30,8 @@ type DataSummary struct { type ItemSummary struct { FoodAllowance float64 `json:"auxilio_alimentacao,omitempty"` BonusLicense float64 `json:"licenca_premio,omitempty"` - VacationCompensation float64 `json:"indenizacao_de_ferias,omitempty"` + VacationCompensation float64 `json:"indenizacao_de_ferias,omitempty"` // indenização + Vacation float64 `json:"ferias,omitempty"` ChristmasBonus float64 `json:"gratificacao_natalina,omitempty"` CompensatoryLicense float64 `json:"licenca_compensatoria,omitempty"` HealthAllowance float64 `json:"auxilio_saude,omitempty"` diff --git a/repo/database/dto/annuaISummary.go b/repo/database/dto/annuaISummary.go index e1ebe10..9fb9ec5 100644 --- a/repo/database/dto/annuaISummary.go +++ b/repo/database/dto/annuaISummary.go @@ -30,6 +30,7 @@ func NewAnnualSummaryDTO(ami models.AnnualSummary) *AnnualSummaryDTO { FoodAllowance: ami.ItemSummary.FoodAllowance, BonusLicense: ami.ItemSummary.BonusLicense, VacationCompensation: ami.ItemSummary.VacationCompensation, + Vacation: ami.ItemSummary.Vacation, ChristmasBonus: ami.ItemSummary.ChristmasBonus, CompensatoryLicense: ami.ItemSummary.CompensatoryLicense, HealthAllowance: ami.ItemSummary.HealthAllowance, @@ -52,6 +53,7 @@ func (ami *AnnualSummaryDTO) ConvertToModel() *models.AnnualSummary { FoodAllowance: ami.ItemSummary.FoodAllowance, BonusLicense: ami.ItemSummary.BonusLicense, VacationCompensation: ami.ItemSummary.VacationCompensation, + Vacation: ami.ItemSummary.Vacation, ChristmasBonus: ami.ItemSummary.ChristmasBonus, CompensatoryLicense: ami.ItemSummary.CompensatoryLicense, HealthAllowance: ami.ItemSummary.HealthAllowance, diff --git a/repo/database/dto/generalMonthlyInfo.go b/repo/database/dto/generalMonthlyInfo.go index c95d665..c04a77f 100644 --- a/repo/database/dto/generalMonthlyInfo.go +++ b/repo/database/dto/generalMonthlyInfo.go @@ -18,6 +18,7 @@ type ItemSummary struct { FoodAllowance float64 `gorm:"column:auxilio_alimentacao"` BonusLicense float64 `gorm:"column:licenca_premio"` VacationCompensation float64 `gorm:"column:indenizacao_de_ferias"` + Vacation float64 `gorm:"column:ferias"` ChristmasBonus float64 `gorm:"column:gratificacao_natalina"` CompensatoryLicense float64 `gorm:"column:licenca_compensatoria"` HealthAllowance float64 `gorm:"column:auxilio_saude"` @@ -36,6 +37,7 @@ func NewGeneralMonthlyInfoDTO(gmi models.GeneralMonthlyInfo) *GeneralMonthlyInfo FoodAllowance: gmi.ItemSummary.FoodAllowance, BonusLicense: gmi.ItemSummary.BonusLicense, VacationCompensation: gmi.ItemSummary.VacationCompensation, + Vacation: gmi.ItemSummary.Vacation, ChristmasBonus: gmi.ItemSummary.ChristmasBonus, CompensatoryLicense: gmi.ItemSummary.CompensatoryLicense, HealthAllowance: gmi.ItemSummary.HealthAllowance, @@ -56,6 +58,7 @@ func (gmi *GeneralMonthlyInfoDTO) ConvertToModel() *models.GeneralMonthlyInfo { FoodAllowance: gmi.ItemSummary.FoodAllowance, BonusLicense: gmi.ItemSummary.BonusLicense, VacationCompensation: gmi.ItemSummary.VacationCompensation, + Vacation: gmi.ItemSummary.Vacation, ChristmasBonus: gmi.ItemSummary.ChristmasBonus, CompensatoryLicense: gmi.ItemSummary.CompensatoryLicense, HealthAllowance: gmi.ItemSummary.HealthAllowance, diff --git a/repo/database/postgres.go b/repo/database/postgres.go index ede5e0f..23bd74c 100644 --- a/repo/database/postgres.go +++ b/repo/database/postgres.go @@ -322,6 +322,7 @@ func (p *PostgresDB) GetAnnualSummary(agency string) ([]models.AnnualSummary, er SUM(CAST(sumario -> 'resumo_rubricas' ->> 'licenca_compensatoria' AS DECIMAL)) AS licenca_compensatoria, SUM(CAST(sumario -> 'resumo_rubricas' ->> 'auxilio_saude' AS DECIMAL)) AS auxilio_saude, SUM(CAST(sumario -> 'resumo_rubricas' ->> 'outras' AS DECIMAL)) AS outras, + SUM(CAST(sumario -> 'resumo_rubricas' ->> 'ferias' AS DECIMAL)) AS ferias, COUNT(*) AS meses_com_dados` m := p.db.Model(&dtoAgmi).Select(query) m = m.Where("id_orgao = ? AND atual = TRUE AND (procinfo::text = 'null' OR procinfo IS NULL) ", agency) @@ -373,6 +374,7 @@ func (p *PostgresDB) GetGeneralMonthlyInfosFromYear(year int) ([]models.GeneralM SUM(CAST(sumario -> 'resumo_rubricas' ->> 'gratificacao_natalina' AS DECIMAL)) AS gratificacao_natalina, SUM(CAST(sumario -> 'resumo_rubricas' ->> 'licenca_compensatoria' AS DECIMAL)) AS licenca_compensatoria, SUM(CAST(sumario -> 'resumo_rubricas' ->> 'auxilio_saude' AS DECIMAL)) AS auxilio_saude, + SUM(CAST(sumario -> 'resumo_rubricas' ->> 'ferias' AS DECIMAL)) AS ferias, SUM(CAST(sumario -> 'resumo_rubricas' ->> 'outras' AS DECIMAL)) AS outras` m := p.db.Model(&dtoAgmi).Select(query) m = m.Where("ano = ? AND atual=true AND (procinfo IS NULL OR procinfo::text = 'null')", year) diff --git a/repo/database/postgres_test.go b/repo/database/postgres_test.go index 6d00717..71d958b 100644 --- a/repo/database/postgres_test.go +++ b/repo/database/postgres_test.go @@ -998,6 +998,7 @@ func (g getAnnualSummary) testWhenMonthlyInfoExists(t *testing.T) { CompensatoryLicense: 75, VacationCompensation: 50, HealthAllowance: 125, + Vacation: 300, }, }, }, @@ -1055,6 +1056,7 @@ func (g getAnnualSummary) testWhenMonthlyInfoExists(t *testing.T) { ChristmasBonus: agmi.Summary.ItemSummary.ChristmasBonus + agmi2.Summary.ItemSummary.ChristmasBonus, CompensatoryLicense: agmi.Summary.ItemSummary.CompensatoryLicense + agmi2.Summary.ItemSummary.CompensatoryLicense, HealthAllowance: agmi.Summary.ItemSummary.HealthAllowance + agmi2.Summary.ItemSummary.HealthAllowance, + Vacation: agmi.Summary.ItemSummary.Vacation + agmi2.Summary.ItemSummary.Vacation, }, }) } @@ -1082,6 +1084,7 @@ func (g getAnnualSummary) testWhenMonthlyInfoExists(t *testing.T) { assert.Equal(t, amis[1].ItemSummary.ChristmasBonus, returnedAmis[1].ItemSummary.ChristmasBonus) assert.Equal(t, amis[1].ItemSummary.CompensatoryLicense, returnedAmis[1].ItemSummary.CompensatoryLicense) assert.Equal(t, amis[1].ItemSummary.HealthAllowance, returnedAmis[1].ItemSummary.HealthAllowance) + assert.Equal(t, amis[1].ItemSummary.Vacation, returnedAmis[1].ItemSummary.Vacation) truncateTables() } @@ -1243,6 +1246,7 @@ func (g getGeneralMonthlyInfoFromYear) testWhenDataExists(t *testing.T) { ChristmasBonus: 75, CompensatoryLicense: 175, HealthAllowance: 130, + Vacation: 300, }, }, }, @@ -1281,6 +1285,7 @@ func (g getGeneralMonthlyInfoFromYear) testWhenDataExists(t *testing.T) { ChristmasBonus: agmi.Summary.ItemSummary.ChristmasBonus + agmi2.Summary.ItemSummary.ChristmasBonus, CompensatoryLicense: agmi.Summary.ItemSummary.CompensatoryLicense + agmi2.Summary.ItemSummary.CompensatoryLicense, HealthAllowance: agmi.Summary.ItemSummary.HealthAllowance + agmi2.Summary.ItemSummary.HealthAllowance, + Vacation: agmi.Summary.ItemSummary.Vacation + agmi2.Summary.ItemSummary.Vacation, }, }) } @@ -1437,6 +1442,7 @@ func (s store) testWhenDataIsOK(t *testing.T) { ChristmasBonus: 175, CompensatoryLicense: 120, HealthAllowance: 130, + Vacation: 300, Others: 200, }, }, @@ -1506,6 +1512,7 @@ func (s store) testWhenDataIsOK(t *testing.T) { assert.Equal(t, agmi.Summary.ItemSummary.ChristmasBonus, result.Summary.ItemSummary.ChristmasBonus) assert.Equal(t, agmi.Summary.ItemSummary.CompensatoryLicense, result.Summary.ItemSummary.CompensatoryLicense) assert.Equal(t, agmi.Summary.ItemSummary.HealthAllowance, result.Summary.ItemSummary.HealthAllowance) + assert.Equal(t, agmi.Summary.ItemSummary.Vacation, result.Summary.ItemSummary.Vacation) truncateTables() }