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,68 @@
|
||||
using Fitness_core_BE.DTOs.Booking;
|
||||
using System.Net;
|
||||
|
||||
namespace Fitness_core_BE.Helpers
|
||||
{
|
||||
// Minimal, dependency-free HTML receipt for a booking payment -- mirrors BookingViewHtml.cs's
|
||||
// "self-contained page, share the link" pattern, kept as its own file since a receipt's
|
||||
// content (itemized charge, payment method) is different enough from the booking confirmation
|
||||
// page to not share a template.
|
||||
public static class BookingInvoiceHtml
|
||||
{
|
||||
public static string Render(BookingInvoiceDto invoice)
|
||||
{
|
||||
var when = $"{invoice.BookingStartTime:dddd, dd MMM yyyy}, {invoice.BookingStartTime:h:mm tt} - {invoice.BookingEndTime:h:mm tt}";
|
||||
|
||||
return $$"""
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Payment Receipt - Vijaya Sport Club</title>
|
||||
<style>
|
||||
body { font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif; background: #f3f4f6; margin: 0; padding: 24px 16px; color: #111827; }
|
||||
.card { max-width: 420px; margin: 0 auto; background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); overflow: hidden; }
|
||||
.header { background: #0f172a; color: #fff; padding: 20px; }
|
||||
.header h1 { margin: 0; font-size: 18px; }
|
||||
.body { padding: 20px; }
|
||||
.row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f1f5f9; }
|
||||
.row .label { color: #6b7280; font-size: 13px; }
|
||||
.row .value { font-weight: 600; font-size: 13px; text-align: right; }
|
||||
.total { margin-top: 16px; text-align: center; background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 8px; padding: 16px; }
|
||||
.total-label { font-size: 12px; color: #6b7280; margin-bottom: 6px; }
|
||||
.total-amount { font-size: 28px; font-weight: 700; color: #0f172a; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="card">
|
||||
<div class="header"><h1>Vijaya Sport Club — Receipt</h1></div>
|
||||
<div class="body">
|
||||
<div class="row"><span class="label">Facility</span><span class="value">{{Encode(invoice.FacilityName)}}</span></div>
|
||||
<div class="row"><span class="label">Session</span><span class="value">{{Encode(when)}}</span></div>
|
||||
<div class="row"><span class="label">Paid by</span><span class="value">{{Encode(invoice.GuestName)}}</span></div>
|
||||
<div class="row"><span class="label">Payment Method</span><span class="value">{{Encode(invoice.PaymentMethod)}}</span></div>
|
||||
<div class="row"><span class="label">Issued</span><span class="value">{{invoice.IssuedAt:dd MMM yyyy, h:mm tt}}</span></div>
|
||||
<div class="total">
|
||||
<div class="total-label">Amount Paid</div>
|
||||
<div class="total-amount">Rs. {{invoice.Amount:N2}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
""";
|
||||
}
|
||||
|
||||
public static string NotFound() => """
|
||||
<!DOCTYPE html>
|
||||
<html><head><meta charset="utf-8" /><title>Receipt not found</title></head>
|
||||
<body style="font-family: sans-serif; text-align: center; padding: 60px 20px; color: #6b7280;">
|
||||
<h2>Receipt not found</h2>
|
||||
<p>This link may be invalid.</p>
|
||||
</body></html>
|
||||
""";
|
||||
|
||||
private static string Encode(string? value) => WebUtility.HtmlEncode(value ?? "");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user