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

adicionando licença-prêmio #127

Merged
merged 3 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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"`
BonusLicense 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,
BonusLicense: ami.ItemSummary.BonusLicense,
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,
BonusLicense: ami.ItemSummary.BonusLicense,
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"`
BonusLicense 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,
BonusLicense: gmi.ItemSummary.BonusLicense,
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,
BonusLicense: gmi.ItemSummary.BonusLicense,
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
18 changes: 17 additions & 1 deletion repo/database/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,11 @@ func (g getAnnualSummary) testWhenMonthlyInfoExists(t *testing.T) {
Remunerations: models.DataSummary{
Total: 1500,
},
joellensilva marked this conversation as resolved.
Show resolved Hide resolved
ItemSummary: models.ItemSummary{
Others: 100,
FoodAllowance: 150,
BonusLicense: 200,
},
},
},
{
Expand Down Expand Up @@ -1039,7 +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,
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,
},
})
}
Expand All @@ -1061,6 +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.BonusLicense, returnedAmis[1].ItemSummary.BonusLicense)
assert.Equal(t, amis[1].ItemSummary.FoodAllowance, returnedAmis[1].ItemSummary.FoodAllowance)
truncateTables()
}

Expand Down Expand Up @@ -1215,6 +1224,10 @@ func (g getGeneralMonthlyInfoFromYear) testWhenDataExists(t *testing.T) {
Remunerations: models.DataSummary{
Total: 3750,
},
ItemSummary: models.ItemSummary{
BonusLicense: 400,
FoodAllowance: 100,
},
},
},
}
Expand Down Expand Up @@ -1247,6 +1260,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,
BonusLicense: agmi.Summary.ItemSummary.BonusLicense + agmi2.Summary.ItemSummary.BonusLicense,
},
})
}
Expand Down Expand Up @@ -1398,6 +1412,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,
BonusLicense: 150,
Others: 200,
},
},
Expand Down Expand Up @@ -1462,6 +1477,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.BonusLicense, result.Summary.ItemSummary.BonusLicense)
truncateTables()
}

Expand Down