Skip to content

Commit 754bbc8

Browse files
committed
fix: parse fiscal year boundaries
1 parent 90857f1 commit 754bbc8

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

parse.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ func Parse(r io.Reader) (*Document, error) {
5454
doc.CompanyName = words[1]
5555

5656
case "#RAR":
57-
// not handled
57+
if words[1] == "0" {
58+
// Current fiscal year
59+
doc.Starts, _ = time.Parse("20060102", words[2])
60+
doc.Ends, _ = time.Parse("20060102", words[3])
61+
}
5862

5963
case "#KPTYP":
6064
doc.AccountPlan = words[1]

parse_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ func TestParse(t *testing.T) {
1919
OrgNo: "123456-7890",
2020
CompanyName: "Kastelo AB",
2121
AccountPlan: "EUBAS97",
22-
Starts: time.Date(2016, 1, 2, 0, 0, 0, 0, time.UTC),
23-
Ends: time.Date(2016, 8, 29, 0, 0, 0, 0, time.UTC),
22+
Starts: time.Date(2016, 1, 1, 0, 0, 0, 0, time.UTC),
23+
Ends: time.Date(2016, 12, 31, 0, 0, 0, 0, time.UTC),
2424
Accounts: []Account{
2525
{
2626
ID: 1930, Type: "T", Description: "Bankkonto",

0 commit comments

Comments
 (0)