Invoice a sales order

distru-create-invoiceWritePOSQuickBooks

Creates the invoice of a sales order that has none. Reaches QuickBooks unless its total is negative, and your POS (Dutchie, Blaze or Treez) when the customer is mapped to one of its retailers.

Inputs

Every tool also takes the common inputs.

FieldTypeRequiredDescription
salesOrderIdstringYesSales order to invoice. Resolve via distru-search-sales-orders.

Output

Presence on a nested field assumes its parent exists.

FieldTypePresence
invoiceobjectAlways
invoice.idstringAlways
invoice.customFieldsobject[]Always
invoice.customFields[].customFieldobjectAlways
invoice.customFields[].customField.idstringAlways
invoice.customFields[].customField.namestringAlways
invoice.customFields[].customField.fieldTypeenum
CHECKBOXDATEDROPDOWNTEXT
Always
invoice.customFields[].valuestringCan be null
invoice.invoiceNumberstringAlways
invoice.paymentStatusenum
NOT_PAIDOVER_PAIDPAIDPARTIALLY_PAID
Always
invoice.totalstringAlways
invoice.subtotalstringAlways
invoice.paidstringAlways
invoice.remainingAmountstringAlways
invoice.creditsAppliedstringCan be null
invoice.paymentsCollectedstringAlways
invoice.invoiceDatestringAlways
invoice.dueDatestringAlways
invoice.externalNotesstringCan be null
invoice.paymentTermNamestringCan be null
invoice.qbInvoiceIdstringCan be null
invoice.qbSyncStatusenum
DELETED_IN_QBOERRORNOT_SYNCEDPARTIALLY_SYNCEDPENDINGSYNCED
Can be null
invoice.voidedAtstringCan be null
invoice.createdDatestringAlways
invoice.updatedDatestringAlways
invoice.customerobjectNull or absent
invoice.customer.idstringAlways
invoice.customer.namestringNull or absent
invoice.ownerobjectCan be null
invoice.owner.idstringAlways
invoice.owner.profileobjectAlways
invoice.owner.profile.fullNamestringAlways
invoice.salesOrderobjectCan be null
invoice.salesOrder.idstringAlways
invoice.salesOrder.orderNumberstringAlways
invoice.billingLocationobjectCan be null
invoice.billingLocation.idstringAlways
invoice.billingLocation.namestringAlways
invoice.billingLocation.addressstringAlways
invoice.invoiceItemsobject[]Always
invoice.invoiceItems[].idstringAlways
invoice.invoiceItems[].quantitystringAlways
invoice.invoiceItems[].orderItemobjectAlways
invoice.invoiceItems[].orderItem.idstringAlways
invoice.invoiceItems[].orderItem.pricestringAlways
invoice.invoiceItems[].orderItem.priceBasestringAlways
invoice.invoiceItems[].orderItem.isSamplebooleanAlways
invoice.invoiceItems[].orderItem.notestringCan be null
invoice.invoiceItems[].orderItem.productobjectAlways
invoice.invoiceItems[].orderItem.product.idstringAlways
invoice.invoiceItems[].orderItem.product.namestringAlways
invoice.invoiceItems[].orderItem.batchobjectCan be null
invoice.invoiceItems[].orderItem.batch.idstringAlways
invoice.invoiceItems[].orderItem.batch.namestringAlways
invoice.invoiceItems[].orderItem.locationobjectCan be null
invoice.invoiceItems[].orderItem.location.idstringAlways
invoice.invoiceItems[].orderItem.location.namestringAlways
invoice.invoiceChargesobject[]Always
invoice.invoiceCharges[].idstringAlways
invoice.invoiceCharges[].namestringAlways
invoice.invoiceCharges[].typestringAlways
invoice.invoiceCharges[].unitTypestringAlways
invoice.invoiceCharges[].percentstringCan be null
invoice.invoiceCharges[].pricestringAlways
invoice.invoiceCharges[].isTaxbooleanAlways
What the AI reads

Creates the invoice of a sales order that has none, the same invoice Distru creates when an order is saved with invoicing on. Bills every line at its ordered minus returned quantity, in the order's line order, with the order's charges; fully returned lines are left out. Dates, due date, payment term, owner, billing location and notes come from the order; the invoice number is assigned per company. Rejected when the order already has an invoice, voided ones included, even one the caller's team can't see (so an empty distru-get-sales-order includeInvoices doesn't prove there is none); when the order is canceled or merged, has no customer or billing location, its billing location was deleted or isn't the customer's, it lacks the due date or the date the invoice date is taken from, or it has nothing left to bill; when the company's invoice numbering (company settings) gives no number, a taken one or one with special characters; when the order's owner can't own invoices in the caller's team; and when the company's custom invoice rules refuse it. Required invoice custom fields are left empty, since this tool can't set them. Queues a QuickBooks and a POS sync when connected; sends no invoice email. To rebuild an invoice, delete it with distru-delete-invoice and create it again; partial invoices and edits are UI-only. Returns the invoice in distru-get-invoice's shape, with its items and charges. Requires authentication via Authorization header.