Adaje has a built-in programming language called Adaje Script that lets users programmatically define costs, custom reports, and much more.
This article introduces the idea of using Adaje Script to write custom programs in Adaje. It covers how to create paths to define variables and how to write programs to perform specific functions, such as creating a cost formula for a custom cost of issuance or defining and appending a new column to a report table.
You can learn more about specific locations to use programs in the articles below:
Defining variables
To define variables to be used in the programmatic inputs, users create a path to the desired value. This can be achieved starting at the highest level container (Organization) or any container underneath (Borrower, Project, Issue, etc.).
Start by giving your variable a one-word title with no spaces to be used later in the formula. For example, to define Average Debt Service, the best option would be AvgDebtService.
Once the variable name is input, you can begin to define your path to the variable in Adaje. A path can begin multiple ways:
/ - Starting with just a forward slash will start at the highest level container, such as the Borrower or Organization level.
../ - Starting with two dots then a forward slash will bring you one level above your current container, such as into the Issue select level when creating a cost.
./ - Starting with a single dot and a forward slash will start you in your current container, such as in the Issue level when creating a cost.
Examples (inputting an upfront cost)
par = ../Issue/Par
avgDebtService = ./Average Debt Service
Both examples above created paths to values in the Issue container and are now ready to be used in a custom programs. In the tables below, you will see the operators, keywords, and directives used to write custom programs.
Operator | Description | Arguments |
+ |
Performs addition between various types. Supported cases:
|
*Arguments*:
- **lhs**: The left-hand side of the operation. Must be one of: `number`, `paymentSeries`, `sum`, or `minOrMax`.
- **rhs**: The right-hand side of the operation. Must be one of: `number`, `paymentSeries`, `sum`, or `minOrMax`.
|
- |
Performs subtraction between various types. Supported cases:
|
*Arguments*:
- **lhs**: The left-hand side of the operation. Must be one of: `number`, `paymentSeries`, `sum`, or `minOrMax`.
- **rhs**: The right-hand side of the operation. Must be one of: `number`, `paymentSeries`, `sum`, or `minOrMax`.
|
* |
Performs multiplication between various types. Supported cases:
|
*Arguments*:
- **lhs**: The left-hand side of the operation. Must be one of: `number`, `paymentSeries`, `sum`, or `minOrMax`.
- **rhs**: The right-hand side of the operation. Must be one of: `number`, `paymentSeries`, `sum`, or `minOrMax`.
|
/ |
Performs division between various types. Supported cases:
|
*Arguments*:
- **lhs**: The left-hand side of the operation. Must be one of: `number`, `paymentSeries`, or `minOrMax`.
- **rhs**: The right-hand side of the operation. Must be one of: `number`, or `paymentSeries`.
|
Keyword | Definition | Description | Arguments |
negate
|
|
Negates the value of its argument.
Supports:
- A single `number` argument.
- A single `paymentSeries` argument.
- A single `sum` argument.
- A single `minOrMax` argument.
|
arg: Argument of type `number`, `paymentSeries`, `sum`, or `minOrMax`. |
partialsums
|
|
Sums the relevant dated values of a paymentSeries based on the operator and value of `this` rows date
|
paymentSeries:
The `paymentSeries` to take partialSums of.
operator:
The operator by which to compare the date of `this` row and and arbitrary row date in `paymentSeries`.
|
sum
|
|
Sums the values in a `paymentSeries`.
|
arg:
Argument of type `paymentSeries`.
|
table
|
|
Creates a table with the given schedule and column names.
|
schedule:
The schedule for the table.
columnNames:
The list of column names for the table.
|
schedule
|
|
Creates a schedule based on the provided start date, end date, frequency, calendar, and start date logic.
|
start_date:
The start date of the schedule.
end_date:
The end date of the schedule.
frequency:
The frequency of the schedule.
calendar:
The calendar to use for the schedule.
start_date_logic:
The logic to apply to the start date (include or exclude).
|
map
|
|
Applies a function to each date in a schedule, resulting in a `paymentSeries`.
|
schedule:
The schedule to apply the function to.
function:
The function to apply to each date in the schedule.
|
group
|
|
Groups a `paymentSeries` by intervals defined in a schedule.
|
paymentSeries:
The `paymentSeries` to group.
schedule:
The schedule defining the intervals for grouping.
|
min
|
|
Finds the minimum value among its arguments. Supports:
- A single `paymentSeries` argument.
- Two to four arguments of type `number`, `sum`, or `minOrMax`
|
args:
Arguments of type `paymentSeries`, `number`, `sum`, or `minOrMax`.
|
max
|
|
Finds the maximum value among its arguments. Supports:
- A single `paymentSeries` argument.
- Two to four arguments of type `number`, `sum`, or `minOrMax`.
|
args:
Arguments of type `paymentSeries`, `number`, `sum`, or `minOrMax`.
|
Directive Start |
Description | Example |
APPEND |
The start of the APPEND directive used to add a new column as the last column in a table
|
APPEND COL `paymentSeries` NAMED "new-column-name" TO `table`
|
INSERT |
The start of the INSERT directive used to add a new column at a specific column/column index in the table
|
INSERT COL `paymentSeries` NAMED "new-column-name" IN `table` at "column-name"
|
UPDATE |
The start of the UPDATE directive used to update a table columns data with a new `paymentSeries`
|
UPDATE COL 'column-name' TO `paymentSeries` IN `table`
|
RENAME |
The start of the RENAME directive used to change the name of a column
|
RENAME COL "column-name" TO "new-column-name" IN `table`
|
DELETE |
The start of the DELETE directive used to remove a column in a table
|
DELETE COL "column-name" IN `table`
|