default to max milage found for a new bill

This commit is contained in:
Thomas Ruoff
2020-10-08 00:35:21 +02:00
parent 48c9fc9301
commit a0cf63dcdc
2 changed files with 19 additions and 4 deletions

View File

@@ -28,7 +28,6 @@ export async function getBookedDays() {
export async function getBookingByUUID(uuid: string) {
await connect()
return Booking.findOne({ uuid })
//return booking.populate('bill').populate('booker').execPopulate()
}
export async function getBookings() {
@@ -116,3 +115,12 @@ export async function patchBill(bookingUUID: string, billData: BillDocument) {
return bill.toJSON()
}
export async function getMilageMax(): Promise<number> {
const billMaxMilageEnd = await Bill.findOne({})
.sort('-milageEnd')
.select('milageEnd')
.exec()
return billMaxMilageEnd?.milageEnd
}