Skip to content

Commit

Permalink
WIP: Order book snapshots, ForecastExport fixed (customer and project…
Browse files Browse the repository at this point in the history
… name were missing)
  • Loading branch information
kreinhard committed Jan 3, 2025
1 parent 1fdc2e1 commit 7163b8c
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,15 @@ class AuftragsCacheService {
order.bemerkung = getString(tuple, "bemerkung")
order.periodOfPerformanceBegin = getLocalDate(tuple, "periodOfPerformanceBegin")
order.periodOfPerformanceEnd = getLocalDate(tuple, "periodOfPerformanceEnd")
order.kundeText = getString(tuple, "kundeText")
getLong(tuple, "kundeId")?.let { kundeId ->
order.kunde = em.getReference(KundeDO::class.java, kundeId)
}
getLong(tuple, "projektId")?.let { projektId ->
order.projekt = em.getReference(ProjektDO::class.java, projektId)
}
getLong(tuple, "contactPersonId")?.let { userId ->
order.contactPerson = PFUserDO().also { it.id = userId }
order.contactPerson = em.getReference(PFUserDO::class.java, userId)
}
}
}
Expand All @@ -82,7 +89,7 @@ class AuftragsCacheService {
AuftragsPositionDO().also { pos ->
pos.id = getLong(tuple, "id")
getLong(tuple, "auftragId")?.let { auftragId ->
pos.auftrag = AuftragDO().also { it.id = auftragId }
pos.auftrag = em.getReference(AuftragDO::class.java, auftragId)
}
pos.number = getShort(tuple, "number")!!
pos.deleted = getBoolean(tuple, "deleted")!!
Expand Down Expand Up @@ -134,7 +141,7 @@ class AuftragsCacheService {
a.entscheidungsDatum as entscheidungsDatum,a.bemerkung as bemerkung,
a.probabilityOfOccurrence as probabilityOfOccurrence,
a.periodOfPerformanceBegin as periodOfPerformanceBegin, a.periodOfPerformanceEnd as periodOfPerformanceEnd,
a.contactPerson.id as contactPersonId
a.contactPerson.id as contactPersonId, a.kunde.id as kundeId, a.projekt.id as projektId, a.kundeText as kundeText
FROM ${AuftragDO::class.simpleName} a
""".trimIndent()
private val SELECT_POSITIONS = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ open class ForecastExport { // open needed by Wicket.
auftragDO.projekt?.id?.let { projektId ->
ctx.projectIds.add(projektId)
}
val orderInfo = if (useAuftragsCache) auftragDO.info else ordersCache.getOrderInfo(auftragDO)
val orderInfo = if (useAuftragsCache) ordersCache.getOrderInfo(auftragDO) else auftragDO.info
auftragDO.id?.let { ctx.orderMap[it] = orderInfo }
orderInfo.infoPositions?.forEach { pos ->
pos.id?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ class OrderInfo() : Serializable {
var created: Date? = null
var erfassungsDatum: LocalDate? = null
var entscheidungsDatum: LocalDate? = null
lateinit var kundeAsString: String
lateinit var projektAsString: String
var kundeId: Long? = null
var kundeAsString: String? = null
var projektId: Long? = null
var projektAsString: String? = null
var probabilityOfOccurrence: Int? = null
var periodOfPerformanceBegin: LocalDate? = null
var periodOfPerformanceEnd: LocalDate? = null
Expand All @@ -82,7 +84,9 @@ class OrderInfo() : Serializable {
* If not set (e.g. by OrderbookSnapshot), the positions will be lazy loaded from cache.
*/
var infoPositions: Collection<OrderPositionInfo>? = null
get() = if (field != null || snapshotVersion) field else AuftragsCache.instance.getOrderPositionInfosByAuftragId(id)
get() = if (field != null || snapshotVersion) field else AuftragsCache.instance.getOrderPositionInfosByAuftragId(
id
)
set(value) {
field = value
}
Expand All @@ -109,7 +113,9 @@ class OrderInfo() : Serializable {
created = order.created
erfassungsDatum = order.erfassungsDatum
entscheidungsDatum = order.entscheidungsDatum
kundeId = order.kunde?.id
kundeAsString = order.kundeAsString
projektId = order.projekt?.id
projektAsString = order.projektAsString
probabilityOfOccurrence = order.probabilityOfOccurrence
periodOfPerformanceBegin = order.periodOfPerformanceBegin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ internal class Order {
var id: Long? = null
var lastUpdate: Date? = null
var nummer: Int? = null
var angebotsDatum: LocalDate? = null
var positionen: Collection<OrderPosition>? = null
var status: AuftragsStatus? = null
var kundeId: Long? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.projectforge.business.PfCaches
import org.projectforge.business.fibu.*
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import java.math.BigDecimal

private val log = KotlinLogging.logger {}

Expand Down Expand Up @@ -65,6 +66,7 @@ internal class OrderConverterService {
id = order.id
lastUpdate = order.lastUpdate
nummer = order.nummer
angebotsDatum = order.angebotsDatum
positionen = order.positionen?.map { from(it) }?.toMutableList()
status = order.status
kunde = caches.getKunde(order.kundeId)
Expand All @@ -75,7 +77,9 @@ internal class OrderConverterService {
periodOfPerformanceBegin = order.periodOfPerformanceBegin
periodOfPerformanceEnd = order.periodOfPerformanceEnd
probabilityOfOccurrence = order.probabilityOfOccurrence
// Write the fields also to the info object.
info.nummer = order.nummer
info.angebotsDatum = order.angebotsDatum
info.netSum = order.netSum
info.commissionedNetSum = order.commissionedNetSum
info.akquiseSum = order.akquiseSum
Expand All @@ -91,6 +95,16 @@ internal class OrderConverterService {
info.periodOfPerformanceBegin = order.periodOfPerformanceBegin
info.periodOfPerformanceEnd = order.periodOfPerformanceEnd
info.infoPositions = positionen?.map { OrderPositionInfo(it, info).also { it.snapshotVersion = true } }
info.infoPositions?.forEach { infoPos ->
order.positionen?.find { it.number == infoPos.number }?.let { pos ->
infoPos.netSum = pos.netSum ?: BigDecimal.ZERO
infoPos.invoicedSum = pos.invoicedSum ?: BigDecimal.ZERO
infoPos.akquiseSum = pos.akquiseSum ?: BigDecimal.ZERO
infoPos.commissionedNetSum = pos.commissionedNetSum ?: BigDecimal.ZERO
infoPos.notYetInvoiced = pos.notYetInvoiced ?: BigDecimal.ZERO
infoPos.toBeInvoicedSum = pos.toBeInvoicedSum ?: BigDecimal.ZERO
}
}
info.kundeAsString = kundeAsString
info.projektAsString = projektAsString
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ internal class OrderPosition {
var status: AuftragsStatus? = null
var titel: String? = null
var netSum: BigDecimal? = null
var invoicedSum: BigDecimal? = null
var akquiseSum: BigDecimal? = null
var commissionedNetSum: BigDecimal? = null
var dbNetSum: BigDecimal? = null
var notYetInvoiced: BigDecimal? = null
var toBeInvoicedSum: BigDecimal? = null
var personDays: BigDecimal? = null
var vollstaendigFakturiert: Boolean? = false
var periodOfPerformanceType: PeriodOfPerformanceType? = PeriodOfPerformanceType.SEEABOVE
Expand All @@ -54,6 +60,12 @@ internal class OrderPosition {
status = pos.status
titel = Order.abbreviate(pos.titel)
netSum = pos.netSum
invoicedSum = pos.invoicedSum
akquiseSum = pos.akquiseSum
commissionedNetSum = pos.commissionedNetSum
dbNetSum = pos.dbNetSum
notYetInvoiced = pos.notYetInvoiced
toBeInvoicedSum = pos.toBeInvoicedSum
personDays = pos.personDays
vollstaendigFakturiert = pos.vollstaendigFakturiert
periodOfPerformanceType = pos.periodOfPerformanceType
Expand Down

0 comments on commit 7163b8c

Please sign in to comment.