From 1b4f7d7e59851473e77d8091371fc4c7e0a958a4 Mon Sep 17 00:00:00 2001 From: Joellensilva Date: Mon, 22 Jan 2024 16:29:43 -0300 Subject: [PATCH] =?UTF-8?q?adicionando=20licen=C3=A7a-pr=C3=AAmio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/summary.go | 1 + repo/database/dto/annuaISummary.go | 2 ++ repo/database/dto/generalMonthlyInfo.go | 3 +++ repo/database/postgres.go | 2 ++ repo/database/postgres_test.go | 14 +++++++++++++- 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/models/summary.go b/models/summary.go index 120e77c..b1c4fef 100644 --- a/models/summary.go +++ b/models/summary.go @@ -29,5 +29,6 @@ type DataSummary struct { type ItemSummary struct { FoodAllowance float64 `json:"auxilio_alimentacao,omitempty"` + BonusLicence float64 `json:"licenca_premio,omitempty"` Others float64 `json:"outras,omitempty"` // valor agregado de outras rubricas não identificadas } diff --git a/repo/database/dto/annuaISummary.go b/repo/database/dto/annuaISummary.go index cc5e0c5..99649d9 100644 --- a/repo/database/dto/annuaISummary.go +++ b/repo/database/dto/annuaISummary.go @@ -28,6 +28,7 @@ func NewAnnualSummaryDTO(ami models.AnnualSummary) *AnnualSummaryDTO { NumMonthsWithData: ami.NumMonthsWithData, ItemSummary: ItemSummary{ FoodAllowance: ami.ItemSummary.FoodAllowance, + BonusLicence: ami.ItemSummary.BonusLicence, Others: ami.ItemSummary.Others, }, } @@ -45,6 +46,7 @@ func (ami *AnnualSummaryDTO) ConvertToModel() *models.AnnualSummary { NumMonthsWithData: ami.NumMonthsWithData, ItemSummary: models.ItemSummary{ FoodAllowance: ami.ItemSummary.FoodAllowance, + BonusLicence: ami.ItemSummary.BonusLicence, Others: ami.ItemSummary.Others, }, } diff --git a/repo/database/dto/generalMonthlyInfo.go b/repo/database/dto/generalMonthlyInfo.go index 4ad45d2..a19f33e 100644 --- a/repo/database/dto/generalMonthlyInfo.go +++ b/repo/database/dto/generalMonthlyInfo.go @@ -16,6 +16,7 @@ type GeneralMonthlyInfoDTO struct { type ItemSummary struct { FoodAllowance float64 `gorm:"column:auxilio_alimentacao"` + BonusLicence float64 `gorm:"column:licenca_premio"` Others float64 `gorm:"column:outras"` } @@ -29,6 +30,7 @@ func NewGeneralMonthlyInfoDTO(gmi models.GeneralMonthlyInfo) *GeneralMonthlyInfo Remunerations: gmi.Remunerations, ItemSummary: ItemSummary{ FoodAllowance: gmi.ItemSummary.FoodAllowance, + BonusLicence: gmi.ItemSummary.BonusLicence, Others: gmi.ItemSummary.Others, }, } @@ -44,6 +46,7 @@ func (gmi *GeneralMonthlyInfoDTO) ConvertToModel() *models.GeneralMonthlyInfo { Remunerations: gmi.Remunerations, ItemSummary: models.ItemSummary{ FoodAllowance: gmi.ItemSummary.FoodAllowance, + BonusLicence: gmi.ItemSummary.BonusLicence, Others: gmi.ItemSummary.Others, }, } diff --git a/repo/database/postgres.go b/repo/database/postgres.go index cfb9048..8003a16 100644 --- a/repo/database/postgres.go +++ b/repo/database/postgres.go @@ -316,6 +316,7 @@ func (p *PostgresDB) GetAnnualSummary(agency string) ([]models.AnnualSummary, er SUM(CAST(sumario -> 'descontos' ->> 'total' AS DECIMAL)) AS descontos, SUM(CAST(sumario -> 'remuneracoes' ->> 'total' AS DECIMAL)) AS remuneracoes, SUM(CAST(sumario -> 'resumo_rubricas' ->> 'auxilio_alimentacao' AS DECIMAL)) AS auxilio_alimentacao, + SUM(CAST(sumario -> 'resumo_rubricas' ->> 'licenca_premio' AS DECIMAL)) AS licenca_premio, SUM(CAST(sumario -> 'resumo_rubricas' ->> 'outras' AS DECIMAL)) AS outras, COUNT(*) AS meses_com_dados` m := p.db.Model(&dtoAgmi).Select(query) @@ -363,6 +364,7 @@ func (p *PostgresDB) GetGeneralMonthlyInfosFromYear(year int) ([]models.GeneralM SUM(CAST(sumario -> 'descontos' ->> 'total' AS DECIMAL)) AS descontos, SUM(CAST(sumario -> 'remuneracoes' ->> 'total' AS DECIMAL)) AS remuneracoes, SUM(CAST(sumario -> 'resumo_rubricas' ->> 'auxilio_alimentacao' AS DECIMAL)) AS auxilio_alimentacao, + SUM(CAST(sumario -> 'resumo_rubricas' ->> 'licenca_premio' AS DECIMAL)) AS licenca_premio, 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 c23cc31..6dec8ea 100644 --- a/repo/database/postgres_test.go +++ b/repo/database/postgres_test.go @@ -990,6 +990,10 @@ func (g getAnnualSummary) testWhenMonthlyInfoExists(t *testing.T) { Remunerations: models.DataSummary{ Total: 1500, }, + ItemSummary: models.ItemSummary{ + Others: 100, + BonusLicence: 200, + }, }, }, { @@ -1039,7 +1043,8 @@ func (g getAnnualSummary) testWhenMonthlyInfoExists(t *testing.T) { Discounts: agmi.Summary.Discounts.Total + agmi2.Summary.Discounts.Total, Remunerations: agmi.Summary.Remunerations.Total + agmi2.Summary.Remunerations.Total, ItemSummary: models.ItemSummary{ - Others: agmi.Summary.ItemSummary.Others + agmi2.Summary.ItemSummary.Others, + Others: agmi.Summary.ItemSummary.Others + agmi2.Summary.ItemSummary.Others, + BonusLicence: agmi.Summary.ItemSummary.BonusLicence + agmi2.Summary.ItemSummary.BonusLicence, }, }) } @@ -1061,6 +1066,7 @@ func (g getAnnualSummary) testWhenMonthlyInfoExists(t *testing.T) { assert.Equal(t, amis[1].TotalCount, returnedAmis[1].TotalCount) assert.Equal(t, 2, returnedAmis[0].NumMonthsWithData) assert.Equal(t, amis[0].ItemSummary.Others, returnedAmis[0].ItemSummary.Others) + assert.Equal(t, amis[1].ItemSummary.BonusLicence, returnedAmis[1].ItemSummary.BonusLicence) truncateTables() } @@ -1215,6 +1221,9 @@ func (g getGeneralMonthlyInfoFromYear) testWhenDataExists(t *testing.T) { Remunerations: models.DataSummary{ Total: 3750, }, + ItemSummary: models.ItemSummary{ + BonusLicence: 400, + }, }, }, } @@ -1247,6 +1256,7 @@ func (g getGeneralMonthlyInfoFromYear) testWhenDataExists(t *testing.T) { Remunerations: agmi.Summary.Remunerations.Total + agmi2.Summary.Remunerations.Total, ItemSummary: models.ItemSummary{ FoodAllowance: agmi.Summary.ItemSummary.FoodAllowance + agmi2.Summary.ItemSummary.FoodAllowance, + BonusLicence: agmi.Summary.ItemSummary.BonusLicence + agmi2.Summary.ItemSummary.BonusLicence, }, }) } @@ -1398,6 +1408,7 @@ func (s store) testWhenDataIsOK(t *testing.T) { IncomeHistogram: map[int]int{-1: 0, 10000: 0, 20000: 0, 30000: 116, 40000: 546, 50000: 0}, ItemSummary: models.ItemSummary{ FoodAllowance: 100, + BonusLicence: 150, Others: 200, }, }, @@ -1462,6 +1473,7 @@ func (s store) testWhenDataIsOK(t *testing.T) { assert.Equal(t, agmi.Score.Score, result.Score.Score) assert.Equal(t, agmi.Duration, result.Duration) assert.Equal(t, agmi.Summary.ItemSummary.FoodAllowance, result.Summary.ItemSummary.FoodAllowance) + assert.Equal(t, agmi.Summary.ItemSummary.BonusLicence, result.Summary.ItemSummary.BonusLicence) truncateTables() }