From 69a1d02fc7da76890d315e3d3f3a2e64f69d3263 Mon Sep 17 00:00:00 2001 From: sky121113 Date: Thu, 18 Jun 2026 11:41:26 +0800 Subject: [PATCH] =?UTF-8?q?[FIX]=20=E9=9B=BB=E5=AD=90=E7=99=BC=E7=A5=A8?= =?UTF-8?q?=E5=88=97=E5=8D=B0=E9=99=90=E7=B8=AE=E7=82=BA=E5=83=85=E7=B5=B1?= =?UTF-8?q?=E7=B7=A8=E7=99=BC=E7=A5=A8=EF=BC=8C=E9=81=BF=E5=85=8D=E8=BC=89?= =?UTF-8?q?=E5=85=B7/=E6=8D=90=E8=B4=88=E5=88=97=E5=8D=B0=E5=A4=B1?= =?UTF-8?q?=E6=95=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 釐清綠界規則:InvoicePrint 僅能列印開立時 Print=1 的發票;本系統開立邏輯為「有統編才 Print=1」,故載具、捐贈、一般無統編 B2C 皆 Print=0,列印會回「取得發票列印網址失敗」。 2. 後端 printInvoice() 守衛改為檢查 metadata['business_tax_id'],非統編發票直接回「Only invoices with a tax ID can be printed」,取代原本僅擋捐贈(love_code)的舊邏輯。 3. 訂單詳情面板列印鈕顯示條件改為 business_tax_id 有值才顯示,非統編發票改顯示「此發票無可列印紙本」。 4. 新增三語系 key(Only invoices with a tax ID can be printed、This invoice has no printable copy),zh_TW/en/ja 對齊排序。 Co-Authored-By: Claude Opus 4.8 (1M context) --- app/Http/Controllers/Admin/SalesController.php | 7 ++++--- lang/en.json | 2 ++ lang/ja.json | 2 ++ lang/zh_TW.json | 2 ++ .../admin/sales/partials/order-detail-panel.blade.php | 9 +++++---- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Admin/SalesController.php b/app/Http/Controllers/Admin/SalesController.php index 7a9c1a2..756d71a 100644 --- a/app/Http/Controllers/Admin/SalesController.php +++ b/app/Http/Controllers/Admin/SalesController.php @@ -1155,9 +1155,10 @@ class SalesController extends Controller if ($invoice->status !== Invoice::STATUS_ISSUED || empty($invoice->invoice_no)) { return back()->with('error', __('Only issued invoices can be printed')); } - // 捐贈發票依法無紙本、不可列印(綠界 InvoicePrint 會回查無資料) - if (!empty($invoice->love_code)) { - return back()->with('error', __('Donation invoices cannot be printed')); + // 僅「統編發票」可列印:本系統開立時 Print=1 僅給帶統編者(見 EcpayInvoiceService::issue 的 Print 規則); + // 捐贈、載具、一般無統編 B2C 皆以 Print=0 開立,綠界 InvoicePrint 會回查無資料而失敗。 + if (empty($invoice->metadata['business_tax_id'] ?? '')) { + return back()->with('error', __('Only invoices with a tax ID can be printed')); } $machine = $invoice->machine; if (!$machine || !$ecpay->configForMachine($machine)) { diff --git a/lang/en.json b/lang/en.json index 406b6b2..6054d97 100644 --- a/lang/en.json +++ b/lang/en.json @@ -1392,6 +1392,7 @@ "Online Status": "Online Status", "Only .xlsx files are supported (Max 5MB)": "Only .xlsx files are supported (Max 5MB)", "Only .xlsx, .xls, .csv files are supported (Max 5MB)": "Only .xlsx, .xls, .csv files are supported (Max 5MB)", + "Only invoices with a tax ID can be printed": "Only invoices with a tax ID can be printed", "Only issued invoices can be printed": "Only issued invoices can be printed", "Only issued invoices can be voided": "Only issued invoices can be voided", "Only machines under the same company can be cloned for security.": "Only machines under the same company can be cloned for security.", @@ -2113,6 +2114,7 @@ "This Month": "This Month", "This Week": "This Week", "This account does not belong to this company.": "This account does not belong to this company.", + "This invoice has no printable copy": "This invoice has no printable copy", "This is a system administrator role. Its name is locked to ensure system stability.": "This is a system administrator role. Its name is locked to ensure system stability.", "This machine has a pending command. Please wait.": "This machine has a pending command. Please wait.", "This machine has no ECPay invoice settings": "This machine has no ECPay invoice settings", diff --git a/lang/ja.json b/lang/ja.json index c90775c..d08fba3 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -1392,6 +1392,7 @@ "Online Status": "オンラインステータス", "Only .xlsx files are supported (Max 5MB)": "Only .xlsx files are supported (Max 5MB)", "Only .xlsx, .xls, .csv files are supported (Max 5MB)": ".xlsx, .xls, .csv ファイルのみサポートされています (最大 5MB)", + "Only invoices with a tax ID can be printed": "統一番号付き請求書のみ印刷できます", "Only issued invoices can be printed": "発行済みの領収書のみ印刷できます", "Only issued invoices can be voided": "Only issued invoices can be voided", "Only machines under the same company can be cloned for security.": "セキュリティのため、同じ会社の機器設定のみコピーできます。", @@ -2113,6 +2114,7 @@ "This Month": "今月", "This Week": "今週", "This account does not belong to this company.": "このアカウントは該当企業に所属していません。", + "This invoice has no printable copy": "この請求書は印刷可能な紙面がありません", "This is a system administrator role. Its name is locked to ensure system stability.": "これはシステム管理者ロールです。システムの安定性を確保するため、名前はロックされています。", "This machine has a pending command. Please wait.": "この機器には実行中のコマンドがあります。しばらくお待ちください。", "This machine has no ECPay invoice settings": "This machine has no ECPay invoice settings", diff --git a/lang/zh_TW.json b/lang/zh_TW.json index bf9e562..499c900 100644 --- a/lang/zh_TW.json +++ b/lang/zh_TW.json @@ -1392,6 +1392,7 @@ "Online Status": "在線狀態", "Only .xlsx files are supported (Max 5MB)": "僅支援 .xlsx 檔案 (最大 5MB)", "Only .xlsx, .xls, .csv files are supported (Max 5MB)": "僅支援 .xlsx, .xls, .csv 檔案 (最大 5MB)", + "Only invoices with a tax ID can be printed": "僅統編發票可列印", "Only issued invoices can be printed": "僅已開立的發票可列印", "Only issued invoices can be voided": "僅已開立的發票可作廢", "Only machines under the same company can be cloned for security.": "基於安全性,僅限複製同公司旗下的機台設定。", @@ -2113,6 +2114,7 @@ "This Month": "本月", "This Week": "本週", "This account does not belong to this company.": "此帳號不屬於該公司。", + "This invoice has no printable copy": "此發票無可列印紙本", "This is a system administrator role. Its name is locked to ensure system stability.": "這是系統管理員角色,名稱已鎖定以確保系統穩定性。", "This machine has a pending command. Please wait.": "此機台已有指令正在執行,請稍後。", "This machine has no ECPay invoice settings": "此機台未設定綠界電子發票", diff --git a/resources/views/admin/sales/partials/order-detail-panel.blade.php b/resources/views/admin/sales/partials/order-detail-panel.blade.php index f9d8ca3..32d5832 100644 --- a/resources/views/admin/sales/partials/order-detail-panel.blade.php +++ b/resources/views/admin/sales/partials/order-detail-panel.blade.php @@ -342,8 +342,9 @@ 'void' => ['label' => __('Void'), 'color' => 'slate'], ]; $invBadge = $invStatusMap[$invStatus] ?? ['label' => $invStatus, 'color' => 'slate']; - // 捐贈發票依法無紙本、不可列印(綠界 InvoicePrint 會回查無資料) - $invPrintable = empty($order->invoice->love_code); + // 僅「統編發票」可列印:本系統開立時 Print=1 僅給帶統編者; + // 捐贈、載具、一般無統編 B2C 皆為 Print=0,綠界 InvoicePrint 會回查無資料而失敗。 + $invPrintable = !empty($order->invoice->metadata['business_tax_id'] ?? ''); @endphp
@@ -361,7 +362,7 @@ @if($invStatus === 'issued')
- {{-- 列印(捐贈發票無紙本,僅非捐贈可列印) --}} + {{-- 列印:僅統編發票可列印(載具/捐贈/一般無統編 B2C 為 Print=0,綠界查無資料) --}} @if($invPrintable)
@csrf @@ -370,7 +371,7 @@
@else - {{ __('Donation invoices cannot be printed') }} + {{ __('This invoice has no printable copy') }} @endif {{-- 作廢:僅平台系統管理員可見可用(後端亦有 403 守衛)。使用自製確認框 UI --}} @if(auth()->user()->isSystemAdmin())