fix recurrents
This commit is contained in:
@@ -7,9 +7,11 @@ import space.luminic.budgerapp.models.*
|
||||
import java.time.ZoneId
|
||||
|
||||
@Component
|
||||
class BudgetMapper : FromDocumentMapper {
|
||||
class BudgetMapper(private val categoryMapper: CategoryMapper) : FromDocumentMapper {
|
||||
|
||||
|
||||
override fun fromDocument(document: Document): Budget {
|
||||
return Budget(
|
||||
return Budget(
|
||||
id = document.getObjectId("_id").toString(),
|
||||
space = Space(id = document.get("spaceDetails", Document::class.java).getObjectId("_id").toString()),
|
||||
name = document.getString("name"),
|
||||
@@ -20,16 +22,8 @@ class BudgetMapper : FromDocumentMapper {
|
||||
it.getObjectId("_id").toString() == cat.get("category", DBRef::class.java).id.toString()
|
||||
}
|
||||
BudgetCategory(
|
||||
category = Category(
|
||||
id = cat.get("category", DBRef::class.java).id.toString(),
|
||||
type = CategoryType(
|
||||
categoryDetailed.get("type", Document::class.java).getString("code"),
|
||||
categoryDetailed.get("type", Document::class.java).getString("name")
|
||||
),
|
||||
name = categoryDetailed.getString("name"),
|
||||
description = categoryDetailed.getString("description"),
|
||||
icon = categoryDetailed.getString("icon")
|
||||
), currentLimit = cat.getDouble("currentLimit")
|
||||
category = categoryMapper.fromDocument(categoryDetailed),
|
||||
currentLimit = cat.getDouble("currentLimit")
|
||||
)
|
||||
}.toMutableList(),
|
||||
incomeCategories = document.getList("incomeCategories", Document::class.java).map { cat ->
|
||||
@@ -38,16 +32,8 @@ class BudgetMapper : FromDocumentMapper {
|
||||
it.getObjectId("_id").toString() == cat.get("category", DBRef::class.java).id.toString()
|
||||
}
|
||||
BudgetCategory(
|
||||
category = Category(
|
||||
id = cat.get("category", DBRef::class.java).id.toString(),
|
||||
type = CategoryType(
|
||||
categoryDetailed.get("type", Document::class.java).getString("code"),
|
||||
categoryDetailed.get("type", Document::class.java).getString("name")
|
||||
),
|
||||
name = categoryDetailed.getString("name"),
|
||||
description = categoryDetailed.getString("description"),
|
||||
icon = categoryDetailed.getString("icon")
|
||||
), currentLimit = cat.getDouble("currentLimit")
|
||||
category = categoryMapper.fromDocument(categoryDetailed),
|
||||
currentLimit = cat.getDouble("currentLimit")
|
||||
)
|
||||
}.toMutableList()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user