feat:재무 기능 개선 (8가지 요청사항)

- 자금계획일정: 금액 소수점 제거 및 세자리 콤마 표시
- 자금계획일정: 관련계좌 → 출금계좌 명칭 변경
- 협력사관리: 거래처등록 계좌번호 입력란 추가
- 채무관리: 미지급금 등록 메모란 추가
- 환불관리: 환불/해지 수정 메모란 추가 (거절사유 입력용)
- 법인카드관리: 카드 사용현황에 체크카드 표시
- 법인차량관리: 차량등록 구분 추가 (법인/렌트/리스)
- 법인차량관리: 렌트/리스 전용 필드 추가

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
김보곤
2026-02-02 21:21:40 +09:00
parent e1c1b93fd2
commit eaf1a2e472
8 changed files with 428 additions and 103 deletions

View File

@@ -161,6 +161,11 @@ public function cards(Request $request): JsonResponse
? $card->CardCompanyName
: $this->getCardCompanyName($cardCompanyCode);
// 체크카드 여부 (IsDebit 또는 CardKind 필드로 판단)
$isCheckCard = ($card->IsDebit ?? '0') === '1' ||
($card->CardKind ?? '') === '2' ||
($card->IsCheck ?? '0') === '1';
$cards[] = [
'cardNum' => $cardNum,
'cardCompany' => $cardCompanyCode,
@@ -168,6 +173,7 @@ public function cards(Request $request): JsonResponse
'alias' => $card->Alias ?? '',
'cardType' => $card->CardType ?? '',
'cardTypeName' => ($card->CardType ?? '') === '2' ? '법인카드' : '개인카드',
'isCheckCard' => $isCheckCard,
'status' => $card->Status ?? '',
'statusName' => $this->getCardStatusName($card->Status ?? ''),
'webId' => $card->WebId ?? '',

View File

@@ -146,14 +146,25 @@ className={`px-4 py-2 rounded-lg text-sm font-medium transition-colors ${
<button
key={card.cardNum}
onClick={() => onSelect(card.cardNum)}
className={`px-4 py-2 rounded-lg text-sm font-medium transition-colors ${
className={`px-4 py-2 rounded-lg text-sm font-medium transition-colors flex items-center gap-2 ${
selectedCard === card.cardNum
? 'bg-purple-600 text-white'
: 'bg-white border border-stone-200 text-stone-700 hover:bg-stone-50'
}`}
>
{card.cardBrand} {card.cardNum ? '****' + card.cardNum.slice(-4) : ''}
{card.alias && ` (${card.alias})`}
<span>
{card.cardBrand} {card.cardNum ? '****' + card.cardNum.slice(-4) : ''}
{card.alias && ` (${card.alias})`}
</span>
{card.isCheckCard && (
<span className={`px-1.5 py-0.5 text-xs rounded ${
selectedCard === card.cardNum
? 'bg-purple-500 text-purple-100'
: 'bg-blue-100 text-blue-700'
}`}>
체크
</span>
)}
</button>
))}
</div>

View File

