For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
API StatusPartner Portal
HomeGuidesAPI ExplorerSDKsGitHubSupport
HomeGuidesAPI ExplorerSDKsGitHubSupport
  • Introduction
    • Welcome to Monite
    • Monite account structure
    • Postman collections
    • Support
  • Get started
    • Step 1. Get your credentials
    • Step 2. Implement server side
      • Overview
      • Countries
        • Overview
          • Overview
          • Approval requests
          • Processes and steps
          • Trigger examples
          • Script examples
        • Manual transition
      • Purchase orders
      • Payable history
LogoLogo
API StatusPartner Portal
On this page
  • Overview
  • Conditional invoice approval
  • Mark invoice as paid
  • Approval chains
Accounts payableApproval processesApproval policies

Script examples

Explore scenarios to gain insights into how to customize the approval policies with practical situations, and adapt them to fit the distinctive needs and goals of your organization.
Was this page helpful?
Previous

Manual status transition

Learn how to manually change the status of the payables and move them through the workflow until their payment.
Next
Built with

Overview

On this page, you will discover how to tailor your approval processes to your specific needs by looking into the practical side of customizing your approval policies.

Customization allows you to adapt the rules to fit your unique requirements, making your application’s decision-making more efficient.

Approval policies are designed using the MoniteScript. The conditions mentioned on this page must be inserted into the script field.

Conditional invoice approval

The approval policy below states that the approval of either one user OR two roles is required for an invoice to be approved:

1"script": [
2 {
3 "if": {
4 "any": [
5 {
6 "call": "ApprovalRequests.request_approval_by_users",
7 "params": {
8 "user_ids": [user_uuid_list],
9 "required_approval_count": 1
10 }
11 },
12 {
13 "call": "ApprovalRequests.request_approval_by_roles",
14 "params": {
15 "role_ids": [role_uuid_list],
16 "required_approval_count": 2
17 }
18 }
19 ]
20 },
21 "then": ["{Payables.approve(invoice.id)}"],
22 "else": ["{Payables.reject(invoice.id)}"]
23 }
24]

Mark invoice as paid

The approval policy below states that once the invoice is approved by two users AND two roles, it is marked as paid with the comment Marked from approval.:

1"script": [
2 {
3 "if": {
4 "all": [
5 {
6 "call": "ApprovalRequests.request_approval_by_users",
7 "params": {
8 "user_ids": [user_uuid_list],
9 "required_approval_count": 2
10 }
11 },
12 {
13 "call": "ApprovalRequests.request_approval_by_roles",
14 "params": {
15 "role_ids": [role_uuid_list],
16 "required_approval_count": 2
17 }
18 }
19 ]
20 },
21 "then": ["{Payables.mark_as_paid(invoice.id, 'Marked from approval.')}"],
22 "else": ["{Payables.reject(invoice.id)}"]
23 }
24]

Approval chains

The approval policy below is a structured sequence of approvals that occur in a particular order and depend on the previous condition:

1"script": [
2 {
3 "if": {
4 "call": "ApprovalRequests.request_approval_by_users",
5 "params": {
6 "user_ids": [
7 "ac717ee4-bd7d-4564-9319-3c8546e40c36"
8 ],
9 "required_approval_count": 1
10 }
11 },
12 "then": [
13 {
14 "if": {
15 "call": "ApprovalRequests.request_approval_by_roles",
16 "params": {
17 "role_ids": [
18 "2b89fb81-2e51-412f-9164-34607bd842a1"
19 ],
20 "required_approval_count": 1
21 }
22 },
23 "then": [
24 "{Payables.approve(invoice.id)}"
25 ],
26 "else": [
27 "{Payables.reject(invoice.id)}"
28 ]
29 }
30 ],
31 "else": [
32 "{Payables.reject(invoice.id)}"
33 ]
34 }
35]