fix: [finance] 계정코드 매핑 이미지 기준 재수정

- 204→25300(미지급금), 205→26200(미지급비용)
- 207→25400(예수금), 208→25500(부가세예수금)
- 826→83700(건물관리비), 253→30800(장기성지급어음)
- 501→45100(상품매출원가), 117→13500(부가세대급금)
- 201→25100(외상매입금)
- 801 대표이사→80100(임원급여), 나머지→80200(직원급여) 분기
This commit is contained in:
김보곤
2026-03-17 18:15:34 +09:00
parent 0cc0ddf4b9
commit a44bb85f76
8 changed files with 58 additions and 35 deletions

View File

@@ -842,11 +842,11 @@ public function generateJournalEntry(Request $request): JsonResponse
}
// 계정과목 조회
$accountCodes = AccountCode::whereIn('code', ['80100', '20700', '20500'])
$accountCodes = AccountCode::whereIn('code', ['80100', '80200', '25400', '26200'])
->where('is_active', true)
->pluck('name', 'code');
$missingCodes = array_diff(['80100', '20700', '20500'], $accountCodes->keys()->toArray());
$missingCodes = array_diff(['80100', '80200', '25400', '26200'], $accountCodes->keys()->toArray());
if (! empty($missingCodes)) {
return response()->json([
'success' => false,
@@ -885,12 +885,14 @@ public function generateJournalEntry(Request $request): JsonResponse
}
}
// 1. 차변: 80100 급여 / 임직원 — 총지급액
// 1. 차변: 80100 임원급여(대표이사) / 80200 직원급여(나머지)
if ($grossAmount > 0) {
// 대표이사 여부에 따라 계정코드 분기
$salaryCode = $this->isCeoPayroll($year, $month) ? '80100' : '80200';
$lines[] = [
'dc_type' => 'debit',
'account_code' => '80100',
'account_name' => $accountCodes['80100'],
'account_code' => $salaryCode,
'account_name' => $accountCodes[$salaryCode],
'trading_partner_id' => $partners['임직원'],
'trading_partner_name' => '임직원',
'debit_amount' => $grossAmount,
@@ -916,8 +918,8 @@ public function generateJournalEntry(Request $request): JsonResponse
} else {
$creditLines[$mergeKey] = [
'dc_type' => 'credit',
'account_code' => '20700',
'account_name' => $accountCodes['20700'],
'account_code' => '25400',
'account_name' => $accountCodes['25400'],
'trading_partner_id' => $partners[$partnerName],
'trading_partner_name' => $partnerName,
'debit_amount' => 0,
@@ -935,12 +937,12 @@ public function generateJournalEntry(Request $request): JsonResponse
$lines[] = $creditLine;
}
// 최종: 대변 20500 미지급비용 / 임직원 — 실수령액 (DB 값)
// 최종: 대변 26200 미지급비용 / 임직원 — 실수령액 (DB 값)
if ($netSalary > 0) {
$lines[] = [
'dc_type' => 'credit',
'account_code' => '20500',
'account_name' => $accountCodes['20500'],
'account_code' => '26200',
'account_name' => $accountCodes['26200'],
'trading_partner_id' => $partners['임직원'],
'trading_partner_name' => '임직원',
'debit_amount' => 0,
@@ -1087,4 +1089,25 @@ public function calculate(Request $request): JsonResponse
'data' => array_merge($result, ['family_count' => $familyCount]),
]);
}
/**
* 해당 월 급여가 대표이사 전용인지 판별
* 대표이사만 있으면 80100(임원급여), 그 외 80200(직원급여)
*/
private function isCeoPayroll(int $year, int $month): bool
{
// 해당 월 급여 대상자 중 대표이사만 있는지 확인
$tenantId = session('selected_tenant_id', 1);
return \App\Models\HR\Payroll::where('tenant_id', $tenantId)
->where('year', $year)
->where('month', $month)
->whereHas('employee', fn ($q) => $q->where('position', '대표이사'))
->exists()
&& ! \App\Models\HR\Payroll::where('tenant_id', $tenantId)
->where('year', $year)
->where('month', $month)
->whereHas('employee', fn ($q) => $q->where('position', '!=', '대표이사'))
->exists();
}
}

View File

@@ -1919,7 +1919,7 @@ private function syncJournalAmounts(int $tenantId, string $uniqueKey, float $new
'journal_entry_id' => $journal->id,
'line_no' => $lineNo++,
'dc_type' => 'debit',
'account_code' => $expenseAccount?->account_code ?? '82600',
'account_code' => $expenseAccount?->account_code ?? '83700',
'account_name' => $expenseAccount?->account_name ?? '잡비',
'debit_amount' => $supplyInt,
'credit_amount' => 0,
@@ -1945,7 +1945,7 @@ private function syncJournalAmounts(int $tenantId, string $uniqueKey, float $new
'journal_entry_id' => $journal->id,
'line_no' => $lineNo++,
'dc_type' => 'debit',
'account_code' => $expenseAccount?->account_code ?? '82600',
'account_code' => $expenseAccount?->account_code ?? '83700',
'account_name' => $expenseAccount?->account_name ?? '잡비',
'debit_amount' => $totalAmount,
'credit_amount' => 0,
@@ -1962,7 +1962,7 @@ private function syncJournalAmounts(int $tenantId, string $uniqueKey, float $new
'journal_entry_id' => $journal->id,
'line_no' => $lineNo,
'dc_type' => 'credit',
'account_code' => $creditAccount?->account_code ?? '20500',
'account_code' => $creditAccount?->account_code ?? '26200',
'account_name' => $creditAccount?->account_name ?? '미지급비용',
'debit_amount' => 0,
'credit_amount' => $totalAmount,

View File

@@ -196,7 +196,7 @@ public function integrated(Request $request): JsonResponse
$account = $request->input('account', 'all');
$vendor = $request->input('vendor', '');
$accountCodes = $account === 'all' ? ['20400', '20500'] : [$account];
$accountCodes = $account === 'all' ? ['25300', '26200'] : [$account];
// 0. 이월 잔액 계산 (startDate 이전의 누적 잔액)
$priorBalanceMap = [];
@@ -431,7 +431,7 @@ public function hometaxPayables(Request $request): JsonResponse
$endDate = $request->input('endDate', date('Y-12-31'));
$account = $request->input('account', 'all');
$accountCodes = $account === 'all' ? ['20400', '20500'] : [$account];
$accountCodes = $account === 'all' ? ['25300', '26200'] : [$account];
$items = HometaxInvoiceJournal::where('tenant_id', $tenantId)
->whereIn('account_code', $accountCodes)
@@ -465,7 +465,7 @@ public function journalPayables(Request $request): JsonResponse
$account = $request->input('account', 'all');
$dcType = $request->input('dcType', 'all');
$accountCodes = $account === 'all' ? ['20400', '20500'] : [$account];
$accountCodes = $account === 'all' ? ['25300', '26200'] : [$account];
$query = JournalEntryLine::where('journal_entry_lines.tenant_id', $tenantId)
->whereIn('journal_entry_lines.account_code', $accountCodes)