feat: Enhance booking functionality with invoice management and dashboard summary
- Added customerId to guest booking requests for better identification. - Implemented new endpoints for managing booking invoices and dashboard summaries. - Created BookingInvoice and BookingDashboardSummary DTOs to support new features. - Updated Booking and BookingInvoice models to include payment method and timestamps. - Enhanced BookingService to handle invoice creation upon payment confirmation. - Modified BookingRepository to support CRUD operations for BookingInvoice. - Updated TenantDbContext to include BookingInvoice DbSet and relevant configurations. - Improved error handling and validation for booking completion and payment processes.
This commit is contained in:
@@ -65,7 +65,8 @@ namespace Fitness_core_BE.Controllers
|
||||
{
|
||||
facilitySessionId = request.FacilitySessionId,
|
||||
guestName = request.GuestName,
|
||||
guestPhone = request.GuestPhone
|
||||
guestPhone = request.GuestPhone,
|
||||
customerId = request.CustomerId
|
||||
}, HttpContext));
|
||||
|
||||
[AllowAnonymous]
|
||||
@@ -79,7 +80,8 @@ namespace Fitness_core_BE.Controllers
|
||||
guestName = request.GuestName,
|
||||
guestPhone = request.GuestPhone,
|
||||
partySize = request.PartySize,
|
||||
pricePerHour = request.PricePerHour
|
||||
pricePerHour = request.PricePerHour,
|
||||
customerId = request.CustomerId
|
||||
}, HttpContext));
|
||||
|
||||
// The actual "copy the link and share it" page -- BookingDto.ShareUrl points here.
|
||||
@@ -135,7 +137,12 @@ namespace Fitness_core_BE.Controllers
|
||||
[RequiresPermission("bookings")]
|
||||
[HttpPost("api/client/bookings/{id:guid}/mark-paid")]
|
||||
public async Task<ActionResult<ApiResponse<object>>> MarkGuestBookingPaid(Guid id, [FromBody] MarkGuestBookingPaidRequest request)
|
||||
=> Response(await _bookingService.MarkGuestBookingPaid(new { bookingId = id, amountCharged = request.AmountCharged }, HttpContext));
|
||||
=> Response(await _bookingService.MarkGuestBookingPaid(new
|
||||
{
|
||||
bookingId = id,
|
||||
amountCharged = request.AmountCharged,
|
||||
paymentMethod = request.PaymentMethod
|
||||
}, HttpContext));
|
||||
|
||||
[CustomMiddleware]
|
||||
[TenantResolution]
|
||||
@@ -180,7 +187,44 @@ namespace Fitness_core_BE.Controllers
|
||||
[TenantResolution]
|
||||
[RequiresPermission("bookings")]
|
||||
[HttpPost("api/client/bookings/{id:guid}/complete")]
|
||||
public async Task<ActionResult<ApiResponse<object>>> CompleteBooking(Guid id)
|
||||
=> Response(await _bookingService.CompleteBooking(new { bookingId = id }, HttpContext));
|
||||
public async Task<ActionResult<ApiResponse<object>>> CompleteBooking(Guid id, [FromBody] CompleteBookingRequest? request)
|
||||
=> Response(await _bookingService.CompleteBooking(new
|
||||
{
|
||||
bookingId = id,
|
||||
markPaid = request?.MarkPaid,
|
||||
amountCollected = request?.AmountCollected,
|
||||
paymentMethod = request?.PaymentMethod
|
||||
}, HttpContext));
|
||||
|
||||
[CustomMiddleware]
|
||||
[TenantResolution]
|
||||
[RequiresPermission("bookings")]
|
||||
[HttpGet("api/client/bookings/invoices")]
|
||||
public async Task<ActionResult<ApiResponse<object>>> GetBookingInvoices([FromQuery] DateTime? fromDate, [FromQuery] DateTime? toDate)
|
||||
=> Response(await _bookingService.GetBookingInvoices(new
|
||||
{
|
||||
fromDate = fromDate?.ToString("o"),
|
||||
toDate = toDate?.ToString("o")
|
||||
}, HttpContext));
|
||||
|
||||
[CustomMiddleware]
|
||||
[TenantResolution]
|
||||
[RequiresPermission("bookings")]
|
||||
[HttpGet("api/client/bookings/dashboard-summary")]
|
||||
public async Task<ActionResult<ApiResponse<object>>> GetBookingDashboardSummary()
|
||||
=> Response(await _bookingService.GetBookingDashboardSummary(new { }, HttpContext));
|
||||
|
||||
// Public, unguessable-GUID receipt page -- same "public but the link IS the credential"
|
||||
// model as ViewBooking above.
|
||||
[AllowAnonymous]
|
||||
[HttpGet("api/public/booking-invoices/{id:guid}/view")]
|
||||
public async Task<ContentResult> ViewBookingInvoice(Guid id)
|
||||
{
|
||||
var invoice = await _bookingService.GetBookingInvoiceView(new { bookingInvoiceId = id }) as BookingInvoiceDto;
|
||||
if (invoice == null)
|
||||
return Content(BookingInvoiceHtml.NotFound(), "text/html");
|
||||
|
||||
return Content(BookingInvoiceHtml.Render(invoice), "text/html");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user