fix: [payables] 전표 삭제 500 에러 수정
- Accept: application/json 헤더 추가 (HTML 응답 방지) - findOrFail → find + 수동 404 처리 (에러 메시지 개선) - try-catch 추가로 상세 에러 메시지 반환
This commit is contained in:
@@ -512,15 +512,30 @@ public function journalPayables(Request $request): JsonResponse
|
||||
*/
|
||||
public function deleteJournalEntry(int $id): JsonResponse
|
||||
{
|
||||
$tenantId = session('selected_tenant_id', 1);
|
||||
try {
|
||||
$tenantId = session('selected_tenant_id', 1);
|
||||
|
||||
$entry = JournalEntry::where('tenant_id', $tenantId)->findOrFail($id);
|
||||
$entry = JournalEntry::where('tenant_id', $tenantId)->find($id);
|
||||
|
||||
$entry->delete();
|
||||
if (! $entry) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => "전표(ID: {$id})를 찾을 수 없습니다. (tenant: {$tenantId})",
|
||||
], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => "전표 {$entry->entry_no}이(가) 삭제되었습니다.",
|
||||
]);
|
||||
$entryNo = $entry->entry_no;
|
||||
$entry->delete();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => "전표 {$entryNo}이(가) 삭제되었습니다.",
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => '삭제 오류: '.$e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ function IntegratedTab({ startDate, endDate, account, vendorSearch }) {
|
||||
try {
|
||||
const res = await fetch(`/finance/payables/journal-entry/${journalEntryId}`, {
|
||||
method: 'DELETE',
|
||||
headers: { 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content },
|
||||
headers: { 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content, 'Accept': 'application/json' },
|
||||
});
|
||||
const json = await res.json();
|
||||
if (json.success) {
|
||||
|
||||
Reference in New Issue
Block a user