Compare commits

122 Commits

Author SHA1 Message Date
유병철
ca259ccb18 fix: [악성채권] JOIN 쿼리 나머지 컬럼 테이블 prefix 보완
- is_active, status 컬럼에도 bad_debts. prefix 추가
- BadDebtService, StatusBoardService 동일 수정

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 16:43:12 +09:00
유병철
3929c5fd1e fix: [악성채권] tenant_id 컬럼 ambiguous 에러 수정
- JOIN 쿼리에서 bad_debts.tenant_id로 테이블 명시
- BadDebtService, StatusBoardService 동일 수정

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 16:38:17 +09:00
유병철
56c60ec3df feat: [현황판/악성채권] 카드별 sub_label(대표 거래처명 + 건수) 추가
- BadDebtService: summary에 카드별(전체/추심중/법적조치/회수완료) sub_labels 추가
- StatusBoardService: 악성채권·신규거래처·결재 카드에 sub_label 추가
  - 악성채권: 최다 금액 거래처명
  - 신규거래처: 최근 등록 업체명
  - 결재: 최근 결재 제목

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 16:32:58 +09:00
유병철
60c4256bd0 feat: [복리후생] 상세 조회 커스텀 날짜 범위 필터 추가
- start_date, end_date 쿼리 파라미터 추가
- 커스텀 날짜 범위 지정 시 해당 범위로 일별 사용 내역 조회
- 미지정 시 기존 분기 기준 유지

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 13:20:30 +09:00
유병철
1861f4daf2 fix: [세금계산서] NOT NULL 컬럼 null 방어 처리
- supplier/buyer corp_num, corp_name null→빈문자열 보정
- Laravel ConvertEmptyStringsToNull 미들웨어로 인한 DB 에러 방지

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 12:40:08 +09:00
유병철
c62e59ad17 fix: [세금계산서] 매입/매출 방향별 공급자·공급받는자 필수값 조건 분리
- 매입(purchases): supplier 정보 필수, buyer 선택
- 매출(sales): buyer 정보 필수, supplier 선택
- required → required_if:direction 조건부 검증으로 변경

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 11:35:39 +09:00
유병철
e6f13e3870 refactor: [세금계산서/바로빌] ApiResponse::handle() 클로저 패턴으로 통일
- BarobillSettingController: show/save/testConnection 클로저 방식 전환
- TaxInvoiceController: 전체 액션(index/show/store/update/destroy/issue/bulkIssue/cancel/checkStatus/summary) 클로저 방식 전환
- 중간 변수 할당 제거, 일관된 응답 패턴 적용

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 11:21:20 +09:00
유병철
1d5d161e05 feat: [finance] 더존 Smart A 표준 계정과목 추가 시딩 마이그레이션
- 기획서 14장 기준 누락분 보완
- tenant_id + code 중복 시 skip (기존 데이터 보호)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 10:56:49 +09:00
유병철
0044779eb4 feat: [finance] 계정과목 확장 및 전표 연동 시스템 구현
- AccountCode 모델/서비스 확장 (업데이트, 기본 계정과목 시딩)
- JournalSyncService 추가 (전표 자동 연동)
- SyncsExpenseAccounts 트레이트 추가
- CardTransactionController, TaxInvoiceController 기능 확장
- expense_accounts 테이블에 전표 연결 컬럼 마이그레이션
- account_codes 테이블 확장 마이그레이션
- 전체 테넌트 기본 계정과목 시딩 마이그레이션

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 10:32:20 +09:00
3ac64d5b76 feat: [품질검사] 수주 선택 필터링 + 개소 상세 + 검사 상태 개선
- availableOrders: client_id/item_id 필터 파라미터 지원
- availableOrders: 응답에 client_id, client_name, item_id, item_name, locations(개소 상세) 추가
- show: 개소별 데이터에 거래처/모델 정보 포함
- DocumentService: fqcStatus rootNodes 기반으로 변경

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:28:53 +09:00
2231c9a48f feat: 제품검사 요청서 Document(EAV) 자동생성 및 동기화
- document_template_sections에 description 컬럼 추가 (마이그레이션)
- DocumentTemplateSection 모델에 description fillable 추가
- QualityDocumentService에 syncRequestDocument() 메서드 추가
  - quality_document 생성/수정/수주연결 시 요청서 Document 자동생성
  - 기본필드, 섹션 데이터, 사전고지 테이블 EAV 자동매핑
  - rendered_html 초기화 (데이터 변경 시 재캡처 트리거)
- transformToFrontend에 request_document_id 포함

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:28:53 +09:00
ff8553055c chore: [API] logging, docs, seeder 등 부수 정리
- LOGICAL_RELATIONSHIPS.md 보완
- Legacy5130Calculator 수정
- logging.php 설정 추가
- KyungdongItemSeeder 수정
- docs/INDEX.md, changes 문서 경로 수정

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:28:53 +09:00
f2eede6e3a feat: [품질관리] order_ids 영속성 + location 데이터 저장
- StoreRequest/UpdateRequest에 order_ids 검증 추가
- UpdateRequest에 locations 검증 추가 (시공규격, 변경사유, 검사데이터)
- QualityDocumentLocation에 inspection_data(JSON) fillable/cast 추가
- QualityDocumentService store()에 syncOrders 연동
- QualityDocumentService update()에 syncOrders + updateLocations 연동
- inspection_data 컬럼 추가 migration 신규

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:28:53 +09:00
c5d5b5d076 feat: [문서스냅샷] Lazy Snapshot API - snapshot 엔드포인트 + resolve에 snapshot_document_id 추가
- PATCH /documents/{id}/snapshot: canEdit 체크 없이 rendered_html만 업데이트
- DocumentService::patchSnapshot() 메서드 추가
- WorkOrderService::resolveInspectionDocument()에 snapshot_document_id 반환 (상태 무관, rendered_html NULL인 문서)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:28:53 +09:00
5ebf940873 fix: [문서스냅샷] UpsertRequest rendered_html 검증 추가 및 upsert() 전달 누락 수정
- UpsertRequest에 rendered_html nullable string 검증 추가
- DocumentService upsert()에서 create/update 시 rendered_html 전달

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:28:53 +09:00
293330c418 feat: 문서 rendered_html 스냅샷 저장 지원
- Document 모델 $fillable에 rendered_html 추가
- DocumentService create/update에서 rendered_html 저장
- StoreRequest/UpdateRequest에 rendered_html 검증 추가
- WorkOrderService 검사문서/작업일지 생성 시 rendered_html 전달

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:28:53 +09:00
a845f52fc0 fix: [생산지시] withCount에서도 보조 공정(재고생산) WO 제외
- 목록 조회 시 work_orders_count에서 is_auxiliary WO 제외
- whereNotNull(process_id) + options->is_auxiliary 조건 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:28:53 +09:00
0f26ea546a feat: [품질관리] 수주선택 API에 발주처(client_name) 필드 추가
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:28:53 +09:00
3600c7b12b fix: [품질관리] 수주선택 모달 납품일 포맷 및 개소 수 수정
- delivery_date: ISO 타임스탬프 → Y-m-d 포맷으로 변환
- location_count: order_items 수 → order_nodes 루트 노드(개소) 수로 변경

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:28:53 +09:00
a6e29bc1f3 feat: [품질관리] 백엔드 API 구현 - 품질관리서 + 실적신고
- 품질관리서(quality_documents) CRUD API 14개 엔드포인트
- 실적신고(performance_reports) 관리 API 6개 엔드포인트
- DB 마이그레이션 4개 테이블 (quality_documents, quality_document_orders, quality_document_locations, performance_reports)
- 모델 4개 + 서비스 2개 + 컨트롤러 2개 + FormRequest 4개
- stats() ambiguous column 버그 수정 (JOIN 시 테이블 접두사 추가)
- missing() status_code 컬럼명/값 수정

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:28:53 +09:00
0aa0a8592d feat: [생산지시] 재고생산 보조 공정 일반 워크플로우에서 분리
- Process P-004 options에 is_auxiliary 플래그 도입
- WO 생성 시 Process의 is_auxiliary를 WO options에 자동 복사
- ProductionOrderService: 보조 공정 WO를 공정 진행 현황에서 제외
- WorkOrderService: 보조 공정 WO의 상태 변경이 수주 상태에 영향 주지 않도록 처리
  - syncOrderStatus(): 보조 공정이면 스킵
  - autoStartWorkOrderOnMaterialInput(): WO는 진행중 전환하되 수주 상태는 유지

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:28:53 +09:00
38c2402771 fix: [생산지시] 공정 진행 현황 WO 필터링 + BOM 파싱 수정
- 공정 진행 현황: process_id=null인 구매품/서비스 WO 제외 (withCount, 목록/상세 모두)
- extractBomProcessGroups: bom_result.items[] 구조에 맞게 파싱 수정
  - process_name → process_group 키 사용
  - 품목 필드 매핑 수정 (item_id, specification, unit, quantity, unit_price, total_price, node_name)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:28:53 +09:00
59d13eeb9f fix: [생산지시] 날짜포맷·개소수·자재투입 시 자동 상태전환
- ProductionOrderService: production_ordered_at를 Y-m-d 포맷으로 변환
- ProductionOrderService: withCount('nodes')로 개소수(node_count) 응답 추가
- WorkOrderService: autoStartWorkOrderOnMaterialInput() 신규 메서드
  - 자재투입 시 WO가 unassigned/pending/waiting이면 in_progress로 자동 전환
  - syncOrderStatus()로 Order도 IN_PRODUCTION 동기화
- Swagger: node_count 필드 문서화, 날짜 포맷 수정

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:28:53 +09:00
2df8ecf765 feat: [생산지시] 전용 API 엔드포인트 신규 생성
- ProductionOrderService: 목록(index), 통계(stats), 상세(show) 구현
  - Order 기반 생산지시 대상 필터링 (IN_PROGRESS~SHIPPED)
  - workOrderProgress 가공 필드 (total/completed/inProgress)
  - production_ordered_at (첫 WorkOrder created_at 기반)
  - BOM 공정 분류 추출 (order_nodes.options.bom_result)
