Remove outdated BillingController implementation, resolve conflicting bean definitions across modules, and retain the updated BillingController for consistency with frontend API logic.

This commit is contained in:
2026-04-12 21:51:33 +02:00
parent 9754f3e36b
commit 5eb2dd6904
28 changed files with 912 additions and 776 deletions
@@ -1,65 +0,0 @@
@file:OptIn(ExperimentalUuidApi::class)
package at.mocode.billing.service.api
import at.mocode.billing.domain.model.Buchung
import at.mocode.billing.domain.model.BuchungsTyp
import at.mocode.billing.domain.model.TeilnehmerKonto
import at.mocode.billing.service.TeilnehmerKontoService
import org.springframework.web.bind.annotation.*
import kotlin.uuid.ExperimentalUuidApi
import kotlin.uuid.Uuid
@RestController
@RequestMapping("/api/v1/billing")
class BillingController(
private val kontoService: TeilnehmerKontoService
) {
@GetMapping("/konten/{kontoId}")
fun getKonto(@PathVariable kontoId: String): TeilnehmerKonto? {
return kontoService.getKontoById(Uuid.parse(kontoId))
}
@GetMapping("/veranstaltungen/{veranstaltungId}/personen/{personId}")
fun getOrCreateKonto(
@PathVariable veranstaltungId: String,
@PathVariable personId: String,
@RequestParam(required = false) personName: String?
): TeilnehmerKonto {
return kontoService.getOrCreateKonto(
Uuid.parse(veranstaltungId),
Uuid.parse(personId),
personName ?: "Unbekannter Teilnehmer"
)
}
@GetMapping("/konten/{kontoId}/historie")
fun getHistorie(@PathVariable kontoId: String): List<Buchung> {
return kontoService.getBuchungsHistorie(Uuid.parse(kontoId))
}
@GetMapping("/veranstaltungen/{veranstaltungId}/konten")
fun getKonten(@PathVariable veranstaltungId: String): List<TeilnehmerKonto> {
return kontoService.getKontenFuerVeranstaltung(Uuid.parse(veranstaltungId))
}
@PostMapping("/konten/{kontoId}/buche")
fun buche(
@PathVariable kontoId: String,
@RequestBody request: BuchungRequest
): TeilnehmerKonto {
return kontoService.buche(
Uuid.parse(kontoId),
request.betragCent,
request.typ,
request.verwendungszweck
)
}
}
data class BuchungRequest(
val betragCent: Long,
val typ: BuchungsTyp,
val verwendungszweck: String
)
@@ -38,12 +38,12 @@ class TeilnehmerKontoServiceTest {
zweck = "Nennung Bewerb 1"
)
assertEquals(1500L, updatedKonto.saldoCent)
assertEquals(-1500L, updatedKonto.saldoCent)
// 3. Buchungshistorie prüfen
val buchungen = service.getBuchungsHistorie(konto.kontoId)
assertEquals(1, buchungen.size)
assertEquals(1500L, buchungen[0].betragCent)
assertEquals(-1500L, buchungen[0].betragCent)
assertEquals("Nennung Bewerb 1", buchungen[0].verwendungszweck)
}
@@ -54,9 +54,9 @@ class TeilnehmerKontoServiceTest {
val konto = service.getOrCreateKonto(vId, pId, "Susi Sorglos")
service.buche(konto.kontoId, 2000L, BuchungsTyp.STARTGEBUEHR, "Startgeld")
val finalKonto = service.buche(konto.kontoId, -500L, BuchungsTyp.STORNIERUNG, "Storno")
val finalKonto = service.buche(konto.kontoId, 500L, BuchungsTyp.STORNIERUNG, "Storno")
assertEquals(1500L, finalKonto.saldoCent)
assertEquals(-1500L, finalKonto.saldoCent)
val historian = service.getBuchungsHistorie(konto.kontoId)
assertEquals(2, historian.size)