text(): write a bank statement line
Hard
An online bank shows each transaction as one line: when it happened, the amount, and the balance afterwards, separated by " | ":
"Thu, Feb 27th 2:05 PM | ($1,234.50) | balance $8,765.43"
- the time: short weekday, short month, the day with its ordinal ending, and 12-hour time
- money in:
"$12.35"; money out, a negative amount, in brackets:"($1,234.50)"; the balance follows the same rule - thousands separators and exactly two decimals, rounded to the nearest cent
Watch out: text() cuts extra decimals off rather than rounding them. And mm means minutes only when it follows an hour.
Inputs
ri!when— Date and Timeri!amount— Decimalri!balance— Decimal
ri! Rule Inputs
ri!whenDate and Timedatetime(2020, 2, 27, 14, 5, 0)
ri!amountDecimal-1234.5
ri!balanceDecimal8765.432
Example 1 — Money out
Input: ri!when
datetime(2020, 2, 27, 14, 5, 0)
Input: ri!amount
-1234.5
Input: ri!balance
8765.432
Output:
"Thu, Feb 27th 2:05 PM | ($1,234.50) | balance $8,765.43"
Example 2 — Money in, rounded to the cent
Input: ri!when
datetime(2021, 3, 1, 9, 30, 0)
Input: ri!amount
12.346
Input: ri!balance
100
Output:
"Mon, Mar 1st 9:30 AM | $12.35 | balance $100.00"
Example 3 — An overdrawn account
Input: ri!when
datetime(2022, 12, 31, 23, 59, 0)
Input: ri!amount
-50
Input: ri!balance
-20.5
Output:
"Sat, Dec 31st 11:59 PM | ($50.00) | balance ($20.50)"
Example 4 — Just after midnight
Input: ri!when
datetime(2023, 1, 2, 0, 15, 0)
Input: ri!amount
0
Input: ri!balance
5
Output:
"Mon, Jan 2nd 12:15 AM | $0.00 | balance $5.00"
Example 5 — The 11th, not the 11st
Input: ri!when
datetime(2024, 1, 11, 10, 0, 0)
Input: ri!amount
1000
Input: ri!balance
1000
Output:
"Thu, Jan 11th 10:00 AM | $1,000.00 | balance $1,000.00"
Appian Expression Tips
- • Use
ri!variableNamefor rule inputs - • Use
a!localVariables(local!x: …, body)for locals - • Use
a!forEach(items: …, expression: fv!item)to iterate - • Use
where()/reject(fn!isnull, list)to filter