| @@ -44,9 +44,8 @@ public class InvoiceRequest | |||||
| [RegularExpression(@"^\d{8}$", ErrorMessage = "統編格式不正確,必須為8位數字")] | [RegularExpression(@"^\d{8}$", ErrorMessage = "統編格式不正確,必須為8位數字")] | ||||
| public string? BuyerIdentifier { get; set; } = string.Empty; | public string? BuyerIdentifier { get; set; } = string.Empty; | ||||
| [StringLength(6, ErrorMessage = "愛心碼長度不能超過6碼")] | |||||
| [RegularExpression(@"^$|^\d{6}$", ErrorMessage = "愛心碼須為空值或6位數字")] | |||||
| public string LoveCode { get; set; } = string.Empty; | |||||
| [RegularExpression(@"^$|^\d+$", ErrorMessage = "捐贈碼須為空值或數字")] | |||||
| public string? LoveCode { get; set; } = string.Empty; | |||||
| [Required(ErrorMessage = "稅別為必填")] | [Required(ErrorMessage = "稅別為必填")] | ||||
| [StringLength(1, ErrorMessage = "稅別長度不能超過1個字元")] | [StringLength(1, ErrorMessage = "稅別長度不能超過1個字元")] | ||||
| @@ -58,7 +58,7 @@ | |||||
| <input type="hidden" asp-for="InvoiceData.TaxType" /> | <input type="hidden" asp-for="InvoiceData.TaxType" /> | ||||
| <div class="alert alert-info mb-4"> | <div class="alert alert-info mb-4"> | ||||
| <strong>注意:</strong>以下三個選項至少需填寫一個 | |||||
| <strong>注意:</strong>以下四個選項至少需填寫一個 | |||||
| </div> | </div> | ||||
| <div class="row mb-3"> | <div class="row mb-3"> | ||||
| @@ -82,12 +82,12 @@ | |||||
| <small class="form-text text-muted">8位數字</small> | <small class="form-text text-muted">8位數字</small> | ||||
| <span asp-validation-for="InvoiceData.BuyerIdentifier" class="text-danger"></span> | <span asp-validation-for="InvoiceData.BuyerIdentifier" class="text-danger"></span> | ||||
| </div> | </div> | ||||
| @* <div class="col-md-6"> | |||||
| <label asp-for="InvoiceData.LoveCode" class="form-label">愛心碼</label> | |||||
| <div class="col-md-6"> | |||||
| <label asp-for="InvoiceData.LoveCode" class="form-label">捐贈碼</label> | |||||
| <input asp-for="InvoiceData.LoveCode" class="form-control" maxlength="7" placeholder="123456" /> | <input asp-for="InvoiceData.LoveCode" class="form-control" maxlength="7" placeholder="123456" /> | ||||
| <small class="form-text text-muted">輸入為捐贈發票</small> | <small class="form-text text-muted">輸入為捐贈發票</small> | ||||
| <span asp-validation-for="InvoiceData.LoveCode" class="text-danger"></span> | <span asp-validation-for="InvoiceData.LoveCode" class="text-danger"></span> | ||||
| </div> *@ | |||||
| </div> | |||||
| </div> | </div> | ||||
| <div id="submitButtonContainer" class="d-grid gap-2 mt-4 @(string.IsNullOrEmpty(Model.SuccessMessage) ? string.Empty : "d-none")"> | <div id="submitButtonContainer" class="d-grid gap-2 mt-4 @(string.IsNullOrEmpty(Model.SuccessMessage) ? string.Empty : "d-none")"> | ||||
| @@ -141,7 +141,8 @@ | |||||
| const requiredGroup = [ | const requiredGroup = [ | ||||
| document.querySelector('input[name="InvoiceData.Email"]'), | document.querySelector('input[name="InvoiceData.Email"]'), | ||||
| document.querySelector('input[name="InvoiceData.CarrierID"]'), | document.querySelector('input[name="InvoiceData.CarrierID"]'), | ||||
| document.querySelector('input[name="InvoiceData.BuyerIdentifier"]') | |||||
| document.querySelector('input[name="InvoiceData.BuyerIdentifier"]'), | |||||
| document.querySelector('input[name="InvoiceData.LoveCode"]') | |||||
| ]; | ]; | ||||
| const form = document.querySelector('form[method="post"]'); | const form = document.querySelector('form[method="post"]'); | ||||
| @@ -179,7 +180,7 @@ | |||||
| const hasValue = requiredGroup.some(field => field && field.value.trim() !== ''); | const hasValue = requiredGroup.some(field => field && field.value.trim() !== ''); | ||||
| if (!hasValue) { | if (!hasValue) { | ||||
| event.preventDefault(); | event.preventDefault(); | ||||
| showError('Email、手機條碼、購買者統編至少需填寫一項。'); | |||||
| showError('Email、手機條碼、購買者統編、捐贈碼至少需填寫一項。'); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -105,7 +105,8 @@ public class InvoiceModel : PageModel | |||||
| // 判斷是否為初始轉頁(三個選項都沒填寫) | // 判斷是否為初始轉頁(三個選項都沒填寫) | ||||
| bool isInitialRedirect = string.IsNullOrEmpty(InvoiceData.Email) && | bool isInitialRedirect = string.IsNullOrEmpty(InvoiceData.Email) && | ||||
| string.IsNullOrEmpty(InvoiceData.CarrierID) && | string.IsNullOrEmpty(InvoiceData.CarrierID) && | ||||
| string.IsNullOrEmpty(InvoiceData.BuyerIdentifier); | |||||
| string.IsNullOrEmpty(InvoiceData.BuyerIdentifier) && | |||||
| string.IsNullOrEmpty(InvoiceData.LoveCode); | |||||
| // 如果是初始轉頁,直接顯示表單讓用戶填寫 | // 如果是初始轉頁,直接顯示表單讓用戶填寫 | ||||
| if (isInitialRedirect) | if (isInitialRedirect) | ||||
| @@ -134,7 +135,7 @@ public class InvoiceModel : PageModel | |||||
| if (!string.IsNullOrEmpty(InvoiceData.Email)) filledCount++; | if (!string.IsNullOrEmpty(InvoiceData.Email)) filledCount++; | ||||
| if (!string.IsNullOrEmpty(InvoiceData.CarrierID)) filledCount++; | if (!string.IsNullOrEmpty(InvoiceData.CarrierID)) filledCount++; | ||||
| if (!string.IsNullOrEmpty(InvoiceData.BuyerIdentifier)) filledCount++; | if (!string.IsNullOrEmpty(InvoiceData.BuyerIdentifier)) filledCount++; | ||||
| // if (!string.IsNullOrEmpty(InvoiceData.LoveCode)) filledCount++; | |||||
| if (!string.IsNullOrEmpty(InvoiceData.LoveCode)) filledCount++; | |||||
| if (filledCount == 0) | if (filledCount == 0) | ||||
| { | { | ||||
| @@ -232,13 +233,9 @@ public class InvoiceModel : PageModel | |||||
| InvoiceData.TransDateTime = InvoiceData.TransDateTime ?? string.Empty; | InvoiceData.TransDateTime = InvoiceData.TransDateTime ?? string.Empty; | ||||
| InvoiceData.TransAmount = InvoiceData.TransAmount ?? string.Empty; | InvoiceData.TransAmount = InvoiceData.TransAmount ?? string.Empty; | ||||
| InvoiceData.DeviceID = InvoiceData.DeviceID ?? string.Empty; | InvoiceData.DeviceID = InvoiceData.DeviceID ?? string.Empty; | ||||
| InvoiceData.Email = InvoiceData.Email ?? string.Empty; | |||||
| InvoiceData.CarrierID = InvoiceData.CarrierID ?? string.Empty; | |||||
| InvoiceData.LocationID = InvoiceData.LocationID ?? string.Empty; | InvoiceData.LocationID = InvoiceData.LocationID ?? string.Empty; | ||||
| InvoiceData.CarPlateNum = InvoiceData.CarPlateNum ?? string.Empty; | InvoiceData.CarPlateNum = InvoiceData.CarPlateNum ?? string.Empty; | ||||
| InvoiceData.OrderID = InvoiceData.OrderID ?? string.Empty; | InvoiceData.OrderID = InvoiceData.OrderID ?? string.Empty; | ||||
| InvoiceData.BuyerIdentifier = InvoiceData.BuyerIdentifier ?? string.Empty; | |||||
| InvoiceData.LoveCode = InvoiceData.LoveCode ?? string.Empty; | |||||
| InvoiceData.TaxType = InvoiceData.TaxType ?? string.Empty; | InvoiceData.TaxType = InvoiceData.TaxType ?? string.Empty; | ||||
| } | } | ||||
| @@ -31,7 +31,7 @@ | |||||
| }, | }, | ||||
| "AllowedHosts": "*", | "AllowedHosts": "*", | ||||
| "CompanyInfo": { | "CompanyInfo": { | ||||
| "Name": "國立台灣大學臨時停車場", | |||||
| "Name": "國立臺灣大學臨時停車場", | |||||
| "TaxId": "18384226" | "TaxId": "18384226" | ||||
| }, | }, | ||||
| "InvoiceApi": { | "InvoiceApi": { | ||||