[PROMOTE] dev 晉升至 demo:電子發票開關閘門與發票操作 UI 調整
1. [FIX] 開立電子發票前檢查機台電子發票開關(tax_invoice_enabled),關閉時略過開立並記 log。 2. [STYLE] 發票操作按鈕配置調整,作廢確認框改用自製 UI。
This commit is contained in:
commit
04195caf9b
@ -371,7 +371,9 @@ class TransactionService
|
||||
|
||||
// 2. Record Invoice — 後台開立版:finalize 帶 invoice 輸入(status=pending)時建 pending 發票,
|
||||
// commit 後派 IssueInvoiceJob 去綠界開立(不在交易內等 ECPay,避免長交易)。
|
||||
if (!empty($data['invoice'])) {
|
||||
// 開立條件:機台「電子發票開關」開啟 AND 上報帶 invoice,兩者皆成立才開立。
|
||||
// 機台關閉電子發票時略過開立(不建發票、不送綠界),僅留 warning log 供日後追查。
|
||||
if (!empty($data['invoice']) && $order->machine?->tax_invoice_enabled) {
|
||||
$invoiceData = $data['invoice'];
|
||||
$invoiceData['serial_no'] = $serialNo;
|
||||
$invoiceData['flow_id'] = $order->flow_id;
|
||||
@ -384,6 +386,13 @@ class TransactionService
|
||||
\App\Jobs\Transaction\IssueInvoiceJob::dispatch($invoice->id);
|
||||
});
|
||||
}
|
||||
} elseif (!empty($data['invoice'])) {
|
||||
// 上報帶了 invoice,但機台「電子發票開關」為關閉 → 略過開立,留軌跡供追查。
|
||||
Log::warning('機台已關閉電子發票,略過開立', [
|
||||
'machine_id' => $order->machine_id,
|
||||
'flow_id' => $order->flow_id,
|
||||
'order_id' => $order->id,
|
||||
]);
|
||||
}
|
||||
|
||||
// 3. Record Dispense Results (B602) - Optional/Multiple
|
||||
|
||||
@ -309,57 +309,29 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
@if($invStatus === 'issued')
|
||||
{{-- 列印(捐贈發票無紙本,僅非捐贈可列印) --}}
|
||||
@if($invPrintable)
|
||||
<form method="POST" action="{{ route('admin.sales.invoices.print', $order->invoice) }}" target="_blank">
|
||||
@csrf
|
||||
<button type="submit" title="{{ __('Print Invoice') }}"
|
||||
class="p-3 rounded-xl bg-white dark:bg-slate-800 text-slate-500 dark:text-slate-400 border border-slate-200 dark:border-slate-700 hover:bg-indigo-500 hover:text-white hover:border-indigo-500 transition-all duration-300 shadow-sm">
|
||||
<svg class="w-4 h-4 stroke-[2.2]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M6.72 13.829c-.24.03-.48.062-.72.096m.72-.096a42.415 42.415 0 0 1 10.56 0m-10.56 0L6.34 18m10.94-4.171c.24.03.48.062.72.096m-.72-.096L17.66 18m0 0 .229 2.523a1.125 1.125 0 0 1-1.12 1.227H7.231c-.662 0-1.18-.568-1.12-1.227L6.34 18m11.318 0h1.091A2.25 2.25 0 0 0 21 15.75V9.456c0-1.081-.768-2.015-1.837-2.175a48.055 48.055 0 0 0-1.913-.247M6.34 18H5.25A2.25 2.25 0 0 1 3 15.75V9.456c0-1.081.768-2.015 1.837-2.175a48.041 48.041 0 0 1 1.913-.247m10.5 0a48.536 48.536 0 0 0-10.5 0m10.5 0V3.375c0-.621-.504-1.125-1.125-1.125h-8.25c-.621 0-1.125.504-1.125 1.125v3.659M18 10.5h.008v.008H18V10.5Z" />
|
||||
</svg>
|
||||
</button>
|
||||
</form>
|
||||
@else
|
||||
<span class="text-[11px] font-bold text-slate-400 dark:text-slate-500 px-2">{{ __('Donation invoices cannot be printed') }}</span>
|
||||
@endif
|
||||
{{-- 作廢:使用自製確認框 UI(不用瀏覽器原生 confirm) --}}
|
||||
<form id="invoice-void-form-{{ $order->invoice->id }}" method="POST" action="{{ route('admin.sales.invoices.void', $order->invoice) }}" class="hidden">
|
||||
@csrf
|
||||
</form>
|
||||
<button type="button" title="{{ __('Void Invoice') }}"
|
||||
@click="confirmVoidInvoice('invoice-void-form-{{ $order->invoice->id }}')"
|
||||
class="p-3 rounded-xl bg-white dark:bg-slate-800 text-slate-500 dark:text-slate-400 border border-slate-200 dark:border-slate-700 hover:bg-rose-500 hover:text-white hover:border-rose-500 transition-all duration-300 shadow-sm">
|
||||
<svg class="w-4 h-4 stroke-[2.2]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="m9.75 9.75 4.5 4.5m0-4.5-4.5 4.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
|
||||
</svg>
|
||||
</button>
|
||||
@elseif(in_array($invStatus, ['pending', 'failed']))
|
||||
{{-- 查詢(對帳) --}}
|
||||
<form method="POST" action="{{ route('admin.sales.invoices.reconcile', $order->invoice) }}">
|
||||
@csrf
|
||||
<button type="submit" title="{{ __('Query') }}"
|
||||
class="p-3 rounded-xl bg-white dark:bg-slate-800 text-slate-500 dark:text-slate-400 border border-slate-200 dark:border-slate-700 hover:bg-amber-500 hover:text-white hover:border-amber-500 transition-all duration-300 shadow-sm">
|
||||
<svg class="w-4 h-4 stroke-[2.2]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z" />
|
||||
</svg>
|
||||
</button>
|
||||
</form>
|
||||
{{-- 補開 --}}
|
||||
<form id="invoice-reissue-form-{{ $order->invoice->id }}" method="POST" action="{{ route('admin.sales.invoices.reissue', $order->invoice) }}" class="hidden">
|
||||
@csrf
|
||||
</form>
|
||||
<button type="button" title="{{ __('Re-issue') }}"
|
||||
@click="confirmReissueInvoice('invoice-reissue-form-{{ $order->invoice->id }}')"
|
||||
class="p-3 rounded-xl bg-white dark:bg-slate-800 text-slate-500 dark:text-slate-400 border border-slate-200 dark:border-slate-700 hover:bg-cyan-500 hover:text-white hover:border-cyan-500 transition-all duration-300 shadow-sm">
|
||||
<svg class="w-4 h-4 stroke-[2.2]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99" />
|
||||
</svg>
|
||||
@if($invStatus === 'issued')
|
||||
<div class="flex items-center gap-3">
|
||||
{{-- 列印(捐贈發票無紙本,僅非捐贈可列印) --}}
|
||||
@if($invPrintable)
|
||||
<form method="POST" action="{{ route('admin.sales.invoices.print', $order->invoice) }}" target="_blank">
|
||||
@csrf
|
||||
<button type="submit" class="flex-1 sm:flex-none px-6 py-3 rounded-xl bg-white dark:bg-slate-800 text-slate-600 dark:text-slate-300 font-bold text-xs border border-slate-200 dark:border-slate-700 hover:bg-indigo-500 hover:text-white hover:border-indigo-500 transition-all duration-300 shadow-sm">
|
||||
{{ __('Print Invoice') }}
|
||||
</button>
|
||||
</form>
|
||||
@else
|
||||
<span class="text-[11px] font-bold text-slate-400 dark:text-slate-500 px-2">{{ __('Donation invoices cannot be printed') }}</span>
|
||||
@endif
|
||||
{{-- 作廢:使用自製確認框 UI(不用瀏覽器原生 confirm) --}}
|
||||
<form id="invoice-void-form-{{ $order->invoice->id }}" method="POST" action="{{ route('admin.sales.invoices.void', $order->invoice) }}" class="hidden">
|
||||
@csrf
|
||||
</form>
|
||||
<button type="button" @click="confirmVoidInvoice('invoice-void-form-{{ $order->invoice->id }}')"
|
||||
class="flex-1 sm:flex-none px-6 py-3 rounded-xl bg-white dark:bg-slate-800 text-slate-600 dark:text-slate-300 font-bold text-xs border border-slate-200 dark:border-slate-700 hover:bg-rose-500 hover:text-white hover:border-rose-500 transition-all duration-300 shadow-sm">
|
||||
{{ __('Void Invoice') }}
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@ -238,21 +238,27 @@
|
||||
<td class="px-6 py-6 text-right" @click.stop>
|
||||
<div class="flex items-center justify-end gap-1.5">
|
||||
@if(in_array($st, ['pending', 'failed']))
|
||||
{{-- 查詢(對帳) --}}
|
||||
<form method="POST" action="{{ route('admin.sales.invoices.reconcile', $invoice) }}">
|
||||
@csrf
|
||||
<button type="submit" title="{{ __('Query ECPay') }}"
|
||||
class="px-2.5 py-1.5 rounded-lg text-[11px] font-bold text-amber-600 dark:text-amber-400 bg-amber-500/5 hover:bg-amber-500/10 border border-amber-500/20 transition-all">
|
||||
{{ __('Query') }}
|
||||
class="p-2 rounded-xl text-slate-400 hover:text-amber-500 hover:bg-amber-500/5 dark:hover:bg-amber-500/10 border border-transparent hover:border-amber-500/20 transition-all">
|
||||
<svg class="w-4 h-4 stroke-[2.5]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z" />
|
||||
</svg>
|
||||
</button>
|
||||
</form>
|
||||
<form method="POST" action="{{ route('admin.sales.invoices.reissue', $invoice) }}"
|
||||
onsubmit="return confirm('{{ __('Re-issue this invoice?') }}')">
|
||||
{{-- 補開:使用自製確認框 UI --}}
|
||||
<form id="invoice-reissue-form-{{ $invoice->id }}" method="POST" action="{{ route('admin.sales.invoices.reissue', $invoice) }}" class="hidden">
|
||||
@csrf
|
||||
<button type="submit" title="{{ __('Re-issue') }}"
|
||||
class="px-2.5 py-1.5 rounded-lg text-[11px] font-bold text-cyan-600 dark:text-cyan-400 bg-cyan-500/5 hover:bg-cyan-500/10 border border-cyan-500/20 transition-all">
|
||||
{{ __('Re-issue') }}
|
||||
</button>
|
||||
</form>
|
||||
<button type="button" title="{{ __('Re-issue') }}"
|
||||
@click="confirmReissueInvoice('invoice-reissue-form-{{ $invoice->id }}')"
|
||||
class="p-2 rounded-xl text-slate-400 hover:text-cyan-500 hover:bg-cyan-500/5 dark:hover:bg-cyan-500/10 border border-transparent hover:border-cyan-500/20 transition-all">
|
||||
<svg class="w-4 h-4 stroke-[2.5]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99" />
|
||||
</svg>
|
||||
</button>
|
||||
@endif
|
||||
{{-- 作廢按鈕僅在「訂單詳情」提供,列表操作欄不再顯示 --}}
|
||||
<button @click="openDetail({{ $invoice->order_id }})"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user