fix: 修复内部转账审计字段超长 (#1227)

修复内部转账审计类型超过 `fin_ledger_edit_events.entity_type` 20 字符限制导致的事务回滚和 Server Error。

将类型缩短为 `internal_xfer_create` / `internal_xfer_delete`,并补充审计落库测试。

验证:内部转账创建、删除测试 2 项通过,38 个断言。
This commit is contained in:
shanshi 2026-11-18 13:51:26 +08:00
parent ceac04e1e0
commit 957504ac1e
2 changed files with 10 additions and 2 deletions

View File

@ -112,7 +112,7 @@ class FinanceLedgerInternalTransferEditor
}
if ($created > 0) {
$this->audit('internal_transfer_create', $approvalNo, [
$this->audit('internal_xfer_create', $approvalNo, [
'txn_date' => $date,
'from_account_short' => $from,
'to_account_short' => $to,
@ -162,7 +162,7 @@ class FinanceLedgerInternalTransferEditor
->where('source', FinanceLedgerTransactionWriter::INTERNAL_TRANSFER_SOURCE)
->where('approval_no', $approvalNo)
->delete();
$this->audit('internal_transfer_delete', $approvalNo, [
$this->audit('internal_xfer_delete', $approvalNo, [
'rows' => $rows->map(static fn (object $item): array => [
'account_short' => (string) $item->account_short,
'income' => round((float) $item->income, 2),

View File

@ -435,6 +435,10 @@ class FinanceLedgerManualTransactionTest extends FeatureTestCase
'account_short' => '手工账户乙',
'current_balance' => 30,
], 'business_mirror');
$this->assertDatabaseHas('fin_ledger_edit_events', [
'entity_type' => 'internal_xfer_create',
'user_name' => 'Test User',
], 'business_mirror');
$this->postJson($this->internalTransferUrl(), $payload)
->assertOk()
@ -469,6 +473,10 @@ class FinanceLedgerManualTransactionTest extends FeatureTestCase
'account_short' => '手工账户乙',
'current_balance' => 0,
], 'business_mirror');
$this->assertDatabaseHas('fin_ledger_edit_events', [
'entity_type' => 'internal_xfer_delete',
'user_name' => 'Test User',
], 'business_mirror');
}
public function test_internal_transfer_page_and_same_account_validation(): void