How to invoice an order
Guide on invoicing orders using GraphQL mutation. Includes example query, result, and parameter descriptions for generating invoices and credit note reports.
To invoice an order, you must first finish the order. You can run the invoicesAndCreditNotes
report on the Order
table in order to invoice an order, as shown in the following example:
Query
mutation invoice_order($cid : Int!,
$ono : [Int]!)
{
useCompany(no : $cid)
{
order_reports
{
invoicesAndCreditNotes(
filter:{orderNo :{_in : $ono}},
returnDocuments : true,
printDestination : PRINT_TO_PDF,
approval : true
)
{
succeeded
documents
{
name
content
attachments
{
name
content
}
}
}
}
}
}
Result
{
"data": {
"useCompany": {
"order_reports": {
"invoicesAndCreditNotes": {
"succeeded": true,
"documents": [
{
"name": "1000013.pdf",
"content": "JVBERi0xLjQKJdD...",
"attachments": []
}
]
}
}
}
}
}
The parameters have the following meaning:
Parameter | Description |
---|---|
filter |
The filter to apply to the report. In this case, we are filtering by the order number (one or more orders). |
returnDocuments |
If set to true , the report will return the invoice document. |
printDestination |
The destination where the invoice will be printed. In this case, we are printing to a PDF file. |
approval |
It updates the tables when set to true (the default value). Set to false to only preview results. |
Tip
The content of the returned documents (and attachments) is base64-encoded. You must decode it to get the original file.