Skip to content

Commit 5066e29

Browse files
committed
feat(cli): Add threshold filters for booking amounts
1 parent ecf510f commit 5066e29

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

cli/src/main/kotlin/FilterCommand.kt

+12
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ class FilterCommand : CliktCommand("filter") {
4545
help = "Remove all booking item whose info matches the given regular expression."
4646
)
4747

48+
private val lessOrEqual by option(
49+
"--less-or-equal",
50+
help = "Only include bookings that are less or equal to the given amount."
51+
)
52+
53+
private val greaterOrEqual by option(
54+
"--greater-or-equal",
55+
help = "Only include bookings that are greater or equal to the given amount."
56+
)
57+
4858
private val statements by requireObject<Set<Statement>>()
4959

5060
override fun run() {
@@ -62,6 +72,8 @@ class FilterCommand : CliktCommand("filter") {
6272
.filterNot { typeNot == it.type }
6373
.filter { filterRegex?.containsMatchIn(it.info.joinInfo()) != false }
6474
.filterNot { filterNotRegex?.containsMatchIn(it.info.joinInfo()) == true }
75+
.filter { lessOrEqual?.toFloat()?.let { threshold -> it.amount <= threshold } != false }
76+
.filter { greaterOrEqual?.toFloat()?.let { threshold -> it.amount >= threshold } != false }
6577

6678
filteredBookings.forEach {
6779
println("${it.valueDate} : ${it.type} : ${"%.2f".format(it.amount)}")

0 commit comments

Comments
 (0)