Skip to content

Commit

Permalink
make sure sequence is always set
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahgreenthal committed Nov 26, 2023
1 parent 47a0887 commit 47cc879
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class InvoiceLineController {
fun addLine(@PathVariable bookingCreationId: String, @RequestBody input: ApiInvoiceLine): ApiBooking {
val booking = bookingService.findThenAuthorize(bookingCreationId)

val sequence: Long = input.sequence
?: ((repo.findByBookingId(booking.id!!).mapNotNull(InvoiceLine::sequence).maxOrNull() ?: 0) + 1)

repo.save(
InvoiceLine(
bookingId = booking.id,
Expand All @@ -61,7 +64,7 @@ class InvoiceLineController {
label = input.label,
quantity = input.quantity,
unitCost = input.unitCost,
sequence = input.sequence,
sequence = sequence,
)
)

Expand Down

0 comments on commit 47cc879

Please sign in to comment.