콘텐츠로 이동

other_expenses / items 스키마 (기타 비용)

현장의 기타 지출 항목(운영비, 접대비 등)을 카테고리 + 상세 지출 2단계로 관리하는 스키마. 상위 other_expenses/{expense_id}는 카테고리(제목/설명 + 집계), 하위 items/{item_id}는 개별 지출 내역입니다.

저장 위치

companies/{company_id}/sites/{site_id}/other_expenses/{expense_id}
companies/{company_id}/sites/{site_id}/other_expenses/{expense_id}/items/{item_id}
  • expense_id, item_id: Firestore 자동 생성 ID

상위: other_expenses/{expense_id}

지출 카테고리 문서. title/description만 사용자가 채우고, 집계 필드는 하위 items 변화 시 트랜잭션으로 갱신됩니다.

필드 타입 설명
title string 카테고리 제목 (예: "운영비", "접대비")
description string 카테고리 설명
total_cost int 전체 공급가액 합계 (원)
total_tax int 전체 세액 합계 (원)
year_costs object 연도별 공급가액 { "2026": 1234000 }
year_tax object 연도별 세액
month_costs object 월별 공급가액 { "202604": 120000 }
month_tax object 월별 세액
created_at timestamp 생성 시각
created_by string 생성자 UID
updated_at timestamp? 카테고리 수정 시각
updated_by string? 수정자 UID

하위: items/{item_id}

카테고리 내 개별 지출 내역.

필드 타입 설명
title string 지출 제목
supply_amount int 공급가액 (원)
tax int 세액 (원)
tax_type string 세금 구분 (예: "과세", "면세", "영세")
total int 합계 (원) = supply_amount + tax
memo string 비고/메모
target_date timestamp 지출 발생 날짜 (KST 00:00)
created_at timestamp 저장 시각
created_by string 저장자 UID
updated_at timestamp? 수정 시각
updated_by string? 수정자 UID

첨부파일 연결

  • 카테고리 단위 첨부(선택): filesrelated_doc_id == expense_id
  • 아이템 단위 첨부(영수증 등): filesrelated_doc_id == item_id

item 삭제 시 related_doc_id == item_idfiles 문서도 함께 정리됩니다. Cloudflare 스토리지 prefix는 companies/{cid}/sites/{sid}/other_expenses/{expense_id}/items/{item_id}/files 하위에 업로드됩니다.

예시 문서

other_expenses/{expense_id}

{
  "title": "운영비",
  "description": "현장 사무실 운영 관련 지출",
  "total_cost": 500000,
  "total_tax": 50000,
  "year_costs": { "2026": 500000 },
  "year_tax": { "2026": 50000 },
  "month_costs": { "202604": 200000 },
  "month_tax": { "202604": 20000 },
  "created_at": "2026-04-01T00:00:00Z",
  "created_by": "uid_admin"
}

items/{item_id}

{
  "title": "사무용품 구매",
  "supply_amount": 100000,
  "tax": 10000,
  "tax_type": "과세",
  "total": 110000,
  "memo": "복사용지, 토너",
  "target_date": "2026-04-15T00:00:00+09:00",
  "created_at": "2026-04-15T10:00:00Z",
  "created_by": "uid_admin"
}