mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
enable bill storing
This commit is contained in:
committed by
Thomas Ruoff
parent
df6ec51af9
commit
ec1b2e9629
13
db/index.ts
13
db/index.ts
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user