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:
@@ -19,21 +19,31 @@ namespace Fitness_core_BE.Interfaces
|
||||
Task<List<Booking>> GetBookings(Guid clientId, Guid? facilityId, Guid? facilitySessionId, DateTime? fromUtc, DateTime? toUtc, string? status);
|
||||
|
||||
// --- Lazy overdue reconciliation (BookingService.SweepOverdueBookingsAsync), run at the
|
||||
// top of every check-in instead of a background job -- see Booking.Status doc comment. ---
|
||||
// top of every check-in AND every checkout instead of a background job -- see
|
||||
// Booking.Status doc comment. ---
|
||||
|
||||
/// <summary>Bulk-flips every Confirmed booking for this client whose EndTime has passed
|
||||
/// to NoShow. Returns the number of rows affected (informational/logging only).</summary>
|
||||
Task<int> MarkOverdueConfirmedAsNoShowAsync(Guid clientId, DateTime now);
|
||||
|
||||
/// <summary>Every CheckedIn booking for this client whose EndTime has passed and hasn't
|
||||
/// been checked out yet, with its RfidTag eagerly loaded so the caller can complete +
|
||||
/// release the tag on the same tracked graph in one SaveChanges.</summary>
|
||||
Task<List<Booking>> GetOverdueCheckedInBookingsAsync(Guid clientId, DateTime now);
|
||||
|
||||
/// <summary>Atomically flips a tag from Available to InUse -- the ONE place a real race
|
||||
/// matters (two staff picking the same tag for two different bookings must not both
|
||||
/// win), so this uses a conditional bulk update rather than read-then-write. Returns
|
||||
/// false if the tag was no longer Available.</summary>
|
||||
Task<bool> TryClaimRfidTagAsync(Guid tagId, DateTime now);
|
||||
|
||||
// --- Booking invoices (snapshot receipts created when a payment is recorded) ---
|
||||
|
||||
Task<BookingInvoice> CreateBookingInvoice(BookingInvoice invoice);
|
||||
|
||||
/// <summary>Listed on their own "Invoices" tab -- deliberately not mixed into the
|
||||
/// membership-based Customer Payments view.</summary>
|
||||
Task<List<BookingInvoice>> GetBookingInvoices(Guid clientId, DateTime? fromUtc, DateTime? toUtc);
|
||||
|
||||
Task<BookingInvoice?> GetBookingInvoiceById(Guid bookingInvoiceId);
|
||||
|
||||
/// <summary>Aggregate counts/sums backing the Bookings page's Dashboard tab.</summary>
|
||||
Task<(int bookingsToday, decimal revenueToday, int checkedInNow, int upcomingConfirmed, decimal outstandingUnpaid)>
|
||||
GetDashboardSummaryAsync(Guid clientId, DateTime now);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,9 @@ namespace Fitness_core_BE.Interfaces
|
||||
// gym's own schema) -- no clientId parameter needed.
|
||||
Task<TenantCustomerLink?> FindActiveLinkByIdentifierAsync(string identifier);
|
||||
|
||||
// Staff picking an existing member to link a walk-in booking to -- identification only.
|
||||
Task<TenantCustomerLink?> GetTenantCustomerLinkById(Guid id);
|
||||
|
||||
Task<bool> DeleteCustomer(Guid customerId);
|
||||
// Client-initiated delete: deactivates only this customer's presence at the calling
|
||||
// client's gym (subscriptions/members/plan assignments scoped to clientId). The shared
|
||||
|
||||
@@ -43,8 +43,10 @@ namespace Fitness_core_BE.Interfaces.Services
|
||||
/// <summary>Staff manually flags a Confirmed, never-arrived booking.</summary>
|
||||
Task<object> MarkNoShow(object payload, HttpContext httpContext);
|
||||
|
||||
/// <summary>Staff manually ends a CheckedIn booking early (before the lazy sweep would
|
||||
/// catch it), releasing its RFID tag if any.</summary>
|
||||
/// <summary>Staff checks out a CheckedIn booking, releasing its RFID tag if any. A guest
|
||||
/// booking still Unpaid must confirm payment in this same call -- see
|
||||
/// BookingService.CompleteBooking. Also lazily sweeps this client's overdue Confirmed
|
||||
/// bookings to NoShow first, same as CheckInBooking.</summary>
|
||||
Task<object> CompleteBooking(object payload, HttpContext httpContext);
|
||||
|
||||
Task<object> GetMyBookings(object payload, HttpContext httpContext);
|
||||
@@ -52,5 +54,16 @@ namespace Fitness_core_BE.Interfaces.Services
|
||||
|
||||
/// <summary>Unified roster covering both booking modes.</summary>
|
||||
Task<object> GetBookings(object payload, HttpContext httpContext);
|
||||
|
||||
/// <summary>Receipts generated whenever a booking's payment is recorded -- their own
|
||||
/// "Invoices" tab, separate from the membership-based Customer Payments view.</summary>
|
||||
Task<object> GetBookingInvoices(object payload, HttpContext httpContext);
|
||||
|
||||
/// <summary>Renders the public, unauthenticated receipt page a BookingInvoice's ShareUrl
|
||||
/// points to. Returns null if not found.</summary>
|
||||
Task<object?> GetBookingInvoiceView(object payload);
|
||||
|
||||
/// <summary>Stat-card summary for the Bookings page's Dashboard tab.</summary>
|
||||
Task<object> GetBookingDashboardSummary(object payload, HttpContext httpContext);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user