Skip to content

Commit

Permalink
Update lunchmoney depndency && fix errors #dockerpush
Browse files Browse the repository at this point in the history
  • Loading branch information
smaugfm committed Aug 11, 2024
1 parent 223fafa commit 60c6453
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ val githubToken: String? by project

repositories {
mavenCentral()
mavenLocal()
maven("https://jitpack.io")
maven("https://s01.oss.sonatype.org/content/repositories/snapshots")
}
Expand All @@ -41,7 +42,7 @@ dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("reflect"))
implementation("io.github.smaugfm:monobank:0.0.2")
implementation("io.github.smaugfm:lunchmoney:1.0.2")
implementation("io.github.smaugfm:lunchmoney:1.0.3-SNAPSHOT")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:$kotlinxCoroutines")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutines")
implementation("com.github.livefront.sealed-enum:runtime:$sealedEnum")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import io.github.smaugfm.monobudget.common.statement.lifecycle.StatementProcessi
import io.github.smaugfm.monobudget.common.statement.lifecycle.StatementProcessingScopeComponent
import io.github.smaugfm.monobudget.common.transaction.TransactionFactory
import kotlinx.coroutines.reactor.awaitSingle
import kotlinx.serialization.SerializationException
import org.koin.core.annotation.Scope
import org.koin.core.annotation.Scoped

Expand All @@ -41,17 +40,10 @@ class LunchmoneyTransactionCreator(
}
} catch (e: LunchmoneyApiResponseException) {
val template = "Текст помилки: "
if (e.cause is SerializationException) {
throw BudgetBackendException(
e,
template + (e.message?.substringBefore("JSON input:") + "HTTP Body:\n" + e.body),
)
} else {
throw BudgetBackendException(
e,
template + e.message,
)
}
throw BudgetBackendException(
e,
template + e.message,
)
}

