Skip to content
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
4 changes: 4 additions & 0 deletions internal/toukibo/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ func (h *Houjin) GetToukiboCreatedAt() time.Time {
return h.header.CreatedAt
}

func (h *Houjin) GetHoujinNumber() string {
return h.body.HoujinNumber
}

func (h *Houjin) GetHoujinKaku() string {
return string(h.body.HoujinKaku)
}
Expand Down
4 changes: 3 additions & 1 deletion internal/toukibo/parse_body.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ func (h *HoujinBody) ConsumeHoujinNumber(s string) bool {

matches := regex.FindStringSubmatch(s)
if len(matches) > 0 {
h.HoujinNumber = ZenkakuToHankaku(matches[1])
//2600-01-037869
houjinNumber := ZenkakuToHankaku(matches[1])
h.HoujinNumber = houjinNumber[:4] + houjinNumber[5:7] + houjinNumber[8:]
return true
}
return false
Expand Down
1 change: 1 addition & 0 deletions scripts/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func mainRun() error {

stock := h.GetHoujinStock()

fmt.Println("HoujinNumber: " + h.GetHoujinNumber())
fmt.Println("HoujinKaku: " + h.GetHoujinKaku())
fmt.Println("HoujinName: " + h.GetHoujinName())
fmt.Println("HoujinAddress: " + h.GetHoujinAddress())
Expand Down
4 changes: 4 additions & 0 deletions toukibo_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
)

type TestData struct {
HoujinNumber string `yaml:"HoujinNumber"`
HoujinKaku string `yaml:"HoujinKaku"`
HoujinName string `yaml:"HoujinName"`
HoujinAddress string `yaml:"HoujinAddress"`
Expand Down Expand Up @@ -69,6 +70,9 @@ func TestToukiboParser(t *testing.T) {
}

// check
if h.GetHoujinNumber() != td.HoujinNumber {
t.Fatalf("number is not match,\nwant : %s,\ngot : %s,", td.HoujinNumber, h.GetHoujinNumber())
}
if h.GetHoujinKaku() != td.HoujinKaku {
t.Fatalf("kaku is not match,\nwant : %s,\ngot : %s,", td.HoujinKaku, h.GetHoujinKaku())
}
Expand Down
Loading