[FIX] 電子發票列印限縮為僅統編發票,避免載具/捐贈列印失敗
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) <noreply@anthropic.com>
This commit is contained in:
parent
ae4c9fb93a
commit
69a1d02fc7
@ -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)) {
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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": "此機台未設定綠界電子發票",
|
||||
|
||||
@ -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
|
||||
<div class="relative flex flex-col sm:flex-row sm:items-center justify-between gap-6">
|
||||
<div class="space-y-3">
|
||||
@ -361,7 +362,7 @@
|
||||
|
||||
@if($invStatus === 'issued')
|
||||
<div class="flex items-center gap-3">
|
||||
{{-- 列印(捐贈發票無紙本,僅非捐贈可列印) --}}
|
||||
{{-- 列印:僅統編發票可列印(載具/捐贈/一般無統編 B2C 為 Print=0,綠界查無資料) --}}
|
||||
@if($invPrintable)
|
||||
<form method="POST" action="{{ route('admin.sales.invoices.print', $order->invoice) }}" target="_blank">
|
||||
@csrf
|
||||
@ -370,7 +371,7 @@
|
||||
</button>
|
||||
</form>
|
||||
@else
|
||||
<span class="text-[11px] font-bold text-slate-400 dark:text-slate-500 px-2">{{ __('Donation invoices cannot be printed') }}</span>
|
||||
<span class="text-[11px] font-bold text-slate-400 dark:text-slate-500 px-2">{{ __('This invoice has no printable copy') }}</span>
|
||||
@endif
|
||||
{{-- 作廢:僅平台系統管理員可見可用(後端亦有 403 守衛)。使用自製確認框 UI --}}
|
||||
@if(auth()->user()->isSystemAdmin())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user