When to use this endpoint

Use this with Invoice_setDiscount when the discount tax rate is edited separately.

Authentication and permissions

The request must use a logged-in CRM session or valid signed API credentials and is scoped to that tenant.

Users whose legacy crm_access mask contains bit 64 receive {"error":"no permission to access api"}. No record-owner check is made.

Parameters

ParameterTypeRequiredDescription
idPositive integerYesActive invoice ID.
valNumeric-compatible scalarYesDiscount tax percentage under the legacy loose numeric check.

Example request

$result = FM_api('Invoice_setDiscountTax', ['id' => 981, 'val' => '20']);

Example response

{
  "ok": 1
}

Errors and unusual responses

ResponseCondition
{"error":"not logged in"}No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs.
{"error":"invalid parameter: val"}The value fails numeric comparison.
{"error":"cannot edit invoices that are marked Paid"}The invoice is Paid.

Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.

Behaviour and edge cases

  • Unlike several neighbouring setters, this route does not return a no-change warning.

Side effects

  • Writes discount_vat, recalculates invoice and linked-job totals, advances edit metadata, and fires Invoice_edit.

See it in Fieldmotion

CRM1

The invoice editor calls it after changing a non-zero invoice-wide discount.

CRM2

No direct production CRM2 caller was found for this route.

Related endpoints