private suspend fun processTransfer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class LunchmoneyTransactionMessageFormatter(
private val shouldNotifyStatuses =
setOf(
LunchmoneyTransactionStatus.UNCLEARED,
LunchmoneyTransactionStatus.RECURRING_SUGGESTED,
LunchmoneyTransactionStatus.PENDING,
)

Expand Down
10 changes: 5 additions & 5 deletions src/test/kotlin/io/github/smaugfm/monobudget/TestData.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.smaugfm.monobudget

import io.github.smaugfm.lunchmoney.model.LunchmoneyCategoryMultiple
import io.github.smaugfm.lunchmoney.model.LunchmoneyCategory
import io.github.smaugfm.monobank.model.MonoStatementItem
import io.github.smaugfm.monobank.model.MonoWebhookResponseData
import io.github.smaugfm.monobudget.mono.MonobankWebhookResponseStatementItem
Expand Down Expand Up @@ -62,7 +62,7 @@ object TestData {

val categories =
listOf(
LunchmoneyCategoryMultiple(
LunchmoneyCategory(
id = 444443,
name = "Авто",
description = null,
Expand All @@ -74,7 +74,7 @@ object TestData {
isGroup = false,
groupId = null,
),
LunchmoneyCategoryMultiple(
LunchmoneyCategory(
id = 444444,
name = "Перекази",
description = null,
Expand All @@ -86,7 +86,7 @@ object TestData {
isGroup = false,
groupId = null,
),
LunchmoneyCategoryMultiple(
LunchmoneyCategory(
id = 444445,
name = "Розваги",
description = null,
Expand All @@ -98,7 +98,7 @@ object TestData {
isGroup = false,
groupId = null,
),
LunchmoneyCategoryMultiple(
LunchmoneyCategory(
id = 444446,
name = "Транспорт",
description = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ class FailTrackerTransformation<T>(private val configs: List<IntegrationFailConf

override fun apply(mono: Mono<T>): Mono<T> =
mono.takeIf { configs.all { !it.attemptFailRange.contains(attempt++) } }
?: Mono.error(LunchmoneyApiResponseException(HttpStatusCode.BadRequest.value))
?: Mono.error(LunchmoneyApiResponseException(HttpStatusCode.BadRequest.description))
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.github.smaugfm.monobudget.integration.util

import io.github.oshai.kotlinlogging.KotlinLogging
import io.github.smaugfm.lunchmoney.api.LunchmoneyApi
import io.github.smaugfm.lunchmoney.model.LunchmoneyCategoryMultiple
import io.github.smaugfm.lunchmoney.model.LunchmoneyCategory
import io.github.smaugfm.lunchmoney.model.LunchmoneyInsertTransaction
import io.github.smaugfm.lunchmoney.model.LunchmoneyTransaction
import io.github.smaugfm.lunchmoney.response.LunchmoneyUpdateTransactionResponse
Expand Down Expand Up @@ -35,6 +35,8 @@ import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.datetime.Clock
import kotlinx.datetime.toJavaInstant
import org.junit.jupiter.api.assertThrows
import org.koin.core.KoinApplication
import org.koin.dsl.bind
Expand Down Expand Up @@ -65,7 +67,7 @@ abstract class IntegrationTestBase : TestBase(), CoroutineScope {

@MockK
lateinit var categoriesFetcherMock:
PeriodicFetcherFactory.PeriodicFetcher<List<LunchmoneyCategoryMultiple>>
PeriodicFetcherFactory.PeriodicFetcher<List<LunchmoneyCategory>>

@MockK
lateinit var budgetSettingsVerifier: BudgetSettingsVerifier
Expand All @@ -81,7 +83,7 @@ abstract class IntegrationTestBase : TestBase(), CoroutineScope {
every { lunchmoneyMock.getBudgetSummary(any(), any(), any()) } returns Mono.just(listOf())
excludeRecords { lunchmoneyMock.getBudgetSummary(any(), any(), any()) }
every {
periodicFetcherFactory.create<List<LunchmoneyCategoryMultiple>>(
periodicFetcherFactory.create<List<LunchmoneyCategory>>(
"Lunchmoney categories",
any(),
)
Expand Down Expand Up @@ -157,6 +159,14 @@ abstract class IntegrationTestBase : TestBase(), CoroutineScope {
notes = insertTransaction?.notes,
categoryId = insertTransaction?.categoryId,
status = insertTransaction!!.status!!,
accountDisplayName = "",
createdAt = Clock.System.now().toJavaInstant(),
updatedAt = Clock.System.now().toJavaInstant(),
displayName = "",
excludeFromTotals = false,
excludeFromBudget = false,
isIncome = false,
isPending = false,
),
).transformDeferred(singleTransform)
}
Expand All @@ -173,6 +183,14 @@ abstract class IntegrationTestBase : TestBase(), CoroutineScope {
notes = insertTransaction2?.notes,
categoryId = insertTransaction2?.categoryId,
status = insertTransaction2!!.status!!,
accountDisplayName = "",
createdAt = Clock.System.now().toJavaInstant(),
updatedAt = Clock.System.now().toJavaInstant(),
displayName = "",
excludeFromTotals = false,
excludeFromBudget = false,
isIncome = false,
isPending = false,
),
).transformDeferred(singleTransform)
}
Expand Down Expand Up @@ -243,6 +261,14 @@ abstract class IntegrationTestBase : TestBase(), CoroutineScope {
notes = insertTransaction?.notes,
categoryId = insertTransaction?.categoryId,
status = insertTransaction!!.status!!,
accountDisplayName = "",
createdAt = Clock.System.now().toJavaInstant(),
updatedAt = Clock.System.now().toJavaInstant(),
displayName = "",
excludeFromTotals = false,
excludeFromBudget = false,
isIncome = false,
isPending = false,
),
).transformDeferred(singleTracker)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import io.mockk.coEvery
import io.mockk.every
import io.mockk.mockkClass
import kotlinx.coroutines.runBlocking
import kotlinx.datetime.Clock
import kotlinx.datetime.toJavaInstant
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.koin.core.KoinApplication
Expand Down Expand Up @@ -58,6 +60,14 @@ class LunchmoneyTransactionCreatorTest : TestBase() {
1.0,
isGroup = false,
status = LunchmoneyTransactionStatus.CLEARED,
accountDisplayName = "",
createdAt = Clock.System.now().toJavaInstant(),
updatedAt = Clock.System.now().toJavaInstant(),
displayName = "",
excludeFromTotals = false,
excludeFromBudget = false,
isIncome = false,
isPending = false,
)
private val insertTransaction =
LunchmoneyInsertTransaction(
Expand Down

0 comments on commit 60c6453

Please sign in to comment.