Browse Source

捐贈碼

master
Joanne.Chuang 2 weeks ago
parent
commit
1b3fb9fac8
4 changed files with 13 additions and 16 deletions
  1. +2
    -3
      Altob.NtuInvoiceGateway/Models/InvoiceRequest.cs
  2. +7
    -6
      Altob.NtuInvoiceGateway/Pages/Invoice.cshtml
  3. +3
    -6
      Altob.NtuInvoiceGateway/Pages/Invoice.cshtml.cs
  4. +1
    -1
      Altob.NtuInvoiceGateway/appsettings.json

+ 2
- 3
Altob.NtuInvoiceGateway/Models/InvoiceRequest.cs View File

@@ -44,9 +44,8 @@ public class InvoiceRequest
[RegularExpression(@"^\d{8}$", ErrorMessage = "統編格式不正確,必須為8位數字")]
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 = "稅別為必填")]
[StringLength(1, ErrorMessage = "稅別長度不能超過1個字元")]


+ 7
- 6
Altob.NtuInvoiceGateway/Pages/Invoice.cshtml View File

@@ -58,7 +58,7 @@
<input type="hidden" asp-for="InvoiceData.TaxType" />

<div class="alert alert-info mb-4">
<strong>注意:</strong>以下個選項至少需填寫一個
<strong>注意:</strong>以下個選項至少需填寫一個
</div>

<div class="row mb-3">
@@ -82,12 +82,12 @@
<small class="form-text text-muted">8位數字</small>
<span asp-validation-for="InvoiceData.BuyerIdentifier" class="text-danger"></span>
</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" />
<small class="form-text text-muted">輸入為捐贈發票</small>
<span asp-validation-for="InvoiceData.LoveCode" class="text-danger"></span>
</div> *@
</div>
</div>

<div id="submitButtonContainer" class="d-grid gap-2 mt-4 @(string.IsNullOrEmpty(Model.SuccessMessage) ? string.Empty : "d-none")">
@@ -141,7 +141,8 @@
const requiredGroup = [
document.querySelector('input[name="InvoiceData.Email"]'),
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"]');
@@ -179,7 +180,7 @@
const hasValue = requiredGroup.some(field => field && field.value.trim() !== '');
if (!hasValue) {
event.preventDefault();
showError('Email、手機條碼、購買者統編至少需填寫一項。');
showError('Email、手機條碼、購買者統編、捐贈碼至少需填寫一項。');
return;
}



+ 3
- 6
Altob.NtuInvoiceGateway/Pages/Invoice.cshtml.cs View File

@@ -105,7 +105,8 @@ public class InvoiceModel : PageModel
// 判斷是否為初始轉頁(三個選項都沒填寫)
bool isInitialRedirect = string.IsNullOrEmpty(InvoiceData.Email) &&
string.IsNullOrEmpty(InvoiceData.CarrierID) &&
string.IsNullOrEmpty(InvoiceData.BuyerIdentifier);
string.IsNullOrEmpty(InvoiceData.BuyerIdentifier) &&
string.IsNullOrEmpty(InvoiceData.LoveCode);

// 如果是初始轉頁,直接顯示表單讓用戶填寫
if (isInitialRedirect)
@@ -134,7 +135,7 @@ public class InvoiceModel : PageModel
if (!string.IsNullOrEmpty(InvoiceData.Email)) filledCount++;
if (!string.IsNullOrEmpty(InvoiceData.CarrierID)) filledCount++;
if (!string.IsNullOrEmpty(InvoiceData.BuyerIdentifier)) filledCount++;
// if (!string.IsNullOrEmpty(InvoiceData.LoveCode)) filledCount++;
if (!string.IsNullOrEmpty(InvoiceData.LoveCode)) filledCount++;

if (filledCount == 0)
{
@@ -232,13 +233,9 @@ public class InvoiceModel : PageModel
InvoiceData.TransDateTime = InvoiceData.TransDateTime ?? string.Empty;
InvoiceData.TransAmount = InvoiceData.TransAmount ?? 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.CarPlateNum = InvoiceData.CarPlateNum ?? 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;
}



+ 1
- 1
Altob.NtuInvoiceGateway/appsettings.json View File

@@ -31,7 +31,7 @@
},
"AllowedHosts": "*",
"CompanyInfo": {
"Name": "國立灣大學臨時停車場",
"Name": "國立灣大學臨時停車場",
"TaxId": "18384226"
},
"InvoiceApi": {


Loading…
Cancel
Save