> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openapi.pluuug.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 정산 생성

> 새 정산을 생성합니다.

**필수 관계:** `contract.id`(계약 ID), `type.id`(정산 형태 ID, 미수금 OUTSTANDING_PAYMENT는 사용 불가).

정산 형태에 따라 단일 결제/정기 결제 등 정산 흐름이 결정됩니다. 정산 상태 변경 이력은 정산 상세/수정 API의 부수효과로 자동 기록됩니다.

### 🚫 제한사항

1. 계약

* 계약은 시작일과 종료일이 모두 지정되어 있어야 합니다.
* 중단된 계약에 대해서는 정산을 생성할 수 없습니다.

2. 정산 형태

* 다차수 생성을 허용하지 않는 정산 형태는 같은 형태로 여러개 생성할 수 없습니다. (추가 정산, 미수 정산 제외)


## OpenAPI

````yaml POST /v1/settlement
openapi: 3.1.0
info:
  title: pluuug openapi
  version: 1.0.0
  description: >-
    플러그에서 제공하는 REST API의 상세 내용을 확인하고 직접 테스트할 수 있는 인터페이스입니다.<br>이 문서를 통해 API의
    엔드포인트, 요청 및 응답 형식 등을 확인할 수 있습니다.
servers:
  - url: https://openapi.pluuug.com
security: []
paths:
  /v1/settlement:
    post:
      tags:
        - settlement
      summary: 정산 생성
      description: >-
        새 정산을 생성합니다.


        **필수 관계:** `contract.id`(계약 ID), `type.id`(정산 형태 ID, 미수금
        OUTSTANDING_PAYMENT는 사용 불가).


        정산 형태에 따라 단일 결제/정기 결제 등 정산 흐름이 결정됩니다. 정산 상태 변경 이력은 정산 상세/수정 API의 부수효과로
        자동 기록됩니다.
      operationId: settlement_create
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OpenapiSettlementListCreateRequest'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/OpenapiSettlementListCreateRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/OpenapiSettlementListCreateRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenapiSettlementListCreate'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/OpenapiSettlementListCreateValidationError
          description: ''
      security:
        - ApiKeyAuth: []
          Signature: []
