diff --git a/go.mod b/go.mod index b932e4b..eea3570 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/dadosjusbr/proto v0.0.0-20221212025627-91c60aa3cd12 - github.com/dadosjusbr/storage v0.0.0-20240315221019-5da10c81ab80 + github.com/dadosjusbr/storage v0.0.0-20240514131514-43ac5da3ae8a github.com/kelseyhightower/envconfig v1.4.0 google.golang.org/protobuf v1.28.1 ) diff --git a/go.sum b/go.sum index c40cbde..8c68859 100644 --- a/go.sum +++ b/go.sum @@ -25,6 +25,7 @@ github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7 github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/dadosjusbr/datapackage v0.0.0-20230904162108-6e2264aafb68/go.mod h1:o1FghJC46mR+lgHcQWVve/q84/SAd0WVdYMcgq88BBU= +github.com/dadosjusbr/datapackage v0.0.0-20240320203926-5f369dadd3a5/go.mod h1:xDZc4jX8VDOP7SFo793x0Q8gjUjuMSOmNEUG/wqLKAw= github.com/dadosjusbr/proto v0.0.0-20221212025627-91c60aa3cd12 h1:ufl8nbCEo6g2VHUbedGy0gYk9Sgrynf9rcnzuSw4TEg= github.com/dadosjusbr/proto v0.0.0-20221212025627-91c60aa3cd12/go.mod h1:gPA7VxjEmyez/xtln4qBj+tM1NO0/zcw3ryjxTRNSco= github.com/dadosjusbr/status v0.0.0-20230428151814-b605fe0e598f h1:MHtPcEeoJ4CCOvFDzvYXU2AndoqiIvZdrOjWACaImLA= @@ -41,6 +42,8 @@ github.com/dadosjusbr/storage v0.0.0-20240307002251-d7ccaca9cd29 h1:PoZPA1Nt+HDF github.com/dadosjusbr/storage v0.0.0-20240307002251-d7ccaca9cd29/go.mod h1:PszGy6CDoG3kNLjIsCmwD3MAWED7xL7U/OWj7ajsiHc= github.com/dadosjusbr/storage v0.0.0-20240315221019-5da10c81ab80 h1:mo6k/MAl6aF662JFUYHxqCNvRkX8OXZN0DmQKJe55D4= github.com/dadosjusbr/storage v0.0.0-20240315221019-5da10c81ab80/go.mod h1:PszGy6CDoG3kNLjIsCmwD3MAWED7xL7U/OWj7ajsiHc= +github.com/dadosjusbr/storage v0.0.0-20240514131514-43ac5da3ae8a h1:1LyzfsNzKgLjC4/cyQr+N724a4dcRCHB5yIauAnhhcI= +github.com/dadosjusbr/storage v0.0.0-20240514131514-43ac5da3ae8a/go.mod h1:rIM/dbZMdrMfVnZgNgRNRRtsxfhSMH8S8X7MZEeKkrQ= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -55,6 +58,7 @@ github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go. github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/frictionlessdata/datapackage-go v1.0.4/go.mod h1:bqt5SzFjnpsZNw4kXO4CFIwH9vV5LhEdQikftJ0uJ5M= github.com/frictionlessdata/tableschema-go v1.1.4-0.20220401172006-6cc5f3b2411c/go.mod h1:B+DhLlwjCf6p6FqVkqpdYyAIy7L8jHCaxa2wFaqpYdc= +github.com/frictionlessdata/tableschema-go v1.5.2/go.mod h1:B+DhLlwjCf6p6FqVkqpdYyAIy7L8jHCaxa2wFaqpYdc= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= diff --git a/main.go b/main.go index 5b04de0..25ca132 100644 --- a/main.go +++ b/main.go @@ -158,12 +158,13 @@ func main() { Year: int(er.Rc.Coleta.Ano), Category: r.Categoria, Item: r.Item, - Value: math.Abs(r.Valor), }) if r.Natureza == coleta.Remuneracao_D { remunerations[len(remunerations)-1].Type = "D" + remunerations[len(remunerations)-1].Value = math.Abs(r.Valor) } else { remunerations[len(remunerations)-1].Type = r.Natureza.String() + "/" + r.TipoReceita.String() + remunerations[len(remunerations)-1].Value = r.Valor } // rubrica inconsistente if !m.MatchString(r.Item) { @@ -173,7 +174,7 @@ func main() { itemSanitizado := sanitizarItem(r.Item) // agregamos o valor por rubrica (não considerando descontos) if r.Natureza != coleta.Remuneracao_D { - itemValues[itemSanitizado] += math.Abs(r.Valor) + itemValues[itemSanitizado] += r.Valor } remunerations[len(remunerations)-1].SanitizedItem = &itemSanitizado } @@ -304,13 +305,14 @@ func calcBaseSalary(emp coleta.ContraCheque) (float64, float64, float64, float64 var discounts float64 for _, v := range emp.Remuneracoes.Remuneracao { if v.TipoReceita == coleta.Remuneracao_B && v.Natureza == coleta.Remuneracao_R { - salaryBase += math.Abs(v.Valor) + salaryBase += v.Valor } else if v.TipoReceita == coleta.Remuneracao_O && v.Natureza == coleta.Remuneracao_R { - benefits += math.Abs(v.Valor) + benefits += v.Valor } else if v.Natureza == coleta.Remuneracao_D { - discounts += math.Abs(v.Valor) + discounts += v.Valor } } + discounts = math.Abs(discounts) remuneration := salaryBase + benefits - discounts return salaryBase, benefits, discounts, remuneration } @@ -412,6 +414,8 @@ func aggregatingItems(itemValues map[string]float64) models.ItemSummary { itemSummary.CompensatoryLicense += value case "auxilio-saude": itemSummary.HealthAllowance += value + case "ferias": + itemSummary.Vacation += value } others = 0 break