Skip to content

Commit

Permalink
fix: parse fiscal year boundaries
Browse files Browse the repository at this point in the history
  • Loading branch information
calmh committed Jan 23, 2025
1 parent 90857f1 commit 754bbc8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ func Parse(r io.Reader) (*Document, error) {
doc.CompanyName = words[1]

case "#RAR":
// not handled
if words[1] == "0" {
// Current fiscal year
doc.Starts, _ = time.Parse("20060102", words[2])
doc.Ends, _ = time.Parse("20060102", words[3])
}

case "#KPTYP":
doc.AccountPlan = words[1]
Expand Down
4 changes: 2 additions & 2 deletions parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ func TestParse(t *testing.T) {
OrgNo: "123456-7890",
CompanyName: "Kastelo AB",
AccountPlan: "EUBAS97",
Starts: time.Date(2016, 1, 2, 0, 0, 0, 0, time.UTC),
Ends: time.Date(2016, 8, 29, 0, 0, 0, 0, time.UTC),
Starts: time.Date(2016, 1, 1, 0, 0, 0, 0, time.UTC),
Ends: time.Date(2016, 12, 31, 0, 0, 0, 0, time.UTC),
Accounts: []Account{
{
ID: 1930, Type: "T", Description: "Bankkonto",
Expand Down

0 comments on commit 754bbc8

Please # to comment.