1. 發票作廢改為僅限平台系統管理員:voidInvoice() 加 isSystemAdmin() 403 守衛,訂單詳情面板與 tab-invoices 手機卡片作廢按鈕同步加 isSystemAdmin 顯示條件(列印鈕維持所有人可用)。 2. 新增 orders、invoices 各自獨立的 remark 欄位(migration + Model fillable),供管理者編輯內部備註。 3. 新增 updateOrderRemark / updateInvoiceRemark 端點與 PATCH 路由,AJAX 回傳 JSON、租戶隔離沿用 TenantScoped。 4. 訂單詳情面板加入訂單與發票備註的 Alpine 內嵌編輯(fetch + toast,不重整頁面),所有可進銷售中心者皆可編輯。 5. confirm-modal 加可選 slot;作廢確認視窗加備註輸入框,submitInvoiceAction() 送出前注入隱藏 remark,寫入 invoice.remark(不影響送綠界的 void_reason)。 6. 訂單列表(桌面與手機)已作廢發票改以灰色刪除線加「已作廢」標記顯示,index eager load 補載 invoice.status。 7. 新增 5 組三語系 key(Voided、Enter remark (optional)、Remark updated、No remark、Only system administrators can void invoices),zh_TW/en/ja 對齊排序至 2572 鍵。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
67 lines
1.8 KiB
PHP
67 lines
1.8 KiB
PHP
<?php
|
||
|
||
namespace App\Models\Transaction;
|
||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
use Illuminate\Database\Eloquent\Model;
|
||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||
use App\Traits\TenantScoped;
|
||
|
||
class Invoice extends Model
|
||
{
|
||
// TenantScoped:自動以登入者 company_id 過濾(含 route-model binding 與列表查詢),
|
||
// 防止跨公司讀取/操作他人發票。console(佇列 Job / reconcile 命令)會自動跳過 scope,
|
||
// 系統身分仍可跨公司開立/對帳。
|
||
use HasFactory, SoftDeletes, TenantScoped;
|
||
|
||
protected $fillable = [
|
||
'company_id',
|
||
'order_id',
|
||
'machine_id',
|
||
'flow_id',
|
||
'invoice_no',
|
||
'status',
|
||
'relate_number',
|
||
'amount',
|
||
'carrier_id',
|
||
'invoice_date',
|
||
'machine_time',
|
||
'last_checked_at',
|
||
'retry_count',
|
||
'voided_at',
|
||
'void_reason',
|
||
'remark',
|
||
'random_number',
|
||
'love_code',
|
||
'rtn_code',
|
||
'rtn_msg',
|
||
'metadata',
|
||
];
|
||
|
||
protected $casts = [
|
||
'amount' => 'decimal:2',
|
||
'invoice_date' => 'date',
|
||
'machine_time' => 'datetime',
|
||
'last_checked_at' => 'datetime',
|
||
'voided_at' => 'datetime',
|
||
'retry_count' => 'integer',
|
||
'metadata' => 'array',
|
||
];
|
||
|
||
// 發票狀態常數
|
||
public const STATUS_PENDING = 'pending'; // 已送出綠界、尚未確認
|
||
public const STATUS_ISSUED = 'issued'; // 已開立成功
|
||
public const STATUS_FAILED = 'failed'; // 綠界回失敗,待補開
|
||
public const STATUS_VOID = 'void'; // 已作廢
|
||
|
||
public function order()
|
||
{
|
||
return $this->belongsTo(Order::class);
|
||
}
|
||
|
||
public function machine()
|
||
{
|
||
return $this->belongsTo(\App\Models\Machine\Machine::class);
|
||
}
|
||
}
|