diff --git a/pkg/ecalc/ecalc.go b/pkg/ecalc/ecalc.go index dbccaf8..53e9128 100644 --- a/pkg/ecalc/ecalc.go +++ b/pkg/ecalc/ecalc.go @@ -66,7 +66,7 @@ type Rating struct { } type Topic struct { - Points int `json:"points"` + Points float64 `json:"points"` MaxPoints float64 `json:"maxPoints"` ID int `json:"id,omitempty"` ShortName string `json:"shortName"` @@ -78,7 +78,7 @@ type Topic struct { } type Aspect struct { - Points int `json:"points"` + Points float64 `json:"points"` MaxPoints float64 `json:"maxPoints"` ID int `json:"id,omitempty"` ShortName string `json:"shortName"` diff --git a/pkg/loader/loader.go b/pkg/loader/loader.go index 69c7486..62d5c79 100644 --- a/pkg/loader/loader.go +++ b/pkg/loader/loader.go @@ -181,7 +181,14 @@ func XLSX(r io.Reader, conf *Conf) (*ecalc.Ecalc, error) { if err != nil { errs = append(errs, err) } - set.Field(&aspect, c.Field, cellValue) + if cellValue == "" { + continue + } + err = set.Field(&aspect, c.Field, cellValue) + if err != nil { + fmt.Println(shortName, c.Field, cellValue) + fmt.Println(err) + } } topic.Aspects = append(topic.Aspects, aspect) } diff --git a/pkg/loader/loader_test.go b/pkg/loader/loader_test.go index e9f7269..2ef4638 100644 --- a/pkg/loader/loader_test.go +++ b/pkg/loader/loader_test.go @@ -3,6 +3,7 @@ package loader import ( "bytes" _ "embed" + "math" "testing" "github.com/matryer/is" @@ -23,6 +24,9 @@ func TestXLSX(t *testing.T) { is.Equal(got.CompanyFacts.FinancialCosts, 12) is.Equal(got.CompanyFacts.EmployeesFractions[1].CountryCode, "AUT") + is.Equal(math.Round(got.CompanyFacts.Rating.Topics[0].Aspects[0].Points), math.Round(4)) + is.Equal(math.Round(got.CompanyFacts.Rating.Topics[0].Aspects[1].Points), math.Round(-9)) + is.Equal(got.Matrix.Topics[0].ShortName, "A1") is.Equal(got.Matrix.Topics[0].MaxPoints, 44) is.Equal(got.Matrix.Topics[4].ShortName, "B1") diff --git a/pkg/loader/test/testfile.xlsx b/pkg/loader/test/testfile.xlsx index e46b3ed..7681071 100644 Binary files a/pkg/loader/test/testfile.xlsx and b/pkg/loader/test/testfile.xlsx differ