Late fee settings

Test a late fee formula

Evaluates a late fee formula against sample numbers and returns what it would charge, without reading or writing any stored setting. Use it to check a formula before saving it as the latefees settings type. Requires the settings:read permission.

POST
https://services.magicdoor.com/settings/company-portal/settings/latefees/test/formula

Authorization

Authorizationstringrequired
Bearer token — Send your API token in the Authorization header as Bearer <token>. Requests without a valid token are rejected with 401 Unauthorized.

Body

application/json

formulastringrequired

The expression to evaluate. Must contain at least one non-whitespace character.

example: Min(due * 0.2, 500) + Max(due - 1000, 0) * 0.05
duenumber

The amount currently overdue on the bill. Zero or greater.

default: 100
totalnumber

The full amount of the bill, paid or not. Zero or greater.

default: 1000
lateBillsinteger

How many bills are already late. Zero or greater.

default: 1
lateDaysinteger

How many days the bill has been late. Zero or greater.

default: 5
gracePeriodinteger

How many days of grace the company allows before a fee applies. Zero or greater.

default: 5
graceBalancenumber

The balance below which no late fee is charged. Zero or greater.

default: 0

Response

200 · What the formula evaluates to.

resultnumberrequired

The fee the formula produced, rounded to two decimal places.

400 · `formula` is missing or blank, or one of the sample numbers is out of range.

401 · The access token is missing, expired, or invalid.

403 · The caller does not hold the `settings:read` permission.

422 · The formula could not be parsed, or it did not evaluate to a number.

VariableComes from
dueThe due value in the request body
totalThe total value in the request body
lateBillsThe lateBills value in the request body
lateDaysThe lateDays value in the request body
gracePeriodThe gracePeriod value in the request body
graceBalanceThe graceBalance value in the request body

Formulas are arithmetic expressions with functions such as Min and Max. The result is rounded to two decimal places, halves away from zero. A formula that does not parse, or that evaluates to something other than a number, comes back as a 422.