@@ -74,12 +74,15 @@ class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:rin
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-emerald-500 focus:border-emerald-500">
</div>
<div>
<label for="amount" class="block text-sm font-medium text-gray-700 mb-1">
<label for="amount_display" class="block text-sm font-medium text-gray-700 mb-1">
금액 <span class="text-red-500">*</span>
</label>
<input type="number" name="amount" id="amount" required
value="0" min="0" step="1"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-emerald-500 focus:border-emerald-500">
<input type="text" id="amount_display" required
value="0" inputmode="numeric"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-emerald-500 focus:border-emerald-500 text-right"
oninput="formatAmountInput(this)"
onblur="formatAmountInput(this)">
<input type="hidden" name="amount" id="amount" value="0">
</div>
</div>
@@ -93,10 +96,10 @@ class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:rin
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-emerald-500 focus:border-emerald-500">
</div>
{{-- 관련 계좌 --}}
{{-- 출금 계좌 --}}
<div>
<label for="related_bank_account_id" class="block text-sm font-medium text-gray-700 mb-1">
관련 계좌
출금 계좌
</label>
<select name="related_bank_account_id" id="related_bank_account_id"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-emerald-500 focus:border-emerald-500">
@@ -165,6 +168,30 @@ class="px-6 py-2 bg-emerald-600 hover:bg-emerald-700 text-white rounded-lg trans
@push('scripts')
<script>
// 금액 입력 포맷팅 (콤마 추가, 소수점 제거)
function formatAmountInput(input) {
// 숫자만 추출
let value = input.value.replace(/[^\d]/g, '');
// 빈 값이면 0
if (!value) value = '0';
// 숫자로 변환 후 콤마 포맷
const numValue = parseInt(value, 10);
input.value = numValue.toLocaleString('ko-KR');
// hidden input에 실제 값 저장
document.getElementById('amount').value = numValue;
}
// 페이지 로드 시 초기화
document.addEventListener('DOMContentLoaded', function() {
const amountDisplay = document.getElementById('amount_display');
if (amountDisplay) {
formatAmountInput(amountDisplay);
}
});
document.body.addEventListener('htmx:afterRequest', function(event) {
if (event.detail.successful) {
try {

View File

@@ -75,12 +75,15 @@ class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:rin
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-emerald-500 focus:border-emerald-500">
</div>
<div>
<label for="amount" class="block text-sm font-medium text-gray-700 mb-1">
<label for="amount_display" class="block text-sm font-medium text-gray-700 mb-1">
금액 <span class="text-red-500">*</span>
</label>
<input type="number" name="amount" id="amount" required
value="{{ $schedule->amount }}" min="0" step="1"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-emerald-500 focus:border-emerald-500">
<input type="text" id="amount_display" required
value="{{ number_format((int)$schedule->amount) }}" inputmode="numeric"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-emerald-500 focus:border-emerald-500 text-right"
oninput="formatAmountInput(this)"
onblur="formatAmountInput(this)">
<input type="hidden" name="amount" id="amount" value="{{ (int)$schedule->amount }}">
</div>
</div>
@@ -94,10 +97,10 @@ class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:rin
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-emerald-500 focus:border-emerald-500">
</div>
{{-- 관련 계좌 --}}
{{-- 출금 계좌 --}}
<div>
<label for="related_bank_account_id" class="block text-sm font-medium text-gray-700 mb-1">
관련 계좌
출금 계좌
</label>
<select name="related_bank_account_id" id="related_bank_account_id"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-emerald-500 focus:border-emerald-500">
@@ -185,6 +188,22 @@ class="px-6 py-2 bg-emerald-600 hover:bg-emerald-700 text-white rounded-lg trans
@push('scripts')
<script>
// 금액 입력 포맷팅 (콤마 추가, 소수점 제거)
function formatAmountInput(input) {
// 숫자만 추출
let value = input.value.replace(/[^\d]/g, '');
// 빈 값이면 0
if (!value) value = '0';
// 숫자로 변환 후 콤마 포맷
const numValue = parseInt(value, 10);
input.value = numValue.toLocaleString('ko-KR');
// hidden input에 실제 값 저장
document.getElementById('amount').value = numValue;
}
document.body.addEventListener('htmx:afterRequest', function(event) {
if (event.detail.successful) {
try {

View File

@@ -71,6 +71,7 @@ function PartnersManagement() {
type: 'vendor',
category: '기타',
bizNo: '',
bankAccount: '',
contact: '',
email: '',
manager: '',
@@ -209,7 +210,10 @@ function PartnersManagement() {
<div><label className="block text-sm font-medium text-gray-700 mb-1">유형</label><select value={formData.type} onChange={(e) => setFormData(prev => ({ ...prev, type: e.target.value }))} className="w-full px-3 py-2 border border-gray-300 rounded-lg">{types.map(t => <option key={t.value} value={t.value}>{t.label}</option>)}</select></div>
<div><label className="block text-sm font-medium text-gray-700 mb-1">분류</label><select value={formData.category} onChange={(e) => setFormData(prev => ({ ...prev, category: e.target.value }))} className="w-full px-3 py-2 border border-gray-300 rounded-lg">{categories.map(c => <option key={c} value={c}>{c}</option>)}</select></div>
</div>
<div><label className="block text-sm font-medium text-gray-700 mb-1">사업자번호</label><input type="text" value={formData.bizNo} onChange={(e) => setFormData(prev => ({ ...prev, bizNo: e.target.value }))} placeholder="123-45-67890" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
<div className="grid grid-cols-2 gap-4">
<div><label className="block text-sm font-medium text-gray-700 mb-1">사업자번호</label><input type="text" value={formData.bizNo} onChange={(e) => setFormData(prev => ({ ...prev, bizNo: e.target.value }))} placeholder="123-45-67890" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
<div><label className="block text-sm font-medium text-gray-700 mb-1">계좌번호</label><input type="text" value={formData.bankAccount} onChange={(e) => setFormData(prev => ({ ...prev, bankAccount: e.target.value }))} placeholder="000-000000-00000" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
</div>
<div className="grid grid-cols-2 gap-4">
<div><label className="block text-sm font-medium text-gray-700 mb-1">연락처</label><input type="text" value={formData.contact} onChange={(e) => setFormData(prev => ({ ...prev, contact: e.target.value }))} placeholder="02-1234-5678" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
<div><label className="block text-sm font-medium text-gray-700 mb-1">이메일</label><input type="email" value={formData.email} onChange={(e) => setFormData(prev => ({ ...prev, email: e.target.value }))} placeholder="email@company.com" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>

View File

@@ -80,7 +80,8 @@ function PayablesManagement() {
paidAmount: 0,
status: 'unpaid',
category: '사무용품',
description: ''
description: '',
memo: ''
};
const [formData, setFormData] = useState(initialFormState);
@@ -286,6 +287,7 @@ function PayablesManagement() {
<div><label className="block text-sm font-medium text-gray-700 mb-1">청구금액 *</label><input type="text" value={formatInputCurrency(formData.amount)} onChange={(e) => setFormData(prev => ({ ...prev, amount: parseInputCurrency(e.target.value) }))} placeholder="0" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-right" /></div>
</div>
<div><label className="block text-sm font-medium text-gray-700 mb-1">적요</label><input type="text" value={formData.description} onChange={(e) => setFormData(prev => ({ ...prev, description: e.target.value }))} placeholder="적요 입력" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
<div><label className="block text-sm font-medium text-gray-700 mb-1">메모</label><textarea value={formData.memo} onChange={(e) => setFormData(prev => ({ ...prev, memo: e.target.value }))} placeholder="부분지급, 연체 사유 등 메모" rows="2" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
{modalMode === 'edit' && (
<div><label className="block text-sm font-medium text-gray-700 mb-1">상태</label><select value={formData.status} onChange={(e) => setFormData(prev => ({ ...prev, status: e.target.value }))} className="w-full px-3 py-2 border border-gray-300 rounded-lg"><option value="unpaid">미지급</option><option value="partial">부분지급</option><option value="paid">지급완료</option><option value="overdue">연체</option></select></div>
)}

View File

@@ -293,10 +293,16 @@ function RefundsManagement() {
<div><label className="block text-sm font-medium text-gray-700 mb-1">사유</label><select value={formData.reason} onChange={(e) => setFormData(prev => ({ ...prev, reason: e.target.value }))} className="w-full px-3 py-2 border border-gray-300 rounded-lg">{reasons.map(r => <option key={r} value={r}>{r}</option>)}</select></div>
</div>
{modalMode === 'edit' && (
<>
<div className="grid grid-cols-2 gap-4">
<div><label className="block text-sm font-medium text-gray-700 mb-1">환불금액</label><input type="text" value={formatInputCurrency(formData.refundAmount)} onChange={(e) => setFormData(prev => ({ ...prev, refundAmount: parseInputCurrency(e.target.value) }))} placeholder="0" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-right" /></div>
<div><label className="block text-sm font-medium text-gray-700 mb-1">상태</label><select value={formData.status} onChange={(e) => setFormData(prev => ({ ...prev, status: e.target.value }))} className="w-full px-3 py-2 border border-gray-300 rounded-lg"><option value="pending">대기</option><option value="approved">승인</option><option value="completed">완료</option><option value="rejected">거절</option></select></div>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">메모 {formData.status === 'rejected' && <span className="text-red-500">(거절 사유)</span>}</label>
<textarea value={formData.note} onChange={(e) => setFormData(prev => ({ ...prev, note: e.target.value }))} placeholder={formData.status === 'rejected' ? '거절 사유를 입력하세요' : '처리 관련 메모'} rows="2" className="w-full px-3 py-2 border border-gray-300 rounded-lg" />
</div>
</>
)}
</div>
<div className="flex gap-3 mt-6">

View File

@@ -1,6 +1,6 @@
@extends('layouts.app')
@section('title', '차량 유지비')
@section('title', '법인차량 관리')
@push('styles')
<style>
@@ -46,13 +46,24 @@
const Car = createIcon('car');
function VehicleMaintenanceManagement() {
// 탭 상태
const [activeTab, setActiveTab] = useState('maintenance');
// 차량 목록 (동적 관리)
const [vehicles, setVehicles] = useState([
{ id: 1, plateNumber: '12가 3456', model: '제네시스 G80', ownershipType: 'corporate', purchaseDate: '2023-05-15', purchasePrice: '', currentMileage: 15000 },
{ id: 2, plateNumber: '34나 5678', model: '현대 스타렉스', ownershipType: 'corporate', purchaseDate: '2022-03-10', purchasePrice: '', currentMileage: 48000 },
{ id: 3, plateNumber: '56다 7890', model: '기아 레이', ownershipType: 'rent', contractDate: '2024-01-01', rentCompany: '롯데렌터카', rentCompanyTel: '1588-1234', rentPeriod: '36개월', agreedMileage: '30000', vehiclePrice: '25000000', residualValue: '15000000', deposit: '3000000', monthlyRent: '450000', monthlyRentTax: '45000', insuranceCompany: '삼성화재', insuranceCompanyTel: '1588-5114', currentMileage: 62000 },
{ id: 4, plateNumber: '78라 1234', model: '포터2', ownershipType: 'lease', contractDate: '2023-06-01', rentCompany: '현대캐피탈', rentCompanyTel: '1588-1234', rentPeriod: '48개월', agreedMileage: '60000', vehiclePrice: '32000000', residualValue: '12000000', deposit: '5000000', monthlyRent: '520000', monthlyRentTax: '52000', insuranceCompany: 'DB손해보험', insuranceCompanyTel: '1588-0100', currentMileage: 95000 },
]);
const [maintenances, setMaintenances] = useState([
{ id: 1, date: '2026-01-20', vehicle: '12가 3456 (제네시스 G80)', category: '주유', description: '휘발유', amount: 120000, mileage: 15000, vendor: 'GS칼텍스', memo: '' },
{ id: 2, date: '2026-01-18', vehicle: '34나 5678 (현대 스타렉스)', category: '주유', description: '경유', amount: 95000, mileage: 48000, vendor: 'SK에너지', memo: '' },
{ id: 3, date: '2026-01-15', vehicle: '78라 1234 (포터2)', category: '정비', description: '엔진오일 교환', amount: 150000, mileage: 95000, vendor: '현대오토', memo: '정기 점검' },
{ id: 4, date: '2026-01-10', vehicle: '56다 7890 (기아 레이)', category: '보험', description: '자동차보험 연납', amount: 850000, mileage: 62000, vendor: '삼성화재', memo: '2025.01~2026.01' },
{ id: 5, date: '2026-01-05', vehicle: '12가 3456 (제네시스 G80)', category: '세차', description: '세차 및 실내크리닝', amount: 50000, mileage: 14500, vendor: '카와시', memo: '' },
{ id: 6, date: '2025-12-20', vehicle: '34나 5678 (현대 스타렉스)', category: '정비', description: '타이어 교체', amount: 480000, mileage: 45000, vendor: '한국타이어', memo: '4개 교체' },
{ id: 1, date: '2026-01-20', vehicleId: 1, category: '주유', description: '휘발유', amount: 120000, mileage: 15000, vendor: 'GS칼텍스', memo: '' },
{ id: 2, date: '2026-01-18', vehicleId: 2, category: '주유', description: '경유', amount: 95000, mileage: 48000, vendor: 'SK에너지', memo: '' },
{ id: 3, date: '2026-01-15', vehicleId: 4, category: '정비', description: '엔진오일 교환', amount: 150000, mileage: 95000, vendor: '현대오토', memo: '정기 점검' },
{ id: 4, date: '2026-01-10', vehicleId: 3, category: '보험', description: '자동차보험 연납', amount: 850000, mileage: 62000, vendor: '삼성화재', memo: '2025.01~2026.01' },
{ id: 5, date: '2026-01-05', vehicleId: 1, category: '세차', description: '세차 및 실내크리닝', amount: 50000, mileage: 14500, vendor: '카와시', memo: '' },
{ id: 6, date: '2025-12-20', vehicleId: 2, category: '정비', description: '타이어 교체', amount: 480000, mileage: 45000, vendor: '한국타이어', memo: '4개 교체' },
]);
const [searchTerm, setSearchTerm] = useState('');
@@ -67,12 +78,41 @@ function VehicleMaintenanceManagement() {
const [modalMode, setModalMode] = useState('add');
const [editingItem, setEditingItem] = useState(null);
// 차량 등록 모달
const [showVehicleModal, setShowVehicleModal] = useState(false);
const [vehicleModalMode, setVehicleModalMode] = useState('add');
const [editingVehicle, setEditingVehicle] = useState(null);
const categories = ['주유', '정비', '보험', '세차', '주차', '통행료', '검사', '기타'];
const vehicles = ['12가 3456 (제네시스 G80)', '34나 5678 (현대 스타렉스)', '56다 7890 (기아 레이)', '78라 1234 (포터2)'];
const ownershipTypes = [
{ value: 'corporate', label: '법인차량' },
{ value: 'rent', label: '렌트차량' },
{ value: 'lease', label: '리스차량' }
];
// 차량 표시용 헬퍼
const getVehicleDisplay = (vehicleId) => {
const v = vehicles.find(v => v.id === vehicleId);
return v ? `${v.plateNumber} (${v.model})` : '-';
};
const getOwnershipLabel = (type) => {
const found = ownershipTypes.find(t => t.value === type);
return found ? found.label : type;
};
const getOwnershipColor = (type) => {
switch(type) {
case 'corporate': return 'bg-blue-100 text-blue-700';
case 'rent': return 'bg-purple-100 text-purple-700';
case 'lease': return 'bg-orange-100 text-orange-700';
default: return 'bg-gray-100 text-gray-700';
}
};
const initialFormState = {
date: new Date().toISOString().split('T')[0],
vehicle: vehicles[0],
vehicleId: vehicles[0]?.id || '',
category: '주유',
description: '',
amount: '',
@@ -82,6 +122,30 @@ function VehicleMaintenanceManagement() {
};
const [formData, setFormData] = useState(initialFormState);
// 차량 등록 초기 상태
const initialVehicleFormState = {
plateNumber: '',
model: '',
ownershipType: 'corporate',
purchaseDate: '',
purchasePrice: '',
currentMileage: '',
// 렌트/리스 전용 필드
contractDate: '',
rentCompany: '',
rentCompanyTel: '',
rentPeriod: '',
agreedMileage: '',
vehiclePrice: '',
residualValue: '',
deposit: '',
monthlyRent: '',
monthlyRentTax: '',
insuranceCompany: '',
insuranceCompanyTel: ''
};
const [vehicleFormData, setVehicleFormData] = useState(initialVehicleFormState);
const formatCurrency = (num) => num ? num.toLocaleString() : '0';
const formatInputCurrency = (value) => {
if (!value && value !== 0) return '';
@@ -94,7 +158,7 @@ function VehicleMaintenanceManagement() {
const matchesSearch = item.description.toLowerCase().includes(searchTerm.toLowerCase()) ||
item.vendor.toLowerCase().includes(searchTerm.toLowerCase());
const matchesCategory = filterCategory === 'all' || item.category === filterCategory;
const matchesVehicle = filterVehicle === 'all' || item.vehicle === filterVehicle;
const matchesVehicle = filterVehicle === 'all' || item.vehicleId === parseInt(filterVehicle);
const matchesDate = item.date >= dateRange.start && item.date <= dateRange.end;
return matchesSearch && matchesCategory && matchesVehicle && matchesDate;
});
@@ -104,24 +168,45 @@ function VehicleMaintenanceManagement() {
const maintenanceAmount = filteredMaintenances.filter(m => m.category === '정비').reduce((sum, item) => sum + item.amount, 0);
const otherAmount = totalAmount - fuelAmount - maintenanceAmount;
const handleAdd = () => { setModalMode('add'); setFormData(initialFormState); setShowModal(true); };
// 유지비 등록/수정
const handleAdd = () => { setModalMode('add'); setFormData({...initialFormState, vehicleId: vehicles[0]?.id || ''}); setShowModal(true); };
const handleEdit = (item) => { setModalMode('edit'); setEditingItem(item); setFormData({ ...item }); setShowModal(true); };
const handleSave = () => {
if (!formData.description || !formData.amount) { alert('필수 항목을 입력해주세요.'); return; }
const amount = parseInt(formData.amount) || 0;
const mileage = parseInt(formData.mileage) || 0;
if (modalMode === 'add') {
setMaintenances(prev => [{ id: Date.now(), ...formData, amount, mileage }, ...prev]);
setMaintenances(prev => [{ id: Date.now(), ...formData, vehicleId: parseInt(formData.vehicleId), amount, mileage }, ...prev]);
} else {
setMaintenances(prev => prev.map(item => item.id === editingItem.id ? { ...item, ...formData, amount, mileage } : item));
setMaintenances(prev => prev.map(item => item.id === editingItem.id ? { ...item, ...formData, vehicleId: parseInt(formData.vehicleId), amount, mileage } : item));
}
setShowModal(false); setEditingItem(null);
};
const handleDelete = (id) => { if (confirm('정말 삭제하시겠습니까?')) { setMaintenances(prev => prev.filter(item => item.id !== id)); setShowModal(false); } };
// 차량 등록/수정
const handleAddVehicle = () => { setVehicleModalMode('add'); setVehicleFormData(initialVehicleFormState); setShowVehicleModal(true); };
const handleEditVehicle = (vehicle) => { setVehicleModalMode('edit'); setEditingVehicle(vehicle); setVehicleFormData({ ...vehicle }); setShowVehicleModal(true); };
const handleSaveVehicle = () => {
if (!vehicleFormData.plateNumber || !vehicleFormData.model) { alert('차량번호와 모델명은 필수입니다.'); return; }
if (vehicleModalMode === 'add') {
setVehicles(prev => [{ id: Date.now(), ...vehicleFormData }, ...prev]);
} else {
setVehicles(prev => prev.map(v => v.id === editingVehicle.id ? { ...v, ...vehicleFormData } : v));
}
setShowVehicleModal(false); setEditingVehicle(null);
};
const handleDeleteVehicle = (id) => {
if (confirm('차량을 삭제하시겠습니까? 관련 유지비 기록도 함께 삭제됩니다.')) {
setVehicles(prev => prev.filter(v => v.id !== id));
setMaintenances(prev => prev.filter(m => m.vehicleId !== id));
setShowVehicleModal(false);
}
};
const handleDownload = () => {
const rows = [['차량 유지비', `${dateRange.start} ~ ${dateRange.end}`], [], ['날짜', '차량', '구분', '내용', '금액', '주행거리', '업체'],
...filteredMaintenances.map(item => [item.date, item.vehicle, item.category, item.description, item.amount, item.mileage, item.vendor])];
...filteredMaintenances.map(item => [item.date, getVehicleDisplay(item.vehicleId), item.category, item.description, item.amount, item.mileage, item.vendor])];
const csvContent = rows.map(row => row.join(',')).join('\n');
const blob = new Blob(['\uFEFF' + csvContent], { type: 'text/csv;charset=utf-8;' });
const link = document.createElement('a'); link.href = URL.createObjectURL(blob); link.download = `차량유지비_${dateRange.start}_${dateRange.end}.csv`; link.click();
@@ -137,86 +222,172 @@ function VehicleMaintenanceManagement() {
<header className="bg-white border-b border-gray-200 rounded-t-xl mb-6">
<div className="px-6 py-4 flex items-center justify-between">
<div className="flex items-center gap-4">
<div className="p-2 bg-amber-100 rounded-xl"><Wrench className="w-6 h-6 text-amber-600" /></div>
<div><h1 className="text-xl font-bold text-gray-900">차량 유지비</h1><p className="text-sm text-gray-500">Vehicle Maintenance</p></div>
<div className="p-2 bg-amber-100 rounded-xl"><Car className="w-6 h-6 text-amber-600" /></div>
<div><h1 className="text-xl font-bold text-gray-900">법인차량 관리</h1><p className="text-sm text-gray-500">Corporate Vehicle Management</p></div>
</div>
<div className="flex items-center gap-3">
<button onClick={handleDownload} className="flex items-center gap-2 px-4 py-2 text-gray-700 hover:bg-gray-100 rounded-lg"><Download className="w-4 h-4" /><span className="text-sm">Excel</span></button>
<button onClick={handleAdd} className="flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg"><Plus className="w-4 h-4" /><span className="text-sm font-medium">비용 등록</span></button>
{activeTab === 'maintenance' ? (
<>
<button onClick={handleDownload} className="flex items-center gap-2 px-4 py-2 text-gray-700 hover:bg-gray-100 rounded-lg"><Download className="w-4 h-4" /><span className="text-sm">Excel</span></button>
<button onClick={handleAdd} className="flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg"><Plus className="w-4 h-4" /><span className="text-sm font-medium">비용 등록</span></button>
</>
) : (
<button onClick={handleAddVehicle} className="flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg"><Plus className="w-4 h-4" /><span className="text-sm font-medium">차량 등록</span></button>
)}
</div>
</div>
{/* 탭 */}
<div className="px-6 flex gap-1">
<button onClick={() => setActiveTab('maintenance')} className={`px-4 py-2 text-sm font-medium rounded-t-lg transition-colors ${activeTab === 'maintenance' ? 'bg-gray-50 text-amber-600 border-b-2 border-amber-500' : 'text-gray-500 hover:text-gray-700'}`}>
유지비 관리
</button>
<button onClick={() => setActiveTab('vehicles')} className={`px-4 py-2 text-sm font-medium rounded-t-lg transition-colors ${activeTab === 'vehicles' ? 'bg-gray-50 text-amber-600 border-b-2 border-amber-500' : 'text-gray-500 hover:text-gray-700'}`}>
차량 등록
</button>
</div>
</header>
<div className="grid grid-cols-1 md:grid-cols-4 gap-4 mb-6">
<div className="bg-white rounded-xl border border-gray-200 p-6">
<div className="flex items-center justify-between mb-2"><span className="text-sm text-gray-500"> 유지비</span><DollarSign className="w-5 h-5 text-gray-400" /></div>
<p className="text-2xl font-bold text-gray-900">{formatCurrency(totalAmount)}</p>
<p className="text-xs text-gray-400 mt-1">{filteredMaintenances.length}</p>
</div>
<div className="bg-white rounded-xl border border-amber-200 p-6 bg-amber-50/30">
<div className="flex items-center justify-between mb-2"><span className="text-sm text-amber-700">주유비</span><Fuel className="w-5 h-5 text-amber-500" /></div>
<p className="text-2xl font-bold text-amber-600">{formatCurrency(fuelAmount)}</p>
</div>
<div className="bg-white rounded-xl border border-blue-200 p-6">
<div className="flex items-center justify-between mb-2"><span className="text-sm text-blue-700">정비비</span><Wrench className="w-5 h-5 text-blue-500" /></div>
<p className="text-2xl font-bold text-blue-600">{formatCurrency(maintenanceAmount)}</p>
</div>
<div className="bg-white rounded-xl border border-gray-200 p-6">
<div className="flex items-center justify-between mb-2"><span className="text-sm text-gray-500">기타</span></div>
<p className="text-2xl font-bold text-gray-900">{formatCurrency(otherAmount)}</p>
</div>
</div>
<div className="bg-white rounded-xl border border-gray-200 p-4 mb-6">
<div className="grid grid-cols-1 md:grid-cols-5 gap-4">
<div className="relative">
<Search className="w-5 h-5 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2" />
<input type="text" placeholder="내용, 업체 검색..." value={searchTerm} onChange={(e) => setSearchTerm(e.target.value)} className="w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-amber-500" />
{/* 유지비 관리 탭 */}
{activeTab === 'maintenance' && (
<>
<div className="grid grid-cols-1 md:grid-cols-4 gap-4 mb-6">
<div className="bg-white rounded-xl border border-gray-200 p-6">
<div className="flex items-center justify-between mb-2"><span className="text-sm text-gray-500"> 유지비</span><DollarSign className="w-5 h-5 text-gray-400" /></div>
<p className="text-2xl font-bold text-gray-900">{formatCurrency(totalAmount)}</p>
<p className="text-xs text-gray-400 mt-1">{filteredMaintenances.length}</p>
</div>
<div className="bg-white rounded-xl border border-amber-200 p-6 bg-amber-50/30">
<div className="flex items-center justify-between mb-2"><span className="text-sm text-amber-700">주유비</span><Fuel className="w-5 h-5 text-amber-500" /></div>
<p className="text-2xl font-bold text-amber-600">{formatCurrency(fuelAmount)}</p>
</div>
<div className="bg-white rounded-xl border border-blue-200 p-6">
<div className="flex items-center justify-between mb-2"><span className="text-sm text-blue-700">정비비</span><Wrench className="w-5 h-5 text-blue-500" /></div>
<p className="text-2xl font-bold text-blue-600">{formatCurrency(maintenanceAmount)}</p>
</div>
<div className="bg-white rounded-xl border border-gray-200 p-6">
<div className="flex items-center justify-between mb-2"><span className="text-sm text-gray-500">기타</span></div>
<p className="text-2xl font-bold text-gray-900">{formatCurrency(otherAmount)}</p>
</div>
</div>
<select value={filterVehicle} onChange={(e) => setFilterVehicle(e.target.value)} className="px-3 py-2 border border-gray-300 rounded-lg"><option value="all">전체 차량</option>{vehicles.map(v => <option key={v} value={v}>{v}</option>)}</select>
<select value={filterCategory} onChange={(e) => setFilterCategory(e.target.value)} className="px-3 py-2 border border-gray-300 rounded-lg"><option value="all">전체 구분</option>{categories.map(c => <option key={c} value={c}>{c}</option>)}</select>
<div className="flex items-center gap-2 md:col-span-2">
<input type="date" value={dateRange.start} onChange={(e) => setDateRange(prev => ({ ...prev, start: e.target.value }))} className="flex-1 px-2 py-2 border border-gray-300 rounded-lg text-sm" />
<span>~</span>
<input type="date" value={dateRange.end} onChange={(e) => setDateRange(prev => ({ ...prev, end: e.target.value }))} className="flex-1 px-2 py-2 border border-gray-300 rounded-lg text-sm" />
<div className="bg-white rounded-xl border border-gray-200 p-4 mb-6">
<div className="grid grid-cols-1 md:grid-cols-5 gap-4">
<div className="relative">
<Search className="w-5 h-5 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2" />
<input type="text" placeholder="내용, 업체 검색..." value={searchTerm} onChange={(e) => setSearchTerm(e.target.value)} className="w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-amber-500" />
</div>
<select value={filterVehicle} onChange={(e) => setFilterVehicle(e.target.value)} className="px-3 py-2 border border-gray-300 rounded-lg">
<option value="all">전체 차량</option>
{vehicles.map(v => <option key={v.id} value={v.id}>{v.plateNumber} ({v.model})</option>)}
</select>
<select value={filterCategory} onChange={(e) => setFilterCategory(e.target.value)} className="px-3 py-2 border border-gray-300 rounded-lg"><option value="all">전체 구분</option>{categories.map(c => <option key={c} value={c}>{c}</option>)}</select>
<div className="flex items-center gap-2 md:col-span-2">
<input type="date" value={dateRange.start} onChange={(e) => setDateRange(prev => ({ ...prev, start: e.target.value }))} className="flex-1 px-2 py-2 border border-gray-300 rounded-lg text-sm" />
<span>~</span>
<input type="date" value={dateRange.end} onChange={(e) => setDateRange(prev => ({ ...prev, end: e.target.value }))} className="flex-1 px-2 py-2 border border-gray-300 rounded-lg text-sm" />
</div>
</div>
</div>
</div>
</div>
<div className="bg-white rounded-xl border border-gray-200 overflow-hidden">
<table className="w-full">
<thead className="bg-gray-50 border-b border-gray-200">
<tr>
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">날짜</th>
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">차량</th>
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">구분</th>
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">내용</th>
<th className="px-6 py-3 text-right text-xs font-semibold text-gray-600">금액</th>
<th className="px-6 py-3 text-right text-xs font-semibold text-gray-600">주행거리</th>
<th className="px-6 py-3 text-center text-xs font-semibold text-gray-600">관리</th>
</tr>
</thead>
<tbody className="divide-y divide-gray-100">
{filteredMaintenances.length === 0 ? (
<tr><td colSpan="7" className="px-6 py-12 text-center text-gray-400">데이터가 없습니다.</td></tr>
) : filteredMaintenances.map(item => (
<tr key={item.id} className="hover:bg-gray-50 cursor-pointer" onClick={() => handleEdit(item)}>
<td className="px-6 py-4 text-sm text-gray-600">{item.date}</td>
<td className="px-6 py-4"><p className="text-sm font-medium text-gray-900">{item.vehicle.split(' (')[0]}</p><p className="text-xs text-gray-400">{item.vehicle.split(' (')[1]?.replace(')', '')}</p></td>
<td className="px-6 py-4"><span className={`px-2 py-1 rounded text-xs font-medium ${getCategoryColor(item.category)}`}>{item.category}</span></td>
<td className="px-6 py-4"><p className="text-sm text-gray-900">{item.description}</p>{item.vendor && <p className="text-xs text-gray-400">{item.vendor}</p>}</td>
<td className="px-6 py-4 text-sm font-bold text-right text-amber-600">{formatCurrency(item.amount)}</td>
<td className="px-6 py-4 text-sm text-right text-gray-600">{formatCurrency(item.mileage)}km</td>
<td className="px-6 py-4 text-center" onClick={(e) => e.stopPropagation()}>
<button onClick={() => handleEdit(item)} className="p-1 text-gray-400 hover:text-blue-500"><Edit className="w-4 h-4" /></button>
<button onClick={() => handleDelete(item.id)} className="p-1 text-gray-400 hover:text-rose-500"><Trash2 className="w-4 h-4" /></button>
</td>
</tr>
))}
</tbody>
</table>
</div>
<div className="bg-white rounded-xl border border-gray-200 overflow-hidden">
<table className="w-full">
<thead className="bg-gray-50 border-b border-gray-200">
<tr>
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">날짜</th>
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">차량</th>
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">구분</th>
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">내용</th>
<th className="px-6 py-3 text-right text-xs font-semibold text-gray-600">금액</th>
<th className="px-6 py-3 text-right text-xs font-semibold text-gray-600">주행거리</th>
<th className="px-6 py-3 text-center text-xs font-semibold text-gray-600">관리</th>
</tr>
</thead>
<tbody className="divide-y divide-gray-100">
{filteredMaintenances.length === 0 ? (
<tr><td colSpan="7" className="px-6 py-12 text-center text-gray-400">데이터가 없습니다.</td></tr>
) : filteredMaintenances.map(item => {
const vehicle = vehicles.find(v => v.id === item.vehicleId);
return (
<tr key={item.id} className="hover:bg-gray-50 cursor-pointer" onClick={() => handleEdit(item)}>
<td className="px-6 py-4 text-sm text-gray-600">{item.date}</td>
<td className="px-6 py-4">
<p className="text-sm font-medium text-gray-900">{vehicle?.plateNumber || '-'}</p>
<p className="text-xs text-gray-400">{vehicle?.model || ''}</p>
</td>
<td className="px-6 py-4"><span className={`px-2 py-1 rounded text-xs font-medium ${getCategoryColor(item.category)}`}>{item.category}</span></td>
<td className="px-6 py-4"><p className="text-sm text-gray-900">{item.description}</p>{item.vendor && <p className="text-xs text-gray-400">{item.vendor}</p>}</td>
<td className="px-6 py-4 text-sm font-bold text-right text-amber-600">{formatCurrency(item.amount)}</td>
<td className="px-6 py-4 text-sm text-right text-gray-600">{formatCurrency(item.mileage)}km</td>
<td className="px-6 py-4 text-center" onClick={(e) => e.stopPropagation()}>
<button onClick={() => handleEdit(item)} className="p-1 text-gray-400 hover:text-blue-500"><Edit className="w-4 h-4" /></button>
<button onClick={() => handleDelete(item.id)} className="p-1 text-gray-400 hover:text-rose-500"><Trash2 className="w-4 h-4" /></button>
</td>
</tr>
);
})}
</tbody>
</table>
</div>
</>
)}
{/* 차량 등록 탭 */}
{activeTab === 'vehicles' && (
<>
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
<div className="bg-white rounded-xl border border-blue-200 p-6 bg-blue-50/30">
<div className="flex items-center justify-between mb-2"><span className="text-sm text-blue-700">법인차량</span><Car className="w-5 h-5 text-blue-500" /></div>
<p className="text-2xl font-bold text-blue-600">{vehicles.filter(v => v.ownershipType === 'corporate').length}</p>
</div>
<div className="bg-white rounded-xl border border-purple-200 p-6 bg-purple-50/30">
<div className="flex items-center justify-between mb-2"><span className="text-sm text-purple-700">렌트차량</span><Car className="w-5 h-5 text-purple-500" /></div>
<p className="text-2xl font-bold text-purple-600">{vehicles.filter(v => v.ownershipType === 'rent').length}</p>
</div>
<div className="bg-white rounded-xl border border-orange-200 p-6 bg-orange-50/30">
<div className="flex items-center justify-between mb-2"><span className="text-sm text-orange-700">리스차량</span><Car className="w-5 h-5 text-orange-500" /></div>
<p className="text-2xl font-bold text-orange-600">{vehicles.filter(v => v.ownershipType === 'lease').length}</p>
</div>
</div>
<div className="bg-white rounded-xl border border-gray-200 overflow-hidden">
<table className="w-full">
<thead className="bg-gray-50 border-b border-gray-200">
<tr>
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">차량번호</th>
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">모델명</th>
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">구분</th>
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">계약/구입일</th>
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">렌트/리스사</th>
<th className="px-6 py-3 text-right text-xs font-semibold text-gray-600"> 렌트료</th>
<th className="px-6 py-3 text-right text-xs font-semibold text-gray-600">현재 주행거리</th>
<th className="px-6 py-3 text-center text-xs font-semibold text-gray-600">관리</th>
</tr>
</thead>
<tbody className="divide-y divide-gray-100">
{vehicles.length === 0 ? (
<tr><td colSpan="8" className="px-6 py-12 text-center text-gray-400">등록된 차량이 없습니다.</td></tr>
) : vehicles.map(vehicle => (
<tr key={vehicle.id} className="hover:bg-gray-50 cursor-pointer" onClick={() => handleEditVehicle(vehicle)}>
<td className="px-6 py-4 text-sm font-medium text-gray-900">{vehicle.plateNumber}</td>
<td className="px-6 py-4 text-sm text-gray-600">{vehicle.model}</td>
<td className="px-6 py-4"><span className={`px-2 py-1 rounded text-xs font-medium ${getOwnershipColor(vehicle.ownershipType)}`}>{getOwnershipLabel(vehicle.ownershipType)}</span></td>
<td className="px-6 py-4 text-sm text-gray-600">{vehicle.contractDate || vehicle.purchaseDate || '-'}</td>
<td className="px-6 py-4 text-sm text-gray-600">{vehicle.rentCompany || '-'}</td>
<td className="px-6 py-4 text-sm font-bold text-right text-purple-600">{vehicle.monthlyRent ? `${formatCurrency(parseInt(vehicle.monthlyRent))}원` : '-'}</td>
<td className="px-6 py-4 text-sm text-right text-gray-600">{formatCurrency(vehicle.currentMileage)}km</td>
<td className="px-6 py-4 text-center" onClick={(e) => e.stopPropagation()}>
<button onClick={() => handleEditVehicle(vehicle)} className="p-1 text-gray-400 hover:text-blue-500"><Edit className="w-4 h-4" /></button>
<button onClick={() => handleDeleteVehicle(vehicle.id)} className="p-1 text-gray-400 hover:text-rose-500"><Trash2 className="w-4 h-4" /></button>
</td>
</tr>
))}
</tbody>
</table>
</div>
</>
)}
{/* 유지비 등록/수정 모달 */}
{showModal && (
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50">
<div className="bg-white rounded-xl p-6 w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto">
@@ -229,7 +400,11 @@ function VehicleMaintenanceManagement() {
<div><label className="block text-sm font-medium text-gray-700 mb-1">날짜 *</label><input type="date" value={formData.date} onChange={(e) => setFormData(prev => ({ ...prev, date: e.target.value }))} className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
<div><label className="block text-sm font-medium text-gray-700 mb-1">구분</label><select value={formData.category} onChange={(e) => setFormData(prev => ({ ...prev, category: e.target.value }))} className="w-full px-3 py-2 border border-gray-300 rounded-lg">{categories.map(c => <option key={c} value={c}>{c}</option>)}</select></div>
</div>
<div><label className="block text-sm font-medium text-gray-700 mb-1">차량</label><select value={formData.vehicle} onChange={(e) => setFormData(prev => ({ ...prev, vehicle: e.target.value }))} className="w-full px-3 py-2 border border-gray-300 rounded-lg">{vehicles.map(v => <option key={v} value={v}>{v}</option>)}</select></div>
<div><label className="block text-sm font-medium text-gray-700 mb-1">차량</label>
<select value={formData.vehicleId} onChange={(e) => setFormData(prev => ({ ...prev, vehicleId: e.target.value }))} className="w-full px-3 py-2 border border-gray-300 rounded-lg">
{vehicles.map(v => <option key={v.id} value={v.id}>{v.plateNumber} ({v.model})</option>)}
</select>
</div>
<div><label className="block text-sm font-medium text-gray-700 mb-1">내용 *</label><input type="text" value={formData.description} onChange={(e) => setFormData(prev => ({ ...prev, description: e.target.value }))} placeholder="내용" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
<div className="grid grid-cols-2 gap-4">
<div><label className="block text-sm font-medium text-gray-700 mb-1">금액 *</label><input type="text" value={formatInputCurrency(formData.amount)} onChange={(e) => setFormData(prev => ({ ...prev, amount: parseInputCurrency(e.target.value) }))} placeholder="0" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-right" /></div>
@@ -241,13 +416,88 @@ function VehicleMaintenanceManagement() {
</div>
</div>
<div className="flex gap-3 mt-6">
{modalMode === 'edit' && <button onClick={() => handleDelete(editingItem.id)} className="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg flex items-center gap-2"><span>🗑️</span> 삭제</button>}
{modalMode === 'edit' && <button onClick={() => handleDelete(editingItem.id)} className="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg">삭제</button>}
<button onClick={() => setShowModal(false)} className="flex-1 px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50">취소</button>
<button onClick={handleSave} className="flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg">{modalMode === 'add' ? '등록' : '저장'}</button>
</div>
</div>
</div>
)}
{/* 차량 등록/수정 모달 */}
{showVehicleModal && (
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50">
<div className="bg-white rounded-xl p-6 w-full max-w-2xl mx-4 max-h-[90vh] overflow-y-auto">
<div className="flex items-center justify-between mb-6">
<h3 className="text-lg font-bold text-gray-900">{vehicleModalMode === 'add' ? '차량 등록' : '차량 수정'}</h3>
<button onClick={() => setShowVehicleModal(false)} className="p-1 hover:bg-gray-100 rounded-lg"><X className="w-5 h-5 text-gray-500" /></button>
</div>
<div className="space-y-4">
{/* 기본 정보 */}
<div className="grid grid-cols-3 gap-4">
<div><label className="block text-sm font-medium text-gray-700 mb-1">차량번호 *</label><input type="text" value={vehicleFormData.plateNumber} onChange={(e) => setVehicleFormData(prev => ({ ...prev, plateNumber: e.target.value }))} placeholder="12가 3456" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
<div><label className="block text-sm font-medium text-gray-700 mb-1">모델명 *</label><input type="text" value={vehicleFormData.model} onChange={(e) => setVehicleFormData(prev => ({ ...prev, model: e.target.value }))} placeholder="제네시스 G80" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
<div><label className="block text-sm font-medium text-gray-700 mb-1">구분 *</label>
<select value={vehicleFormData.ownershipType} onChange={(e) => setVehicleFormData(prev => ({ ...prev, ownershipType: e.target.value }))} className="w-full px-3 py-2 border border-gray-300 rounded-lg">
{ownershipTypes.map(t => <option key={t.value} value={t.value}>{t.label}</option>)}
</select>
</div>
</div>
<div className="grid grid-cols-2 gap-4">
<div><label className="block text-sm font-medium text-gray-700 mb-1">현재 주행거리 (km)</label><input type="text" value={formatInputCurrency(vehicleFormData.currentMileage)} onChange={(e) => setVehicleFormData(prev => ({ ...prev, currentMileage: parseInputCurrency(e.target.value) }))} placeholder="0" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-right" /></div>
{vehicleFormData.ownershipType === 'corporate' && (
<>
<div><label className="block text-sm font-medium text-gray-700 mb-1">구입일</label><input type="date" value={vehicleFormData.purchaseDate} onChange={(e) => setVehicleFormData(prev => ({ ...prev, purchaseDate: e.target.value }))} className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
</>
)}
</div>
{/* 렌트/리스 전용 필드 */}
{(vehicleFormData.ownershipType === 'rent' || vehicleFormData.ownershipType === 'lease') && (
<>
<div className="border-t pt-4 mt-4">
<h4 className="text-sm font-semibold text-gray-900 mb-3">{vehicleFormData.ownershipType === 'rent' ? '렌트' : '리스'} 계약 정보</h4>
<div className="grid grid-cols-2 gap-4">
<div><label className="block text-sm font-medium text-gray-700 mb-1">계약일자</label><input type="date" value={vehicleFormData.contractDate} onChange={(e) => setVehicleFormData(prev => ({ ...prev, contractDate: e.target.value }))} className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
<div><label className="block text-sm font-medium text-gray-700 mb-1">{vehicleFormData.ownershipType === 'rent' ? '렌트' : '리스'}회사명</label><input type="text" value={vehicleFormData.rentCompany} onChange={(e) => setVehicleFormData(prev => ({ ...prev, rentCompany: e.target.value }))} placeholder="렌터카/리스사명" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
</div>
<div className="grid grid-cols-2 gap-4 mt-3">
<div><label className="block text-sm font-medium text-gray-700 mb-1">{vehicleFormData.ownershipType === 'rent' ? '렌트' : '리스'}회사 연락처</label><input type="text" value={vehicleFormData.rentCompanyTel} onChange={(e) => setVehicleFormData(prev => ({ ...prev, rentCompanyTel: e.target.value }))} placeholder="02-1234-5678" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
<div><label className="block text-sm font-medium text-gray-700 mb-1">{vehicleFormData.ownershipType === 'rent' ? '렌트' : '리스'}기간</label><input type="text" value={vehicleFormData.rentPeriod} onChange={(e) => setVehicleFormData(prev => ({ ...prev, rentPeriod: e.target.value }))} placeholder="36개월" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
</div>
<div className="grid grid-cols-2 gap-4 mt-3">
<div><label className="block text-sm font-medium text-gray-700 mb-1">약정운행거리 (km)</label><input type="text" value={formatInputCurrency(vehicleFormData.agreedMileage)} onChange={(e) => setVehicleFormData(prev => ({ ...prev, agreedMileage: parseInputCurrency(e.target.value) }))} placeholder="0" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-right" /></div>
<div><label className="block text-sm font-medium text-gray-700 mb-1">차량가격 ()</label><input type="text" value={formatInputCurrency(vehicleFormData.vehiclePrice)} onChange={(e) => setVehicleFormData(prev => ({ ...prev, vehiclePrice: parseInputCurrency(e.target.value) }))} placeholder="0" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-right" /></div>
</div>
<div className="grid grid-cols-2 gap-4 mt-3">
<div><label className="block text-sm font-medium text-gray-700 mb-1">추정잔존가액 ()</label><input type="text" value={formatInputCurrency(vehicleFormData.residualValue)} onChange={(e) => setVehicleFormData(prev => ({ ...prev, residualValue: parseInputCurrency(e.target.value) }))} placeholder="0" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-right" /></div>
<div><label className="block text-sm font-medium text-gray-700 mb-1">보증금 ()</label><input type="text" value={formatInputCurrency(vehicleFormData.deposit)} onChange={(e) => setVehicleFormData(prev => ({ ...prev, deposit: parseInputCurrency(e.target.value) }))} placeholder="0" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-right" /></div>
</div>
<div className="grid grid-cols-2 gap-4 mt-3">
<div><label className="block text-sm font-medium text-gray-700 mb-1"> {vehicleFormData.ownershipType === 'rent' ? '렌트' : '리스'} - 공급가액 ()</label><input type="text" value={formatInputCurrency(vehicleFormData.monthlyRent)} onChange={(e) => setVehicleFormData(prev => ({ ...prev, monthlyRent: parseInputCurrency(e.target.value) }))} placeholder="0" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-right" /></div>
<div><label className="block text-sm font-medium text-gray-700 mb-1"> {vehicleFormData.ownershipType === 'rent' ? '렌트' : '리스'} - 세액 ()</label><input type="text" value={formatInputCurrency(vehicleFormData.monthlyRentTax)} onChange={(e) => setVehicleFormData(prev => ({ ...prev, monthlyRentTax: parseInputCurrency(e.target.value) }))} placeholder="0" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-right" /></div>
</div>
</div>
<div className="border-t pt-4 mt-4">
<h4 className="text-sm font-semibold text-gray-900 mb-3">보험 정보</h4>
<div className="grid grid-cols-2 gap-4">
<div><label className="block text-sm font-medium text-gray-700 mb-1">보험사명</label><input type="text" value={vehicleFormData.insuranceCompany} onChange={(e) => setVehicleFormData(prev => ({ ...prev, insuranceCompany: e.target.value }))} placeholder="삼성화재" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
<div><label className="block text-sm font-medium text-gray-700 mb-1">보험사 연락처</label><input type="text" value={vehicleFormData.insuranceCompanyTel} onChange={(e) => setVehicleFormData(prev => ({ ...prev, insuranceCompanyTel: e.target.value }))} placeholder="1588-0000" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
</div>
</div>
</>
)}
</div>
<div className="flex gap-3 mt-6">
{vehicleModalMode === 'edit' && <button onClick={() => handleDeleteVehicle(editingVehicle.id)} className="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg">삭제</button>}
<button onClick={() => setShowVehicleModal(false)} className="flex-1 px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50">취소</button>
<button onClick={handleSaveVehicle} className="flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg">{vehicleModalMode === 'add' ? '등록' : '저장'}</button>
</div>
</div>
</div>
)}
</div>
);
}