- ProductionOrderController: FormRequest + ApiResponse 패턴
- ProductionOrderIndexRequest: search, production_status, sort, pagination 검증
- ProductionOrderApi.php: Swagger 문서 (목록/통계/상세)
- production.php: GET /production-orders, /stats, /{orderId} 라우트 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:28:53 +09:00
김보곤
ad93743bdc feat: [approval] 연차사용촉진 통지서 1차/2차 양식 마이그레이션 추가
- leave_promotion_1st: 연차사용촉진 통지서 (1차) - hr 카테고리
- leave_promotion_2nd: 연차사용촉진 통지서 (2차) - hr 카테고리
2026-03-07 00:28:59 +09:00
김보곤
449fce1d2b feat: [approval] 공문서 양식 마이그레이션 추가 2026-03-06 23:38:56 +09:00
김보곤
9d4143a4dc feat: [approval] 견적서 양식 마이그레이션 추가 2026-03-06 23:21:50 +09:00
김보곤
c5a0115e01 feat: [approval] 이사회의사록 양식 데이터 마이그레이션 추가 2026-03-06 23:00:55 +09:00
김보곤
eb28b577e0 feat: [approval] 위임장 양식 데이터 마이그레이션 추가
- 전체 테넌트에 delegation 양식 레코드 자동 삽입
2026-03-06 22:41:31 +09:00
김보곤
22160e5904 feat: [menu] 경조사비관리 메뉴 추가 마이그레이션
- 각 테넌트의 부가세관리 메뉴 하위에 경조사비관리 메뉴 자동 추가
- 중복 방지 (이미 존재하면 skip)
2026-03-06 21:44:52 +09:00
김보곤
0ea5fa5eb9 feat: [database] 경조사비 관리 테이블 생성
- condolence_expenses 테이블: 거래처 경조사비 관리대장
- 경조사일자, 지출일자, 거래처명, 내역, 구분(축의/부조)
- 부조금(여부/지출방법/금액), 선물(여부/종류/금액), 총금액
2026-03-06 21:39:02 +09:00
김보곤
58fedb0d43 feat: [approvals] 사용인감계 양식 데이터 마이그레이션 추가
- 모든 테넌트에 seal_usage 양식 자동 등록
2026-03-06 20:51:38 +09:00
김보곤
56e7164243 feat: [departments] options JSON 컬럼 추가
- 조직도 숨기기 등 확장 속성 저장용
2026-03-06 20:24:56 +09:00
김보곤
a67c5d9fca feat: [menu] menu_favorites 테이블 마이그레이션 추가
- tenant_id, user_id, menu_id, sort_order 컬럼
- unique 제약: (tenant_id, user_id, menu_id)
- FK cascade delete: users, menus
2026-03-06 14:35:14 +09:00
유병철
816c25a631 fix: [finance] 일반전표 목록 source 필드 및 페이지네이션 구조 수정
- deposits/withdrawals 조회 시 source를 항상 'linked'로 고정
- 페이지네이션 meta 래핑 제거하여 플랫 구조로 변경

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:26:58 +09:00
유병철
12d172e4c3 feat: [finance] 계정과목 및 일반전표 API 추가
- AccountCode 모델/서비스/컨트롤러 구현
- JournalEntry, JournalEntryLine 모델 구현
- GeneralJournalEntry 서비스/컨트롤러 구현
- FormRequest 검증 클래스 추가
- finance 라우트 등록
- i18n 메시지 키 추가 (message.php, error.php)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:10:45 +09:00
유병철
be9c1baa34 fix: [receivables] 상위 거래처 집계에서 soft delete 레코드 제외
- orders, deposits, bills 서브쿼리에 whereNull('deleted_at') 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 10:59:16 +09:00
유병철
a7973bb555 feat: [loan] 상품권 summary에 접대비 해당 집계 추가
- expense_accounts 테이블에서 접대비(상품권) 건수/금액 조회
- entertainment_count, entertainment_amount 응답 필드 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 10:37:57 +09:00
김보곤
96def0d71e feat: [approval] 사직서 양식 마이그레이션 추가 2026-03-06 00:13:18 +09:00
김보곤
846ced3ead feat: [approval] 위촉증명서 양식 데이터 마이그레이션 2026-03-05 23:57:45 +09:00
김보곤
0f25a5d4e1 feat: [approval] 경력증명서 양식 데이터 마이그레이션 2026-03-05 23:42:16 +09:00
유병철
c57e768b87 fix: [loan] 상품권 접대비 연동 시 receipt_no에 시리얼번호 매핑
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 22:12:46 +09:00
유병철
7fe856f3b7 fix: [loan] 상품권 카테고리는 상태 무관하게 수정/삭제 가능하도록 변경
- isEditable(): 상품권이면 상태와 무관하게 수정 허용
- isDeletable(): 상품권이면 상태와 무관하게 삭제 허용

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 21:42:00 +09:00
유병철
652ac3d1ec fix: [loan] dashboard summary/목록에서도 used/disposed 상품권 제외
- dashboard summary 쿼리에 excludeUsedGiftCert 조건 적용
- 가지급금 목록 쿼리에도 동일 조건 적용

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 21:39:17 +09:00
유병철
03f86f375e fix: [loan] 상품권 store 시 접대비 연동 + 카테고리 집계에서 사용/폐기 제외
- store()에서도 상품권 접대비 자동 연동 호출
- getCategoryBreakdown: used/disposed 상품권은 가지급금 집계에서 제외

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 21:32:36 +09:00
유병철
31d2f08dd8 feat: [loan] 상품권 접대비 자동 연동 기능 추가
- ExpenseAccount: loan_id 필드 + SUB_TYPE_GIFT_CERTIFICATE 상수 추가
- LoanService: 상품권 used+접대비해당 시 expense_accounts 자동 upsert/삭제
- 마이그레이션: expense_accounts에 loan_id 컬럼 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 21:22:44 +09:00
유병철
8c9f2fcfb5 feat: [bill,loan] 어음 V8 확장 필드 및 가지급금 상품권 카테고리 지원
- Bill 모델: V8 확장 필드 54개 추가 (증권종류, 할인, 배서, 추심, 개서, 부도 등)
- Bill 상태: 수취/발행 어음·수표별 세분화된 상태 체계
- BillService: assignV8Fields/syncInstallments 헬퍼 추출, instrument_type/medium 필터
- BillInstallment: type/counterparty 필드 추가
- Loan 모델: holding/used/disposed 상태 + metadata(JSON) 필드 추가
- LoanService: 상품권 카테고리 지원 (summary 상태별 집계, store 기본상태 holding)
- FormRequest: V8 확장 필드 검증 규칙 추가
- 마이그레이션: bills V8 필드 + loans metadata 컬럼

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 20:45:54 +09:00
김보곤
f41605ca73 feat: [approval] 재직증명서 양식 마이그레이션 추가
- approval_forms 테이블에 employment_cert 폼 삽입
2026-03-05 18:54:25 +09:00
김보곤
66d1004bc2 feat: [rd] CM송 저장 테이블 마이그레이션 추가
- cm_songs 테이블: tenant_id, user_id, company_name, industry, lyrics, audio_path, options
2026-03-05 14:36:47 +09:00
김보곤
ce1f91074e feat: [approval] approvals 테이블에 rejection_history JSON 컬럼 추가 2026-03-05 13:50:46 +09:00
김보곤
558a393c85 feat: [approval] approvals 테이블에 resubmit_count 컬럼 추가 2026-03-05 13:06:31 +09:00
김보곤
ac72487eff feat: [approval] approvals 테이블에 drafter_read_at 컬럼 추가
- 기안자가 완료 결과를 확인했는지 추적하는 타임스탬프
- 완료함 미읽음 뱃지 기능 지원
2026-03-05 11:37:31 +09:00
3d4dd9f252 chore: [infra] Slack 알림 채널 분리 — product_infra → deploy_api
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 11:32:16 +09:00
2507dcf142 chore: [docs] 모델 관계 문서 갱신 + summary 플레이스홀더 API 추가
- LOGICAL_RELATIONSHIPS.md: 최신 모델 관계 반영 (inspections, shipment dispatches 등)
- stats.php: production/construction/unshipped/attendance summary 플레이스홀더

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 11:01:24 +09:00
9b8cdfa2a5 refactor: [core] 모델 스코프 적용 — Tenant::active() 사용 및 코드 규칙 추가
- RecordStorageUsage: where 하드코딩 → Tenant::active() 스코프
- CLAUDE.md: 쿼리 수정 시 모델 스코프 우선 규칙 명시

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 11:01:10 +09:00
7432fb16aa feat: [production] 자재투입 replace 모드 지원
- registerMaterialInputForItem에 replace 파라미터 추가
- 기존 투입 교체 방식 선택 가능

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 11:01:07 +09:00
d4f21f06d6 refactor: [production] 셔터박스 prefix — isStandard 파라미터 제거
- CF/CL/CP/CB 품목이 모든 길이에 등록되어 boxSize 무관하게 적용
- resolveShutterBoxPrefix()에서 불필요한 isStandard 분기 제거

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 11:01:04 +09:00
1f7f45ee60 feat: [process] 공정단계 options 컬럼 추가 — 검사 설정/범위 지원
- ProcessStep 모델에 options JSON 컬럼 추가 (fillable, cast)
- Store/UpdateProcessStepRequest에 inspection_setting, inspection_scope 검증 규칙
- process_steps 테이블 마이그레이션

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 11:01:01 +09:00
cd847e01a0 feat: [approval] Document ↔ Approval 브릿지 연동 (Phase 4.2)
- Approval 모델에 linkable morphTo 관계 추가
- DocumentService: 상신 시 Approval 자동 생성 + approval_steps 변환
- ApprovalService: 승인/반려/회수 시 Document 상태 동기화
- approvals 테이블에 linkable_type, linkable_id 컬럼 마이그레이션

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 11:00:53 +09:00
ef7d9fae24 fix: [production] 절곡 검사 products 배열 FormRequest 검증 규칙 추가
- StoreItemInspectionRequest에 inspection_data.products 검증 규칙 누락으로 validated()에서 제거되던 버그 수정
- products.*.id, bendingStatus, lengthMeasured, widthMeasured, gapPoints 규칙 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 10:44:54 +09:00
1a8bb46137 feat: [outbound] 배차차량 관리 API — CRUD + options JSON 정책
- VehicleDispatchService: index(검색/필터/페이지네이션), stats(선불/착불/합계), show, update
- VehicleDispatchController + VehicleDispatchUpdateRequest
- options JSON 컬럼 추가 (dispatch_no, status, freight_cost_type, supply_amount, vat, total_amount, writer)
- ShipmentService.syncDispatches에 options 필드 지원 추가
- inventory.php에 vehicle-dispatches 라우트 4개 등록

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 10:44:54 +09:00
897511cb55 fix: [production] 절곡 검사 데이터 전체 item 복제 + bending EAV 변환
- storeItemInspection: bending/bending_wip 시 동일 작업지시 모든 item에 복제 저장
- transformBendingProductsToRecords: products 배열 → bending EAV 레코드 변환
- getMaterialInputLots: 품목코드별 그룹핑으로 변경

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 10:44:54 +09:00
5ee97c2d74 fix: [production] 자재투입 bom_group_key 개별 저장 — 동일 자재 다중 BOM 그룹 지원
- bom_group_key 컬럼 추가 마이그레이션 (work_order_material_inputs)
- WorkOrderMaterialInput 모델 fillable에 bom_group_key 추가
- MaterialInputForItemRequest에 bom_group_key 검증 + replace 옵션 추가
- WorkOrderService.getMaterialsForItem: stock_lot_id+bom_group_key 복합키 기투입 조회 (하위호환)
- WorkOrderService.registerMaterialInputForItem: bom_group_key 저장 + replace 모드 (기존 삭제→재등록)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 10:44:54 +09:00
8518621432 feat: [shipment] 배차정보 다중 행 시스템 — shipment_vehicle_dispatches 테이블 추가
- 신규 마이그레이션: shipment_vehicle_dispatches 테이블 (seq, logistics_company, arrival_datetime, tonnage, vehicle_no, driver_contact, remarks)
- 신규 모델: ShipmentVehicleDispatch (ShipmentItem 패턴 복제)
- Shipment 모델: vehicleDispatches() HasMany 관계 추가
- ShipmentService: syncDispatches() 추가, store/update/delete/show/index에서 연동
- FormRequest: Store/Update에 vehicle_dispatches 배열 검증 규칙 추가
- delivery_method 검증에 확장 옵션 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 10:44:54 +09:00
fc537898fc fix: [production] 자재투입 모달 개선 — lot_managed 필터링, BOM 그룹키, 셔터박스 순서
- getMaterialsForItem: lot_managed===false 품목 자재투입 목록에서 제외 (L-Bar, 보강평철)
- getMaterialsForItem: bom_group_key 필드 추가 (category+partType 기반 고유키)
- BendingInfoBuilder: shutterPartTypes에서 top_cover/fin_cover 제거 (별도 생성과 중복)
- BendingInfoBuilder: 셔터박스 루프 순서 파트→길이로 변경 (작업일지 순서 일치)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 10:44:54 +09:00
유병철
fefd129795 refactor: [daily-report] 엑셀 내보내기 화면 데이터 기반으로 리팩토링
- DailyReportService: exportData를 dailyAccounts() 재사용 구조로 변경
- DailyReportExport: 헤더 라벨 전월이월/당월입금/당월출금/잔액으로 수정
- 화면 합계와 엑셀 합계 일치하도록 개선

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 10:44:29 +09:00
유병철
1b2363d661 feat: [daily-report] 엑셀 내보내기에 어음/외상매출채권 현황 섹션 추가
- DailyReportExport: 어음 현황 테이블 + 합계 + 스타일링 추가
- DailyReportService: exportData에 noteReceivables 데이터 포함

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 10:06:48 +09:00
유병철
f1a3e0f164 fix: [dashboard-ceo] 공정명 컬럼 및 근태 부서 조인 수정
- processes 테이블: p.name → p.process_name 컬럼명 수정
- 근태: users.department_id → tenant_user_profiles 경유 조인으로 변경
- 직급: users.position → tup.position_key 컬럼 수정

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 09:41:54 +09:00
유병철
e8da2ea1b1 feat: [dashboard-ceo] CEO 대시보드 섹션별 API 및 일일보고서 엑셀 추가
- DashboardCeoController/Service: 6개 섹션 API 신규 (매출/매입/생산/미출고/시공/근태)
- DailyReportController/Service: 엑셀 다운로드 API 추가 (GET /daily-report/export)
- 라우트: dashboard 하위 6개 + daily-report/export 엔드포인트 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 09:35:30 +09:00
김보곤
e0bb19a017 fix: [storage] RecordStorageUsage 명령어 tenants 테이블 컬럼명 오류 수정
- Tenant::where('status', 'active') → Tenant::active() 스코프 사용
- tenants 테이블에 status 컬럼 없음, tenant_st_code 사용
2026-03-05 09:16:19 +09:00
유병철
74a60e06bc feat: [calendar,vat] 캘린더 CRUD 및 부가세 상세 조회 API 추가
- CalendarController/Service: 일정 등록/수정/삭제 API 추가
- VatController/Service: getDetail() 상세 조회 (요약, 참조테이블, 미발행 목록, 신고기간 옵션)
- 라우트: POST/PUT/DELETE /calendar/schedules, GET /vat/detail 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 20:33:04 +09:00
유병철
2f3ec13b24 fix: [entertainment] 분기 사용액 조회에 날짜 필터 적용
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 20:00:04 +09:00
유병철
94b96e22f6 feat: [entertainment] 접대비 상세 조회 날짜 필터 파라미터 추가
- EntertainmentController: detail에 start_date/end_date 파라미터 전달
- EntertainmentService: getDetail 리스크/사용자분포/거래내역에 날짜 필터 적용

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 15:32:16 +09:00
유병철
a173a5a4fc fix: [loan] getCategoryBreakdown SQL alias 충돌 수정
- outstanding_amount → cat_outstanding alias 변경 (Loan accessor 충돌 방지)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 15:30:31 +09:00
유병철
66da2972fa feat: [entertainment,loan] 접대비 상세 조회 API 및 가지급금 날짜 필터 추가
- EntertainmentController/Service: getDetail() 상세 조회 API 추가 (손금한도, 월별추이, 사용자분포, 거래내역, 분기현황)
- EntertainmentService: 수입금액별 추가한도 계산(세법 기준), 거래건별 리스크 감지
- LoanController/Service: dashboard에 start_date/end_date 파라미터 지원
- LoanService: getCategoryBreakdown 날짜 필터 적용, 목록 limit 10→50 확대
- 라우트: GET /entertainment/detail 엔드포인트 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 15:11:37 +09:00
김보곤
282bf26eec feat: [approval] 지출결의서 body_template 고도화
- 참조 문서 기반으로 정형 양식 HTML 리디자인
- 지출형식/세금계산서 체크박스, 기본정보, 8열 내역 테이블, 합계, 첨부 섹션 포함
2026-03-04 14:52:19 +09:00
김보곤
b86af29cc9 feat: [approval] body_template 컬럼 추가 및 지출결의서 양식 등록
- approval_forms 테이블에 body_template TEXT 컬럼 추가
- 지출결의서(expense) 양식 데이터 등록 (HTML 테이블 본문 템플릿 포함)
2026-03-04 14:52:19 +09:00
유병철
f665d3aea8 fix: [entertainment,welfare] 바로빌 조인 컬럼명 및 심야 시간 파싱 수정
- approval_no → approval_num 컬럼명 수정
- use_time 심야 판별: HOUR() → SUBSTRING 문자열 파싱으로 변경
- whereNotNull('bct.use_time') 조건 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 14:28:00 +09:00
유병철
e637e3d1f7 feat: [dashboard] D1.7 기획서 기반 리스크 감지형 서비스 리팩토링
- EntertainmentService: 리스크 감지형 전환 (주말/심야, 기피업종, 고액결제, 증빙미비)
- WelfareService: 리스크 감지형 전환 (비과세 한도 초과, 사적 사용 의심, 특정인 편중, 항목별 한도 초과)
- ReceivablesService: summary를 cards + check_points 구조로 개선 (누적/당월 미수금, Top3 거래처)
- LoanService: getCategoryBreakdown 전체 대상으로 집계 조건 변경

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 14:21:05 +09:00
김보곤
7cf70dbcaa fix: [address] 주소 필드 255자 → 500자 확장
- DB 마이그레이션: clients, tenants, site_briefings, sites 테이블 address 컬럼 varchar(500)
- FormRequest 8개 파일 max:255 → max:500 변경
2026-03-04 11:29:08 +09:00
김보곤
76192fc177 fix: [cards] cards/stats → card-transactions/dashboard 리다이렉트 추가 2026-03-04 11:10:01 +09:00
김보곤
da04b84bb5 fix: [models] User 모델 import 누락/오류 수정
- Loan.php: User import 누락 → App\Models\Members\User 추가
- TodayIssue.php: App\Models\Users\User → App\Models\Members\User 수정
- Tenants 네임스페이스에서 User::class가 App\Models\Tenants\User로 잘못 해석되는 문제 해결
2026-03-04 11:06:11 +09:00
유병철
1deeafc4de feat: [expense,loan] 대시보드 상세 필터 및 가지급금 카테고리 분류
- ExpectedExpenseController/Service: dashboardDetail에 start_date/end_date/search 파라미터 추가
- Loan 모델: category 상수 및 라벨 정의 (카드/경조사/상품권/접대비)
- LoanService: dashboard에 category_breakdown 집계 추가
- 마이그레이션: loans 테이블 category 컬럼 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 10:42:53 +09:00
김보곤
4f3467c3b0 feat: [barobill] 바로빌 연동 API 엔드포인트 추가
- GET /api/v1/barobill/status — 연동 현황 조회
- POST /api/v1/barobill/login — 로그인 정보 등록
- POST /api/v1/barobill/signup — 회원가입 정보 등록
- GET /api/v1/barobill/bank-service-url — 은행 서비스 URL
- GET /api/v1/barobill/account-link-url — 계좌 연동 URL
- GET /api/v1/barobill/card-link-url — 카드 연동 URL
- GET /api/v1/barobill/certificate-url — 공인인증서 URL
2026-03-04 09:03:55 +09:00
김보곤
e9fd75fa74 feat: [inspection] 캘린더 스케줄 조회 API 추가
- GET /api/v1/inspections/calendar 엔드포인트 추가
- year, month, inspector, status 파라미터 지원
- React 프론트엔드 CalendarItemApi 형식에 맞춰 응답
2026-03-04 08:33:32 +09:00
김보곤
23c6cf6919 feat: [hr] Leave 모델 확장 + 결재양식 마이그레이션 추가
- Leave 타입 6개 추가: business_trip, remote, field_work, early_leave, late_reason, absent_reason
- 그룹 상수 추가: VACATION_TYPES, ATTENDANCE_REQUEST_TYPES, REASON_REPORT_TYPES
- FORM_CODE_MAP: 유형 → 결재양식코드 매핑 상수
- ATTENDANCE_STATUS_MAP: 유형 → 근태상태 매핑 상수
- 결재양식 2개 추가: attendance_request(근태신청), reason_report(사유서)
2026-03-03 23:52:13 +09:00
유병철
42443349dc feat: [stock,client,status-board] 날짜 필터 및 조건 보완
- StockController/StockService: 입출고 이력 기반 날짜 범위 필터 추가
- ClientService: 등록일 기간 필터(start_date/end_date) 추가
- StatusBoardService: 부실채권 현황에 is_active 조건 추가 (목록 페이지 일치)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 21:53:30 +09:00
유병철
ad27090bfc feat: [daily-report] 자금현황 카드용 필드 추가
- 미수금 잔액(receivable_balance) 계산 로직 구현
- 미지급금 잔액(payable_balance) 계산 로직 구현
- 당월 예상 지출(monthly_expense_total) 계산 로직 구현
- summary API 응답에 자금현황 3개 필드 포함

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 21:06:09 +09:00
유병철
b7465becab feat: [approval] 결재 수신함 날짜 범위 필터 추가
- InboxIndexRequest에 start_date/end_date 검증 룰 추가
- ApprovalService.inbox()에 created_at 날짜 범위 필터 구현

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 20:02:07 +09:00
유병철
83a774572a feat: [today-issue] 날짜 기반 이전 이슈 조회 기능 추가
- TodayIssueController에 date 파라미터(YYYY-MM-DD) 추가
- TodayIssueService.summary()에 날짜 기반 필터링 로직 구현
- 이전 이슈 조회 시 만료(active) 필터 무시하여 과거 데이터 조회 가능

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 18:48:30 +09:00
김보곤
da1142af62 feat: [ai-quotation] 제조 견적서 마이그레이션 추가
- ai_quotations: quote_mode, quote_number, product_category 컬럼 추가
- ai_quotation_items: specification, unit, quantity, unit_price, total_price, item_category, floor_code 컬럼 추가
- ai_quote_price_tables 테이블 신규 생성
2026-03-03 15:57:19 +09:00
김보곤
b3c7d08b2c feat: [hr] 사업소득자 임금대장 display_name/business_reg_number 컬럼 추가
- user_id nullable 변경 (직접 입력 대상자 지원)
- display_name, business_reg_number 컬럼 추가
- 기존 데이터 earner 프로필에서 자동 채움
2026-03-03 14:33:03 +09:00
7e309e4057 fix: [deploy] 배포 시 .env 권한 640 보장 추가
- Stage/Production 배포 스크립트에 chmod 640 추가
- vi 편집으로 인한 .env 권한 변경(600) 방지
- 2026-03-03 장애 재발 방지 (PHP-FPM이 .env 읽기 실패 → 500)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 09:51:07 +09:00
김보곤
f79d008777 chore: [ai] Gemini 모델 gemini-2.0-flash → gemini-2.5-flash 마이그레이션
- config/services.php fallback 기본값 변경
- AiReportService fallback 기본값 변경
2026-03-03 08:09:08 +09:00
김보곤
abe04607e4 feat: [rd] AI 견적 엔진 테이블 생성 + 모듈 카탈로그 시더
- ai_quotation_modules: SAM 모듈 카탈로그 (18개 모듈)
- ai_quotations: AI 견적 요청/결과
- ai_quotation_items: AI 추천 모듈 목록
- AiQuotationModuleSeeder: customer-pricing 기반 초기 데이터
2026-03-02 17:43:36 +09:00
김보곤
3ca161e9e2 feat: [roadmap] 중장기 계획 테이블 마이그레이션 추가
- admin_roadmap_plans: 계획 테이블 (제목, 카테고리, 상태, Phase, 진행률 등)
- admin_roadmap_milestones: 마일스톤 테이블 (plan_id FK, 상태, 예정일 등)
2026-03-02 15:50:05 +09:00
김보곤
587bdf5d80 feat: [interview] 마스터 질문 데이터 시드 마이그레이션 추가
- 8개 도메인, 16개 템플릿, 80개 마스터 질문 INSERT
- idempotent 처리: 이미 도메인 카테고리 존재 시 스킵
- Jenkins 자동 배포로 운영서버 데이터 반영 목적
2026-02-28 22:05:59 +09:00
김보곤
f2d36c3616 feat: [interview] 카테고리 계층 구조 parent_id 마이그레이션 추가
- interview_categories 테이블에 parent_id 컬럼 추가
- self-referencing FK, nullOnDelete
2026-02-28 21:23:19 +09:00
김보곤
397d50de1f feat: [interview] 인터뷰 시나리오 고도화 마이그레이션
- interview_projects 테이블 신규 (회사별 프로젝트)
- interview_attachments 테이블 신규 (첨부파일 + AI 분석)
- interview_knowledge 테이블 신규 (AI 추출 지식)
- interview_categories에 project_id, domain 컬럼 추가
- interview_questions에 ai_hint, expected_format, depends_on, domain 추가
- interview_answers에 answer_data, attachments JSON 추가
- interview_sessions에 project_id, session_type, voice_recording_id 추가
2026-02-28 20:02:33 +09:00
김보곤
73949b1282 feat: [document] 블록 빌더 지원 마이그레이션 추가
- document_templates: builder_type, schema, page_config 컬럼 추가
- documents: data JSON, rendered_html, pdf_path 컬럼 추가
2026-02-28 19:31:46 +09:00
김보곤
e40555ad37 feat: [leaves] 휴가-결재 연동을 위한 DB 변경
- leaves 테이블에 approval_id 컬럼 추가 (마이그레이션)
- 휴가신청 결재 양식(approval_forms) 등록 (마이그레이션)
- Leave 모델 fillable에 approval_id 추가
2026-02-28 15:54:34 +09:00
김보곤
79da7a6da7 feat: [equipment] 다중 점검주기 + 부 담당자 DB 스키마 추가
- equipments: sub_manager_id 컬럼 추가
- equipment_inspection_templates: inspection_cycle 컬럼 + 유니크 변경
- equipment_inspections: inspection_cycle 컬럼 + 유니크 변경
2026-02-28 12:37:26 +09:00
김보곤
b04d407fdb feat: [approval] Phase 2 마이그레이션 추가
- approval_steps: parallel_group, acted_by, approval_type 컬럼 추가
- approvals: recall_reason, parent_doc_id 컬럼 추가
- approval_delegations 테이블 생성 (위임/대결)
2026-02-27 23:41:34 +09:00
김보곤
c32d68f069 feat: [approval] 결재관리 Phase 1 마이그레이션
- approvals 테이블: line_id, body, is_urgent, department_id 컬럼 추가
- approval_steps 테이블: approver_name, approver_department, approver_position 스냅샷 컬럼 추가
2026-02-27 23:26:40 +09:00
afc1aa72a8 feat: [inspection] 절곡 검사 마감유형(S1/S2/S3) 프로파일 분리 — 5130 레거시 기준
- BENDING_GAP_PROFILES를 S1/S2/S3 + common 계층 구조로 재구성
  - S1(KSS01): 벽면 4pt, 측면 6pt, 하단 1pt
  - S2(KSS02): 벽면 3pt, 측면 5pt, 하단 1pt
  - S3(KWE01/KSE01+SUS): 벽면 5pt, 측면 7pt, 하단 2pt
- resolveFinishingType() 신규: product_code → 마감유형 자동 판별
- buildBendingInspectionItems()에 마감유형별 프로파일 적용
- getInspectionConfig() 응답에 finishing_type 필드 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 23:18:09 +09:00
f970b6bf4b feat: [inspection] Phase 3 절곡 검사 동적 구현 — inspection-config API + 트랜잭션 보강
- inspection-config API 신규: GET /work-orders/{id}/inspection-config
  - 공정 자동 판별 (resolveInspectionProcessType)
  - bending_info 기반 구성품 목록 + gap_points 반환
  - BENDING_GAP_PROFILES 상수 (6개 구성품 간격 기준치)
