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:
@@ -0,0 +1,12 @@
|
||||
namespace Fitness_core_BE.DTOs.Booking
|
||||
{
|
||||
/// <summary>Backs the Bookings page's Dashboard tab stat-card row.</summary>
|
||||
public class BookingDashboardSummaryDto
|
||||
{
|
||||
public int BookingsToday { get; set; }
|
||||
public decimal RevenueToday { get; set; }
|
||||
public int CheckedInNow { get; set; }
|
||||
public int UpcomingConfirmed { get; set; }
|
||||
public decimal OutstandingUnpaid { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,9 @@ namespace Fitness_core_BE.DTOs.Booking
|
||||
|
||||
public string PaymentStatus { get; set; } = string.Empty;
|
||||
public decimal AmountCharged { get; set; }
|
||||
/// <summary>"Cash" | "Bank". Null until PaymentStatus becomes "Paid".</summary>
|
||||
public string? PaymentMethod { get; set; }
|
||||
public DateTime? PaidAt { get; set; }
|
||||
public string Status { get; set; } = string.Empty;
|
||||
public DateTime BookedAt { get; set; }
|
||||
public DateTime? CheckedInAt { get; set; }
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace Fitness_core_BE.DTOs.Booking
|
||||
{
|
||||
/// <summary>A booking payment receipt -- deliberately separate from the membership-based
|
||||
/// CustomerInvoice, listed on its own "Invoices" tab, not mixed into Customer Payments.</summary>
|
||||
public class BookingInvoiceDto
|
||||
{
|
||||
public Guid BookingInvoiceId { get; set; }
|
||||
public Guid BookingId { get; set; }
|
||||
public decimal Amount { get; set; }
|
||||
public string PaymentMethod { get; set; } = string.Empty;
|
||||
public string GuestName { get; set; } = string.Empty;
|
||||
public string? GuestPhone { get; set; }
|
||||
public string FacilityName { get; set; } = string.Empty;
|
||||
public DateTime BookingStartTime { get; set; }
|
||||
public DateTime BookingEndTime { get; set; }
|
||||
public DateTime IssuedAt { get; set; }
|
||||
|
||||
/// <summary>Public, unauthenticated link to this receipt's printable page.</summary>
|
||||
public string? ShareUrl { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,11 @@ namespace Fitness_core_BE.DTOs.Booking
|
||||
|
||||
[Required]
|
||||
public string GuestPhone { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>Optional link to an existing registered customer (TenantCustomerLinkId) when
|
||||
/// staff recognizes the walk-in as an already-registered member -- purely for
|
||||
/// identification/auto-fill, doesn't change payment/membership handling at all.</summary>
|
||||
public Guid? CustomerId { get; set; }
|
||||
}
|
||||
|
||||
public class CreateAdhocBookingRequest
|
||||
@@ -57,6 +62,10 @@ namespace Fitness_core_BE.DTOs.Booking
|
||||
/// the FE pre-fills this from the facility but lets staff adjust it.</summary>
|
||||
[Range(typeof(decimal), "0", "79228162514264337593543950335", ErrorMessage = "PricePerHour cannot be negative")]
|
||||
public decimal? PricePerHour { get; set; }
|
||||
|
||||
/// <summary>Optional link to an existing registered customer -- see
|
||||
/// CreateGuestBookingRequest.CustomerId.</summary>
|
||||
public Guid? CustomerId { get; set; }
|
||||
}
|
||||
|
||||
public class MarkGuestBookingPaidRequest
|
||||
@@ -67,6 +76,20 @@ namespace Fitness_core_BE.DTOs.Booking
|
||||
[Required]
|
||||
[Range(0.01, double.MaxValue, ErrorMessage = "AmountCharged must be greater than zero")]
|
||||
public decimal AmountCharged { get; set; }
|
||||
|
||||
/// <summary>"Cash" | "Bank". Defaults to "Cash" if omitted.</summary>
|
||||
public string? PaymentMethod { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>Body for POST .../complete. Only required when the booking is a guest booking
|
||||
/// still Unpaid -- see BookingService.CompleteBooking. Ignored otherwise (member bookings,
|
||||
/// or a guest booking already Paid).</summary>
|
||||
public class CompleteBookingRequest
|
||||
{
|
||||
public bool? MarkPaid { get; set; }
|
||||
public decimal? AmountCollected { get; set; }
|
||||
/// <summary>"Cash" | "Bank". Defaults to "Cash" if omitted.</summary>
|
||||
public string? PaymentMethod { get; set; }
|
||||
}
|
||||
|
||||
public class CheckInBookingRequest
|
||||
|
||||
Reference in New Issue
Block a user