Monite script

Learn and explore all the possibilities of the Monite script.

Overview

Monite script is our unique declarative programming language based on JSON and YAML syntax that allows the creation of complex business logic scenarios related to business logic objects.

Through the Monite script, it is possible to implement customized scenarios, such as:

  • Set a specific workflow for all payables with more than 300 EUR worth to be approved by a specific entity user.
  • Set a specific workflow for all payables from a specific counterpart with more than 500 USD worth to be approved by a list of entity users, in a row.
  • Set a specific workflow for all payables between 1000 and 5000 GBP worth to be approved by any user with a specific role.

🚧

Currently, the Monite script only supports the payable object. More objects will be added to the Monite script in the near future.

The sample script below defines a workflow in which all the payables created for a specific counterpart (bbe12a96-a09e-45ef-b407-6fc914329c32), with more than 300 EUR worth must be approved by a specific user (5f3196d2-48ce-4c1e-b29e-c3e5d1fb7a13) in order to change their status:

{
  "trigger": {
    "version": 1,
    "object_type": "payable",
    "action": "create",
    "counterparts": [
      "bbe12a96-a09e-45ef-b407-6fc914329c32"
    ],
    "amount": {
      "gt": 30000
    },
    "currency": "EUR",
    "custom_params": {
      "comes_from_email": true,
      "comes_from_upload": true,
      "previously_approved": true
    },
    "statuses": [
      "paid",
      "waiting_to_be_paid"
    ]
  },
  "functions": [
    {
      "call": {
        "method": "Payables.request_approval_by_entity_user",
        "params": {
          "entity_user_ids": [
            "5f3196d2-48ce-4c1e-b29e-c3e5d1fb7a13"
          ]
        }
      }
    }
  ]
}
trigger:
  version: 1
  
  # All payables created for a specific counterpart with more than 300 EUR worth ...
  object_type: payable
  action: create
  counterparts:
  - bbe12a96-a09e-45ef-b407-6fc914329c32
  amount:
    gt: 30000
  currency: EUR
  
  custom_params:
    comes_from_email: true
    comes_from_upload: true
    previously_approved: true
  statuses:
  - paid
  - waiting_to_be_paid
  
# ... must be approved by some user with a specific role_ID
functions:
  - call:
      method: Payables.request_approval_by_role_id
      params:
        role_id: 5f3196d2-48ce-4c1e-b29e-c3e5d1fb7a13

A Monite script consists of two parts:

  • trigger: The conditions for executing the script.

  • functions: The main logical statement flow executed by the script.

Trigger

The trigger defines the conditions that cause the functions to be executed. All trigger conditions are combined using logical AND.

Below is a sample trigger:

"trigger": {
    "version": 1,
    "object_type": "payable",
    "action": "create",
    "counterparts": ["bbe12a96-a09e-45ef-b407-6fc914329c32"],
    "amount": {
      "gt": 30000
    },
    "currency": "EUR",
    "custom_params": {
      "comes_from_email": true,
      "comes_from_upload": true,
      "previously_approved": true
    },
    "statuses": [
      "paid",
      "waiting_to_be_paid"
    ]
  },
trigger:
  version: 1
  
  # All payables created for a specific counterpart with more than 300 EUR worth
  object_type: payable
  action: create
  counterparts:
  - bbe12a96-a09e-45ef-b407-6fc914329c32
  amount:
    gt: 30000
  currency: EUR
  
  custom_params:
    comes_from_email: true
    comes_from_upload: true
    previously_approved: true
  statuses:
  - paid
  - waiting_to_be_paid
  tags:
  - travel

Required fields

Field

Description

version

The version of the Monite script syntax. Must be 1.

currency

The currency code. The functions can only be triggered for objects that have this currency code attached to it.

object_type

The type of objects that are connected with the trigger.

Currently, the Monite script only supports the payable object.

action

The functions will be triggered only when this action is performed on an object. Possible values:

  • create: A new object is created
  • read: An existing object is accessed (for example, via an HTTP GET request)
  • update: An existing object is updated (for example, via an HTTP PATCH or PUT request)
  • delete: An existing object is deleted (for example, via an HTTP DELETE request). Not applicable to payables because they cannot be deleted.

Optional fields

Field

Description

amount

The amount value range, expressed using the comparison operators:

  • gt (greater than)
  • gte (greater than or equal)
  • lt (less than)
  • lte (less than or equal)The amount value is specified as an integer, in the minor units of currency. For example, 12.5 EUR is represented as 1250.

counterparts

The functions will be triggered only if the object was created for one of these counterparts. In the case of payables, the counterpart is the vendor or supplier that issued the invoice to the entity.

