# Built-in Functions

## Introduction

This guide explains what built-in functions there are in Rulecube and how to use them.

Rulecube has many built-in functions ready to use for you and grouped them into these categories:

* Global
* Finance
* HTTP
* Mail
* MongoDB
* SQL
* Statistics
* Workflow
* System
* Array
* Date

For example, in the Finance group, you have the `pv` function for calculating the present value of a loan or investment. And in the Statistics group, you'll find the `mean` and `median` functions.&#x20;

To discover what's available, the best way is to click on the ![](/files/A38mSqTGAD1JPrMB1MdV) icon and then on "Documentation". This will open the Rulecube Manual.

Alternatively you can access this Manual from any code editor, like when editing a Rule:

<figure><img src="/files/rrjsxqFLutuuFzDxqoXG" alt=""><figcaption><p>Clicking the "Rulecube manual" link will open the Manual in a new window.</p></figcaption></figure>

## Procedure

Let's say you want to calculate the VAT amount from an amount that includes the VAT. The resulting VAT amount can have several decimal places, but for a neat presentation, you want to limit the decimal places to two. Rulecube has the `ROUND` function for this:

1. Create a ruleset named `VAT_calculator`.

2. Create an input named `AmountIncludingVAT` and set its **Type** to `number`.

3. Create a rule named `ExtractVAT` and set its **Type** to `number` and the **Expression** to:<br>

   <pre class="language-javascript" data-line-numbers><code class="lang-javascript">ROUND(AmountIncludingVAT / 121 * 21, 2)
   </code></pre>

4. Click **Save** and click **Try it out** to test the ruleset.

## Additional resources

* [Language (Methods) Reference](/language-reference.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rulecube.com/how-to-guides/ruleset-development/built-in-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
