4ec55e7290
The HTML entity sweep script had a bug where it wrote empty files for any
view that contained no target Unicode characters, zeroing out 215 view files.
All views restored from the pre-sweep commit (cefdf3e).
Bulk gift certificate feature:
- BulkCreateGiftCertificateDto with Quantity (1-500), Amount, Reason, Expiry, Notes
- GenerateBulkGiftCertificatePdfAsync on IPdfService / PdfService: one Letter page
per cert, reusing the same purple/gold branded ComposeGiftCertificateContent helper
- GiftCertificatesController: BulkCreate GET/POST, BulkResult GET, BulkDownloadPdf POST
- Views: BulkCreate.cshtml (form with live total preview), BulkResult.cshtml (table +
Download All PDF button that POSTs cert IDs to avoid URL length limits)
- gift-certificate-bulk.js: live preview + spinner/disable on submit
- Index.cshtml: Bulk Create button added alongside New Certificate
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
114 lines
3.6 KiB
C#
114 lines
3.6 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using PowderCoating.Core.Enums;
|
|
|
|
namespace PowderCoating.Application.DTOs.GiftCertificate;
|
|
|
|
public class GiftCertificateListDto
|
|
{
|
|
public int Id { get; set; }
|
|
public string CertificateCode { get; set; } = string.Empty;
|
|
public decimal OriginalAmount { get; set; }
|
|
public decimal RedeemedAmount { get; set; }
|
|
public decimal RemainingBalance { get; set; }
|
|
public string? RecipientName { get; set; }
|
|
public string? RecipientEmail { get; set; }
|
|
public GiftCertificateIssuedReason IssuedReason { get; set; }
|
|
public GiftCertificateStatus Status { get; set; }
|
|
public DateTime IssueDate { get; set; }
|
|
public DateTime? ExpiryDate { get; set; }
|
|
}
|
|
|
|
public class GiftCertificateDto : GiftCertificateListDto
|
|
{
|
|
public int? RecipientCustomerId { get; set; }
|
|
public decimal? PurchasePrice { get; set; }
|
|
public int? PurchasingCustomerId { get; set; }
|
|
public string? PurchasingCustomerName { get; set; }
|
|
public string? Notes { get; set; }
|
|
public string? IssuedByName { get; set; }
|
|
public List<GiftCertificateRedemptionDto> Redemptions { get; set; } = new();
|
|
}
|
|
|
|
public class GiftCertificateRedemptionDto
|
|
{
|
|
public int Id { get; set; }
|
|
public int GiftCertificateId { get; set; }
|
|
public int InvoiceId { get; set; }
|
|
public string InvoiceNumber { get; set; } = string.Empty;
|
|
public decimal AmountRedeemed { get; set; }
|
|
public DateTime RedeemedDate { get; set; }
|
|
public string? RedeemedByName { get; set; }
|
|
}
|
|
|
|
public class CreateGiftCertificateDto
|
|
{
|
|
[Required]
|
|
[Range(1.00, 9999.99, ErrorMessage = "Amount must be between $1.00 and $9,999.99")]
|
|
[Display(Name = "Certificate Amount")]
|
|
public decimal Amount { get; set; }
|
|
|
|
[Required]
|
|
[Display(Name = "Issued Reason")]
|
|
public GiftCertificateIssuedReason IssuedReason { get; set; } = GiftCertificateIssuedReason.Sold;
|
|
|
|
[Range(0, 9999.99)]
|
|
[Display(Name = "Purchase Price (if sold)")]
|
|
public decimal? PurchasePrice { get; set; }
|
|
|
|
[Display(Name = "Purchasing Customer")]
|
|
public int? PurchasingCustomerId { get; set; }
|
|
|
|
[Display(Name = "Recipient Customer")]
|
|
public int? RecipientCustomerId { get; set; }
|
|
|
|
[StringLength(200)]
|
|
[Display(Name = "Recipient Name")]
|
|
public string? RecipientName { get; set; }
|
|
|
|
[EmailAddress]
|
|
[StringLength(200)]
|
|
[Display(Name = "Recipient Email")]
|
|
public string? RecipientEmail { get; set; }
|
|
|
|
[Display(Name = "Expiry Date (optional)")]
|
|
public DateTime? ExpiryDate { get; set; }
|
|
|
|
[StringLength(1000)]
|
|
[Display(Name = "Notes")]
|
|
public string? Notes { get; set; }
|
|
}
|
|
|
|
public class RedeemGiftCertificateDto
|
|
{
|
|
[Required]
|
|
public string CertificateCode { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
[Range(0.01, 9999.99)]
|
|
public decimal Amount { get; set; }
|
|
}
|
|
|
|
public class BulkCreateGiftCertificateDto
|
|
{
|
|
[Required]
|
|
[Range(1, 500, ErrorMessage = "Quantity must be between 1 and 500.")]
|
|
[Display(Name = "Number of Certificates")]
|
|
public int Quantity { get; set; } = 25;
|
|
|
|
[Required]
|
|
[Range(1.00, 9999.99, ErrorMessage = "Amount must be between $1.00 and $9,999.99.")]
|
|
[Display(Name = "Face Value (each)")]
|
|
public decimal Amount { get; set; }
|
|
|
|
[Required]
|
|
[Display(Name = "Issued Reason")]
|
|
public GiftCertificateIssuedReason IssuedReason { get; set; } = GiftCertificateIssuedReason.Promotional;
|
|
|
|
[Display(Name = "Expiry Date (optional)")]
|
|
public DateTime? ExpiryDate { get; set; }
|
|
|
|
[StringLength(1000)]
|
|
[Display(Name = "Event / Notes (applied to all certificates)")]
|
|
public string? Notes { get; set; }
|
|
}
|