feat(bookings): add transaction document uploads for bank payments
Add payment method selection (Cash/Bank) to booking details Support uploading, downloading, and deleting transaction documents Update database schema and API endpoints to handle file storage
This commit is contained in:
26
server/api/bookings/[id]/transaction-document.delete.ts
Normal file
26
server/api/bookings/[id]/transaction-document.delete.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import type { UpdateBookingDetailsResponse } from '~~/shared/booking'
|
||||
|
||||
import { requireAuth } from '../../../utils/auth'
|
||||
import { clearBookingTransactionDocument } from '../../../utils/booking-repository'
|
||||
import { getRequiredRouteParam, httpError } from '../../../utils/http'
|
||||
import { deleteTransactionDocument } from '../../../utils/transaction-documents'
|
||||
|
||||
export default defineEventHandler(async (event): Promise<UpdateBookingDetailsResponse> => {
|
||||
const auth = await requireAuth(event)
|
||||
const bookingId = getRequiredRouteParam(event, 'id', 'Booking ID')
|
||||
|
||||
const result = await clearBookingTransactionDocument({
|
||||
bookingId,
|
||||
personInChargeId: auth.user.role === 'super_admin' ? undefined : auth.user.id
|
||||
})
|
||||
|
||||
if (!result) {
|
||||
httpError(404, 'Booking not found')
|
||||
}
|
||||
|
||||
await deleteTransactionDocument(result.previousStorageName)
|
||||
|
||||
return {
|
||||
booking: result.booking
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user