using System.ComponentModel.DataAnnotations;

namespace Altob.NtuInvoiceGateway.Models;

public class InvoiceRequest
{
    [Required(ErrorMessage = "開發票者統編為必填")]
    [StringLength(8, ErrorMessage = "統編長度不能超過8個字元")]
    [RegularExpression(@"^\d{8}$", ErrorMessage = "統編格式不正確，必須為8位數字")]
    public string Identifier { get; set; } = string.Empty;

    [Required(ErrorMessage = "發票交易日期為必填")]
    public string TransDateTime { get; set; } = string.Empty;

    [Required(ErrorMessage = "發票交易金額為必填")]
    [StringLength(6, ErrorMessage = "金額長度不能超過6個字元")]
    public string TransAmount { get; set; } = string.Empty;

    [Required(ErrorMessage = "設備代號為必填")]
    [StringLength(16, ErrorMessage = "設備代號長度不能超過16個字元")]
    public string DeviceID { get; set; } = string.Empty;

    [StringLength(64, ErrorMessage = "Email長度不能超過64個字元")]
    [EmailAddress(ErrorMessage = "Email格式不正確")]
    public string? Email { get; set; }  = string.Empty;

    [StringLength(8, ErrorMessage = "手機條碼長度不能超過8個字元")]
    [RegularExpression(@"^\/[A-Z0-9.+\-]{7}$", ErrorMessage = "手機條碼格式不正確，必須為8碼，第一碼為/，其餘為大寫英數字、點、加號或減號")]
    public string? CarrierID { get; set; } = string.Empty;

    [Required(ErrorMessage = "停車場站代號為必填")]
    [StringLength(1, ErrorMessage = "停車場站代號長度不能超過1個字元")]
    public string LocationID { get; set; } = string.Empty;

    [Required(ErrorMessage = "車牌號碼為必填")]
    [StringLength(8, ErrorMessage = "車牌號碼長度不能超過8個字元")]
    public string CarPlateNum { get; set; } = string.Empty;

    [Required(ErrorMessage = "訂單編號為必填")]
    [StringLength(64, ErrorMessage = "訂單編號長度不能超過64個字元")]
    public string OrderID { get; set; } = string.Empty;

    [StringLength(8, ErrorMessage = "購買者統編長度不能超過8個字元")]
    [RegularExpression(@"^\d{8}$", ErrorMessage = "統編格式不正確，必須為8位數字")]
    public string? BuyerIdentifier { get; set; } = string.Empty;

    [RegularExpression(@"^$|^\d+$", ErrorMessage = "捐贈碼須為空值或數字")]
    public string? LoveCode { get; set; } = string.Empty;

    [Required(ErrorMessage = "稅別為必填")]
    [StringLength(1, ErrorMessage = "稅別長度不能超過1個字元")]
    public string TaxType { get; set; } = string.Empty;
}