- createInspectionDocument 트랜잭션 보강
  - DB::transaction() + lockForUpdate() 적용
  - 동시 생성 race condition 방지

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 23:18:09 +09:00
e6c02292d2 feat: [quote/quality] Phase 2B 견적 product_code 자동추출 + inspections work_order_id FK
- QuoteService: extractProductCodeFromInputs() 추가, store/update에서 자동 추출
- BackfillQuoteProductCodeCommand: 기존 quotes 25건 product_code 보정
- inspections 테이블에 work_order_id FK 마이그레이션 (nullable, nullOnDelete)
- Inspection↔WorkOrder 양방향 관계 추가
- InspectionService: store/show/index에 work_order_id 처리 + transformToFrontend
- InspectionStoreRequest: work_order_id 검증 규칙 추가
2026-02-27 23:18:09 +09:00
9e84fa04a6 fix: [production] product_code 전파 버그 수정
- OrderService::createProductionOrder에 product_code/product_name 추가
- WorkOrderService::store 수주복사 경로에 product_code/product_name 추가
- order_nodes.options → work_order_items.options 전파 누락 해결
2026-02-27 23:18:09 +09:00
김보곤
ff8b37670e feat: [hr] 사업소득자 임금대장 테이블 마이그레이션 추가
- business_income_payments 테이블 생성
- 소득세(3%)/지방소득세(0.3%) 고정세율 구조
- (tenant_id, user_id, pay_year, pay_month) 유니크 제약
2026-02-27 20:21:59 +09:00
김보곤
75408d925f feat: [esign] esign_contracts 테이블에 completion_template_name 컬럼 추가
- 완료 알림톡 템플릿명을 저장하기 위한 nullable string 컬럼
2026-02-27 16:28:57 +09:00
김보곤
dd11f780b4 feat: [payroll] 근로소득세 간이세액표 DB 테이블 및 시더 추가
- income_tax_brackets 테이블 마이그레이션 생성
- 2024년 국세청 간이세액표 데이터 시더 (7,117건)
- salary_from/salary_to(천원), family_count(1~11), tax_amount(원)
2026-02-27 13:58:39 +09:00
김보곤
c94bef1dae feat: [hr] 사업소득자관리 worker_type 컬럼 추가
- tenant_user_profiles 테이블에 worker_type 컬럼 추가 (employee/business_income)
- TenantUserProfile 모델 fillable에 worker_type 추가
2026-02-27 13:46:42 +09:00
f53f04de65 fix: [cicd] 배포 시 storage/bootstrap 권한 설정 추가
- mkdir 후 www-data:webservice 소유권 + 775 권한 설정
- Stage/Production 배포 모두 적용
- 원인: PHP-FPM(www-data)이 storage 쓰기 불가 → 500 에러
2026-02-27 10:43:11 +09:00
김보곤
96c4f71607 Merge branch 'develop' of http://114.203.209.83:3000/SamProject/sam-api into develop 2026-02-27 10:08:06 +09:00
김보곤
0d1d056b13 feat: [payroll] payrolls 테이블에 long_term_care 컬럼 추가 2026-02-27 10:06:25 +09:00
ac7279606d chore: 운영 배포 승인 단계 비활성화 (개발 단계)
- Production Approval stage 주석처리
- 런칭 후 다시 활성화 예정
- 배포 흐름: main push → Stage → Production (승인 없이 자동)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 22:32:13 +09:00
김보곤
fcb377a40c feat: [attendance] attendance_requests 테이블 마이그레이션 추가
- 근태 승인 워크플로우용 신청 테이블
- tenant_id, user_id, request_type, start_date, end_date, status 등
2026-02-26 20:56:41 +09:00
김보곤
1a2350db7d feat: [calendar] 달력 일정 관리 API 구현
- GET /api/v1/calendar-schedules — 연도별 일정 목록 조회
- GET /api/v1/calendar-schedules/stats — 통계 조회
- GET /api/v1/calendar-schedules/{id} — 단건 조회
- POST /api/v1/calendar-schedules — 등록
- PUT /api/v1/calendar-schedules/{id} — 수정
- DELETE /api/v1/calendar-schedules/{id} — 삭제
- POST /api/v1/calendar-schedules/bulk — 대량 등록
2026-02-26 14:29:12 +09:00
김보곤
0ff731ab09 Merge branch 'develop' of http://114.203.209.83:3000/SamProject/sam-api into develop 2026-02-25 21:35:53 +09:00
0345ddcce3 fix: 세션 만료 예외를 슬랙 알림에서 제외
- '회원정보 정보 없음' AuthenticationException은 API Key 검증 통과 후 발생하므로 세션 만료 정상 케이스
- IP 기반 필터링(EXCEPTION_IGNORED_IPS) 대신 예외 자체를 무조건 제외하도록 단순화

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 21:14:48 +09:00
김보곤
a6e547f40d feat: [equipment] files 테이블에 GCS 컬럼 추가
- gcs_object_name, gcs_uri 컬럼 추가
- 설비 사진 멀티 업로드 기능 지원
2026-02-25 20:14:41 +09:00
김보곤
e819635ea6 feat: [equipment] 설비관리 테이블 마이그레이션 6개 생성
- equipments (설비 마스터)
- equipment_inspection_templates (점검항목 템플릿)
- equipment_inspections (월간 점검 헤더)
- equipment_inspection_details (일자별 점검 결과)
- equipment_repairs (수리이력)
- equipment_process (설비-공정 피봇)
2026-02-25 19:39:52 +09:00
29 changed files with 1906 additions and 116 deletions

View File

@@ -54,4 +54,4 @@ ## 관련 파일
- `api/app/Services/ComprehensiveAnalysisService.php`
- `api/database/seeders/ComprehensiveAnalysisSeeder.php`
- `docs/plans/react-mock-remaining-tasks.md`
- `docs/dev/dev_plans/react-mock-remaining-tasks.md`

View File

@@ -15,7 +15,7 @@ ## Phase 구성
- Phase 5: MNG 관리자 패널 (4항목) — mng/ /system/alerts
## 핵심 파일
- 계획 문서: docs/plans/db-backup-system-plan.md
- 계획 문서: docs/dev/dev_plans/db-backup-system-plan.md
- 개발서버: 114.203.209.83 (SSH: hskwon)
- DB: sam (메인) + sam_stat (통계)
- Slack 웹훅: api/.env → LOG_SLACK_WEBHOOK_URL (이미 설정됨)

View File

@@ -16,7 +16,7 @@ ### 생성된 파일
| 파일 | 설명 |
|------|------|
| `app/Http/Requests/Quote/QuoteBomBulkCalculateRequest.php` | 다건 BOM 산출 FormRequest |
| `api/docs/changes/20260102_1300_quote_bom_bulk_calculation.md` | 변경 내용 문서 |
| `api/docs/dev/changes/20260102_1300_quote_bom_bulk_calculation.md` | 변경 내용 문서 |
### 수정된 파일
| 파일 | 설명 |
@@ -93,9 +93,9 @@ ### QuoteCalculationService::calculateBomBulk()
- 개별 품목 실패가 전체에 영향 없음 (예외 처리)
## 관련 문서
- 계획 문서: `docs/plans/quote-calculation-api-plan.md`
- Phase 1.1 문서: `docs/changes/20260102_quote_bom_calculation_api.md`
- Phase 1.2 문서: `docs/changes/20260102_1300_quote_bom_bulk_calculation.md`
- 계획 문서: `docs/dev/dev_plans/quote-calculation-api-plan.md`
- Phase 1.1 문서: `docs/dev/changes/20260102_quote_bom_calculation_api.md`
- Phase 1.2 문서: `docs/dev/changes/20260102_1300_quote_bom_bulk_calculation.md`
## 다음 단계
- React 프론트엔드에서 `/calculate/bom/bulk` API 연동

View File

@@ -107,3 +107,10 @@ fixed_tools: []
# override of the corresponding setting in serena_config.yml, see the documentation there.
# If null or missing, the value from the global config is used.
symbol_info_budget:
# The language backend to use for this project.
# If not set, the global setting from serena_config.yml is used.
# Valid values: LSP, JetBrains
# Note: the backend is fixed at startup. If a project with a different backend
# is activated post-init, an error will be returned.
language_backend:

View File

@@ -1,6 +1,6 @@
# 논리적 데이터베이스 관계 문서
> **자동 생성**: 2026-03-07 02:57:21
> **자동 생성**: 2026-03-06 21:25:05
> **소스**: Eloquent 모델 관계 분석
## 📊 모델별 관계 현황

View File

@@ -5,6 +5,7 @@
use App\Helpers\ApiResponse;
use App\Http\Controllers\Controller;
use App\Http\Requests\V1\AccountSubject\StoreAccountSubjectRequest;
use App\Http\Requests\V1\AccountSubject\UpdateAccountSubjectRequest;
use App\Services\AccountCodeService;
use Illuminate\Http\Request;
@@ -19,7 +20,10 @@ public function __construct(
*/
public function index(Request $request)
{
$params = $request->only(['search', 'category']);
$params = $request->only([
'search', 'category', 'sub_category',
'department_type', 'depth', 'is_active', 'selectable',
]);
$subjects = $this->service->index($params);
@@ -36,6 +40,16 @@ public function store(StoreAccountSubjectRequest $request)
return ApiResponse::success($subject, __('message.created'), [], 201);
}
/**
* 계정과목 수정
*/
public function update(int $id, UpdateAccountSubjectRequest $request)
{
$subject = $this->service->update($id, $request->validated());
return ApiResponse::success($subject, __('message.updated'));
}
/**
* 계정과목 활성/비활성 토글
*/
@@ -57,4 +71,17 @@ public function destroy(int $id)
return ApiResponse::success(null, __('message.deleted'));
}
/**
* 기본 계정과목표 일괄 생성 (더존 표준)
*/
public function seedDefaults()
{
$count = $this->service->seedDefaults();
return ApiResponse::success(
['inserted_count' => $count],
__('message.created')
);
}
}

View File

@@ -18,12 +18,9 @@ public function __construct(
*/
public function show()
{
$setting = $this->barobillService->getSetting();
return ApiResponse::handle(
data: $setting,
message: __('message.fetched')
);
return ApiResponse::handle(function () {
return $this->barobillService->getSetting();
}, __('message.fetched'));
}
/**
@@ -31,12 +28,9 @@ public function show()
*/
public function save(SaveBarobillSettingRequest $request)
{
$setting = $this->barobillService->saveSetting($request->validated());
return ApiResponse::handle(
data: $setting,
message: __('message.saved')
);
return ApiResponse::handle(function () use ($request) {
return $this->barobillService->saveSetting($request->validated());
}, __('message.saved'));
}
/**
@@ -44,11 +38,8 @@ public function save(SaveBarobillSettingRequest $request)
*/
public function testConnection()
{
$result = $this->barobillService->testConnection();
return ApiResponse::handle(
data: $result,
message: __('message.barobill.connection_success')
);
return ApiResponse::handle(function () {
return $this->barobillService->testConnection();
}, __('message.barobill.connection_success'));
}
}

View File

@@ -4,7 +4,9 @@
use App\Helpers\ApiResponse;
use App\Http\Controllers\Controller;
use App\Models\Tenants\JournalEntry;
use App\Services\CardTransactionService;
use App\Services\JournalSyncService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -14,7 +16,8 @@
class CardTransactionController extends Controller
{
public function __construct(
protected CardTransactionService $service
protected CardTransactionService $service,
protected JournalSyncService $journalSyncService,
) {}
/**
@@ -148,4 +151,105 @@ public function destroy(int $id): JsonResponse
return $this->service->destroy($id);
}, __('message.deleted'));
}
// =========================================================================
// 분개 (Journal Entries)
// =========================================================================
/**
* 카드 거래 분개 조회
*/
public function getJournalEntries(int $id): JsonResponse
{
return ApiResponse::handle(function () use ($id) {
$sourceKey = "card_{$id}";
$data = $this->journalSyncService->getForSource(
JournalEntry::SOURCE_CARD_TRANSACTION,
$sourceKey
);
if (! $data) {
return ['items' => []];
}
// 프론트엔드가 기대하는 items 형식으로 변환
$items = array_map(fn ($row) => [
'id' => $row['id'],
'supply_amount' => $row['debit_amount'],
'tax_amount' => 0,
'account_code' => $row['account_code'],
'deduction_type' => 'deductible',
'vendor_name' => $row['vendor_name'],
'description' => $row['memo'],
'memo' => '',
], $data['rows']);
return ['items' => $items];
}, __('message.fetched'));
}
/**
* 카드 거래 분개 저장
*/
public function storeJournalEntries(Request $request, int $id): JsonResponse
{
return ApiResponse::handle(function () use ($request, $id) {
$validated = $request->validate([
'items' => 'required|array|min:1',
'items.*.supply_amount' => 'required|integer|min:0',
'items.*.tax_amount' => 'required|integer|min:0',
'items.*.account_code' => 'required|string|max:20',
'items.*.deduction_type' => 'nullable|string|max:20',
'items.*.vendor_name' => 'nullable|string|max:200',
'items.*.description' => 'nullable|string|max:500',
'items.*.memo' => 'nullable|string|max:500',
]);
// 카드 거래 정보 조회 (날짜용)
$transaction = $this->service->show($id);
if (! $transaction) {
throw new \Illuminate\Database\Eloquent\ModelNotFoundException;
}
$entryDate = $transaction->used_at
? $transaction->used_at->format('Y-m-d')
: ($transaction->withdrawal_date?->format('Y-m-d') ?? now()->format('Y-m-d'));
// items → journal rows 변환 (각 item을 차변 행으로)
$rows = [];
foreach ($validated['items'] as $item) {
$amount = ($item['supply_amount'] ?? 0) + ($item['tax_amount'] ?? 0);
$rows[] = [
'side' => 'debit',
'account_code' => $item['account_code'],
'debit_amount' => $amount,
'credit_amount' => 0,
'vendor_name' => $item['vendor_name'] ?? '',
'memo' => $item['description'] ?? $item['memo'] ?? '',
];
}
// 대변 합계 행 (카드미지급금)
$totalAmount = array_sum(array_column($rows, 'debit_amount'));
$rows[] = [
'side' => 'credit',
'account_code' => '25300', // 미지급금 (표준 코드)
'account_name' => '미지급금',
'debit_amount' => 0,
'credit_amount' => $totalAmount,
'vendor_name' => $transaction->merchant_name ?? '',
'memo' => '카드결제',
];
$sourceKey = "card_{$id}";
return $this->journalSyncService->saveForSource(
JournalEntry::SOURCE_CARD_TRANSACTION,
$sourceKey,
$entryDate,
"카드거래 분개 (#{$id})",
$rows,
);
}, __('message.created'));
}
}

View File

@@ -10,12 +10,17 @@
use App\Http\Requests\TaxInvoice\TaxInvoiceSummaryRequest;
use App\Http\Requests\TaxInvoice\UpdateTaxInvoiceRequest;
use App\Http\Requests\V1\TaxInvoice\BulkIssueRequest;
use App\Models\Tenants\JournalEntry;
use App\Services\JournalSyncService;
use App\Services\TaxInvoiceService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class TaxInvoiceController extends Controller
{
public function __construct(
private TaxInvoiceService $taxInvoiceService
private TaxInvoiceService $taxInvoiceService,
private JournalSyncService $journalSyncService,
) {}
/**
@@ -23,12 +28,9 @@ public function __construct(
*/
public function index(TaxInvoiceListRequest $request)
{
$taxInvoices = $this->taxInvoiceService->list($request->validated());
return ApiResponse::handle(
data: $taxInvoices,
message: __('message.fetched')
);
return ApiResponse::handle(function () use ($request) {
return $this->taxInvoiceService->list($request->validated());
}, __('message.fetched'));
}
/**
@@ -36,12 +38,9 @@ public function index(TaxInvoiceListRequest $request)
*/
public function show(int $id)
{
$taxInvoice = $this->taxInvoiceService->show($id);
return ApiResponse::handle(
data: $taxInvoice,
message: __('message.fetched')
);
return ApiResponse::handle(function () use ($id) {
return $this->taxInvoiceService->show($id);
}, __('message.fetched'));
}
/**
@@ -49,13 +48,9 @@ public function show(int $id)
*/
public function store(CreateTaxInvoiceRequest $request)
{
$taxInvoice = $this->taxInvoiceService->create($request->validated());
return ApiResponse::handle(
data: $taxInvoice,
message: __('message.created'),
status: 201
);
return ApiResponse::handle(function () use ($request) {
return $this->taxInvoiceService->create($request->validated());
}, __('message.created'));
}
/**
@@ -63,12 +58,9 @@ public function store(CreateTaxInvoiceRequest $request)
*/
public function update(UpdateTaxInvoiceRequest $request, int $id)
{
$taxInvoice = $this->taxInvoiceService->update($id, $request->validated());
return ApiResponse::handle(
data: $taxInvoice,
message: __('message.updated')
);
return ApiResponse::handle(function () use ($request, $id) {
return $this->taxInvoiceService->update($id, $request->validated());
}, __('message.updated'));
}
/**
@@ -76,12 +68,11 @@ public function update(UpdateTaxInvoiceRequest $request, int $id)
*/
public function destroy(int $id)
{
$this->taxInvoiceService->delete($id);
return ApiResponse::handle(function () use ($id) {
$this->taxInvoiceService->delete($id);
return ApiResponse::handle(
data: null,
message: __('message.deleted')
);
return null;
}, __('message.deleted'));
}
/**
@@ -89,12 +80,9 @@ public function destroy(int $id)
*/
public function issue(int $id)
{
$taxInvoice = $this->taxInvoiceService->issue($id);
return ApiResponse::handle(
data: $taxInvoice,
message: __('message.tax_invoice.issued')
);
return ApiResponse::handle(function () use ($id) {
return $this->taxInvoiceService->issue($id);
}, __('message.tax_invoice.issued'));
}
/**
@@ -102,12 +90,9 @@ public function issue(int $id)
*/
public function bulkIssue(BulkIssueRequest $request)
{
$result = $this->taxInvoiceService->bulkIssue($request->getIds());
return ApiResponse::handle(
data: $result,
message: __('message.tax_invoice.bulk_issued')
);
return ApiResponse::handle(function () use ($request) {
return $this->taxInvoiceService->bulkIssue($request->getIds());
}, __('message.tax_invoice.bulk_issued'));
}
/**
@@ -115,12 +100,9 @@ public function bulkIssue(BulkIssueRequest $request)
*/
public function cancel(CancelTaxInvoiceRequest $request, int $id)
{
$taxInvoice = $this->taxInvoiceService->cancel($id, $request->validated()['reason']);
return ApiResponse::handle(
data: $taxInvoice,
message: __('message.tax_invoice.cancelled')
);
return ApiResponse::handle(function () use ($request, $id) {
return $this->taxInvoiceService->cancel($id, $request->validated()['reason']);
}, __('message.tax_invoice.cancelled'));
}
/**
@@ -128,12 +110,9 @@ public function cancel(CancelTaxInvoiceRequest $request, int $id)
*/
public function checkStatus(int $id)
{
$taxInvoice = $this->taxInvoiceService->checkStatus($id);
return ApiResponse::handle(
data: $taxInvoice,
message: __('message.fetched')
);
return ApiResponse::handle(function () use ($id) {
return $this->taxInvoiceService->checkStatus($id);
}, __('message.fetched'));
}
/**
@@ -141,11 +120,79 @@ public function checkStatus(int $id)
*/
public function summary(TaxInvoiceSummaryRequest $request)
{
$summary = $this->taxInvoiceService->summary($request->validated());
return ApiResponse::handle(function () use ($request) {
return $this->taxInvoiceService->summary($request->validated());
}, __('message.fetched'));
}
return ApiResponse::handle(
data: $summary,
message: __('message.fetched')
);
// =========================================================================
// 분개 (Journal Entries)
// =========================================================================
/**
* 세금계산서 분개 조회
*/
public function getJournalEntries(int $id): JsonResponse
{
return ApiResponse::handle(function () use ($id) {
$sourceKey = "tax_invoice_{$id}";
$data = $this->journalSyncService->getForSource(
JournalEntry::SOURCE_TAX_INVOICE,
$sourceKey
);
return $data ?? ['rows' => []];
}, __('message.fetched'));
}
/**
* 세금계산서 분개 저장/수정
*/
public function storeJournalEntries(Request $request, int $id): JsonResponse
{
return ApiResponse::handle(function () use ($request, $id) {
$validated = $request->validate([
'rows' => 'required|array|min:1',
'rows.*.side' => 'required|in:debit,credit',
'rows.*.account_subject' => 'required|string|max:20',
'rows.*.debit_amount' => 'required|integer|min:0',
'rows.*.credit_amount' => 'required|integer|min:0',
]);
// 세금계산서 정보 조회 (entry_date용)
$taxInvoice = $this->taxInvoiceService->show($id);
$rows = array_map(fn ($row) => [
'side' => $row['side'],
'account_code' => $row['account_subject'],
'debit_amount' => $row['debit_amount'],
'credit_amount' => $row['credit_amount'],
], $validated['rows']);
$sourceKey = "tax_invoice_{$id}";
return $this->journalSyncService->saveForSource(
JournalEntry::SOURCE_TAX_INVOICE,
$sourceKey,
$taxInvoice->issue_date?->format('Y-m-d') ?? now()->format('Y-m-d'),
"세금계산서 분개 (#{$id})",
$rows,
);
}, __('message.created'));
}
/**
* 세금계산서 분개 삭제
*/
public function deleteJournalEntries(int $id): JsonResponse
{
return ApiResponse::handle(function () use ($id) {
$sourceKey = "tax_invoice_{$id}";
return $this->journalSyncService->deleteForSource(
JournalEntry::SOURCE_TAX_INVOICE,
$sourceKey
);
}, __('message.deleted'));
}
}

