feat(inventory): 實作盤點、盤調與調撥操作紀錄,並支援前端本地化顯示

This commit is contained in:
2026-02-04 13:24:33 +08:00
parent 95fdec8a06
commit a8b88b3375
4 changed files with 122 additions and 12 deletions

View File

@@ -76,6 +76,22 @@ class AdjustDocController extends Controller
}
$doc = $this->adjustService->createFromCountDoc($countDoc, auth()->id());
// 記錄活動
activity()
->performedOn($doc)
->causedBy(auth()->user())
->event('created')
->withProperties([
'attributes' => $doc->toArray(),
'snapshot' => [
'doc_no' => $doc->doc_no,
'warehouse_name' => $doc->warehouse?->name,
'count_doc_no' => $countDoc->doc_no,
]
])
->log('created_from_count');
return redirect()->route('inventory.adjust.show', [$doc->id])
->with('success', '已從盤點單生成盤調單');
}
@@ -172,6 +188,22 @@ class AdjustDocController extends Controller
// 提交 (items 更新 或 過帳)
if ($request->input('action') === 'post') {
$this->adjustService->post($doc, auth()->id());
// 記錄活動
activity()
->performedOn($doc)
->causedBy(auth()->user())
->event('posted')
->withProperties([
'attributes' => ['status' => 'posted'],
'old' => ['status' => 'draft'],
'snapshot' => [
'doc_no' => $doc->doc_no,
'warehouse_name' => $doc->warehouse?->name,
]
])
->log('posted');
return redirect()->route('inventory.adjust.index')
->with('success', '盤調單已過帳生效');
}
@@ -195,12 +227,19 @@ class AdjustDocController extends Controller
return redirect()->back()->with('success', '儲存成功');
}
public function destroy(InventoryAdjustDoc $doc)
{
if ($doc->status !== 'draft') {
return redirect()->back()->with('error', '只能刪除草稿狀態的單據');
}
// 記錄活動
activity()
->performedOn($doc)
->causedBy(auth()->user())
->event('deleted')
->withProperties([
'snapshot' => [
'doc_no' => $doc->doc_no,
'warehouse_name' => $doc->warehouse?->name,
]
])
->log('deleted');
$doc->items()->delete();
$doc->delete();