This feature is currently under development and, although not available in the current version, its preliminary documentation is provided to give you a preview of the enhancements that will be included in an upcoming update.

Description

This page explains how to use the public API to create advance invoices and invoices with advance payment deductions.

In the Sage Active interface, from a quote or an order, it is possible to request the creation of an advance invoice.
A form allows defining the advance amount to be invoiced.
Then, when generating an invoice for the same customer, it is possible to deduct the amount of one or more advance invoices already issued to the customer.

Technically, Sage Active uses a product ADVANCE_PAYMENT which is not visible in the product list.
Note that this value depends on the legislation, e.g. ACOMPTE for the French Legislation.

An advance invoice will always include a line with this ADVANCE_PAYMENT product and the corresponding advance amount.
To deduct an advance payment from an invoice, Sage Active adds a line with a negative quantity associated with the ADVANCE_PAYMENT product, reflecting the amount to be deducted.

In the API context, the same mutation operation createSalesInvoice is used, just like for standard invoice creation.

The only distinction with a classical invoice is:

  • Creating an advance invoice requires using the ADVANCE_PAYMENT product, with a quantity of 1 and the amount set to the advance payment value.
  • Deducting an advance payment from an invoice involves adding one or multiple lines (in case of multiple advance payments) to the invoice with the ADVANCE_PAYMENT product, a quantity of -1, and the positive amount to be deducted.

img img img img

Key Points to Know

Example of Creating an Advance Invoice

Here, a single line with the advance payment product ID, a quantity of 1, and the advance payment amount.

In the example, the ID f50af716-34ff-4c1b-8e65-dd08220a056b for the advance payment line must strictly be the ID of the advance payment product retrieved by filtering on the product with the CONCEPT category.

graphQL Mutation
mutation ($values: SalesInvoiceCreateGLDtoInput!) {  
    createSalesInvoice(input: $values) {
    id
  }
}
graphQL Variables
{
  "values": {
    "customerId": "3ec1023d-96b4-4a9e-b536-2f8951d63ba0",
    "documentDate": "2025-02-10",
    "lines": [
      {
        "productId": "f50af716-34ff-4c1b-8e65-dd08220a056b",
        "productName": "Advance payment for Quote 0078", 
        "totalQuantity": 1,
        "unitPrice": 1000
      }
    ]
  }
}

Example of Creating an Invoice with Advance Payment Deduction

Here, the last line deducts the advance payment using the ID of the advance payment product.

In the example, the ID f50af716-34ff-4c1b-8e65-dd08220a056b for the advance payment line must strictly be the ID of the advance payment product retrieved by filtering on the product with the CONCEPT category.

graphQL Mutation
mutation ($values: SalesInvoiceCreateGLDtoInput!) {  
    createSalesInvoice(input: $values) {
    id
  }
}
graphQL Variables
{
  "values": {
    "customerId": "3ec1023d-96b4-4a9e-b536-2f8951d63ba0",
    "documentDate": "2025-02-10",
    "lines": [
      {
        "productId": "f50af716-3200-4c1b-8e65-dd08220a056b",
        "totalQuantity": 50,
        "unitPrice": 11,
        "firstDiscount": 5
      },
      {
        "productId": "f50af716-3412-4c1b-8e65-dd08220a056b",
        "totalQuantity": 4,
        "unitPrice": 22,
        "firstDiscount": 0
      },
      {
        "productId": "f50af716-34ff-4c1b-8e65-dd08220a056b",
        "productName": "Advance payment for Quote 0078",
        "totalQuantity": -1,
        "unitPrice": 1000
      }
    ]
  }
}