Skip to content

Commit

Permalink
adicionando licença-prêmio
Browse files Browse the repository at this point in the history
  • Loading branch information
joellensilva committed Jan 22, 2024
1 parent e8fa5bd commit 1b4f7d7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions models/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions repo/database/dto/annuaISummary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
Expand All @@ -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,
},
}
Expand Down
3 changes: 3 additions & 0 deletions repo/database/dto/generalMonthlyInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand All @@ -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,
},
}
Expand All @@ -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,
},
}
Expand Down
2 changes: 2 additions & 0 deletions repo/database/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 13 additions & 1 deletion repo/database/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,10 @@ func (g getAnnualSummary) testWhenMonthlyInfoExists(t *testing.T) {
Remunerations: models.DataSummary{
Total: 1500,
},
ItemSummary: models.ItemSummary{
Others: 100,
BonusLicence: 200,
},
},
},
{
Expand Down Expand Up @@ -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,
},
})
}
Expand All @@ -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()
}

Expand Down Expand Up @@ -1215,6 +1221,9 @@ func (g getGeneralMonthlyInfoFromYear) testWhenDataExists(t *testing.T) {
Remunerations: models.DataSummary{
Total: 3750,
},
ItemSummary: models.ItemSummary{
BonusLicence: 400,
},
},
},
}
Expand Down Expand Up @@ -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,
},
})
}
Expand Down Expand Up @@ -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,
},
},
Expand Down Expand Up @@ -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()
}

Expand Down

0 comments on commit 1b4f7d7

Please sign in to comment.