created_by_roles

The functions will be triggered only if the object was created by entity users who have any of these roles.

created_by_users

The functions will be triggered only if the object was created by one of these entity users.

custom_params

The currently available custom_params are from the payable object. They describe the origin of the object and can be set as true or false:

  • comes_from_email
  • comes_from_upload
  • previously_approved

statuses

The functions will be triggered only if the object is currently in one of these statuses.

For the payable object, the available values are:

  • new
  • approve_in_progress
  • waiting_to_be_paid
  • paid
  • canceled
  • rejected

tags

The functions will be triggered only if the object has all of the specified tags attached.

For example, "tags": ["travel expenses", "marketing"] means the functions will be triggered only for objects that have both of these tags, but not for objects with just the "travel expenses" or just the "marketing" tag.

Functions

The functions are the main logical statement flow executed by the trigger.

Below is an example of a workflow function. This example requires approval from any one user with a specific role ID. The arguments for the chosen method are set under params:

"functions": [
  {
    "call": {
      "method": "Payables.request_approval_by_role_id",
      "params": {
        "role_id": "5f3196d2-48ce-4c1e-b29e-c3e5d1fb7a13"
      }
    }
  }
]
# ... must be approve by some user with a specific role_ID
functions:
  - call:
      method: Payables.request_approval_by_role_id
      params:
        role_id: 5f3196d2-48ce-4c1e-b29e-c3e5d1fb7a13

Methods

Business logic objects can contain some predefined methods. These methods perform a specific action and do not return any results. They are:

Payables.request_approval_by_entity_user

In this method, the operation has to be approved by a specific number of entity users from the given list of users. For example, you can use this method to require approval from:

  • One specific entity user
  • The given list of entity users (all of them)
  • Any N users from the given list

The example below requires approval from both of the specified entity users:

"functions": [
  {
    "call": {
      "method": "Payables.request_approval_by_entity_user",
      "params": {
        "entity_user_ids": [
          "5f3196d2-48ce-4c1e-b29e-c3e5d1fb7a13",
          "7a3696a5-56ef-5b43-af9f-2ae5d1fb7b25"
        ],
        "entity_users_to_approve": 2
      }
    }
  }
]
functions:
  - call:
      method: Payables.request_approval_by_entity_user
      params:
        entity_user_ids:
        - 5f3196d2-48ce-4c1e-b29e-c3e5d1fb7a13
        - 7a3696a5-56ef-5b43-af9f-2ae5d1fb7b25
        entity_users_to_approve: 2
ArgumentsTypeDescriptionRequired?
entity_user_idsarray of UUIDsA list of users who can approve the requested action. User IDs in the list must be unique.Yes
entity_users_to_approveintegerThe number of users whose approval is required. The default value is 1, meaning the operation can be approved by any user from the entity_user_ids list.No

Payables.request_approval_by_role_id

In this method, the operation has to be approved by any user who has a specific role within the entity. A single user's approval is enough. If there are no users with the specified role, the operation is declined:

"functions": [
  {
    "call": {
      "method": "Payables.request_approval_by_role_id",
      "params": {
        "role_id": "5f3196d2-48ce-4c1e-b29e-c3e5d1fb7a13"
      }
    }
  }
]
functions:
  - call:
      method: Payables.request_approval_by_role_id
      params:
        role_id: 5f3196d2-48ce-4c1e-b29e-c3e5d1fb7a13
ArgumentsTypeDescriptionRequired?
role_idUUIDThe ID of the role required to approve the operation. Any user with this role can approve the operation.Yes

Payables.request_approval_by_chain

In this method, the operation has to be approved by multiple users, one by one, sequentially. If one of the users of the chain refuses to approve the operation, the operation is declined and the next people in the chain do not receive the approval request:

"functions": [
  {
    "call": {
      "method": "Payables.request_approval_by_chain",
      "params": {
        "entity_user_ids": [
          "5f3196d2-48ce-4c1e-b29e-c3e5d1fb7a13",
          "7a3696a5-56ef-5b43-af9f-2ae5d1fb7b25"
        ]
      }
    }
  }
]
functions:
  - call:
      method: Payables.request_approval_by_chain
      params:
        entity_user_ids:
        - 5f3196d2-48ce-4c1e-b29e-c3e5d1fb7a13
        - 7a3696a5-56ef-5b43-af9f-2ae5d1fb7b25
ArgumentsTypeDescriptionRequired?
entity_user_idsarray of UUIDsA list of users who need to approve the requested action. User IDs in the list must be unique.Yes

Did this page help you?