Skip to content

Commit

Permalink
Add flag to omit sector report
Browse files Browse the repository at this point in the history
  • Loading branch information
dude333 committed Mar 6, 2021
1 parent d423731 commit 704cb0d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
3 changes: 3 additions & 0 deletions cli/cmd/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var scriptMode bool
var all bool
var showShares bool
var extraRatios bool
var omitSector bool
var outputDir string

// reportCmd represents the report command
Expand All @@ -52,6 +53,7 @@ func init() {
reportCmd.Flags().BoolVarP(&all, "all", "a", false, "Mostra todos os indicadores")
reportCmd.Flags().BoolVarP(&showShares, "showShares", "f", false, "Mostra o número de ações e free float")
reportCmd.Flags().BoolVarP(&extraRatios, "extraRatios", "x", false, "Reporte de índices extras")
reportCmd.Flags().BoolVarP(&omitSector, "omitSector", "o", false, "Omite o relatório das empresas do mesmo setor")
reportCmd.Flags().StringVarP(&outputDir, "outputDir", "d", "", "Diretório onde o relatório será salvo")
}

Expand All @@ -75,6 +77,7 @@ func report(company string) {
YamlFile: yamlFile,
ExtraRatios: extraRatios,
ShowShares: showShares,
OmitSector: omitSector,
}
err := rapina.Report(parms)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ type Parms struct {
ExtraRatios bool
// ShowShares: shows the number of shares and free float on report
ShowShares bool
// OmitSector: omits the sector report
OmitSector bool
}
1 change: 1 addition & 0 deletions report.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func Report(p Parms) (err error) {
YamlFile: p.YamlFile,
ExtraRatios: p.ExtraRatios,
ShowShares: p.ShowShares,
OmitSector: p.OmitSector,
}
return reports.Report(parms)
}
Expand Down
2 changes: 2 additions & 0 deletions reports/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ type Parms struct {
ExtraRatios bool
// ShowShares: shows the number of shares and free float on report
ShowShares bool
// OmitSector: omits the sector report
OmitSector bool
}
18 changes: 11 additions & 7 deletions reports/reports.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
grpAccts int = iota + 100
grpShares
grpExtra
grpSector
)

// metric parameters
Expand Down Expand Up @@ -62,6 +63,7 @@ func Report(p Parms) error {
r.groups[grpAccts] = true
r.groups[grpShares] = p.ShowShares
r.groups[grpExtra] = p.ExtraRatios
r.groups[grpSector] = !p.OmitSector

e := newExcel()
sheet, _ := e.newSheet(p.Company)
Expand Down Expand Up @@ -220,13 +222,15 @@ func Report(p Parms) error {
sheet.autoWidth()

// SECTOR REPORT
sheet2, err := e.newSheet("SETOR")
if err == nil {
sheet2.xlsx.SetSheetViewOptions(sheet2.name, 0,
excelize.ShowGridLines(false),
excelize.ZoomScale(80),
)
r.sectorReport(sheet2, p.Company)
if !p.OmitSector {
sheet2, err := e.newSheet("SETOR")
if err == nil {
sheet2.xlsx.SetSheetViewOptions(sheet2.name, 0,
excelize.ShowGridLines(false),
excelize.ZoomScale(80),
)
r.sectorReport(sheet2, p.Company)
}
}

err = e.saveAndCloseExcel(p.Filename)
Expand Down

0 comments on commit 704cb0d

Please sign in to comment.