From 1b4f7d7e59851473e77d8091371fc4c7e0a958a4 Mon Sep 17 00:00:00 2001 From: Joellensilva Date: Mon, 22 Jan 2024 16:29:43 -0300 Subject: [PATCH 1/3] =?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() } From c705bf52b30d3092076620261db05b018d710e22 Mon Sep 17 00:00:00 2001 From: Joellensilva Date: Mon, 22 Jan 2024 17:03:26 -0300 Subject: [PATCH 2/3] =?UTF-8?q?endere=C3=A7ando=20coment=C3=A1rios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/summary.go | 2 +- repo/database/dto/annuaISummary.go | 4 ++-- repo/database/dto/generalMonthlyInfo.go | 6 +++--- repo/database/postgres_test.go | 21 ++++++++++++--------- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/models/summary.go b/models/summary.go index b1c4fef..473a39e 100644 --- a/models/summary.go +++ b/models/summary.go @@ -29,6 +29,6 @@ type DataSummary struct { type ItemSummary struct { FoodAllowance float64 `json:"auxilio_alimentacao,omitempty"` - BonusLicence float64 `json:"licenca_premio,omitempty"` + BonusLicense 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 99649d9..6b9cfbc 100644 --- a/repo/database/dto/annuaISummary.go +++ b/repo/database/dto/annuaISummary.go @@ -28,7 +28,7 @@ func NewAnnualSummaryDTO(ami models.AnnualSummary) *AnnualSummaryDTO { NumMonthsWithData: ami.NumMonthsWithData, ItemSummary: ItemSummary{ FoodAllowance: ami.ItemSummary.FoodAllowance, - BonusLicence: ami.ItemSummary.BonusLicence, + BonusLicense: ami.ItemSummary.BonusLicense, Others: ami.ItemSummary.Others, }, } @@ -46,7 +46,7 @@ func (ami *AnnualSummaryDTO) ConvertToModel() *models.AnnualSummary { NumMonthsWithData: ami.NumMonthsWithData, ItemSummary: models.ItemSummary{ FoodAllowance: ami.ItemSummary.FoodAllowance, - BonusLicence: ami.ItemSummary.BonusLicence, + BonusLicense: ami.ItemSummary.BonusLicense, Others: ami.ItemSummary.Others, }, } diff --git a/repo/database/dto/generalMonthlyInfo.go b/repo/database/dto/generalMonthlyInfo.go index a19f33e..279f6f1 100644 --- a/repo/database/dto/generalMonthlyInfo.go +++ b/repo/database/dto/generalMonthlyInfo.go @@ -16,7 +16,7 @@ type GeneralMonthlyInfoDTO struct { type ItemSummary struct { FoodAllowance float64 `gorm:"column:auxilio_alimentacao"` - BonusLicence float64 `gorm:"column:licenca_premio"` + BonusLicense float64 `gorm:"column:licenca_premio"` Others float64 `gorm:"column:outras"` } @@ -30,7 +30,7 @@ func NewGeneralMonthlyInfoDTO(gmi models.GeneralMonthlyInfo) *GeneralMonthlyInfo Remunerations: gmi.Remunerations, ItemSummary: ItemSummary{ FoodAllowance: gmi.ItemSummary.FoodAllowance, - BonusLicence: gmi.ItemSummary.BonusLicence, + BonusLicense: gmi.ItemSummary.BonusLicense, Others: gmi.ItemSummary.Others, }, } @@ -46,7 +46,7 @@ func (gmi *GeneralMonthlyInfoDTO) ConvertToModel() *models.GeneralMonthlyInfo { Remunerations: gmi.Remunerations, ItemSummary: models.ItemSummary{ FoodAllowance: gmi.ItemSummary.FoodAllowance, - BonusLicence: gmi.ItemSummary.BonusLicence, + BonusLicense: gmi.ItemSummary.BonusLicense, Others: gmi.ItemSummary.Others, }, } diff --git a/repo/database/postgres_test.go b/repo/database/postgres_test.go index 6dec8ea..dcd7c74 100644 --- a/repo/database/postgres_test.go +++ b/repo/database/postgres_test.go @@ -991,8 +991,9 @@ func (g getAnnualSummary) testWhenMonthlyInfoExists(t *testing.T) { Total: 1500, }, ItemSummary: models.ItemSummary{ - Others: 100, - BonusLicence: 200, + Others: 100, + FoodAllowance: 150, + BonusLicense: 200, }, }, }, @@ -1043,8 +1044,9 @@ 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, - BonusLicence: agmi.Summary.ItemSummary.BonusLicence + agmi2.Summary.ItemSummary.BonusLicence, + Others: agmi.Summary.ItemSummary.Others + agmi2.Summary.ItemSummary.Others, + BonusLicense: agmi.Summary.ItemSummary.BonusLicense + agmi2.Summary.ItemSummary.BonusLicense, + FoodAllowance: agmi.Summary.ItemSummary.FoodAllowance + agmi2.Summary.ItemSummary.FoodAllowance, }, }) } @@ -1066,7 +1068,8 @@ 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) + assert.Equal(t, amis[1].ItemSummary.BonusLicense, returnedAmis[1].ItemSummary.BonusLicense) + assert.Equal(t, amis[1].ItemSummary.FoodAllowance, returnedAmis[1].ItemSummary.FoodAllowance) truncateTables() } @@ -1222,7 +1225,7 @@ func (g getGeneralMonthlyInfoFromYear) testWhenDataExists(t *testing.T) { Total: 3750, }, ItemSummary: models.ItemSummary{ - BonusLicence: 400, + BonusLicense: 400, }, }, }, @@ -1256,7 +1259,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, + BonusLicense: agmi.Summary.ItemSummary.BonusLicense + agmi2.Summary.ItemSummary.BonusLicense, }, }) } @@ -1408,7 +1411,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, + BonusLicense: 150, Others: 200, }, }, @@ -1473,7 +1476,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) + assert.Equal(t, agmi.Summary.ItemSummary.BonusLicense, result.Summary.ItemSummary.BonusLicense) truncateTables() } From a0e69cf4a3bdb4a57967874a315ccf8f2c05825d Mon Sep 17 00:00:00 2001 From: Joellensilva Date: Mon, 22 Jan 2024 17:08:56 -0300 Subject: [PATCH 3/3] adicionando food-allowance ao teste --- repo/database/postgres_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/repo/database/postgres_test.go b/repo/database/postgres_test.go index dcd7c74..9b568fd 100644 --- a/repo/database/postgres_test.go +++ b/repo/database/postgres_test.go @@ -1225,7 +1225,8 @@ func (g getGeneralMonthlyInfoFromYear) testWhenDataExists(t *testing.T) { Total: 3750, }, ItemSummary: models.ItemSummary{ - BonusLicense: 400, + BonusLicense: 400, + FoodAllowance: 100, }, }, },