콘텐츠로 이동

add_other_expense_item (기타 비용 내역 추가)

기타 비용에 새로운 내역을 추가합니다.

기본 정보

항목
URL https://asia-northeast3-construction24-test.cloudfunctions.net/add_other_expense_item
Method POST
인증 Firebase ID Token 필요
권한 해당 회사의 멤버

요청

Body

필드 타입 필수 설명 검증
token string O Firebase ID Token -
company_id string O 회사 ID -
site_id string O 현장 ID -
expense_id string O 기타 비용 ID -
title string O 내역 제목 -
supply_amount number O 공급가액 숫자로 변환 가능해야 함
tax number O 부가세 숫자로 변환 가능해야 함
tax_type string O 과세 구분 "과세", "영세", "면세" 중 하나
memo string O 메모 -
target_date string/number/timestamp O 대상 날짜 다양한 형식 지원

target_date 지원 형식

  • 문자열: "YYYY-MM-DD" 형식
  • epoch 숫자: 밀리초 또는 초 (자동 판별)
  • Firestore Timestamp: { _seconds: number } 형태
  • datetime 객체

요청 예시

{
  "token": "eyJhbGci...",
  "company_id": "abc123",
  "site_id": "site456",
  "expense_id": "expense789",
  "title": "3월 임대료",
  "supply_amount": 909091,
  "tax": 90909,
  "tax_type": "과세",
  "memo": "3월분 임대료 지급",
  "target_date": "2024-03-15"
}

응답

성공 (200)

{
  "message": "기타 비용 내역 추가 완료",
  "item_id": "item001"
}

실패

코드 message 원인
400 "숫자 필드 형식이 올바르지 않습니다." supply_amount 또는 tax 변환 실패
400 "합계 금액이 올바르지 않습니다. 계산된 값: ..., 제공된 값: ..." 제공된 total이 공급가액+세액과 다른 경우
500 "tax_type은 '과세', '영세', '면세' 중 하나여야 합니다." tax_type 값 오류
500 "target_date는 YYYY-MM-DD 형식이어야 합니다." 날짜 형식 오류
500 "해당 회사의 멤버가 아닙니다." 요청자가 해당 회사의 멤버가 아닌 경우
500 "존재하지 않는 기타 비용입니다." 해당 기타 비용이 존재하지 않는 경우

참고

  • 합계(total)는 공급가액(supply_amount) + 부가세(tax)로 자동 계산됩니다.
  • 클라이언트에서 total을 전송하면 계산 결과와 일치하는지 검증합니다.
  • 저장 후 Firestore 트리거에 의해 기타 비용의 total_cost, total_tax, year_costs, year_tax, month_costs, month_tax가 자동 업데이트됩니다.
  • 관련 API: [[edit_other_expense_item]], [[delete_other_expense_item]], [[add_other_expense]]