enable bill storing

This commit is contained in:
Thomas Ruoff
2020-10-05 00:09:05 +02:00
committed by Thomas Ruoff
parent df6ec51af9
commit ec1b2e9629
7 changed files with 152 additions and 109 deletions

View File

@@ -1,6 +1,7 @@
import * as mongoose from 'mongoose'
import Booker from './booker'
import Booking from './booking'
import Bill, { BillDocument } from './bill'
import { dateFormatFrontend } from '../helpers/date'
import { BOOKING_STATUS } from './enums'
@@ -82,3 +83,15 @@ export async function createBooking({
await booking.populate('booker').execPopulate()
return booking.toJSON()
}
export async function createBill(bookingUUID: string, billData: BillDocument) {
await connect()
const bill = new Bill(billData)
const booking = await getBookingByUUID(bookingUUID)
bill.booking = booking._id
await bill.save()
await bill.populate('booking').execPopulate()
return bill.toJSON()
}