components:
  schemas:
    OpenapiSettlementListCreateRequest:
      type: object
      properties:
        title:
          type: string
          minLength: 1
          description: 정산 제목
          maxLength: 128
        amount:
          type: integer
          minimum: 0
          description: 정산 금액
        additionalAmount:
          type: integer
          minimum: 0
          description: 추가 금액
        vat:
          type: integer
          minimum: 0
          description: 부가세
        settlementRound:
          type: integer
          minimum: 1
          writeOnly: true
          description: 정산 차수
        dueDate:
          type:
            - string
            - 'null'
          format: date
          description: 지급 예정일
        settledDate:
          type:
            - string
            - 'null'
          format: date
          description: 지급 완료일
        isTaxInvoiceIssued:
          type: boolean
          writeOnly: true
          default: false
          description: 세금 계산서 발행 여부
        isTaxInvoiceNeeded:
          type: boolean
          writeOnly: true
          default: false
          description: 세금 계산서 발행 필요 여부
        taxInvoiceIssuedDate:
          type:
            - string
            - 'null'
          format: date
          writeOnly: true
          description: 세금 계산서 발행 날짜
        taxInvoiceIssueDueDate:
          type:
            - string
            - 'null'
          format: date
          writeOnly: true
          description: 세금 계산서 발행 예정 날짜
        contract:
          allOf:
            - $ref: '#/components/schemas/OpenapiNestedSettlementContractRequest'
          description: 계약
        type:
          allOf:
            - $ref: '#/components/schemas/OpenapiNestedSettlementTypeRequest'
          writeOnly: true
          description: 정산 형태
        inChargeSet:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/OpenapiNestedMemberRequest'
          writeOnly: true
          description: 담당자
      required:
        - additionalAmount
        - amount
        - contract
        - title
        - type
        - vat
    OpenapiSettlementListCreate:
      type: object
      properties:
        id:
          type: integer
          readOnly: true
        title:
          type: string
          description: 정산 제목
          maxLength: 128
        status:
          enum:
            - C
            - D
            - S
            - P
          type: string
          x-spec-enum-id: 3bf0af9565254de8
          readOnly: true
          description: |-
            정산 상태

            * `C` - 정산 예정
            * `D` - 정산 지연
            * `S` - 정산 완료
            * `P` - 정산 중단
          x-enumNames:
            - 정산 예정
            - 정산 지연
            - 정산 완료
            - 정산 중단
        amount:
          type: integer
          minimum: 0
          description: 정산 금액
        additionalAmount:
          type: integer
          minimum: 0
          description: 추가 금액
        vat:
          type: integer
          minimum: 0
          description: 부가세
        dueDate:
          type:
            - string
            - 'null'
          format: date
          description: 지급 예정일
        settledDate:
          type:
            - string
            - 'null'
          format: date
          description: 지급 완료일
        typeAlias:
          type: string
          readOnly: true
          description: 정산 형태
        created:
          type: string
          format: date-time
          readOnly: true
          description: 생성일시
        contract:
          allOf:
            - $ref: '#/components/schemas/OpenapiNestedSettlementContract'
          description: 계약
      required:
        - additionalAmount
        - amount
        - contract
        - created
        - id
        - status
        - title
        - typeAlias
        - vat
    OpenapiSettlementListCreateValidationError:
      type: object
      properties:
        nonField:
          type: array
          items:
            type: string
        title:
          type: array
          items:
            type: string
        amount:
          type: array
          items:
            type: string
        additionalAmount:
          type: array
          items:
            type: string
        vat:
          type: array
          items:
            type: string
        settlementRound:
          type: array
          items:
            type: string
        dueDate:
          type: array
          items:
            type: string
        settledDate:
          type: array
          items:
            type: string
        isTaxInvoiceIssued:
          type: array
          items:
            type: string
        isTaxInvoiceNeeded:
          type: array
          items:
            type: string
        taxInvoiceIssuedDate:
          type: array
          items:
            type: string
        taxInvoiceIssueDueDate:
          type: array
          items:
            type: string
        contract:
          $ref: '#/components/schemas/OpenapiNestedSettlementContractValidationError'
        type:
          $ref: '#/components/schemas/OpenapiNestedSettlementTypeValidationError'
        inChargeSet:
          type: array
          items:
            type: string
    OpenapiNestedSettlementContractRequest:
      type: object
      description: |-
        nested 아이템이 제공되면 선언된 required 필드를 모두 가져야 함을 강제한다.

        부모 레벨 partial(미전송 필드 생략)은 유지하되, nested 아이템은 object-level
        validate에서 required 필드 존재를 재확인해 누락 시 400을 반환한다.
      properties:
        id:
          type: integer
      required:
        - id
    OpenapiNestedSettlementTypeRequest:
      type: object
      properties:
        id:
          type: integer
      required:
        - id
    OpenapiNestedMemberRequest:
      type: object
      description: |-
        nested 아이템이 제공되면 선언된 required 필드를 모두 가져야 함을 강제한다.

        부모 레벨 partial(미전송 필드 생략)은 유지하되, nested 아이템은 object-level
        validate에서 required 필드 존재를 재확인해 누락 시 400을 반환한다.
      properties:
        id:
          type: integer
      required:
        - id
    OpenapiNestedSettlementContract:
      type: object
      description: |-
        nested 아이템이 제공되면 선언된 required 필드를 모두 가져야 함을 강제한다.

        부모 레벨 partial(미전송 필드 생략)은 유지하되, nested 아이템은 object-level
        validate에서 required 필드 존재를 재확인해 누락 시 400을 반환한다.
      properties:
        id:
          type: integer
        title:
          type: string
          readOnly: true
          description: 계약 제목
        amount:
          type: integer
          readOnly: true
          description: 계약 금액
        type:
          enum:
            - I
            - S
            - G
          type: string
          x-spec-enum-id: 4b039ce324ed7b8c
          readOnly: true
          description: |-
            계약 타입

            * `I` - 회차 정산형
            * `S` - 정기 결제형
            * `G` - 단건 정산
          x-enumNames:
            - 회차 정산형
            - 정기 결제형
            - 단건 정산
        status:
          enum:
            - P
            - I
            - C
            - T
          type: string
          x-spec-enum-id: 81c3becab4b92e5c
          readOnly: true
          description: |-
            계약 상태

            * `P` - 계약 준비 중
            * `I` - 정산 진행 중
            * `C` - 계약 종료
            * `T` - 계약 중단
          x-enumNames:
            - 계약 준비 중
            - 정산 진행 중
            - 계약 종료
            - 계약 중단
        startDate:
          type:
            - string
            - 'null'
          format: date
          readOnly: true
          description: 계약 착수일
        endDate:
          type:
            - string
            - 'null'
          format: date
          readOnly: true
          description: 계약 종료일
      required:
        - amount
        - endDate
        - id
        - startDate
        - status
        - title
        - type
    OpenapiNestedSettlementContractValidationError:
      type: object
      properties:
        id:
          type: array
          items:
            type: string
    OpenapiNestedSettlementTypeValidationError:
      type: object
      properties:
        id:
          type: array
          items:
            type: string
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
    Signature:
      type: apiKey
      in: header
      name: X-Signature
      description: |-
        HMAC-SHA256 방식으로 body를 secret key로 해싱하여 생성한 서명을 넣어야 합니다.
        서버는 X-API-Key와 대응되는 secret key로 서명을 검증합니다.

````