{
  "swagger": "2.0",
  "info": {
    "description": "API para criação de lote de contas a pagar.",
    "version": "1.0.0.0",
    "title": "TOTVS - API Account Payable Document",
    "termsOfService": "https://www.totvs.com/termos-de-uso/",
    "contact": {
      "email": "box@totvs.com.br"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
    }
  },
  "basePath": "/api/fin/v1/accountPayableDocument",
  "tags": [
    {
      "name": "AccountPayableBatch",
      "description": "Operações relacionadas ao lote de contas a pagar"
    },
    {
      "name": "AccountPayableAdvance",
      "description": "Operações relacionadas a adiantamento de contas a pagar"
    },
    {
      "name": "Payment",
      "description": "Operações relacionadas ao pagamento de contas a pagar"
    },
    {
      "name": "Reversal",
      "description": "Operações relacionadas ao estorno de títulos de contas a pagar"
    },
    {
      "name": "Update",
      "description": "Operações relacionadas à atualização de títulos de contas a pagar"
    }
  ],
  "schemes": [
    "http",
    "https"
  ],
  "paths": {
    "/accountPayableBatch": {
      "post": {
        "tags": [
          "AccountPayableBatch"
        ],
        "summary": "Criação de lote de contas a pagar",
        "description": "Cria um novo lote de contas a pagar com documentos associados.",
        "operationId": "postAccountPayableBatch",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "Payload do lote de contas a pagar",
            "required": true,
            "schema": {
              "$ref": "#/definitions/AccountPayableBatchPayload"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Lote criado com sucesso"
          },
          "400": {
            "description": "Erro de validação ou dados inválidos"
          },
          "500": {
            "description": "Erro interno no servidor"
          }
        }
      }
    },
    "/accountPayableAdvance": {
      "post": {
        "tags": [
          "AccountPayableAdvance"
        ],
        "summary": "Criação de adiantamento de contas a pagar",
        "description": "Cria um novo registro de adiantamento de contas a pagar",
        "operationId": "postAccountPayableAdvance",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "Payload do adiantamento de contas a pagar",
            "required": true,
            "schema": {
              "$ref": "#/definitions/AccountPayableAdvancePayload"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Adiantamento criado com sucesso"
          },
          "400": {
            "description": "Erro de validação ou dados inválidos"
          },
          "500": {
            "description": "Erro interno no servidor"
          }
        }
      }
    },
    "/payment": {
      "post": {
        "tags": [
          "Payment"
        ],
        "summary": "Criação de pagamento de contas a pagar",
        "description": "Cria lote de pagamento ou borderô",
        "operationId": "postPayment",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "Payload do pagamento de contas a pagar",
            "required": true,
            "schema": {
              "$ref": "#/definitions/AccountPayableBatchPayload"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Pagamento criado com sucesso"
          },
          "400": {
            "description": "Erro de validação ou dados inválidos"
          },
          "500": {
            "description": "Erro interno no servidor"
          }
        }
      }
    },
    "/reversal": {
      "put": {
        "tags": [
          "Reversal"
        ],
        "summary": "Estorno de título de contas a pagar",
        "description": "Estorna um título de contas a pagar",
        "operationId": "putReversal",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "Payload do estorno do título",
            "required": true,
            "schema": {
              "$ref": "#/definitions/AccountPayableAdvancePayload"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Título estornado com sucesso"
          },
          "400": {
            "description": "Erro de validação ou dados inválidos"
          },
          "500": {
            "description": "Erro interno no servidor"
          }
        }
      }
    },
    "/": {
      "put": {
        "tags": [
          "Update"
        ],
        "summary": "Atualização de título de contas a pagar",
        "description": "Atualiza um título de contas a pagar",
        "operationId": "put",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "Payload de atualização do título",
            "required": true,
            "schema": {
              "$ref": "#/definitions/AccountPayableAdvancePayload"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Título atualizado com sucesso"
          },
          "400": {
            "description": "Erro de validação ou dados inválidos"
          },
          "500": {
            "description": "Erro interno no servidor"
          }
        }
      }
    }
  },
  "definitions": {
    "AccountPayableBatchPayload": {
      "type": "object",
      "properties": {
        "externalOrganizationTranslationMatrixCode": {
          "type": "string"
        },
        "accountPayableBatchInformation": {
          "$ref": "#/definitions/AccountPayableBatchInformation"
        }
      }
    },
    "AccountPayableBatchInformation": {
      "type": "object",
      "properties": {
        "branchCode": {
          "type": "string"
        },
        "reference": {
          "type": "string"
        },
        "documentClassCode": {
          "type": "string"
        },
        "transactionDate": {
          "type": "string",
          "format": "date"
        },
        "externalBranchCode": {
          "type": "string"
        },
        "transactionTotalValue": {
          "type": "number"
        },
        "companyCode": {
          "type": "string"
        },
        "externalCompanyCode": {
          "type": "string"
        },
        "externalEconomicPurposeCode": {
          "type": "string"
        },
        "currencyCode": {
          "type": "string"
        },
        "isBalanceImplantation": {
          "type": "boolean"
        },
        "referenceBranchCode": {
          "type": "string"
        },
        "bordereauBranchCode": {
          "type": "string"
        },
        "totalPaymentValue": {
          "type": "number"
        },
        "totalInformedValue": {
          "type": "number"
        },
        "supplierCode": {
          "type": "integer"
        },
        "statementNumber": {
          "type": "integer"
        },
        "initialMessage": {
          "type": "string"
        },
        "finalMessage": {
          "type": "string"
        },
        "isStatementEletronic": {
          "type": "boolean"
        },
        "isStatementSent": {
          "type": "boolean"
        },
        "economicPurposeCode": {
          "type": "string"
        },
        "portfolioCode": {
          "type": "string"
        },
        "isReferenceUpdated": {
          "type": "boolean"
        },
        "isPartialBatchGenerated": {
          "type": "boolean"
        },
        "collectorCode": {
          "type": "string"
        },
        "externalCollectorCode": {
          "type": "string"
        },
        "externalModalityCode": {
          "type": "string"
        },
        "transactionType": {
          "type": "integer"
        },
        "isDocumentBranchUsed": {
          "type": "boolean"
        },
        "accountPayableDocumentInformation": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/AccountPayableDocument"
          }
        },
        "tenNineNineInformation": {
          "$ref": "#/definitions/TenNineNineInformation"
        }
      }
    },
    "AccountPayableDocument": {
      "type": "object",
      "properties": {
        "alternativePaymentMethodCode": {
          "type": "string"
        },
        "companyCode": {
          "type": "string"
        },
        "branchCode": {
          "type": "string"
        },
        "documentClassCode": {
          "type": "string"
        },
        "documentNumber": {
          "type": "string"
        },
        "documentParcelNumber": {
          "type": "string"
        },
        "documentSerieCode": {
          "type": "string"
        },
        "documentValue": {
          "type": "number"
        },
        "dueDate": {
          "type": "string",
          "format": "date"
        },
        "currencyCode": {
          "type": "string"
        },
        "economicPurposeCode": {
          "type": "string"
        },
        "supplierCode": {
          "type": "integer"
        },
        "supplierName": {
          "type": "string"
        },
        "paymentMethodCode": {
          "type": "string"
        },
        "portfolioCode": {
          "type": "string"
        },
        "transactionDate": {
          "type": "string",
          "format": "date"
        },
        "reference": {
          "type": "string"
        },
        "paymentValue": {
          "type": "number"
        }
      }
    },
    "TenNineNineInformation": {
      "type": "object",
      "properties": {
        "tenNineNineValue": {
          "type": "number"
        },
        "taxIndentificationNumber": {
          "type": "string"
        },
        "tenNineNineTransactionType": {
          "type": "integer"
        }
      }
    },
    "AccountPayableAdvancePayload": {
      "type": "object",
      "properties": {
        "externalOrganizationTranslationMatrixCode": {
          "type": "string"
        },
        "accountPayableDocumentInformation": {
          "$ref": "#/definitions/AccountPayableDocumentInformation"
        }
      }
    },
    "AccountPayableDocumentInformation": {
      "type": "object",
      "properties": {
        "companyCode": {
          "type": "string"
        },
        "branchCode": {
          "type": "string"
        },
        "documentClassCode": {
          "type": "string"
        },
        "documentNumber": {
          "type": "string"
        },
        "documentParcelNumber": {
          "type": "string"
        },
        "documentSerieCode": {
          "type": "string"
        },
        "documentValue": {
          "type": "number"
        },
        "dueDate": {
          "type": "string",
          "format": "date"
        },
        "supplierCode": {
          "type": "integer"
        },
        "currencyCode": {
          "type": "string"
        },
        "reference": {
          "type": "string"
        },
        "transactionDate": {
          "type": "string",
          "format": "date"
        },
        "paymentValue": {
          "type": "number"
        },
        "collectorCode": {
          "type": "string"
        },
        "prepaymentReference": {
          "type": "string"
        },
        "quotationDate": {
          "type": "string",
          "format": "date"
        },
        "quotationValue": {
          "type": "number"
        },
        "discountValue": {
          "type": "number"
        },
        "writeOffValue": {
          "type": "number"
        },
        "penaltyValue": {
          "type": "number"
        },
        "interestValue": {
          "type": "number"
        },
        "comment": {
          "type": "string"
        },
        "paymentMethodCode": {
          "type": "string"
        },
        "alternativePaymentMethodCode": {
          "type": "string"
        },
        "paymentBankDocumentNumber": {
          "type": "string"
        },
        "checkBranchCode": {
          "type": "string"
        },
        "sequence": {
          "type": "number"
        },
        "economicPurposeCode": {
          "type": "string"
        },
        "checkbookNumber": {
          "type": "number"
        },
        "checkNumber": {
          "type": "number"
        },
        "checkBearer": {
          "type": "string"
        },
        "checkBearerName": {
          "type": "string"
        },
        "exchangeVarianceValue": {
          "type": "number"
        },
        "portfolioCode": {
          "type": "string"
        },
        "externalCollectorCode": {
          "type": "string"
        },
        "externalModalityCode": {
          "type": "string"
        },
        "externalEconomicPurposeCode": {
          "type": "string"
        },
        "prepaymentWriteOffInformation": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/PrepaymentWriteOffInformation"
          }
        },
        "provisionWriteOffInformation": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/ProvisionWriteOffInformation"
          }
        },
        "pendentGLAppropriationInformation": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/PendentGLAppropriationInformation"
          }
        },
        "pendentTaxInformation": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/PendentTaxInformation"
          }
        },
        "pendentRelationInformation": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/PendentRelationInformation"
          }
        },
        "exchangeInformation": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/ExchangeInformation"
          }
        }
      }
    },
    "PrepaymentWriteOffInformation": {
      "type": "object",
      "properties": {
        "documentClassCode": {
          "type": "string"
        },
        "documentNumber": {
          "type": "string"
        },
        "documentParcelNumber": {
          "type": "string"
        },
        "documentSerieCode": {
          "type": "string"
        },
        "writeOffValue": {
          "type": "number"
        },
        "isZeroBal": {
          "type": "boolean"
        },
        "supplierCode": {
          "type": "string"
        },
        "branchCode": {
          "type": "string"
        }
      }
    },
    "ProvisionWriteOffInformation": {
      "type": "object",
      "properties": {
        "documentClassCode": {
          "type": "string"
        },
        "documentNumber": {
          "type": "string"
        },
        "documentParcelNumber": {
          "type": "string"
        },
        "documentSerieCode": {
          "type": "string"
        },
        "writeOffValue": {
          "type": "number"
        },
        "isZeroBal": {
          "type": "boolean"
        },
        "supplierCode": {
          "type": "string"
        },
        "branchCode": {
          "type": "string"
        }
      }
    },
    "PendentGLAppropriationInformation": {
      "type": "object",
      "properties": {
        "accountCode": {
          "type": "string"
        },
        "accountPlanCode": {
          "type": "string"
        },
        "costCenterCode": {
          "type": "string"
        },
        "glAppropriationValue": {
          "type": "number"
        },
        "branchCode": {
          "type": "string"
        },
        "reference": {
          "type": "string"
        },
        "sequence": {
          "type": "integer"
        },
        "businessUnitCode": {
          "type": "string"
        },
        "costCenterPlanCode": {
          "type": "string"
        },
        "financialFlowTypeCode": {
          "type": "string"
        },
        "countryCode": {
          "type": "string"
        },
        "stateCode": {
          "type": "string"
        },
        "taxCode": {
          "type": "string"
        },
        "taxClassificationCode": {
          "type": "string"
        },
        "externalFinancialFlowTypeCode": {
          "type": "string"
        },
        "externalAccountCode": {
          "type": "string"
        },
        "externalSubAccountCode": {
          "type": "string"
        },
        "externalCostCenterCode": {
          "type": "string"
        },
        "externalBusinessUnitCode": {
          "type": "string"
        }
      }
    },
    "PendentTaxInformation": {
      "type": "object",
      "properties": {
        "countyCode": {
          "type": "string"
        },
        "stateCode": {
          "type": "string"
        },
        "documentClassCode": {
          "type": "string"
        },
        "documentNumber": {
          "type": "string"
        },
        "documentParcelNumber": {
          "type": "string"
        },
        "documentSerieCode": {
          "type": "string"
        },
        "taxCode": {
          "type": "string"
        },
        "taxValue": {
          "type": "number"
        },
        "taxBaseValue": {
          "type": "number"
        },
        "taxPercentage": {
          "type": "number"
        },
        "taxType": {
          "type": "integer"
        },
        "taxClass": {
          "type": "integer"
        },
        "taxClassification": {
          "type": "string"
        },
        "accountPlanCode": {
          "type": "string"
        },
        "accountCode": {
          "type": "string"
        },
        "dueDate": {
          "type": "string",
          "format": "date"
        },
        "revenueTax": {
          "type": "number"
        },
        "inssDeduction": {
          "type": "number"
        },
        "dependentDeduction": {
          "type": "number"
        },
        "pensionDeduction": {
          "type": "number"
        },
        "otherDeductions": {
          "type": "number"
        },
        "paidTax": {
          "type": "number"
        },
        "currencyCode": {
          "type": "string"
        },
        "economicPurposeValue": {
          "type": "number"
        },
        "standardHistoryDescription": {
          "type": "string"
        },
        "supplierCode": {
          "type": "number"
        },
        "deductionValue": {
          "type": "number"
        },
        "externalCountryCode": {
          "type": "string"
        },
        "externalAccountCode": {
          "type": "string"
        },
        "externalSubAccountCode": {
          "type": "string"
        },
        "externalFinancialFlowTypeCode": {
          "type": "string"
        }
      }
    },
    "PendentRelationInformation": {
      "type": "object",
      "properties": {
        "branchCode": {
          "type": "string"
        },
        "relationValue": {
          "type": "number"
        },
        "correctValueReason": {
          "type": "integer"
        },
        "relationAppropriationInformation": {
          "$ref": "#/definitions/RelationAppropriationInformation"
        }
      }
    },
    "RelationAppropriationInformation": {
      "type": "object",
      "properties": {
        "accountCode": {
          "type": "string"
        },
        "glAppropriationType": {
          "type": "integer"
        },
        "glAppropriationValue": {
          "type": "number"
        },
        "reducedAccountCode": {
          "type": "integer"
        },
        "subAccountCode": {
          "type": "string"
        }
      }
    },
    "ExchangeInformation": {
      "type": "object",
      "properties": {
        "branchCode": {
          "type": "string"
        },
        "exchangeContractIDNumber": {
          "type": "integer"
        },
        "exchangeContractNumber": {
          "type": "string"
        },
        "importExchangeContractDate": {
          "type": "string",
          "format": "date"
        },
        "reference": {
          "type": "string"
        },
        "referenceDate": {
          "type": "string",
          "format": "date"
        }
      }
    }
  }
}