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 e2f9d7d18e
commit ffbed199cb
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();
}
}