-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
355 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package co.uproot.abandon | ||
|
||
import org.scalatest.{FlatSpec, Matchers} | ||
|
||
class GroupByTest extends FlatSpec with Matchers { | ||
|
||
behavior of "GroupBy" | ||
it should "handle unknown groupBy" in { | ||
assertThrows [SettingsError] { | ||
GroupBy(Option("asdf")) | ||
} | ||
} | ||
it should "handle default" in { | ||
GroupBy(None) shouldBe an[GroupByMonth] | ||
} | ||
it should "handle year" in { | ||
GroupBy(Option("year")) shouldBe an[GroupByYear] | ||
} | ||
it should "handle month" in { | ||
GroupBy(Option("month")) shouldBe an[GroupByMonth] | ||
} | ||
it should "handle day" in { | ||
GroupBy(Option("day")) shouldBe an[GroupByDay] | ||
} | ||
it should "handle week" in { | ||
GroupBy(Option("isoWeek")) shouldBe an[GroupByIsoWeek] | ||
} | ||
it should "handle week date" in { | ||
GroupBy(Option("isoWeekDate")) shouldBe an[GroupByIsoWeekDate] | ||
} | ||
|
||
|
||
behavior of "groupByOp" | ||
it should "select toIntYYYY for year" in { | ||
val regCfg = RegisterReportSettings("", None, Nil, GroupBy(Option("year"))) | ||
val date = Date(2016, 12, 21) | ||
val postGroup = new PostGroup(Nil, null, date, None, None, Nil) | ||
|
||
val str = regCfg.groupOp match { | ||
case Left(groupBy) => groupBy(postGroup) | ||
case _ => fail("wrong way") | ||
} | ||
str should be(date.toIntYYYY) | ||
} | ||
it should "select toIntYYYYMM for month" in { | ||
val regCfg = RegisterReportSettings("", None, Nil, GroupBy(Option("month"))) | ||
val date = Date(2016, 12, 21) | ||
val postGroup = new PostGroup(Nil, null, date, None, None, Nil) | ||
|
||
val str = regCfg.groupOp match { | ||
case Left(groupBy) => groupBy(postGroup) | ||
case _ => fail("wrong way") | ||
} | ||
str should be(date.toIntYYYYMM) | ||
} | ||
it should "select toInt for day" in { | ||
val regCfg = RegisterReportSettings("", None, Nil, GroupBy(Option("day"))) | ||
val date = Date(2016, 12, 21) | ||
val postGroup = new PostGroup(Nil, null, date, None, None, Nil) | ||
|
||
val str = regCfg.groupOp match { | ||
case Left(groupBy) => groupBy(postGroup) | ||
case _ => fail("wrong way") | ||
} | ||
str should be(date.toInt) | ||
} | ||
it should "select formatISO8601Week for iso week" in { | ||
val regCfg = RegisterReportSettings("", None, Nil, GroupBy(Option("isoWeek"))) | ||
val date = Date(2016, 12, 21) | ||
val postGroup = new PostGroup(Nil, null, date, None, None, Nil) | ||
|
||
val str = regCfg.groupOp match { | ||
case Right(groupBy) => groupBy(postGroup) | ||
case _ => fail("wrong way") | ||
} | ||
str should be(date.formatISO8601Week) | ||
} | ||
it should "select formatISO8601WeekDate for iso week date" in { | ||
val regCfg = RegisterReportSettings("", None, Nil, GroupBy(Option("isoWeekDate"))) | ||
val date = Date(2016, 12, 21) | ||
val postGroup = new PostGroup(Nil, null, date, None, None, Nil) | ||
|
||
val str = regCfg.groupOp match { | ||
case Right(groupBy) => groupBy(postGroup) | ||
case _ => fail("wrong way") | ||
} | ||
str should be(date.formatISO8601WeekDate) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
inputs += groupby.ledger | ||
|
||
reports += { | ||
title = "Balance Sheet" | ||
type = balance | ||
outFiles = ["-", "out.g01.balance.txt"] | ||
accountMatch = ["^Assets.*", "^Expenses.*"] | ||
} | ||
|
||
reports += { | ||
title = "Register" | ||
type = register | ||
outFiles = ["-", "out.g01.register.txt"] | ||
groupBy = month | ||
accountMatch = ["^Assets.*", "^Expenses.*"] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Balance Sheet | ||
|
||
-197.00 Assets (-174) | ||
-23.00 └╴MatchSubAccount | ||
197.00 Expenses | ||
2.00 ├╴E02 | ||
3.00 ├╴E03 | ||
5.00 ├╴E05 | ||
7.00 ├╴E07 | ||
11.00 ├╴E11 | ||
13.00 ├╴E13:matchme | ||
23.00 ├╴E23 | ||
29.00 ├╴E29 | ||
31.00 ├╴E31 | ||
37.00 ├╴E37 | ||
36.00 └╴MatchSubAccount | ||
17.00 ├╴E17 | ||
19.00 └╴E19 | ||
───────────────────────────────────────────── | ||
0.00 0.00 = Zero |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Register | ||
|
||
2016 / Jan | ||
Assets -2.00 -2.00 | ||
Expenses:E02 2.00 2.00 | ||
2016 / Feb | ||
Assets -104.00 -106.00 | ||
Assets:MatchSubAccount -23.00 -23.00 | ||
Expenses:E03 3.00 3.00 | ||
Expenses:E05 5.00 5.00 | ||
Expenses:E07 7.00 7.00 | ||
Expenses:E11 11.00 11.00 | ||
Expenses:E13:matchme 13.00 13.00 | ||
Expenses:E23 23.00 23.00 | ||
Expenses:E29 29.00 29.00 | ||
Expenses:MatchSubAccount:E17 17.00 17.00 | ||
Expenses:MatchSubAccount:E19 19.00 19.00 | ||
2016 / Mar | ||
Assets -68.00 -174.00 | ||
Expenses:E31 31.00 31.00 | ||
Expenses:E37 37.00 37.00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
inputs += groupby.ledger | ||
|
||
reports += { | ||
title = "Balance Sheet" | ||
type = balance | ||
outFiles = ["-", "out.g02.balance.txt"] | ||
accountMatch = ["^Assets.*", "^Expenses.*"] | ||
} | ||
|
||
reports += { | ||
title = "Register" | ||
type = register | ||
outFiles = ["-", "out.g02.register.txt"] | ||
groupBy = isoWeek | ||
accountMatch = ["^Assets.*", "^Expenses.*"] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Balance Sheet | ||
|
||
-197.00 Assets (-174) | ||
-23.00 └╴MatchSubAccount | ||
197.00 Expenses | ||
2.00 ├╴E02 | ||
3.00 ├╴E03 | ||
5.00 ├╴E05 | ||
7.00 ├╴E07 | ||
11.00 ├╴E11 | ||
13.00 ├╴E13:matchme | ||
23.00 ├╴E23 | ||
29.00 ├╴E29 | ||
31.00 ├╴E31 | ||
37.00 ├╴E37 | ||
36.00 └╴MatchSubAccount | ||
17.00 ├╴E17 | ||
19.00 └╴E19 | ||
───────────────────────────────────────────── | ||
0.00 0.00 = Zero |
Oops, something went wrong.