View File

@@ -61,14 +61,18 @@ public function detail(Request $request): JsonResponse
: 0.05;
$year = $request->query('year') ? (int) $request->query('year') : null;
$quarter = $request->query('quarter') ? (int) $request->query('quarter') : null;
$startDate = $request->query('start_date');
$endDate = $request->query('end_date');
return ApiResponse::handle(function () use ($calculationType, $fixedAmountPerMonth, $ratio, $year, $quarter) {
return ApiResponse::handle(function () use ($calculationType, $fixedAmountPerMonth, $ratio, $year, $quarter, $startDate, $endDate) {
return $this->welfareService->getDetail(
$calculationType,
$fixedAmountPerMonth,
$ratio,
$year,
$quarter
$quarter,
$startDate,
$endDate
);
}, __('message.fetched'));
}

View File

@@ -20,18 +20,18 @@ public function rules(): array
'issue_type' => ['required', 'string', Rule::in(TaxInvoice::ISSUE_TYPES)],
'direction' => ['required', 'string', Rule::in(TaxInvoice::DIRECTIONS)],
// 공급자 정보
'supplier_corp_num' => ['required', 'string', 'max:20'],
'supplier_corp_name' => ['required', 'string', 'max:100'],
// 공급자 정보 (매입 시 필수, 매출 시 선택)
'supplier_corp_num' => ['required_if:direction,purchases', 'nullable', 'string', 'max:20'],
'supplier_corp_name' => ['required_if:direction,purchases', 'nullable', 'string', 'max:100'],
'supplier_ceo_name' => ['nullable', 'string', 'max:50'],
'supplier_addr' => ['nullable', 'string', 'max:200'],
'supplier_biz_type' => ['nullable', 'string', 'max:100'],
'supplier_biz_class' => ['nullable', 'string', 'max:100'],
'supplier_contact_id' => ['nullable', 'string', 'email', 'max:100'],
// 공급받는자 정보
'buyer_corp_num' => ['required', 'string', 'max:20'],
'buyer_corp_name' => ['required', 'string', 'max:100'],
// 공급받는자 정보 (매출 시 필수, 매입 시 선택)
'buyer_corp_num' => ['required_if:direction,sales', 'nullable', 'string', 'max:20'],
'buyer_corp_name' => ['required_if:direction,sales', 'nullable', 'string', 'max:100'],
'buyer_ceo_name' => ['nullable', 'string', 'max:50'],
'buyer_addr' => ['nullable', 'string', 'max:200'],
'buyer_biz_type' => ['nullable', 'string', 'max:100'],

View File

@@ -17,6 +17,12 @@ public function rules(): array
'code' => ['required', 'string', 'max:10'],
'name' => ['required', 'string', 'max:100'],
'category' => ['nullable', 'string', 'in:asset,liability,capital,revenue,expense'],
'sub_category' => ['nullable', 'string', 'max:50'],
'parent_code' => ['nullable', 'string', 'max:10'],
'depth' => ['nullable', 'integer', 'in:1,2,3'],
'department_type' => ['nullable', 'string', 'in:common,manufacturing,admin'],
'description' => ['nullable', 'string', 'max:500'],
'sort_order' => ['nullable', 'integer'],
];
}
@@ -26,6 +32,8 @@ public function messages(): array
'code.required' => '계정과목 코드를 입력하세요.',
'name.required' => '계정과목명을 입력하세요.',
'category.in' => '유효한 분류를 선택하세요.',
'depth.in' => '계층은 1(대), 2(중), 3(소) 중 하나여야 합니다.',
'department_type.in' => '부문은 common, manufacturing, admin 중 하나여야 합니다.',
];
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace App\Http\Requests\V1\AccountSubject;
use Illuminate\Foundation\Http\FormRequest;
class UpdateAccountSubjectRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'name' => ['sometimes', 'string', 'max:100'],
'category' => ['nullable', 'string', 'in:asset,liability,capital,revenue,expense'],
'sub_category' => ['nullable', 'string', 'max:50'],
'parent_code' => ['nullable', 'string', 'max:10'],
'depth' => ['nullable', 'integer', 'in:1,2,3'],
'department_type' => ['nullable', 'string', 'in:common,manufacturing,admin'],
'description' => ['nullable', 'string', 'max:500'],
'sort_order' => ['nullable', 'integer'],
];
}
public function messages(): array
{
return [
'category.in' => '유효한 분류를 선택하세요.',
'depth.in' => '계층은 1(대), 2(중), 3(소) 중 하나여야 합니다.',
'department_type.in' => '부문은 common, manufacturing, admin 중 하나여야 합니다.',
];
}
}

View File

@@ -15,16 +15,22 @@ class AccountCode extends Model
'code',
'name',
'category',
'sub_category',
'parent_code',
'depth',
'department_type',
'description',
'sort_order',
'is_active',
];
protected $casts = [
'depth' => 'integer',
'sort_order' => 'integer',
'is_active' => 'boolean',
];
// Categories
// Categories (대분류)
public const CATEGORY_ASSET = 'asset';
public const CATEGORY_LIABILITY = 'liability';
public const CATEGORY_CAPITAL = 'capital';
@@ -39,6 +45,36 @@ class AccountCode extends Model
self::CATEGORY_EXPENSE => '비용',
];
// Sub-categories (중분류)
public const SUB_CATEGORIES = [
'current_asset' => '유동자산',
'fixed_asset' => '비유동자산',
'current_liability' => '유동부채',
'long_term_liability' => '비유동부채',
'capital' => '자본',
'sales_revenue' => '매출',
'other_revenue' => '영업외수익',
'cogs' => '매출원가',
'selling_admin' => '판매비와관리비',
'other_expense' => '영업외비용',
];
// Department types (부문)
public const DEPT_COMMON = 'common';
public const DEPT_MANUFACTURING = 'manufacturing';
public const DEPT_ADMIN = 'admin';
public const DEPARTMENT_TYPES = [
self::DEPT_COMMON => '공통',
self::DEPT_MANUFACTURING => '제조',
self::DEPT_ADMIN => '관리',
];
// Depth levels (계층)
public const DEPTH_MAJOR = 1;
public const DEPTH_MIDDLE = 2;
public const DEPTH_MINOR = 3;
/**
* 활성 계정과목만 조회
*/
@@ -46,4 +82,21 @@ public function scopeActive(Builder $query): Builder
{
return $query->where('is_active', true);
}
/**
* 소분류(입력 가능 계정)만 조회
*/
public function scopeSelectable(Builder $query): Builder
{
return $query->where('depth', self::DEPTH_MINOR);
}
/**
* 하위 계정과목 관계
*/
public function children()
{
return $this->hasMany(self::class, 'parent_code', 'code')
->where('tenant_id', $this->tenant_id);
}
}

View File

@@ -35,6 +35,8 @@ class ExpenseAccount extends Model
'payment_method',
'card_no',
'loan_id',
'journal_entry_id',
'journal_entry_line_id',
'created_by',
'updated_by',
'deleted_by',

View File

@@ -39,6 +39,8 @@ class JournalEntry extends Model
// Source type
public const SOURCE_MANUAL = 'manual';
public const SOURCE_BANK_TRANSACTION = 'bank_transaction';
public const SOURCE_TAX_INVOICE = 'tax_invoice';
public const SOURCE_CARD_TRANSACTION = 'card_transaction';
// Entry type
public const TYPE_GENERAL = 'general';

View File

