HTTP Operation Type Object DTO Why-DTOs?
(Mutation) generateCreditNote GenerateCreditNoteGLDtoInput

Description

The GenerateCreditNote service allows you to create a full or partial credit note for an invoice that must be in Closed or Posted status directly through the API.

This service facilitates the automated creation of credit notes to adjust or cancel issued invoices.

img

Functionality

Input Parameters

Invoice Details: Specify the details of the invoice for which a credit note is being created.

Response

The service returns a GenerateCreditNoteOutputGLDto object containing the following fields:

Key Value
Authorization Bearer Current access Token How to find?
X-TenantId Current tenant id How to find?
X-OrganizationId Current organization Id How to find?
x-api-key Primary or secondary subscription key of your app How to find?
Case 1: Full Credit Note

If only the invoice ID is provided, a credit note is generated for the entire invoice amount.

graphQL Query
mutation($input: GenerateCreditNoteGLDtoInput!) {
  generateCreditNote(input: $input) {
    id
  }
}
graphQL Variables
{
  "input": {
    "id": "7af9f050-4a34-4a0b-a1af-30fe00a38abc"
  }
}
Example Response
{
    "data": {
        "generateCreditNote": {
            "id": "0e1987c3-f762-4906-8b26-42e4a4c36079"
        }
    }
}

Case 2: Partial Credit Note

If a lines block is provided, a partial credit note is generated, specifying which products, quantities, and amounts are affected.

graphQL Query
mutation($input: GenerateCreditNoteGLDtoInput!) {
  generateCreditNote(input: $input) {
    id
  }
}
graphQL Variables
{
  "input": {
    "id": "7af9f050-4a34-4a0b-a1af-30fe00a38abc",
    "lines": [
      {
        "productId": "e9d05ca3-79f8-4f50-ad2e-14dfa3d5604e",
        "quantity": 1.00
      },
      {
        "productId": "a3f29b17-5c2d-4d8e-91f1-9b8dcf1a8d3c",
        "quantity": 2.50
      }
    ]
  }
}

Example Response
{
    "data": {
        "generateCreditNote": {
            "id": "3b12a8d2-9b4d-4c6d-8e47-10f6e2d9e7fa"
        }
    }
}_

generateCreditNote Input parameters

Fields Type Description
id UUID Unique identifier of the invoice
lines Array (Optional) List of specific invoice lines for partial credit
  • productId
UUID Unique identifier of the product
  • quantity
Number Mandatory quantity of the product to be credited
  • unitPrice
Number Optional Unit price of the product in the credit note
Info
  • id: Unique identifier of the invoice related to the credit note. The invoice must be in Closed or Posted status.
  • lines:
    • If not provided, the credit note will be full, meaning the invoice will be completely canceled.
    • If provided, the credit note will be partial, specifying which products and quantities are to be credited.
      Lines is an array that can contain multiple products, each with its own quantity and optional unit price.
    • productId: Unique identifier of the product being credited.
    • quantity:
      • The quantity of the product to be credited.
      • For example, if Product A was originally invoiced with a quantity of 5 and the customer returns 2, the credit note should specify a quantity of 2.
      • The credited quantity cannot exceed the originally invoiced quantity, taking into account any previous credit notes issued for the same product on this invoice.
    • unitPrice:
      • The unit price is automatically retrieved from the original invoice line.
      • However, it can be specified if the invoice contains multiple instances of the same product with different prices, allowing the credit note to target the exact line(s) affected.

generateCreditNote Response

Fields Type Description
id UUID Unique identifier of the credit note created