feat: [finance] 은행거래 레코드 삭제 기능 추가 (관리자 전용)
- 은행거래 행에 레코드 삭제 버튼 추가 (분개 유무 무관) - 삭제 시 연결된 분개 전표도 함께 삭제 - 관리자(isAdmin) 권한 검증 적용
This commit is contained in:
@@ -477,6 +477,7 @@ public function bankTransactions(Request $request): JsonResponse
|
||||
$accountBalances[$accNum] = $newBal;
|
||||
|
||||
$logs[] = [
|
||||
'id' => $tx->id,
|
||||
'uniqueKey' => $tx->unique_key,
|
||||
'transDate' => $tx->trans_date,
|
||||
'transTime' => $tx->trans_time,
|
||||
@@ -761,6 +762,40 @@ public function deleteBankJournal(int $id): JsonResponse
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 은행거래 레코드 삭제 — 관리자 이상만 가능
|
||||
*/
|
||||
public function destroyBankTransaction(int $id): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
if (! $user || ! $user->isAdmin()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => '은행거래 삭제는 관리자만 가능합니다.',
|
||||
], 403);
|
||||
}
|
||||
|
||||
$tenantId = session('selected_tenant_id', 1);
|
||||
$tx = BankTransaction::where('tenant_id', $tenantId)->findOrFail($id);
|
||||
|
||||
// 연결된 분개 전표도 함께 삭제
|
||||
$journal = JournalEntry::where('tenant_id', $tenantId)
|
||||
->where('source_type', 'bank_transaction')
|
||||
->where('source_key', $tx->unique_key)
|
||||
->first();
|
||||
|
||||
if ($journal) {
|
||||
$journal->delete();
|
||||
}
|
||||
|
||||
$tx->delete();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => '은행거래 레코드가 삭제되었습니다.',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 조회기간 이전의 계좌별 잔액 계산
|
||||
* EaccountController::findBaseBalance() 패턴을 계좌별로 확장
|
||||
|
||||
Reference in New Issue
Block a user