@@ -4,6 +4,7 @@
use App\Models\Tenants\AccountCode;
use App\Models\Tenants\JournalEntryLine;
use Illuminate\Support\Facades\DB;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
class AccountCodeService extends Service
@@ -27,12 +28,37 @@ public function index(array $params): array
});
}
// 분류 필터
// 분류 필터 (대분류)
if (! empty($params['category'])) {
$query->where('category', $params['category']);
}
return $query->orderBy('sort_order')->orderBy('code')->get()->toArray();
// 중분류 필터
if (! empty($params['sub_category'])) {
$query->where('sub_category', $params['sub_category']);
}
// 부문 필터
if (! empty($params['department_type'])) {
$query->where('department_type', $params['department_type']);
}
// 계층 필터
if (! empty($params['depth'])) {
$query->where('depth', (int) $params['depth']);
}
// 활성 상태 필터
if (isset($params['is_active'])) {
$query->where('is_active', filter_var($params['is_active'], FILTER_VALIDATE_BOOLEAN));
}
// 선택 가능한 계정만 (소분류만 = Select용)
if (! empty($params['selectable'])) {
$query->selectable();
}
return $query->orderBy('code')->orderBy('sort_order')->get()->toArray();
}
/**
@@ -57,6 +83,11 @@ public function store(array $data): AccountCode
$accountCode->code = $data['code'];
$accountCode->name = $data['name'];
$accountCode->category = $data['category'] ?? null;
$accountCode->sub_category = $data['sub_category'] ?? null;
$accountCode->parent_code = $data['parent_code'] ?? null;
$accountCode->depth = $data['depth'] ?? AccountCode::DEPTH_MINOR;
$accountCode->department_type = $data['department_type'] ?? AccountCode::DEPT_COMMON;
$accountCode->description = $data['description'] ?? null;
$accountCode->sort_order = $data['sort_order'] ?? 0;
$accountCode->is_active = true;
$accountCode->save();
@@ -64,6 +95,36 @@ public function store(array $data): AccountCode
return $accountCode;
}
/**
* 계정과목 수정
*/
public function update(int $id, array $data): AccountCode
{
$tenantId = $this->tenantId();
$accountCode = AccountCode::query()
->where('tenant_id', $tenantId)
->findOrFail($id);
// 코드 변경 시 중복 체크
if (isset($data['code']) && $data['code'] !== $accountCode->code) {
$exists = AccountCode::query()
->where('tenant_id', $tenantId)
->where('code', $data['code'])
->where('id', '!=', $id)
->exists();
if ($exists) {
throw new BadRequestHttpException(__('error.account_subject.duplicate_code'));
}
}
$accountCode->fill($data);
$accountCode->save();
return $accountCode;
}
/**
* 계정과목 활성/비활성 토글
*/
@@ -106,4 +167,242 @@ public function destroy(int $id): bool
return true;
}
/**
* 기본 계정과목표 일괄 생성 (초기 세팅)
*/
public function seedDefaults(): int
{
$tenantId = $this->tenantId();
$defaults = $this->getDefaultAccountCodes();
$insertedCount = 0;
DB::transaction(function () use ($tenantId, $defaults, &$insertedCount) {
foreach ($defaults as $item) {
$exists = AccountCode::query()
->where('tenant_id', $tenantId)
->where('code', $item['code'])
->exists();
if (! $exists) {
AccountCode::create(array_merge($item, ['tenant_id' => $tenantId]));
$insertedCount++;
}
}
});
return $insertedCount;
}
/**
* 기본 계정과목표 데이터 (더존 Smart A 표준 기반)
*
* 코드 체계: 5자리 (10100~99900)
* - 10100~24000: 자산
* - 25000~31700: 부채
* - 33100~38700: 자본
* - 40100~41000: 매출
* - 50100~53700: 매출원가/제조경비 (제조부문)
* - 80100~84800: 판매비와관리비 (관리부문)
* - 90100~99900: 영업외수익/비용
*
* 계층: depth 1(대분류) → depth 2(중분류) → depth 3(소분류=더존 실제코드)
*/
private function getDefaultAccountCodes(): array
{
$c = fn ($code, $name, $cat, $sub, $parent, $depth, $dept, $sort) => [
'code' => $code, 'name' => $name, 'category' => $cat,
'sub_category' => $sub, 'parent_code' => $parent,
'depth' => $depth, 'department_type' => $dept, 'sort_order' => $sort,
];
return [
// ============================================================
// 자산 (Assets)
// ============================================================
$c('1', '자산', 'asset', null, null, 1, 'common', 100),
// -- 유동자산 --
$c('11', '유동자산', 'asset', 'current_asset', '1', 2, 'common', 110),
$c('10100', '현금', 'asset', 'current_asset', '11', 3, 'common', 1010),
$c('10200', '당좌예금', 'asset', 'current_asset', '11', 3, 'common', 1020),
$c('10300', '보통예금', 'asset', 'current_asset', '11', 3, 'common', 1030),
$c('10400', '기타제예금', 'asset', 'current_asset', '11', 3, 'common', 1040),
$c('10500', '정기적금', 'asset', 'current_asset', '11', 3, 'common', 1050),
$c('10800', '외상매출금', 'asset', 'current_asset', '11', 3, 'common', 1080),
$c('10900', '대손충당금(외상매출금)', 'asset', 'current_asset', '11', 3, 'common', 1090),
$c('11000', '받을어음', 'asset', 'current_asset', '11', 3, 'common', 1100),
$c('11400', '단기대여금', 'asset', 'current_asset', '11', 3, 'common', 1140),
$c('11600', '미수수익', 'asset', 'current_asset', '11', 3, 'common', 1160),
$c('12000', '미수금', 'asset', 'current_asset', '11', 3, 'common', 1200),
$c('12200', '소모품', 'asset', 'current_asset', '11', 3, 'common', 1220),
$c('12500', '미환급세금', 'asset', 'current_asset', '11', 3, 'common', 1250),
$c('13100', '선급금', 'asset', 'current_asset', '11', 3, 'common', 1310),
$c('13300', '선급비용', 'asset', 'current_asset', '11', 3, 'common', 1330),
$c('13400', '가지급금', 'asset', 'current_asset', '11', 3, 'common', 1340),
$c('13500', '부가세대급금', 'asset', 'current_asset', '11', 3, 'common', 1350),
$c('13600', '선납세금', 'asset', 'current_asset', '11', 3, 'common', 1360),
$c('14000', '선납법인세', 'asset', 'current_asset', '11', 3, 'common', 1400),
// -- 재고자산 --
$c('12', '재고자산', 'asset', 'current_asset', '1', 2, 'common', 120),
$c('14600', '상품', 'asset', 'current_asset', '12', 3, 'common', 1460),
$c('15000', '제품', 'asset', 'current_asset', '12', 3, 'common', 1500),
$c('15300', '원재료', 'asset', 'current_asset', '12', 3, 'common', 1530),
$c('16200', '부재료', 'asset', 'current_asset', '12', 3, 'common', 1620),
$c('16700', '저장품', 'asset', 'current_asset', '12', 3, 'common', 1670),
$c('16900', '재공품', 'asset', 'current_asset', '12', 3, 'common', 1690),
// -- 비유동자산 --
$c('13', '비유동자산', 'asset', 'fixed_asset', '1', 2, 'common', 130),
$c('17600', '장기성예금', 'asset', 'fixed_asset', '13', 3, 'common', 1760),
$c('17900', '장기대여금', 'asset', 'fixed_asset', '13', 3, 'common', 1790),
$c('18700', '투자부동산', 'asset', 'fixed_asset', '13', 3, 'common', 1870),
$c('19200', '단체퇴직보험예치금', 'asset', 'fixed_asset', '13', 3, 'common', 1920),
$c('20100', '토지', 'asset', 'fixed_asset', '13', 3, 'common', 2010),
$c('20200', '건물', 'asset', 'fixed_asset', '13', 3, 'common', 2020),
$c('20300', '감가상각누계액(건물)', 'asset', 'fixed_asset', '13', 3, 'common', 2030),
$c('20400', '구축물', 'asset', 'fixed_asset', '13', 3, 'common', 2040),
$c('20500', '감가상각누계액(구축물)', 'asset', 'fixed_asset', '13', 3, 'common', 2050),
$c('20600', '기계장치', 'asset', 'fixed_asset', '13', 3, 'common', 2060),
$c('20700', '감가상각누계액(기계장치)', 'asset', 'fixed_asset', '13', 3, 'common', 2070),
$c('20800', '차량운반구', 'asset', 'fixed_asset', '13', 3, 'common', 2080),
$c('20900', '감가상각누계액(차량운반구)', 'asset', 'fixed_asset', '13', 3, 'common', 2090),
$c('21000', '공구와기구', 'asset', 'fixed_asset', '13', 3, 'common', 2100),
$c('21200', '비품', 'asset', 'fixed_asset', '13', 3, 'common', 2120),
$c('21300', '건설중인자산', 'asset', 'fixed_asset', '13', 3, 'common', 2130),
$c('24000', '소프트웨어', 'asset', 'fixed_asset', '13', 3, 'common', 2400),
// ============================================================
// 부채 (Liabilities)
// ============================================================
$c('2', '부채', 'liability', null, null, 1, 'common', 200),
// -- 유동부채 --
$c('21', '유동부채', 'liability', 'current_liability', '2', 2, 'common', 210),
$c('25100', '외상매입금', 'liability', 'current_liability', '21', 3, 'common', 2510),
$c('25200', '지급어음', 'liability', 'current_liability', '21', 3, 'common', 2520),
$c('25300', '미지급금', 'liability', 'current_liability', '21', 3, 'common', 2530),
$c('25400', '예수금', 'liability', 'current_liability', '21', 3, 'common', 2540),
$c('25500', '부가세예수금', 'liability', 'current_liability', '21', 3, 'common', 2550),
$c('25900', '선수금', 'liability', 'current_liability', '21', 3, 'common', 2590),
$c('26000', '단기차입금', 'liability', 'current_liability', '21', 3, 'common', 2600),
$c('26100', '미지급세금', 'liability', 'current_liability', '21', 3, 'common', 2610),
$c('26200', '미지급비용', 'liability', 'current_liability', '21', 3, 'common', 2620),
$c('26400', '유동성장기차입금', 'liability', 'current_liability', '21', 3, 'common', 2640),
$c('26500', '미지급배당금', 'liability', 'current_liability', '21', 3, 'common', 2650),
// -- 비유동부채 --
$c('22', '비유동부채', 'liability', 'long_term_liability', '2', 2, 'common', 220),
$c('29300', '장기차입금', 'liability', 'long_term_liability', '22', 3, 'common', 2930),
$c('29400', '임대보증금', 'liability', 'long_term_liability', '22', 3, 'common', 2940),
$c('29500', '퇴직급여충당부채', 'liability', 'long_term_liability', '22', 3, 'common', 2950),
$c('30700', '장기임대보증금', 'liability', 'long_term_liability', '22', 3, 'common', 3070),
// ============================================================
// 자본 (Capital)
// ============================================================
$c('3', '자본', 'capital', null, null, 1, 'common', 300),
// -- 자본금 --
$c('31', '자본금', 'capital', 'capital', '3', 2, 'common', 310),
$c('33100', '자본금', 'capital', 'capital', '31', 3, 'common', 3310),
$c('33200', '우선주자본금', 'capital', 'capital', '31', 3, 'common', 3320),
// -- 잉여금 --
$c('32', '잉여금', 'capital', 'capital', '3', 2, 'common', 320),
$c('34100', '주식발행초과금', 'capital', 'capital', '32', 3, 'common', 3410),
$c('35100', '이익준비금', 'capital', 'capital', '32', 3, 'common', 3510),
$c('37500', '이월이익잉여금', 'capital', 'capital', '32', 3, 'common', 3750),
$c('37900', '당기순이익', 'capital', 'capital', '32', 3, 'common', 3790),
// ============================================================
// 수익 (Revenue)
// ============================================================
$c('4', '수익', 'revenue', null, null, 1, 'common', 400),
// -- 매출 --
$c('41', '매출', 'revenue', 'sales_revenue', '4', 2, 'common', 410),
$c('40100', '상품매출', 'revenue', 'sales_revenue', '41', 3, 'common', 4010),
$c('40400', '제품매출', 'revenue', 'sales_revenue', '41', 3, 'common', 4040),
$c('40700', '공사수입금', 'revenue', 'sales_revenue', '41', 3, 'common', 4070),
$c('41000', '임대료수입', 'revenue', 'sales_revenue', '41', 3, 'common', 4100),
// -- 영업외수익 --
$c('42', '영업외수익', 'revenue', 'other_revenue', '4', 2, 'common', 420),
$c('90100', '이자수익', 'revenue', 'other_revenue', '42', 3, 'common', 9010),
$c('90300', '배당금수익', 'revenue', 'other_revenue', '42', 3, 'common', 9030),
$c('90400', '수입임대료', 'revenue', 'other_revenue', '42', 3, 'common', 9040),
$c('90700', '외환차익', 'revenue', 'other_revenue', '42', 3, 'common', 9070),
$c('93000', '잡이익', 'revenue', 'other_revenue', '42', 3, 'common', 9300),
// ============================================================
// 비용 (Expenses)
// ============================================================
$c('5', '비용', 'expense', null, null, 1, 'common', 500),
// -- 매출원가/제조원가 (제조부문) --
$c('51', '매출원가', 'expense', 'cogs', '5', 2, 'manufacturing', 510),
$c('50100', '원재료비', 'expense', 'cogs', '51', 3, 'manufacturing', 5010),
$c('50200', '외주가공비', 'expense', 'cogs', '51', 3, 'manufacturing', 5020),
$c('50300', '급여(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5030),
$c('50400', '임금', 'expense', 'cogs', '51', 3, 'manufacturing', 5040),
$c('50500', '상여금(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5050),
$c('50800', '퇴직급여(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5080),
$c('51100', '복리후생비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5110),
$c('51200', '여비교통비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5120),
$c('51300', '접대비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5130),
$c('51400', '통신비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5140),
$c('51600', '전력비', 'expense', 'cogs', '51', 3, 'manufacturing', 5160),
$c('51700', '세금과공과금(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5170),
$c('51800', '감가상각비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5180),
$c('51900', '지급임차료(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5190),
$c('52000', '수선비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5200),
$c('52100', '보험료(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5210),
$c('52200', '차량유지비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5220),
$c('52400', '운반비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5240),
$c('53000', '소모품비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5300),
$c('53100', '지급수수료(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5310),
// -- 판매비와관리비 (관리부문) --
$c('52', '판매비와관리비', 'expense', 'selling_admin', '5', 2, 'admin', 520),
$c('80100', '임원급여', 'expense', 'selling_admin', '52', 3, 'admin', 8010),
$c('80200', '직원급여', 'expense', 'selling_admin', '52', 3, 'admin', 8020),
$c('80300', '상여금', 'expense', 'selling_admin', '52', 3, 'admin', 8030),
$c('80600', '퇴직급여', 'expense', 'selling_admin', '52', 3, 'admin', 8060),
$c('81100', '복리후생비', 'expense', 'selling_admin', '52', 3, 'admin', 8110),
$c('81200', '여비교통비', 'expense', 'selling_admin', '52', 3, 'admin', 8120),
$c('81300', '접대비', 'expense', 'selling_admin', '52', 3, 'admin', 8130),
$c('81400', '통신비', 'expense', 'selling_admin', '52', 3, 'admin', 8140),
$c('81500', '수도광열비', 'expense', 'selling_admin', '52', 3, 'admin', 8150),
$c('81700', '세금과공과금', 'expense', 'selling_admin', '52', 3, 'admin', 8170),
$c('81800', '감가상각비', 'expense', 'selling_admin', '52', 3, 'admin', 8180),
$c('81900', '지급임차료', 'expense', 'selling_admin', '52', 3, 'admin', 8190),
$c('82000', '수선비', 'expense', 'selling_admin', '52', 3, 'admin', 8200),
$c('82100', '보험료', 'expense', 'selling_admin', '52', 3, 'admin', 8210),
$c('82200', '차량유지비', 'expense', 'selling_admin', '52', 3, 'admin', 8220),
$c('82300', '경상연구개발비', 'expense', 'selling_admin', '52', 3, 'admin', 8230),
$c('82400', '운반비', 'expense', 'selling_admin', '52', 3, 'admin', 8240),
$c('82500', '교육훈련비', 'expense', 'selling_admin', '52', 3, 'admin', 8250),
$c('82600', '도서인쇄비', 'expense', 'selling_admin', '52', 3, 'admin', 8260),
$c('82700', '회의비', 'expense', 'selling_admin', '52', 3, 'admin', 8270),
$c('82900', '사무용품비', 'expense', 'selling_admin', '52', 3, 'admin', 8290),
$c('83000', '소모품비', 'expense', 'selling_admin', '52', 3, 'admin', 8300),
$c('83100', '지급수수료', 'expense', 'selling_admin', '52', 3, 'admin', 8310),
$c('83200', '보관료', 'expense', 'selling_admin', '52', 3, 'admin', 8320),
$c('83300', '광고선전비', 'expense', 'selling_admin', '52', 3, 'admin', 8330),
$c('83500', '대손상각비', 'expense', 'selling_admin', '52', 3, 'admin', 8350),
$c('84800', '잡비', 'expense', 'selling_admin', '52', 3, 'admin', 8480),
// -- 영업외비용 --
$c('53', '영업외비용', 'expense', 'other_expense', '5', 2, 'common', 530),
$c('93100', '이자비용', 'expense', 'other_expense', '53', 3, 'common', 9310),
$c('93200', '외환차손', 'expense', 'other_expense', '53', 3, 'common', 9320),
$c('93300', '기부금', 'expense', 'other_expense', '53', 3, 'common', 9330),
$c('96000', '잡손실', 'expense', 'other_expense', '53', 3, 'common', 9600),
$c('99800', '법인세', 'expense', 'other_expense', '53', 3, 'common', 9980),
$c('99900', '소득세등', 'expense', 'other_expense', '53', 3, 'common', 9990),
];
}
}

View File

@@ -86,8 +86,8 @@ public function summary(array $params = []): array
// is_active=true인 악성채권만 통계
$query = BadDebt::query()
->where('tenant_id', $tenantId)
->where('is_active', true);
->where('bad_debts.tenant_id', $tenantId)
->where('bad_debts.is_active', true);
// 거래처 필터
if (! empty($params['client_id'])) {
@@ -110,6 +110,9 @@ public function summary(array $params = []): array
->distinct('client_id')
->count('client_id');
// per-card sub_label: 각 상태별 최다 금액 거래처명 + 건수
$subLabels = $this->buildPerCardSubLabels($query);
return [
'total_amount' => (float) $totalAmount,
'collecting_amount' => (float) $collectingAmount,
@@ -117,9 +120,56 @@ public function summary(array $params = []): array
'recovered_amount' => (float) $recoveredAmount,
'bad_debt_amount' => (float) $badDebtAmount,
'client_count' => $clientCount,
'sub_labels' => $subLabels,
];
}
/**
* 카드별 sub_label 생성 (최다 금액 거래처명 + 건수)
*/
private function buildPerCardSubLabels($baseQuery): array
{
$result = [];
$statusScopes = [
'dc1' => null, // 전체 (누적)
'dc2' => 'collecting', // 추심중
'dc3' => 'legalAction', // 법적조치
'dc4' => 'recovered', // 회수완료
];
foreach ($statusScopes as $cardId => $scope) {
$q = clone $baseQuery;
if ($scope) {
$q = $q->$scope();
}
$clientCount = (clone $q)->distinct('client_id')->count('client_id');
if ($clientCount <= 0) {
$result[$cardId] = null;
continue;
}
$topClient = (clone $q)
->join('clients', 'bad_debts.client_id', '=', 'clients.id')
->selectRaw('clients.name, SUM(bad_debts.debt_amount) as total_amount')
->groupBy('clients.id', 'clients.name')
->orderByDesc('total_amount')
->first();
if ($topClient) {
$result[$cardId] = $clientCount > 1
? $topClient->name.' 외 '.($clientCount - 1).'건'
: $topClient->name;
} else {
$result[$cardId] = null;
}
}
return $result;
}
/**
* 악성채권 상세 조회
*/

View File

@@ -5,11 +5,13 @@
use App\Models\Tenants\AccountCode;
use App\Models\Tenants\JournalEntry;
use App\Models\Tenants\JournalEntryLine;
use App\Traits\SyncsExpenseAccounts;
use Illuminate\Support\Facades\DB;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
class GeneralJournalEntryService extends Service
{
use SyncsExpenseAccounts;
/**
* 일반전표입력 통합 목록 (입금 + 출금 + 수기전표)
* deposits/withdrawals는 계좌이체 건만, LEFT JOIN journal_entries로 분개 여부 표시
@@ -326,6 +328,9 @@ public function store(array $data): JournalEntry
// 분개 행 생성
$this->createLines($entry, $data['rows'], $tenantId);
// expense_accounts 동기화 (복리후생비/접대비 → CEO 대시보드)
$this->syncExpenseAccounts($entry);
return $entry->load('lines');
});
}
@@ -373,6 +378,9 @@ public function updateJournal(int $id, array $data): JournalEntry
$entry->save();
// expense_accounts 동기화 (복리후생비/접대비 → CEO 대시보드)
$this->syncExpenseAccounts($entry);
return $entry->load('lines');
});
}
@@ -389,6 +397,9 @@ public function destroyJournal(int $id): bool
->where('tenant_id', $tenantId)
->findOrFail($id);
// expense_accounts 정리 (복리후생비/접대비 → CEO 대시보드)
$this->cleanupExpenseAccounts($tenantId, $entry->id);
// lines 먼저 삭제 (soft delete가 아니므로 물리 삭제)
JournalEntryLine::query()
->where('journal_entry_id', $entry->id)
@@ -503,6 +514,9 @@ private function resolveVendorName(?int $vendorId): string
return $vendor ? $vendor->name : '';
}
// syncExpenseAccounts, cleanupExpenseAccounts, getExpenseAccountType
// → SyncsExpenseAccounts 트레이트로 이관
/**
* 원본 거래 정보 조회 (입금/출금)
*/

View File

@@ -0,0 +1,214 @@
<?php
namespace App\Services;
use App\Models\Tenants\AccountCode;
use App\Models\Tenants\JournalEntry;
use App\Models\Tenants\JournalEntryLine;
use App\Traits\SyncsExpenseAccounts;
use Illuminate\Support\Facades\DB;
/**
* 세금계산서/카드거래 등 외부 소스의 분개 통합 관리 서비스
*
* journal_entries + journal_entry_lines에 저장하고
* 복리후생비/접대비는 expense_accounts에 동기화 (CEO 대시보드)
*/
class JournalSyncService extends Service
{
use SyncsExpenseAccounts;
/**
* 소스에 대한 분개 저장 (생성 또는 교체)
*
* @param string $sourceType JournalEntry::SOURCE_TAX_INVOICE 등
* @param string $sourceKey 'tax_invoice_123' 등
* @param string $entryDate 전표일자 (Y-m-d)
* @param string|null $description 적요
* @param array $rows 분개 행 [{side, account_code, account_name?, debit_amount, credit_amount, vendor_id?, vendor_name?, memo?}]
*/
public function saveForSource(
string $sourceType,
string $sourceKey,
string $entryDate,
?string $description,
array $rows,
): JournalEntry {
$tenantId = $this->tenantId();
return DB::transaction(function () use ($sourceType, $sourceKey, $entryDate, $description, $rows, $tenantId) {
// 기존 전표가 있으면 삭제 후 재생성 (교체 방식)
$existing = JournalEntry::query()
->where('tenant_id', $tenantId)
->where('source_type', $sourceType)
->where('source_key', $sourceKey)
->first();
if ($existing) {
$this->cleanupExpenseAccounts($tenantId, $existing->id);
JournalEntryLine::where('journal_entry_id', $existing->id)->delete();
$existing->forceDelete();
}
// 합계 계산
$totalDebit = 0;
$totalCredit = 0;
foreach ($rows as $row) {
$totalDebit += (int) ($row['debit_amount'] ?? 0);
$totalCredit += (int) ($row['credit_amount'] ?? 0);
}
// 전표번호 생성
$entryNo = $this->generateEntryNo($tenantId, $entryDate);
// 전표 생성
$entry = new JournalEntry;
$entry->tenant_id = $tenantId;
$entry->entry_no = $entryNo;
$entry->entry_date = $entryDate;
$entry->entry_type = JournalEntry::TYPE_GENERAL;
$entry->description = $description;
$entry->total_debit = $totalDebit;
$entry->total_credit = $totalCredit;
$entry->status = JournalEntry::STATUS_CONFIRMED;
$entry->source_type = $sourceType;
$entry->source_key = $sourceKey;
$entry->save();
// 분개 행 생성
foreach ($rows as $index => $row) {
$accountCode = $row['account_code'] ?? '';
$accountName = $row['account_name'] ?? $this->resolveAccountName($tenantId, $accountCode);
$line = new JournalEntryLine;
$line->tenant_id = $tenantId;
$line->journal_entry_id = $entry->id;
$line->line_no = $index + 1;
$line->dc_type = $row['side'];
$line->account_code = $accountCode;
$line->account_name = $accountName;
$line->trading_partner_id = ! empty($row['vendor_id']) ? (int) $row['vendor_id'] : null;
$line->trading_partner_name = $row['vendor_name'] ?? '';
$line->debit_amount = (int) ($row['debit_amount'] ?? 0);
$line->credit_amount = (int) ($row['credit_amount'] ?? 0);
$line->description = $row['memo'] ?? null;
$line->save();
}
// expense_accounts 동기화 (복리후생비/접대비 → CEO 대시보드)
$this->syncExpenseAccounts($entry);
return $entry->load('lines');
});
}
/**
* 소스에 대한 분개 조회
*/
public function getForSource(string $sourceType, string $sourceKey): ?array
{
$tenantId = $this->tenantId();
$entry = JournalEntry::query()
->where('tenant_id', $tenantId)
->where('source_type', $sourceType)
->where('source_key', $sourceKey)
->whereNull('deleted_at')
->with('lines')
->first();
if (! $entry) {
return null;
}
return [
'id' => $entry->id,
'entry_no' => $entry->entry_no,
'entry_date' => $entry->entry_date->format('Y-m-d'),
'description' => $entry->description,
'total_debit' => $entry->total_debit,
'total_credit' => $entry->total_credit,
'rows' => $entry->lines->map(function ($line) {
return [
'id' => $line->id,
'side' => $line->dc_type,
'account_code' => $line->account_code,
'account_name' => $line->account_name,
'vendor_id' => $line->trading_partner_id,
'vendor_name' => $line->trading_partner_name ?? '',
'debit_amount' => (int) $line->debit_amount,
'credit_amount' => (int) $line->credit_amount,
'memo' => $line->description ?? '',
];
})->toArray(),
];
}
/**
* 소스에 대한 분개 삭제
*/
public function deleteForSource(string $sourceType, string $sourceKey): bool
{
$tenantId = $this->tenantId();
return DB::transaction(function () use ($sourceType, $sourceKey, $tenantId) {
$entry = JournalEntry::query()
->where('tenant_id', $tenantId)
->where('source_type', $sourceType)
->where('source_key', $sourceKey)
->first();
if (! $entry) {
return false;
}
$this->cleanupExpenseAccounts($tenantId, $entry->id);
JournalEntryLine::where('journal_entry_id', $entry->id)->delete();
$entry->delete(); // soft delete
return true;
});
}
/**
* 전표번호 생성: JE-YYYYMMDD-NNN
*/
private function generateEntryNo(int $tenantId, string $date): string
{
$dateStr = str_replace('-', '', substr($date, 0, 10));
$prefix = "JE-{$dateStr}-";
$lastEntry = DB::table('journal_entries')
->where('tenant_id', $tenantId)
->where('entry_no', 'like', "{$prefix}%")
->lockForUpdate()
->orderBy('entry_no', 'desc')
->first(['entry_no']);
if ($lastEntry) {
$lastSeq = (int) substr($lastEntry->entry_no, -3);
$nextSeq = $lastSeq + 1;
} else {
$nextSeq = 1;
}
return $prefix . str_pad($nextSeq, 3, '0', STR_PAD_LEFT);
}
/**
* 계정과목 코드 → 이름 조회
*/
private function resolveAccountName(int $tenantId, string $code): string
{
if (empty($code)) {
return '';
}
$account = AccountCode::query()
->where('tenant_id', $tenantId)
->where('code', $code)
->first(['name']);
return $account ? $account->name : $code;
}
}

View File

@@ -67,16 +67,35 @@ private function getOrdersStatus(int $tenantId, Carbon $today): array
*/
private function getBadDebtStatus(int $tenantId): array
{
$count = BadDebt::query()
->where('tenant_id', $tenantId)
->where('status', BadDebt::STATUS_COLLECTING) // 추심 진행 중
->where('is_active', true) // 활성 채권만 (목록 페이지와 일치)
->count();
$query = BadDebt::query()
->where('bad_debts.tenant_id', $tenantId)
->where('bad_debts.status', BadDebt::STATUS_COLLECTING)
->where('bad_debts.is_active', true);
$count = (clone $query)->count();
// 최다 금액 거래처명 조회
$subLabel = null;
if ($count > 0) {
$topClient = (clone $query)
->join('clients', 'bad_debts.client_id', '=', 'clients.id')
->selectRaw('clients.name, SUM(bad_debts.debt_amount) as total_amount')
->groupBy('clients.id', 'clients.name')
->orderByDesc('total_amount')
->first();
if ($topClient) {
$subLabel = $count > 1
? $topClient->name.' 외 '.($count - 1).'건'
: $topClient->name;
}
}
return [
'id' => 'bad_debts',
'label' => __('message.status_board.bad_debts'),
'count' => $count,
'sub_label' => $subLabel,
'path' => '/accounting/bad-debt-collection',
'isHighlighted' => false,
];
@@ -152,15 +171,31 @@ private function getTaxDeadlineStatus(int $tenantId, Carbon $today): array
*/
private function getNewClientStatus(int $tenantId, Carbon $today): array
{
$count = Client::query()
$query = Client::query()
->where('tenant_id', $tenantId)
->where('created_at', '>=', $today->copy()->subDays(7))
->count();
->where('created_at', '>=', $today->copy()->subDays(7));
$count = (clone $query)->count();
// 가장 최근 등록 업체명 조회
$subLabel = null;
if ($count > 0) {
$latestClient = (clone $query)
->orderByDesc('created_at')
->first();
if ($latestClient) {
$subLabel = $count > 1
? $latestClient->name.' 외 '.($count - 1).'건'
: $latestClient->name;
}
}
return [
'id' => 'new_clients',
'label' => __('message.status_board.new_clients'),
'count' => $count,
'sub_label' => $subLabel,
'path' => '/accounting/vendors',
'isHighlighted' => false,
];
@@ -211,19 +246,33 @@ private function getPurchaseStatus(int $tenantId): array
*/
private function getApprovalStatus(int $tenantId, int $userId): array
{
$count = ApprovalStep::query()
->whereHas('approval', function ($query) use ($tenantId) {
$query->where('tenant_id', $tenantId)
$query = ApprovalStep::query()
->whereHas('approval', function ($q) use ($tenantId) {
$q->where('tenant_id', $tenantId)
->where('status', 'pending');
})
->where('approver_id', $userId)
->where('status', 'pending')
->count();
->where('status', 'pending');
$count = (clone $query)->count();
// 최근 결재 유형 조회
$subLabel = null;
if ($count > 0) {
$latestStep = (clone $query)->with('approval')->latest()->first();
if ($latestStep && $latestStep->approval) {
$typeLabel = $latestStep->approval->title ?? '결재';
$subLabel = $count > 1
? $typeLabel.' 외 '.($count - 1).'건'
: $typeLabel;
}
}
return [
'id' => 'approvals',
'label' => __('message.status_board.approvals'),
'count' => $count,
'sub_label' => $subLabel,
'path' => '/approval/inbox',
'isHighlighted' => $count > 0,
];

View File

@@ -112,6 +112,12 @@ public function create(array $data): TaxInvoice
// 합계금액 계산
$data['total_amount'] = ($data['supply_amount'] ?? 0) + ($data['tax_amount'] ?? 0);
// NOT NULL 컬럼: Laravel ConvertEmptyStringsToNull 미들웨어가 ''→null 변환하므로 보정
$data['supplier_corp_num'] = $data['supplier_corp_num'] ?? '';
$data['supplier_corp_name'] = $data['supplier_corp_name'] ?? '';
$data['buyer_corp_num'] = $data['buyer_corp_num'] ?? '';
$data['buyer_corp_name'] = $data['buyer_corp_name'] ?? '';
$taxInvoice = TaxInvoice::create(array_merge($data, [
'tenant_id' => $tenantId,
'status' => TaxInvoice::STATUS_DRAFT,

View File

@@ -498,7 +498,9 @@ public function getDetail(
?int $fixedAmountPerMonth = 200000,
?float $ratio = 0.05,
?int $year = null,
?int $quarter = null
?int $quarter = null,
?string $startDate = null,
?string $endDate = null
): array {
$tenantId = $this->tenantId();
$now = Carbon::now();
@@ -562,8 +564,10 @@ public function getDetail(
// 3. 항목별 분포
$categoryDistribution = $this->getCategoryDistribution($tenantId, $annualStartDate, $annualEndDate);
// 4. 일별 사용 내역
$transactions = $this->getTransactions($tenantId, $quarterStartDate, $quarterEndDate);
// 4. 일별 사용 내역 (커스텀 날짜 범위가 있으면 해당 범위, 없으면 분기 기준)
$txStartDate = $startDate ?? $quarterStartDate;
$txEndDate = $endDate ?? $quarterEndDate;
$transactions = $this->getTransactions($tenantId, $txStartDate, $txEndDate);
// 5. 계산 정보
$calculation = [

View File

@@ -0,0 +1,98 @@
<?php
namespace App\Traits;
use App\Models\Tenants\ExpenseAccount;
use App\Models\Tenants\JournalEntry;
/**
* 전표 저장/수정/삭제 시 expense_accounts 동기화 (복리후생비/접대비 → CEO 대시보드)
*
* 사용처: GeneralJournalEntryService, JournalSyncService
*/
trait SyncsExpenseAccounts
{
/**
* 계정과목명 → expense_accounts account_type 매핑
*/
private static array $expenseAccountMap = [
'복리후생비' => ExpenseAccount::TYPE_WELFARE,
'접대비' => ExpenseAccount::TYPE_ENTERTAINMENT,
];
/**
* 전표 저장/수정 후 expense_accounts 동기화
* 복리후생비/접대비 계정과목이 포함된 lines → expense_accounts에 반영
*/
protected function syncExpenseAccounts(JournalEntry $entry): void
{
$tenantId = $entry->tenant_id;
// 1. 기존 이 전표에서 생성된 expense_accounts 삭제
ExpenseAccount::where('tenant_id', $tenantId)
->where('journal_entry_id', $entry->id)
->forceDelete();
// 2. 현재 lines 중 복리후생비/접대비 해당하는 것만 insert
$lines = $entry->lines()->get();
foreach ($lines as $line) {
$accountType = $this->getExpenseAccountType($line->account_name);
if (! $accountType) {
continue;
}
// 차변(debit)이 대변보다 큰 경우만 비용 발생으로 처리
$amount = $line->debit_amount - $line->credit_amount;
if ($amount <= 0) {
continue;
}
// source_type에 따라 payment_method 결정
$paymentMethod = match ($entry->source_type) {
JournalEntry::SOURCE_CARD_TRANSACTION => ExpenseAccount::PAYMENT_CARD,
default => ExpenseAccount::PAYMENT_TRANSFER,
};
ExpenseAccount::create([
'tenant_id' => $tenantId,
'account_type' => $accountType,
'sub_type' => null,
'expense_date' => $entry->entry_date,
'amount' => $amount,
'description' => $line->description ?? $entry->description,
'receipt_no' => null,
'vendor_id' => $line->trading_partner_id,
'vendor_name' => $line->trading_partner_name,
'payment_method' => $paymentMethod,
'card_no' => null,
'journal_entry_id' => $entry->id,
'journal_entry_line_id' => $line->id,
]);
}
}
/**
* 전표 삭제 시 expense_accounts 정리
*/
protected function cleanupExpenseAccounts(int $tenantId, int $entryId): void
{
ExpenseAccount::where('tenant_id', $tenantId)
->where('journal_entry_id', $entryId)
->forceDelete();
}
/**
* 계정과목명에서 비용 유형 판별
*/
private function getExpenseAccountType(string $accountName): ?string
{
foreach (self::$expenseAccountMap as $keyword => $type) {
if (str_contains($accountName, $keyword)) {
return $type;
}
}
return null;
}
}

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('expense_accounts', function (Blueprint $table) {
$table->unsignedBigInteger('journal_entry_id')->nullable()->after('loan_id');
$table->unsignedBigInteger('journal_entry_line_id')->nullable()->after('journal_entry_id');
$table->index(['tenant_id', 'journal_entry_id']);
$table->index(['journal_entry_line_id']);
});
}
public function down(): void
{
Schema::table('expense_accounts', function (Blueprint $table) {
$table->dropIndex(['tenant_id', 'journal_entry_id']);
$table->dropIndex(['journal_entry_line_id']);
$table->dropColumn(['journal_entry_id', 'journal_entry_line_id']);
});
}
};

View File

@@ -0,0 +1,54 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 계정과목 마스터 확장
*
* - sub_category: 중분류 (유동자산, 판관비, 매출원가 등)
* - parent_code: 상위 계정과목 코드 (계층 구조)
* - depth: 계층 깊이 (1=대, 2=중, 3=소)
* - department_type: 부문 (common=공통, manufacturing=제조, admin=관리)
* - description: 계정과목 설명
*/
public function up(): void
{
Schema::table('account_codes', function (Blueprint $table) {
$table->string('sub_category', 50)->nullable()->after('category')
->comment('중분류 (current_asset, fixed_asset, selling_admin, cogs 등)');
$table->string('parent_code', 10)->nullable()->after('sub_category')
->comment('상위 계정과목 코드 (계층 구조)');
$table->tinyInteger('depth')->default(3)->after('parent_code')
->comment('계층 깊이 (1=대분류, 2=중분류, 3=소분류)');
$table->string('department_type', 20)->default('common')->after('depth')
->comment('부문 (common=공통, manufacturing=제조, admin=관리)');
$table->string('description', 500)->nullable()->after('department_type')
->comment('계정과목 설명');
$table->index(['tenant_id', 'category'], 'account_codes_tenant_category_idx');
$table->index(['tenant_id', 'parent_code'], 'account_codes_tenant_parent_idx');
$table->index(['tenant_id', 'depth'], 'account_codes_tenant_depth_idx');
});
}
public function down(): void
{
Schema::table('account_codes', function (Blueprint $table) {
$table->dropIndex('account_codes_tenant_category_idx');
$table->dropIndex('account_codes_tenant_parent_idx');
$table->dropIndex('account_codes_tenant_depth_idx');
$table->dropColumn([
'sub_category',
'parent_code',
'depth',
'department_type',
'description',
]);
});
}
};

View File

@@ -0,0 +1,218 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
/**
* 모든 기존 테넌트에 더존 Smart A 표준 계정과목 128건 자동 시드
*
* 조건: tenant_id + code 중복 시 skip (기존 데이터 보호)
*/
return new class extends Migration
{
public function up(): void
{
$tenantIds = DB::table('tenants')
->whereNull('deleted_at')
->pluck('id');
$defaults = $this->getDefaultAccountCodes();
$now = now();
foreach ($tenantIds as $tenantId) {
// 이미 등록된 코드 조회
$existingCodes = DB::table('account_codes')
->where('tenant_id', $tenantId)
->pluck('code')
->toArray();
$inserts = [];
foreach ($defaults as $item) {
if (! in_array($item['code'], $existingCodes)) {
$inserts[] = array_merge($item, [
'tenant_id' => $tenantId,
'is_active' => true,
'created_at' => $now,
'updated_at' => $now,
]);
}
}
if (! empty($inserts)) {
// 500건 단위 청크 insert
foreach (array_chunk($inserts, 500) as $chunk) {
DB::table('account_codes')->insert($chunk);
}
}
}
}
public function down(): void
{
// 시드 데이터만 롤백 (수동 추가 데이터는 보호)
$defaultCodes = array_column($this->getDefaultAccountCodes(), 'code');
DB::table('account_codes')
->whereIn('code', $defaultCodes)
->delete();
}
private function getDefaultAccountCodes(): array
{
$c = fn ($code, $name, $cat, $sub, $parent, $depth, $dept, $sort) => [
'code' => $code, 'name' => $name, 'category' => $cat,
'sub_category' => $sub, 'parent_code' => $parent,
'depth' => $depth, 'department_type' => $dept, 'sort_order' => $sort,
];
return [
// 자산 (Assets)
$c('1', '자산', 'asset', null, null, 1, 'common', 100),
$c('11', '유동자산', 'asset', 'current_asset', '1', 2, 'common', 110),
$c('10100', '현금', 'asset', 'current_asset', '11', 3, 'common', 1010),
$c('10200', '당좌예금', 'asset', 'current_asset', '11', 3, 'common', 1020),
$c('10300', '보통예금', 'asset', 'current_asset', '11', 3, 'common', 1030),
$c('10400', '기타제예금', 'asset', 'current_asset', '11', 3, 'common', 1040),
$c('10500', '정기적금', 'asset', 'current_asset', '11', 3, 'common', 1050),
$c('10800', '외상매출금', 'asset', 'current_asset', '11', 3, 'common', 1080),
$c('10900', '대손충당금(외상매출금)', 'asset', 'current_asset', '11', 3, 'common', 1090),
$c('11000', '받을어음', 'asset', 'current_asset', '11', 3, 'common', 1100),
$c('11400', '단기대여금', 'asset', 'current_asset', '11', 3, 'common', 1140),
$c('11600', '미수수익', 'asset', 'current_asset', '11', 3, 'common', 1160),
$c('12000', '미수금', 'asset', 'current_asset', '11', 3, 'common', 1200),
$c('12200', '소모품', 'asset', 'current_asset', '11', 3, 'common', 1220),
$c('12500', '미환급세금', 'asset', 'current_asset', '11', 3, 'common', 1250),
$c('13100', '선급금', 'asset', 'current_asset', '11', 3, 'common', 1310),
$c('13300', '선급비용', 'asset', 'current_asset', '11', 3, 'common', 1330),
$c('13400', '가지급금', 'asset', 'current_asset', '11', 3, 'common', 1340),
$c('13500', '부가세대급금', 'asset', 'current_asset', '11', 3, 'common', 1350),
$c('13600', '선납세금', 'asset', 'current_asset', '11', 3, 'common', 1360),
$c('14000', '선납법인세', 'asset', 'current_asset', '11', 3, 'common', 1400),
$c('12', '재고자산', 'asset', 'current_asset', '1', 2, 'common', 120),
$c('14600', '상품', 'asset', 'current_asset', '12', 3, 'common', 1460),
$c('15000', '제품', 'asset', 'current_asset', '12', 3, 'common', 1500),
$c('15300', '원재료', 'asset', 'current_asset', '12', 3, 'common', 1530),
$c('16200', '부재료', 'asset', 'current_asset', '12', 3, 'common', 1620),
$c('16700', '저장품', 'asset', 'current_asset', '12', 3, 'common', 1670),
$c('16900', '재공품', 'asset', 'current_asset', '12', 3, 'common', 1690),
$c('13', '비유동자산', 'asset', 'fixed_asset', '1', 2, 'common', 130),
$c('17600', '장기성예금', 'asset', 'fixed_asset', '13', 3, 'common', 1760),
$c('17900', '장기대여금', 'asset', 'fixed_asset', '13', 3, 'common', 1790),
$c('18700', '투자부동산', 'asset', 'fixed_asset', '13', 3, 'common', 1870),
$c('19200', '단체퇴직보험예치금', 'asset', 'fixed_asset', '13', 3, 'common', 1920),
$c('20100', '토지', 'asset', 'fixed_asset', '13', 3, 'common', 2010),
$c('20200', '건물', 'asset', 'fixed_asset', '13', 3, 'common', 2020),
$c('20300', '감가상각누계액(건물)', 'asset', 'fixed_asset', '13', 3, 'common', 2030),
$c('20400', '구축물', 'asset', 'fixed_asset', '13', 3, 'common', 2040),
$c('20500', '감가상각누계액(구축물)', 'asset', 'fixed_asset', '13', 3, 'common', 2050),
$c('20600', '기계장치', 'asset', 'fixed_asset', '13', 3, 'common', 2060),
$c('20700', '감가상각누계액(기계장치)', 'asset', 'fixed_asset', '13', 3, 'common', 2070),
$c('20800', '차량운반구', 'asset', 'fixed_asset', '13', 3, 'common', 2080),
$c('20900', '감가상각누계액(차량운반구)', 'asset', 'fixed_asset', '13', 3, 'common', 2090),
$c('21000', '공구와기구', 'asset', 'fixed_asset', '13', 3, 'common', 2100),
$c('21200', '비품', 'asset', 'fixed_asset', '13', 3, 'common', 2120),
$c('21300', '건설중인자산', 'asset', 'fixed_asset', '13', 3, 'common', 2130),
$c('24000', '소프트웨어', 'asset', 'fixed_asset', '13', 3, 'common', 2400),
// 부채 (Liabilities)
$c('2', '부채', 'liability', null, null, 1, 'common', 200),
$c('21', '유동부채', 'liability', 'current_liability', '2', 2, 'common', 210),
$c('25100', '외상매입금', 'liability', 'current_liability', '21', 3, 'common', 2510),
$c('25200', '지급어음', 'liability', 'current_liability', '21', 3, 'common', 2520),
$c('25300', '미지급금', 'liability', 'current_liability', '21', 3, 'common', 2530),
$c('25400', '예수금', 'liability', 'current_liability', '21', 3, 'common', 2540),
$c('25500', '부가세예수금', 'liability', 'current_liability', '21', 3, 'common', 2550),
$c('25900', '선수금', 'liability', 'current_liability', '21', 3, 'common', 2590),
$c('26000', '단기차입금', 'liability', 'current_liability', '21', 3, 'common', 2600),
$c('26100', '미지급세금', 'liability', 'current_liability', '21', 3, 'common', 2610),
$c('26200', '미지급비용', 'liability', 'current_liability', '21', 3, 'common', 2620),
$c('26400', '유동성장기차입금', 'liability', 'current_liability', '21', 3, 'common', 2640),
$c('26500', '미지급배당금', 'liability', 'current_liability', '21', 3, 'common', 2650),
$c('22', '비유동부채', 'liability', 'long_term_liability', '2', 2, 'common', 220),
$c('29300', '장기차입금', 'liability', 'long_term_liability', '22', 3, 'common', 2930),
$c('29400', '임대보증금', 'liability', 'long_term_liability', '22', 3, 'common', 2940),
$c('29500', '퇴직급여충당부채', 'liability', 'long_term_liability', '22', 3, 'common', 2950),
$c('30700', '장기임대보증금', 'liability', 'long_term_liability', '22', 3, 'common', 3070),
// 자본 (Capital)
$c('3', '자본', 'capital', null, null, 1, 'common', 300),
$c('31', '자본금', 'capital', 'capital', '3', 2, 'common', 310),
$c('33100', '자본금', 'capital', 'capital', '31', 3, 'common', 3310),
$c('33200', '우선주자본금', 'capital', 'capital', '31', 3, 'common', 3320),
$c('32', '잉여금', 'capital', 'capital', '3', 2, 'common', 320),
$c('34100', '주식발행초과금', 'capital', 'capital', '32', 3, 'common', 3410),
$c('35100', '이익준비금', 'capital', 'capital', '32', 3, 'common', 3510),
$c('37500', '이월이익잉여금', 'capital', 'capital', '32', 3, 'common', 3750),
$c('37900', '당기순이익', 'capital', 'capital', '32', 3, 'common', 3790),
// 수익 (Revenue)
$c('4', '수익', 'revenue', null, null, 1, 'common', 400),
$c('41', '매출', 'revenue', 'sales_revenue', '4', 2, 'common', 410),
$c('40100', '상품매출', 'revenue', 'sales_revenue', '41', 3, 'common', 4010),
$c('40400', '제품매출', 'revenue', 'sales_revenue', '41', 3, 'common', 4040),
$c('40700', '공사수입금', 'revenue', 'sales_revenue', '41', 3, 'common', 4070),
$c('41000', '임대료수입', 'revenue', 'sales_revenue', '41', 3, 'common', 4100),
$c('42', '영업외수익', 'revenue', 'other_revenue', '4', 2, 'common', 420),
$c('90100', '이자수익', 'revenue', 'other_revenue', '42', 3, 'common', 9010),
$c('90300', '배당금수익', 'revenue', 'other_revenue', '42', 3, 'common', 9030),
$c('90400', '수입임대료', 'revenue', 'other_revenue', '42', 3, 'common', 9040),
$c('90700', '외환차익', 'revenue', 'other_revenue', '42', 3, 'common', 9070),
$c('93000', '잡이익', 'revenue', 'other_revenue', '42', 3, 'common', 9300),
// 비용 (Expenses)
$c('5', '비용', 'expense', null, null, 1, 'common', 500),
$c('51', '매출원가', 'expense', 'cogs', '5', 2, 'manufacturing', 510),
$c('50100', '원재료비', 'expense', 'cogs', '51', 3, 'manufacturing', 5010),
$c('50200', '외주가공비', 'expense', 'cogs', '51', 3, 'manufacturing', 5020),
$c('50300', '급여(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5030),
$c('50400', '임금', 'expense', 'cogs', '51', 3, 'manufacturing', 5040),
$c('50500', '상여금(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5050),
$c('50800', '퇴직급여(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5080),
$c('51100', '복리후생비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5110),
$c('51200', '여비교통비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5120),
$c('51300', '접대비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5130),
$c('51400', '통신비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5140),
$c('51600', '전력비', 'expense', 'cogs', '51', 3, 'manufacturing', 5160),
$c('51700', '세금과공과금(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5170),
$c('51800', '감가상각비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5180),
$c('51900', '지급임차료(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5190),
$c('52000', '수선비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5200),
$c('52100', '보험료(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5210),
$c('52200', '차량유지비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5220),
$c('52400', '운반비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5240),
$c('53000', '소모품비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5300),
$c('53100', '지급수수료(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5310),
$c('52', '판매비와관리비', 'expense', 'selling_admin', '5', 2, 'admin', 520),
$c('80100', '임원급여', 'expense', 'selling_admin', '52', 3, 'admin', 8010),
$c('80200', '직원급여', 'expense', 'selling_admin', '52', 3, 'admin', 8020),
$c('80300', '상여금', 'expense', 'selling_admin', '52', 3, 'admin', 8030),
$c('80600', '퇴직급여', 'expense', 'selling_admin', '52', 3, 'admin', 8060),
$c('81100', '복리후생비', 'expense', 'selling_admin', '52', 3, 'admin', 8110),
$c('81200', '여비교통비', 'expense', 'selling_admin', '52', 3, 'admin', 8120),
$c('81300', '접대비', 'expense', 'selling_admin', '52', 3, 'admin', 8130),
$c('81400', '통신비', 'expense', 'selling_admin', '52', 3, 'admin', 8140),
$c('81500', '수도광열비', 'expense', 'selling_admin', '52', 3, 'admin', 8150),
$c('81700', '세금과공과금', 'expense', 'selling_admin', '52', 3, 'admin', 8170),
$c('81800', '감가상각비', 'expense', 'selling_admin', '52', 3, 'admin', 8180),
$c('81900', '지급임차료', 'expense', 'selling_admin', '52', 3, 'admin', 8190),
$c('82000', '수선비', 'expense', 'selling_admin', '52', 3, 'admin', 8200),
$c('82100', '보험료', 'expense', 'selling_admin', '52', 3, 'admin', 8210),
$c('82200', '차량유지비', 'expense', 'selling_admin', '52', 3, 'admin', 8220),
$c('82300', '경상연구개발비', 'expense', 'selling_admin', '52', 3, 'admin', 8230),
$c('82400', '운반비', 'expense', 'selling_admin', '52', 3, 'admin', 8240),
$c('82500', '교육훈련비', 'expense', 'selling_admin', '52', 3, 'admin', 8250),
$c('82600', '도서인쇄비', 'expense', 'selling_admin', '52', 3, 'admin', 8260),
$c('82700', '회의비', 'expense', 'selling_admin', '52', 3, 'admin', 8270),
$c('82900', '사무용품비', 'expense', 'selling_admin', '52', 3, 'admin', 8290),
$c('83000', '소모품비', 'expense', 'selling_admin', '52', 3, 'admin', 8300),
$c('83100', '지급수수료', 'expense', 'selling_admin', '52', 3, 'admin', 8310),
$c('83200', '보관료', 'expense', 'selling_admin', '52', 3, 'admin', 8320),
$c('83300', '광고선전비', 'expense', 'selling_admin', '52', 3, 'admin', 8330),
$c('83500', '대손상각비', 'expense', 'selling_admin', '52', 3, 'admin', 8350),
$c('84800', '잡비', 'expense', 'selling_admin', '52', 3, 'admin', 8480),
$c('53', '영업외비용', 'expense', 'other_expense', '5', 2, 'common', 530),
$c('93100', '이자비용', 'expense', 'other_expense', '53', 3, 'common', 9310),
$c('93200', '외환차손', 'expense', 'other_expense', '53', 3, 'common', 9320),
$c('93300', '기부금', 'expense', 'other_expense', '53', 3, 'common', 9330),
$c('96000', '잡손실', 'expense', 'other_expense', '53', 3, 'common', 9600),
$c('99800', '법인세', 'expense', 'other_expense', '53', 3, 'common', 9980),
$c('99900', '소득세등', 'expense', 'other_expense', '53', 3, 'common', 9990),
];
}
};

View File

@@ -0,0 +1,467 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
/**
* 더존 Smart A 표준 계정과목 추가 시드 — 기획서 14장 기준 누락분 보완
*
* 조건: tenant_id + code 중복 시 skip (기존 데이터 보호)
*/
return new class extends Migration
{
public function up(): void
{
$tenantIds = DB::table('tenants')
->whereNull('deleted_at')
->pluck('id');
$defaults = $this->getAdditionalAccountCodes();
$now = now();
foreach ($tenantIds as $tenantId) {
$existingCodes = DB::table('account_codes')
->where('tenant_id', $tenantId)
->pluck('code')
->toArray();
$inserts = [];
foreach ($defaults as $item) {
if (! in_array($item['code'], $existingCodes)) {
$inserts[] = array_merge($item, [
'tenant_id' => $tenantId,
'is_active' => true,
'created_at' => $now,
'updated_at' => $now,
]);
}
}
if (! empty($inserts)) {
foreach (array_chunk($inserts, 500) as $chunk) {
DB::table('account_codes')->insert($chunk);
}
}
}
}
public function down(): void
{
$codes = array_column($this->getAdditionalAccountCodes(), 'code');
DB::table('account_codes')->whereIn('code', $codes)->delete();
}
private function getAdditionalAccountCodes(): array
{
$c = fn ($code, $name, $cat, $sub, $parent, $depth, $dept, $sort) => [
'code' => $code, 'name' => $name, 'category' => $cat,
'sub_category' => $sub, 'parent_code' => $parent,
'depth' => $depth, 'department_type' => $dept, 'sort_order' => $sort,
];
return [
// ================================================================
// 새 depth-2 카테고리
// ================================================================
$c('33', '자본조정', 'capital', 'capital_adjustment', '3', 2, 'common', 330),
$c('54', '건설원가', 'expense', 'construction_cost', '5', 2, 'construction', 540),
// ================================================================
// 자산 — 유동자산 추가 (parent: '11')
// ================================================================
$c('10600', '기타단기금융상품예금', 'asset', 'current_asset', '11', 3, 'common', 1060),
$c('10700', '단기투자자산', 'asset', 'current_asset', '11', 3, 'common', 1070),
$c('11100', '대손충당금(받을어음)', 'asset', 'current_asset', '11', 3, 'common', 1110),
$c('11200', '공사미수금', 'asset', 'current_asset', '11', 3, 'common', 1120),
$c('11300', '대손충당금(공사미수금)', 'asset', 'current_asset', '11', 3, 'common', 1130),
$c('11500', '대손충당금(단기대여금)', 'asset', 'current_asset', '11', 3, 'common', 1150),
$c('11700', '대손충당금(미수수익)', 'asset', 'current_asset', '11', 3, 'common', 1170),
$c('11800', '분양미수금', 'asset', 'current_asset', '11', 3, 'common', 1180),
$c('11900', '대손충당금(분양미수금)', 'asset', 'current_asset', '11', 3, 'common', 1190),
$c('12100', '대손충당금(미수금)', 'asset', 'current_asset', '11', 3, 'common', 1210),
$c('12300', '매도가능증권', 'asset', 'current_asset', '11', 3, 'common', 1230),
$c('12400', '만기보유증권', 'asset', 'current_asset', '11', 3, 'common', 1240),
$c('13200', '대손충당금(선급금)', 'asset', 'current_asset', '11', 3, 'common', 1320),
$c('13700', '주임종단기채권', 'asset', 'current_asset', '11', 3, 'common', 1370),
$c('13800', '전도금', 'asset', 'current_asset', '11', 3, 'common', 1380),
$c('13900', '선급공사비', 'asset', 'current_asset', '11', 3, 'common', 1390),
// ================================================================
// 자산 — 재고자산 추가 (parent: '12')
// ================================================================
$c('14700', '매입환출및에누리(상품)', 'asset', 'current_asset', '12', 3, 'common', 1470),
$c('14800', '매입할인(상품)', 'asset', 'current_asset', '12', 3, 'common', 1480),
$c('14900', '관세환급금(상품)', 'asset', 'current_asset', '12', 3, 'common', 1490),
$c('15100', '관세환급금(제품)', 'asset', 'current_asset', '12', 3, 'common', 1510),
$c('15200', '완성건물', 'asset', 'current_asset', '12', 3, 'common', 1520),
$c('15400', '매입환출및에누리(원재료)', 'asset', 'current_asset', '12', 3, 'common', 1540),
$c('15500', '매입할인(원재료)', 'asset', 'current_asset', '12', 3, 'common', 1550),
$c('15600', '원재료(도급)', 'asset', 'current_asset', '12', 3, 'common', 1560),
$c('15700', '매입환출및에누리(원재료-도급)', 'asset', 'current_asset', '12', 3, 'common', 1570),
$c('15800', '매입할인(원재료-도급)', 'asset', 'current_asset', '12', 3, 'common', 1580),
$c('15900', '원재료(분양)', 'asset', 'current_asset', '12', 3, 'common', 1590),
$c('16000', '매입환출및에누리(원재료-분양)', 'asset', 'current_asset', '12', 3, 'common', 1600),
$c('16100', '매입할인(원재료-분양)', 'asset', 'current_asset', '12', 3, 'common', 1610),
$c('16300', '매입환출및에누리(부재료)', 'asset', 'current_asset', '12', 3, 'common', 1630),
$c('16400', '매입할인(부재료)', 'asset', 'current_asset', '12', 3, 'common', 1640),
$c('16500', '건설용지', 'asset', 'current_asset', '12', 3, 'common', 1650),
$c('16600', '가설재', 'asset', 'current_asset', '12', 3, 'common', 1660),
$c('16800', '미착품', 'asset', 'current_asset', '12', 3, 'common', 1680),
$c('17000', '미완성공사(도급)', 'asset', 'current_asset', '12', 3, 'common', 1700),
$c('17100', '미완성공사(분양)', 'asset', 'current_asset', '12', 3, 'common', 1710),
// ================================================================
// 자산 — 비유동자산 추가 (parent: '13')
// ================================================================
$c('17700', '특정현금과예금', 'asset', 'fixed_asset', '13', 3, 'common', 1770),
$c('17800', '장기투자증권', 'asset', 'fixed_asset', '13', 3, 'common', 1780),
$c('18000', '대손충당금(장기대여금)', 'asset', 'fixed_asset', '13', 3, 'common', 1800),
$c('18100', '만기보유증권(장기)', 'asset', 'fixed_asset', '13', 3, 'common', 1810),
$c('18200', '지분법적용투자주식', 'asset', 'fixed_asset', '13', 3, 'common', 1820),
$c('19100', '출자금', 'asset', 'fixed_asset', '13', 3, 'common', 1910),
$c('19700', '투자임대계약자산', 'asset', 'fixed_asset', '13', 3, 'common', 1970),
$c('19800', '출자금(장기)', 'asset', 'fixed_asset', '13', 3, 'common', 1980),
$c('19900', '퇴직보험예치금', 'asset', 'fixed_asset', '13', 3, 'common', 1990),
$c('20000', '국민연금전환금', 'asset', 'fixed_asset', '13', 3, 'common', 2000),
$c('21100', '감가상각누계액(공구와기구)', 'asset', 'fixed_asset', '13', 3, 'common', 2110),
$c('21400', '건설중인자산(임대)', 'asset', 'fixed_asset', '13', 3, 'common', 2140),
$c('21500', '미착기계', 'asset', 'fixed_asset', '13', 3, 'common', 2150),
$c('21600', '감가상각누계액(비품)', 'asset', 'fixed_asset', '13', 3, 'common', 2160),
// 무형자산
$c('23100', '영업권', 'asset', 'fixed_asset', '13', 3, 'common', 2310),
$c('23200', '특허권', 'asset', 'fixed_asset', '13', 3, 'common', 2320),
$c('23300', '상표권', 'asset', 'fixed_asset', '13', 3, 'common', 2330),
$c('23400', '실용신안권', 'asset', 'fixed_asset', '13', 3, 'common', 2340),
$c('23500', '의장권', 'asset', 'fixed_asset', '13', 3, 'common', 2350),
$c('23600', '면허권', 'asset', 'fixed_asset', '13', 3, 'common', 2360),
$c('23700', '광업권', 'asset', 'fixed_asset', '13', 3, 'common', 2370),
$c('23800', '창업비', 'asset', 'fixed_asset', '13', 3, 'common', 2380),
$c('23900', '개발비', 'asset', 'fixed_asset', '13', 3, 'common', 2390),
// 기타비유동자산 (96xxx-97xxx)
$c('96100', '이연법인세자산', 'asset', 'fixed_asset', '13', 3, 'common', 9610),
$c('96200', '임차보증금', 'asset', 'fixed_asset', '13', 3, 'common', 9620),
$c('96300', '전세금', 'asset', 'fixed_asset', '13', 3, 'common', 9630),
$c('96400', '기타보증금', 'asset', 'fixed_asset', '13', 3, 'common', 9640),
$c('96500', '장기외상매출금', 'asset', 'fixed_asset', '13', 3, 'common', 9650),
$c('96600', '현재가치할인차금(장기외상매출금)', 'asset', 'fixed_asset', '13', 3, 'common', 9660),
$c('96700', '대손충당금(장기외상매출금)', 'asset', 'fixed_asset', '13', 3, 'common', 9670),
$c('96800', '장기받을어음', 'asset', 'fixed_asset', '13', 3, 'common', 9680),
$c('96900', '현재가치할인차금(장기받을어음)', 'asset', 'fixed_asset', '13', 3, 'common', 9690),
$c('97000', '대손충당금(장기받을어음)', 'asset', 'fixed_asset', '13', 3, 'common', 9700),
$c('97100', '장기미수금', 'asset', 'fixed_asset', '13', 3, 'common', 9710),
$c('97200', '현재가치할인차금(장기미수금)', 'asset', 'fixed_asset', '13', 3, 'common', 9720),
$c('97300', '대손충당금(장기미수금)', 'asset', 'fixed_asset', '13', 3, 'common', 9730),
$c('97400', '장기선급비용', 'asset', 'fixed_asset', '13', 3, 'common', 9740),
$c('97500', '장기선급금', 'asset', 'fixed_asset', '13', 3, 'common', 9750),
$c('97600', '부도어음과수표', 'asset', 'fixed_asset', '13', 3, 'common', 9760),
$c('97700', '대손충당금(부도어음)', 'asset', 'fixed_asset', '13', 3, 'common', 9770),
$c('97800', '전신전화가입권', 'asset', 'fixed_asset', '13', 3, 'common', 9780),
// ================================================================
// 부채 — 유동부채 추가 (parent: '21')
// ================================================================
$c('25600', '당좌차월', 'liability', 'current_liability', '21', 3, 'common', 2560),
$c('25700', '가수금', 'liability', 'current_liability', '21', 3, 'common', 2570),
$c('25800', '예수보증금', 'liability', 'current_liability', '21', 3, 'common', 2580),
$c('26300', '수입금', 'liability', 'current_liability', '21', 3, 'common', 2630),
$c('26600', '지급보증채무', 'liability', 'current_liability', '21', 3, 'common', 2660),
$c('26700', '수출금융', 'liability', 'current_liability', '21', 3, 'common', 2670),
$c('26800', '수입금융', 'liability', 'current_liability', '21', 3, 'common', 2680),
$c('26900', '공사손실충당금', 'liability', 'current_liability', '21', 3, 'common', 2690),
$c('27000', '하자보수충당금', 'liability', 'current_liability', '21', 3, 'common', 2700),
$c('27100', '공사선수금', 'liability', 'current_liability', '21', 3, 'common', 2710),
$c('27200', '분양선수금', 'liability', 'current_liability', '21', 3, 'common', 2720),
$c('27300', '이연법인세부채', 'liability', 'current_liability', '21', 3, 'common', 2730),
// ================================================================
// 부채 — 비유동부채 추가 (parent: '22')
// ================================================================
$c('29100', '사채', 'liability', 'long_term_liability', '22', 3, 'common', 2910),
$c('29200', '사채할인발행차금', 'liability', 'long_term_liability', '22', 3, 'common', 2920),
$c('29600', '퇴직보험충당부채', 'liability', 'long_term_liability', '22', 3, 'common', 2960),
$c('29700', '중소기업투자준비금', 'liability', 'long_term_liability', '22', 3, 'common', 2970),
$c('29800', '기술개발준비금', 'liability', 'long_term_liability', '22', 3, 'common', 2980),
$c('29900', '해외시장개척준비금', 'liability', 'long_term_liability', '22', 3, 'common', 2990),
$c('30100', '지방이전준비금', 'liability', 'long_term_liability', '22', 3, 'common', 3010),
$c('30200', '수출손실준비금', 'liability', 'long_term_liability', '22', 3, 'common', 3020),
$c('30300', '주임종장기차입금', 'liability', 'long_term_liability', '22', 3, 'common', 3030),
$c('30400', '관계회사장기차입금', 'liability', 'long_term_liability', '22', 3, 'common', 3040),
$c('30500', '외화장기차입금', 'liability', 'long_term_liability', '22', 3, 'common', 3050),
$c('30600', '공사선수금(장기)', 'liability', 'long_term_liability', '22', 3, 'common', 3060),
$c('30800', '장기성지급어음', 'liability', 'long_term_liability', '22', 3, 'common', 3080),
$c('30900', '환율조정대', 'liability', 'long_term_liability', '22', 3, 'common', 3090),
$c('31000', '이연법인세대', 'liability', 'long_term_liability', '22', 3, 'common', 3100),
$c('31100', '신주인수권부사채', 'liability', 'long_term_liability', '22', 3, 'common', 3110),
$c('31200', '전환사채', 'liability', 'long_term_liability', '22', 3, 'common', 3120),
$c('31300', '사채할증발행차금', 'liability', 'long_term_liability', '22', 3, 'common', 3130),
$c('31400', '장기제품보증부채', 'liability', 'long_term_liability', '22', 3, 'common', 3140),
// ================================================================
// 자본 — 잉여금 추가 (parent: '32')
// ================================================================
$c('34200', '감자차익', 'capital', 'capital', '32', 3, 'common', 3420),
$c('34300', '자기주식처분이익', 'capital', 'capital', '32', 3, 'common', 3430),
$c('34900', '기타자본잉여금', 'capital', 'capital', '32', 3, 'common', 3490),
$c('35000', '재평가적립금', 'capital', 'capital', '32', 3, 'common', 3500),
$c('35200', '기업합리화적립금', 'capital', 'capital', '32', 3, 'common', 3520),
$c('35300', '법정적립금', 'capital', 'capital', '32', 3, 'common', 3530),
$c('35400', '재무구조개선적립금', 'capital', 'capital', '32', 3, 'common', 3540),
$c('35500', '임의적립금', 'capital', 'capital', '32', 3, 'common', 3550),
$c('35600', '사업확장적립금', 'capital', 'capital', '32', 3, 'common', 3560),
$c('35700', '감채적립금', 'capital', 'capital', '32', 3, 'common', 3570),
$c('35800', '배당평균적립금', 'capital', 'capital', '32', 3, 'common', 3580),
$c('35900', '주식할인발행차손', 'capital', 'capital', '32', 3, 'common', 3590),
$c('36000', '배당건설이자상각', 'capital', 'capital', '32', 3, 'common', 3600),
$c('36100', '자기주식상환액', 'capital', 'capital', '32', 3, 'common', 3610),
$c('36200', '자기주식처분차금', 'capital', 'capital', '32', 3, 'common', 3620),
$c('36300', '중소기업투자준비금(자본)', 'capital', 'capital', '32', 3, 'common', 3630),
$c('36400', '기술개발준비금(자본)', 'capital', 'capital', '32', 3, 'common', 3640),
$c('36500', '해외시장개척준비금(자본)', 'capital', 'capital', '32', 3, 'common', 3650),
$c('36600', '지방이전준비금(자본)', 'capital', 'capital', '32', 3, 'common', 3660),
$c('36700', '수출손실준비금(자본)', 'capital', 'capital', '32', 3, 'common', 3670),
$c('36800', '기타임의적립금', 'capital', 'capital', '32', 3, 'common', 3680),
$c('36900', '회계변경의누적효과', 'capital', 'capital', '32', 3, 'common', 3690),
$c('37000', '전기오류수정이익', 'capital', 'capital', '32', 3, 'common', 3700),
$c('37100', '전기오류수정손실', 'capital', 'capital', '32', 3, 'common', 3710),
$c('37200', '중간배당금', 'capital', 'capital', '32', 3, 'common', 3720),
$c('37400', '기타이익잉여금', 'capital', 'capital', '32', 3, 'common', 3740),
$c('37600', '이월결손금', 'capital', 'capital', '32', 3, 'common', 3760),
$c('37800', '처분전이익잉여금', 'capital', 'capital', '32', 3, 'common', 3780),
// ================================================================
// 자본 — 자본조정 (parent: '33')
// ================================================================
$c('38000', '당기순손실', 'capital', 'capital_adjustment', '33', 3, 'common', 3800),
$c('38100', '주식할인발행차금', 'capital', 'capital_adjustment', '33', 3, 'common', 3810),
$c('38200', '배당건설이자', 'capital', 'capital_adjustment', '33', 3, 'common', 3820),
$c('38300', '자기주식', 'capital', 'capital_adjustment', '33', 3, 'common', 3830),
$c('38400', '환전대가', 'capital', 'capital_adjustment', '33', 3, 'common', 3840),
$c('38500', '신주인수권대가', 'capital', 'capital_adjustment', '33', 3, 'common', 3850),
$c('38600', '신주발행비', 'capital', 'capital_adjustment', '33', 3, 'common', 3860),
$c('38700', '미교부주식배당금', 'capital', 'capital_adjustment', '33', 3, 'common', 3870),
$c('38800', '신주청약증거금', 'capital', 'capital_adjustment', '33', 3, 'common', 3880),
$c('39200', '국고보조금', 'capital', 'capital_adjustment', '33', 3, 'common', 3920),
$c('39300', '공사부담금', 'capital', 'capital_adjustment', '33', 3, 'common', 3930),
$c('39400', '감자차손', 'capital', 'capital_adjustment', '33', 3, 'common', 3940),
$c('39500', '자기주식처분손실', 'capital', 'capital_adjustment', '33', 3, 'common', 3950),
$c('39600', '주식매입선택권', 'capital', 'capital_adjustment', '33', 3, 'common', 3960),
// 기타포괄손익누계액
$c('98100', '매도가능증권평가이익', 'capital', 'capital_adjustment', '33', 3, 'common', 9810),
$c('98200', '매도가능증권평가손실', 'capital', 'capital_adjustment', '33', 3, 'common', 9820),
$c('98300', '해외사업환산이익', 'capital', 'capital_adjustment', '33', 3, 'common', 9830),
$c('98400', '해외사업환산손실', 'capital', 'capital_adjustment', '33', 3, 'common', 9840),
$c('98500', '파생상품평가이익', 'capital', 'capital_adjustment', '33', 3, 'common', 9850),
$c('98600', '파생상품평가손실', 'capital', 'capital_adjustment', '33', 3, 'common', 9860),
// ================================================================
// 수익 — 매출 추가 (parent: '41')
// ================================================================
$c('40200', '매출환입및에누리(상품)', 'revenue', 'sales_revenue', '41', 3, 'common', 4020),
$c('40300', '매출할인(상품)', 'revenue', 'sales_revenue', '41', 3, 'common', 4030),
$c('40500', '매출환입및에누리(제품)', 'revenue', 'sales_revenue', '41', 3, 'common', 4050),
$c('40600', '매출할인(제품)', 'revenue', 'sales_revenue', '41', 3, 'common', 4060),
$c('40800', '매출할인(공사)', 'revenue', 'sales_revenue', '41', 3, 'common', 4080),
$c('40900', '완성건물매출', 'revenue', 'sales_revenue', '41', 3, 'common', 4090),
// ================================================================
// 수익 — 영업외수익 추가 (parent: '42')
// ================================================================
$c('90200', '만기보유증권이자', 'revenue', 'other_revenue', '42', 3, 'common', 9020),
$c('90500', '단기투자자산평가이익', 'revenue', 'other_revenue', '42', 3, 'common', 9050),
$c('90600', '단기투자자산처분이익', 'revenue', 'other_revenue', '42', 3, 'common', 9060),
$c('90800', '대손충당금환입', 'revenue', 'other_revenue', '42', 3, 'common', 9080),
$c('90900', '수입수수료', 'revenue', 'other_revenue', '42', 3, 'common', 9090),
$c('91000', '외화환산이익', 'revenue', 'other_revenue', '42', 3, 'common', 9100),
$c('91100', '사채상환이익', 'revenue', 'other_revenue', '42', 3, 'common', 9110),
$c('91200', '전기오류수정이익', 'revenue', 'other_revenue', '42', 3, 'common', 9120),
$c('91300', '하자보수충당금환입', 'revenue', 'other_revenue', '42', 3, 'common', 9130),
$c('91400', '유형자산처분이익', 'revenue', 'other_revenue', '42', 3, 'common', 9140),
$c('91500', '투자자산처분이익', 'revenue', 'other_revenue', '42', 3, 'common', 9150),
$c('91600', '상각채권추심이익', 'revenue', 'other_revenue', '42', 3, 'common', 9160),
$c('91700', '자산수증이익', 'revenue', 'other_revenue', '42', 3, 'common', 9170),
$c('91800', '채무면제이익', 'revenue', 'other_revenue', '42', 3, 'common', 9180),
$c('92000', '투자증권손상차환입', 'revenue', 'other_revenue', '42', 3, 'common', 9200),
$c('92100', '지분법이익', 'revenue', 'other_revenue', '42', 3, 'common', 9210),
$c('92400', '중소투자준비금환입', 'revenue', 'other_revenue', '42', 3, 'common', 9240),
$c('92500', '기술개발준비금환입', 'revenue', 'other_revenue', '42', 3, 'common', 9250),
$c('92600', '해외개척준비금환입', 'revenue', 'other_revenue', '42', 3, 'common', 9260),
$c('92700', '지방이전준비금환입', 'revenue', 'other_revenue', '42', 3, 'common', 9270),
$c('92800', '수출손실준비금환입', 'revenue', 'other_revenue', '42', 3, 'common', 9280),
// ================================================================
// 비용 — 매출원가 추가: 45xxx (parent: '51')
// ================================================================
$c('45100', '상품매출원가', 'expense', 'cogs', '51', 3, 'common', 4510),
$c('45200', '도급공사매출원가', 'expense', 'cogs', '51', 3, 'common', 4520),
$c('45300', '분양공사매출원가', 'expense', 'cogs', '51', 3, 'common', 4530),
$c('45500', '제품매출원가', 'expense', 'cogs', '51', 3, 'common', 4550),
// ================================================================
// 비용 — 제조원가 추가: 50xxx-53xxx (parent: '51')
// ================================================================
$c('50600', '제수당(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5060),
$c('50700', '잡급(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5070),
$c('50900', '퇴직보험충당금전입(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5090),
$c('51000', '퇴직금여(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5100),
$c('51500', '가스수도료(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5150),
$c('52300', '경상연구개발비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5230),
$c('52500', '교육훈련비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5250),
$c('52600', '도서인쇄비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5260),
$c('52700', '회의비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5270),
$c('52800', '포장비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5280),
$c('52900', '사무용품비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5290),
$c('53200', '보관료(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5320),
$c('53300', '외주가공비(제조경비)', 'expense', 'cogs', '51', 3, 'manufacturing', 5330),
$c('53400', '시험비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5340),
$c('53500', '기밀비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5350),
$c('53600', '잡비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5360),
$c('53700', '폐기물처리비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5370),
// ================================================================
// 비용 — 건설원가 60xxx (parent: '54')
// ================================================================
$c('60100', '원재료비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6010),
$c('60200', '외주비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6020),
$c('60300', '급여(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6030),
$c('60400', '임금(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6040),
$c('60500', '상여금(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6050),
$c('60600', '잡급(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6060),
$c('60700', '퇴직급여(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6070),
$c('60800', '퇴직보험충당금전입(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6080),
$c('60900', '퇴직금여(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6090),
$c('61000', '중기및운반비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6100),
$c('61100', '복리후생비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6110),
$c('61200', '여비교통비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6120),
$c('61300', '접대비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6130),
$c('61400', '통신비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6140),
$c('61500', '가스수도료(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6150),
$c('61600', '전력비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6160),
$c('61700', '세금과공과금(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6170),
$c('61800', '감가상각비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6180),
$c('61900', '지급임차료(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6190),
$c('62000', '수선비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6200),
$c('62100', '보험료(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6210),
$c('62200', '차량유지비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6220),
$c('62300', '운반비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6230),
$c('62400', '잡자재대(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6240),
$c('62500', '교육훈련비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6250),
$c('62600', '도서인쇄비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6260),
$c('62700', '회의비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6270),
$c('62800', '포장비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6280),
$c('62900', '사무용품비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6290),
$c('63000', '소모품비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6300),
$c('63100', '지급수수료(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6310),
$c('63200', '보관료(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6320),
$c('63300', '외주용역비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6330),
$c('63400', '장비사용료(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6340),
$c('63500', '설계용역비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6350),
$c('63600', '광고선전비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6360),
$c('63700', '소모공구비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6370),
$c('63800', '외주시공비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6380),
$c('63900', '협비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6390),
$c('64000', '잡비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6400),
$c('64100', '공사손실충당금전입(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6410),
$c('64200', '공사손실충당금환입(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6420),
$c('64300', '외주비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 6430),
$c('64400', '유류비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6440),
// ================================================================
// 비용 — 건설원가 70xxx (parent: '54')
// ================================================================
$c('70100', '원재료비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7010),
$c('70200', '중기및운반비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7020),
$c('70300', '급여(건설노무비)', 'expense', 'construction_cost', '54', 3, 'construction', 7030),
$c('70400', '임금(건설노무비)', 'expense', 'construction_cost', '54', 3, 'construction', 7040),
$c('70500', '상여금(건설노무비)', 'expense', 'construction_cost', '54', 3, 'construction', 7050),
$c('70600', '제수당(건설노무비)', 'expense', 'construction_cost', '54', 3, 'construction', 7060),
$c('70700', '퇴직급여(건설노무비)', 'expense', 'construction_cost', '54', 3, 'construction', 7070),
$c('70800', '퇴직보험충당금전입(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7080),
$c('70900', '퇴직금여(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7090),
$c('71000', '건설용지비', 'expense', 'construction_cost', '54', 3, 'construction', 7100),
$c('71100', '복리후생비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7110),
$c('71200', '여비교통비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7120),
$c('71300', '접대비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7130),
$c('71400', '통신비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7140),
$c('71500', '가스수도료(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7150),
$c('71600', '전력비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7160),
$c('71700', '세금과공과금(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7170),
$c('71800', '감가상각비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7180),
$c('71900', '지급임차료(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7190),
$c('72000', '수선비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7200),
$c('72100', '보험료(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7210),
$c('72200', '차량유지비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7220),
$c('72300', '경상연구개발비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7230),
$c('72400', '잡자재대(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7240),
$c('72500', '교육훈련비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7250),
$c('72600', '도서인쇄비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7260),
$c('72700', '회의비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7270),
$c('72800', '포장비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7280),
$c('72900', '사무용품비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7290),
$c('73000', '소모품비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7300),
$c('73100', '지급수수료(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7310),
$c('73200', '보관료(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7320),
$c('73300', '외주가공비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7330),
$c('73400', '시험비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7340),
$c('73500', '설계용역비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7350),
$c('73600', '가설재손료(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7360),
$c('73700', '잡비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7370),
$c('73800', '폐기물처리비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7380),
$c('73900', '장비사용료(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7390),
$c('74100', '공사손실충당금전입(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7410),
$c('74200', '공사손실충당금환입(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7420),
$c('74300', '외주비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7430),
$c('74900', '명예퇴직금(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 7490),
// ================================================================
// 비용 — 판관비 추가 (parent: '52')
// ================================================================
$c('80400', '제수당', 'expense', 'selling_admin', '52', 3, 'admin', 8040),
$c('80500', '잡급', 'expense', 'selling_admin', '52', 3, 'admin', 8050),
$c('80700', '퇴직보험충당금전입', 'expense', 'selling_admin', '52', 3, 'admin', 8070),
$c('80800', '퇴직금여', 'expense', 'selling_admin', '52', 3, 'admin', 8080),
$c('81600', '전력비', 'expense', 'selling_admin', '52', 3, 'admin', 8160),
$c('82800', '포장비', 'expense', 'selling_admin', '52', 3, 'admin', 8280),
$c('83400', '판매촉진비', 'expense', 'selling_admin', '52', 3, 'admin', 8340),
$c('83600', '기밀비', 'expense', 'selling_admin', '52', 3, 'admin', 8360),
$c('83700', '건물관리비', 'expense', 'selling_admin', '52', 3, 'admin', 8370),
$c('83800', '수출제비용', 'expense', 'selling_admin', '52', 3, 'admin', 8380),
$c('83900', '판매수수료', 'expense', 'selling_admin', '52', 3, 'admin', 8390),
$c('84000', '무형고정자산상각', 'expense', 'selling_admin', '52', 3, 'admin', 8400),
$c('84100', '환가료', 'expense', 'selling_admin', '52', 3, 'admin', 8410),
$c('84200', '견본비', 'expense', 'selling_admin', '52', 3, 'admin', 8420),
$c('84300', '해외접대비', 'expense', 'selling_admin', '52', 3, 'admin', 8430),
$c('84400', '해외시장개척비', 'expense', 'selling_admin', '52', 3, 'admin', 8440),
$c('84500', '미분양주택관리비', 'expense', 'selling_admin', '52', 3, 'admin', 8450),
$c('84600', '수주비', 'expense', 'selling_admin', '52', 3, 'admin', 8460),
$c('84700', '하자보수충당금전입', 'expense', 'selling_admin', '52', 3, 'admin', 8470),
$c('84900', '명예퇴직금', 'expense', 'selling_admin', '52', 3, 'admin', 8490),
// ================================================================
// 비용 — 영업외비용 추가 (parent: '53')
// ================================================================
$c('93400', '기타의대손상각비', 'expense', 'other_expense', '53', 3, 'common', 9340),
$c('93500', '외화환산손실', 'expense', 'other_expense', '53', 3, 'common', 9350),
$c('93600', '매출채권처분손실', 'expense', 'other_expense', '53', 3, 'common', 9360),
$c('93700', '단기투자자산평가손실', 'expense', 'other_expense', '53', 3, 'common', 9370),
$c('93800', '단기투자자산처분손실', 'expense', 'other_expense', '53', 3, 'common', 9380),
$c('93900', '재고자산감모손실', 'expense', 'other_expense', '53', 3, 'common', 9390),
$c('94000', '재고자산평가손실', 'expense', 'other_expense', '53', 3, 'common', 9400),
$c('94100', '재해손실', 'expense', 'other_expense', '53', 3, 'common', 9410),
$c('94200', '전기오류수정손실', 'expense', 'other_expense', '53', 3, 'common', 9420),
$c('94300', '투자증권손상차손', 'expense', 'other_expense', '53', 3, 'common', 9430),
$c('94700', '사채상환손실', 'expense', 'other_expense', '53', 3, 'common', 9470),
$c('95000', '투자자산처분손실', 'expense', 'other_expense', '53', 3, 'common', 9500),
$c('95100', '중소투자준비금전입', 'expense', 'other_expense', '53', 3, 'common', 9510),
$c('95200', '기술개발준비금전입', 'expense', 'other_expense', '53', 3, 'common', 9520),
$c('95300', '해외개척준비금전입', 'expense', 'other_expense', '53', 3, 'common', 9530),
$c('95400', '지방이전준비금전입', 'expense', 'other_expense', '53', 3, 'common', 9540),
$c('95500', '수출손실준비금전입', 'expense', 'other_expense', '53', 3, 'common', 9550),
$c('95700', '특별상각', 'expense', 'other_expense', '53', 3, 'common', 9570),
// 중단사업
$c('99100', '사업중단직접비', 'expense', 'other_expense', '53', 3, 'common', 9910),
$c('99200', '중단사업자산손상차손', 'expense', 'other_expense', '53', 3, 'common', 9920),
$c('99300', '중단사업손상차환입', 'expense', 'other_expense', '53', 3, 'common', 9930),
$c('99700', '중단손익', 'expense', 'other_expense', '53', 3, 'common', 9970),
];
}
};

View File

@@ -163,6 +163,8 @@
Route::get('/{id}', [CardTransactionController::class, 'show'])->whereNumber('id')->name('v1.card-transactions.show');
Route::put('/{id}', [CardTransactionController::class, 'update'])->whereNumber('id')->name('v1.card-transactions.update');
Route::delete('/{id}', [CardTransactionController::class, 'destroy'])->whereNumber('id')->name('v1.card-transactions.destroy');
Route::get('/{id}/journal-entries', [CardTransactionController::class, 'getJournalEntries'])->whereNumber('id')->name('v1.card-transactions.journal-entries.show');
Route::post('/{id}/journal-entries', [CardTransactionController::class, 'storeJournalEntries'])->whereNumber('id')->name('v1.card-transactions.journal-entries.store');
});
// Bank Transaction API (은행 거래 조회)
@@ -287,6 +289,10 @@
Route::post('/{id}/cancel', [TaxInvoiceController::class, 'cancel'])->whereNumber('id')->name('v1.tax-invoices.cancel');
Route::get('/{id}/check-status', [TaxInvoiceController::class, 'checkStatus'])->whereNumber('id')->name('v1.tax-invoices.check-status');
Route::post('/bulk-issue', [TaxInvoiceController::class, 'bulkIssue'])->name('v1.tax-invoices.bulk-issue');
Route::get('/{id}/journal-entries', [TaxInvoiceController::class, 'getJournalEntries'])->whereNumber('id')->name('v1.tax-invoices.journal-entries.show');
Route::post('/{id}/journal-entries', [TaxInvoiceController::class, 'storeJournalEntries'])->whereNumber('id')->name('v1.tax-invoices.journal-entries.store');
Route::put('/{id}/journal-entries', [TaxInvoiceController::class, 'storeJournalEntries'])->whereNumber('id')->name('v1.tax-invoices.journal-entries.update');
Route::delete('/{id}/journal-entries', [TaxInvoiceController::class, 'deleteJournalEntries'])->whereNumber('id')->name('v1.tax-invoices.journal-entries.destroy');
});
// Bad Debt API (악성채권 추심관리)
@@ -320,6 +326,8 @@
Route::prefix('account-subjects')->group(function () {
Route::get('', [AccountSubjectController::class, 'index'])->name('v1.account-subjects.index');
Route::post('', [AccountSubjectController::class, 'store'])->name('v1.account-subjects.store');
Route::post('/seed-defaults', [AccountSubjectController::class, 'seedDefaults'])->name('v1.account-subjects.seed-defaults');
Route::put('/{id}', [AccountSubjectController::class, 'update'])->whereNumber('id')->name('v1.account-subjects.update');
Route::patch('/{id}/status', [AccountSubjectController::class, 'toggleStatus'])->whereNumber('id')->name('v1.account-subjects.toggle-status');
Route::delete('/{id}', [AccountSubjectController::class, 'destroy'])->whereNumber('id')->name('v1.account-subjects.destroy');
});