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

# Calculate Invoice Payment

> Calculate the payment details for an invoice.

        This endpoint calculates:
        - Total amount due on the invoice
        - Applied payments (existing + proposed)
        - Applied credits (existing + proposed credit memos)
        - Payment term discounts (based on payment dates) - ALL OR NOTHING: discount only applies if paying full invoice
        - Remaining balance due

        Supports payment terms with early payment discounts (all-or-nothing).
        



## OpenAPI

````yaml https://api.meetcampfire.com/api/schema?format=json post /coa/api/v1/invoice/{invoice_id}/calculate-payment
openapi: 3.0.3
info:
  title: Campfire Developer APIs
  version: 1.0.0
  description: >
    ## Introduction

    Campfire's developer APIs offer granular access to Campfire's core
    accounting,

    revenue recognition, and financial data features.


    These APIs are designed to be used by developers to build custom
    integrations,

    automate workflows, and perform any other programmatic operations.
servers:
  - url: https://api.meetcampfire.com
    description: Production server
security: []
tags:
  - name: Cash Management
    description: Operations related to accounts, transactions, and other bank-related data.
  - name: Core Accounting
    description: >-
      Operations related to core accounting data, such as the chart of accounts,
      entity management, and the general ledger.
  - name: Revenue Recognition
    description: >-
      Operations related to revenue recognition, contract management, and
      contract data aggregation.
  - name: Accounts Receivable
    description: Operations related to invoicing and the AR subledger
  - name: Accounts Payable
    description: Operations related to billing and the AP subledger.
  - name: Financial Statements
    description: Operations related to financial statement generation and data aggregation.
  - name: Settings
    description: Operations related to system and accounting settings configuration.
paths:
  /coa/api/v1/invoice/{invoice_id}/calculate-payment:
    post:
      tags:
        - Accounts Receivable
      summary: Calculate Invoice Payment
      description: |-
        Calculate the payment details for an invoice.

                This endpoint calculates:
                - Total amount due on the invoice
                - Applied payments (existing + proposed)
                - Applied credits (existing + proposed credit memos)
                - Payment term discounts (based on payment dates) - ALL OR NOTHING: discount only applies if paying full invoice
                - Remaining balance due

                Supports payment terms with early payment discounts (all-or-nothing).
                
      operationId: coa_api_v1_invoice_calculate_payment_create
      parameters:
        - in: path
          name: invoice_id
          schema:
            type: integer
          description: ID of the invoice
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CalculatePaymentInput'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/CalculatePaymentInput'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/CalculatePaymentInput'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CalculatePaymentOutput'
          description: ''
        '400':
          content:
            application/json:
              schema:
                type: object
                additionalProperties: {}
                description: Unspecified response body
          description: ''
        '404':
          content:
            application/json:
              schema:
                type: object
                additionalProperties: {}
                description: Unspecified response body
          description: ''
      security:
        - knoxApiToken: []
components:
  schemas:
    CalculatePaymentInput:
      type: object
      properties:
        transactions:
          type: array
          items:
            $ref: '#/components/schemas/TransactionPaymentInput'
        credit_memos:
          type: array
          items:
            $ref: '#/components/schemas/CreditMemoPaymentInput'
        empty_transactions:
          type: array
          items:
            $ref: '#/components/schemas/EmptyTransactionInput'
    CalculatePaymentOutput:
      type: object
      properties:
        total_due:
          type: number
          format: double
          maximum: 1000000000000000000
          minimum: -1000000000000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
        applied_payments:
          type: number
          format: double
          maximum: 1000000000000000000
          minimum: -1000000000000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
        applied_credits:
          type: number
          format: double
          maximum: 1000000000000000000
          minimum: -1000000000000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
        term_discounts:
          type: number
          format: double
          maximum: 1000000000000000000
          minimum: -1000000000000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
        remaining_due:
          type: number
          format: double
          maximum: 1000000000000000000
          minimum: -1000000000000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
      required:
        - applied_credits
        - applied_payments
        - remaining_due
        - term_discounts
        - total_due
    TransactionPaymentInput:
      type: object
      properties:
        transaction_id:
          type: integer
        amount:
          type: number
          format: double
          maximum: 1000000000000000000
          minimum: -1000000000000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
        posted_at:
          type: string
          format: date
          description: Payment date for term discount calculation
      required:
        - amount
        - posted_at
        - transaction_id
    CreditMemoPaymentInput:
      type: object
      properties:
        credit_memo_id:
          type: integer
        amount:
          type: number
          format: double
          maximum: 1000000000000000000
          minimum: -1000000000000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
        posted_at:
          type: string
          format: date
          description: Application date
      required:
        - amount
        - credit_memo_id
        - posted_at
    EmptyTransactionInput:
      type: object
      properties:
        amount:
          type: number
          format: double
          maximum: 1000000000000000000
          minimum: -1000000000000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
        payment_date:
          type: string
          format: date
          description: Payment date for term discount calculation
      required:
        - amount
        - payment_date
  securitySchemes:
    knoxApiToken:
      type: apiKey
      in: header
      name: Authorization
      description: Token-based authentication with required prefix "Token"

````