Function reference
A function is written with its name in square brackets, then its values, joined by words that read naturally:
[round] amount to 2. Tests are written after is: account is a valid gstin. How functions fit into rules is
explained in Writing rules and the rule language guide.
84 functions in 12 categories: Text · Text tests · Clean up · Missing values · Numbers · Amounts · Dates · Similarity · Tax and identifiers · Keys · Lists and ranges · Lookup tables
Text
| Write | Gives | What it does |
|---|---|---|
[trim] text | text | Without spaces at the start and end Example: [trim] reference |
[trim start of] text | text | Without spaces at the start Example: [trim start of] reference |
[trim end of] text | text | Without spaces at the end Example: [trim end of] reference |
[lower case] text | text | In small letters Example: [lower case] party |
[upper case] text | text | In capitals Example: [upper case] party |
[title case] text | text | First letter of each word in capitals Example: [title case] party |
[replace in] text, find with with | text | Every occurrence of a piece of text replaced Example: [replace in] reference, '/' with '-' |
[replace pattern in] text, pattern with with | text | What a regular expression matches, replaced Example: [replace pattern in] narration, '[0-9]+' with '' |
[extract] pattern from text | text | The first part of the text a regular expression matches Example: [extract] 'UTR[0-9]+' from narration |
[join] value, value, … | text | Values joined into one text, missing ones left out Example: [join] prefix, '-', number |
[join with] separator, value, … | text | Values joined with a separator, blank ones left out Example: [join with] '/', branch, account |
[left] count of text | text | The first characters Example: [left] 4 of reference |
[right] count of text | text | The last characters Example: [right] 4 of account |
[characters] from to to of text | text | Characters from one position to another, counting from 1 Example: [characters] 3 to 8 of reference |
[part] n of text by separator | text | The nth piece of the text split at a separator, counting from 1 Example: [part] 2 of narration by '/' |
[length of] text | a number | How many characters Example: [length of] reference |
[pad left] text to length with character | text | Filled on the left up to a length Example: [pad left] cheque to 6 with '0' |
[pad right] text to length with character | text | Filled on the right up to a length Example: [pad right] code to 8 with ' ' |
[reverse] text | text | The characters in reverse order Example: [reverse] code |
Text tests
| Write | Gives | What it does |
|---|---|---|
text contains part | yes or no | Whether the text has the part in it, ignoring case Example: narration contains 'NEFT' |
text starts with start | yes or no | Whether the text starts with it, ignoring case Example: reference starts with 'INV' |
text ends with end | yes or no | Whether the text ends with it, ignoring case Example: account ends with '001' |
text contains any of part, … | yes or no | Whether the text has any of the parts in it, ignoring case Example: narration contains any of 'SMS', 'CHG' |
text matches pattern | yes or no | Whether a regular expression finds a match in the text Example: reference matches '^INV[0-9]+' |
Clean up
| Write | Gives | What it does |
|---|---|---|
[remove spaces from] text | text | Without any spaces Example: [remove spaces from] account |
[single spaces in] text | text | Trimmed, runs of spaces turned into one Example: [single spaces in] party |
[digits of] text | text | Only the digits Example: [digits of] cheque |
[letters and digits of] text | text | Only letters and digits Example: [letters and digits of] reference |
[remove special characters from] text | text | Only letters, digits, underscores and spaces Example: [remove special characters from] party |
[remove punctuation from] text | text | Without punctuation Example: [remove punctuation from] party |
[remove accents from] text | text | Accented letters as plain ones Example: [remove accents from] party |
[tidy] text | text | Upper case, trimmed, single spaces Example: [tidy] narration |
[tidy name] text | text | A name for comparing: capitals, letters, digits and single spaces Example: [tidy name] party |
[tidy phone] text | text | Only digits and + Example: [tidy phone] phone |
[tidy email] text | text | Trimmed, in small letters Example: [tidy email] email |
[tidy reference] text | text | Capitals and digits only Example: [tidy reference] reference |
Missing values
| Write | Gives | What it does |
|---|---|---|
value is present | yes or no | Whether there is a value: not missing and not blank Example: reference is present |
[first present of] value, value, … | a value | The first value that is present (not missing or blank) Example: [first present of] utr, cheque, 'NONE' |
Numbers
| Write | Gives | What it does |
|---|---|---|
[number from] text | a number | A number from text such as '1,250.50', '?500' or '(75.00)' Example: [number from] column "Amount" |
value is a number | yes or no | Whether the value reads as a number Example: column "Amount" is a number |
[text of] value | text | The value as text Example: [text of] amount |
[absolute] number | a number | Without its sign Example: [absolute] amount |
[round] number to decimals | a number | Rounded half up to the decimals Example: [round] amount to 2 |
[round up] number to decimals | a number | Rounded up to the decimals Example: [round up] amount to 0 |
[round down] number to decimals | a number | Rounded down to the decimals Example: [round down] amount to 0 |
[sign of] number | a number | 1, 0 or -1 Example: [sign of] amount |
[square root of] number | a number | The square root Example: [square root of] value |
[power of] number to exponent | a number | Raised to a power Example: [power of] rate to 2 |
Amounts
| Write | Gives | What it does |
|---|---|---|
[difference between] a and b | a number | The size of the difference, without sign Example: [difference between] bank_amount and book_amount |
[percent difference between] a and b | a number | The difference as a percentage of the second Example: [percent difference between] invoice and payment |
[within] tolerance of a and b | yes or no | Whether two amounts differ by at most the tolerance Example: [within] 1 of bank_amount and book_amount |
[within percent] percent of a and b | yes or no | Whether two amounts differ by at most a percentage of the second Example: [within percent] 0.5 of invoice and payment |
Dates
| Write | Gives | What it does |
|---|---|---|
[today] | a date | Today's date; also written today Example: date is before today |
[date of] value | a date | The value read as a date (day first unless written year first) Example: [date of] column "Value Date" |
[date from] text as format | a date | A date written in a given format Example: [date from] value_date as 'MM/dd/yyyy' |
value is a date | yes or no | Whether the value reads as a date Example: column "Value Date" is a date |
[format] date as format | text | A date written in a given format Example: [format] date as 'MMM yyyy' |
[days between] from and to | a number | Days from the first date to the second Example: [days between] invoice_date and payment_date |
[year of] date | a number | The year Example: [year of] date |
[month of] date | a number | The month, 1 to 12 Example: [month of] date |
[day of] date | a number | The day of the month Example: [day of] date |
[quarter of] date | a number | The calendar quarter, 1 to 4 Example: [quarter of] date |
[start of month of] date | a date | The first day of its month Example: [start of month of] date |
[end of month of] date | a date | The last day of its month Example: [end of month of] date |
date is a weekend | yes or no | Whether the date is a Saturday or Sunday Example: date is a weekend |
date is a business day | yes or no | Whether the date is Monday to Friday Example: date is a business day |
Similarity
| Write | Gives | What it does |
|---|---|---|
[similarity of] a and b | a number | How alike two texts are, 0 to 1, ignoring case Example: [similarity of] party and payee is at least 0.85 |
[characters different between] a and b | a number | How many characters must change to turn one into the other Example: [characters different between] reference and utr is at most 2 |
[name similarity of] a and b | a number | How alike two names are, 0 to 1 (Jaro-Winkler) Example: [name similarity of] party and payee is at least 0.9 |
[sound of] text | text | A code for how a name sounds (Soundex) Example: [sound of] party is [sound of] payee |
Tax and identifiers
| Write | Gives | What it does |
|---|---|---|
[tidy gstin] text | text | A GSTIN in capitals without separators Example: [tidy gstin] gstin |
text is a valid gstin | yes or no | Whether the text is a well-formed GSTIN Example: gstin is a valid gstin |
[state code of gstin] text | text | The two-digit state code of a GSTIN Example: [state code of gstin] gstin |
[pan of gstin] text | text | The PAN inside a GSTIN Example: [pan of gstin] gstin |
Keys
| Write | Gives | What it does |
|---|---|---|
[key of] value, value, … | text | Values joined with | into one key Example: [key of] account, date |
[fingerprint of] value, value, … | text | A SHA-256 fingerprint of the values Example: [fingerprint of] date, amount, reference |
[md5 of] text | text | MD5 fingerprint Example: [md5 of] reference |
[sha256 of] text | text | SHA-256 fingerprint Example: [sha256 of] reference |
Lists and ranges
| Write | Gives | What it does |
|---|---|---|
value is one of option, … | yes or no | Whether the value is one of those listed Example: status is one of 'OPEN', 'HELD' |
value is between low and high | yes or no | Whether the value is from low to high, both included Example: amount is between 0 and 500 |
Lookup tables
| Write | Gives | What it does |
|---|---|---|
column of key in table | a value | A value from one of the workspace's lookup tables: the row whose key matches; 'default' when there is none Example: the group of party in VENDORS default 'OTHER' |
column for number in table | a value | A value from a range table: the row whose range holds the number Example: the rate for amount in TDS_SLABS |
key is in table | yes or no | Whether a lookup table has the key Example: account is in BLOCKED_ACCOUNTS |
(value, value, …) | text | A key of several values, for tables keyed on more than one column Example: the rate of (party, currency) in RATES |