Finance ledger (v1)

https://github.com/folio-org/mod-finance

Table of contents

Ledger API

This documents the API calls that can be made to manage ledgers

Finance ledger

Finance ledger APIs

POST /finance/ledgers

Create a new ledger item.

POST /finance/ledgers
Query Parameters
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "A financial ledger",
  "type": "object",
  "properties": {
    "id": {
      "description": "UUID of this ledger",
      "$ref": "../../common/schemas/uuid.json"
    },
    "name": {
      "description": "The name of the ledger",
      "type": "string"
    },
    "code": {
      "description": "The code for the ledger",
      "type": "string"
    },
    "description": {
      "description": "The description of the ledger",
      "type": "string"
    },
    "fiscalYearOneId": {
      "description": "UUID of the first fiscal year associated with this ledger",
      "$ref": "../../common/schemas/uuid.json"
    },
    "ledgerStatus": {
      "description": "The status of the ledger",
      "type": "string",
      "enum": [
        "Active",
        "Inactive",
        "Frozen"
      ]
    },
    "allocated": {
      "description": "The amount currently allocated to this ledger",
      "type": "number",
      "readonly": true
    },
    "available": {
      "description": "The amount currently available in this ledger",
      "type": "number",
      "readonly": true
    },
    "unavailable": {
      "description": "The amount already utilized from the allocated amount",
      "type": "number",
      "readonly": true
    },
    "currency": {
      "description": "The ISO code for currency",
      "type": "string"
    },
    "acqUnitIds": {
      "description": "acquisition unit ids associated with this ledger",
      "type": "array",
      "items": {
        "$ref": "../../common/schemas/uuid.json"
      }
    },
    "restrictEncumbrance": {
      "description": "If true, imposes restrictions on encumbrances",
      "type": "boolean",
      "default": true
    },
    "restrictExpenditures": {
      "description": "If true, imposes restrictions on payments",
      "type": "boolean",
      "default": true
    },
    "metadata": {
      "type": "object",
      "$ref": "../../../raml-util/schemas/metadata.schema",
      "readonly": true
    }
  },
  "additionalProperties": false,
  "required": [
    "name",
    "code",
    "fiscalYearOneId",
    "ledgerStatus",
    "restrictEncumbrance",
    "restrictExpenditures"
  ]
}

Example:

{
  "id": "7cef8378-7cbd-1fae-bcdd-8b9d7c0af9de",
  "name": "Main Library",
  "code": "MAIN-LIB",
  "description": "This is the ledger for the Main Library",
  "fiscalYearOneId": "d875618b-7cf5-442f-a823-9814e7bce92a",
  "ledgerStatus": "Active",
  "allocated": 2000,
  "available": 1000,
  "unavailable": 1000,
  "currency": "USD",
  "restrictEncumbrance": false,
  "restrictExpenditures": false,
  "acqUnitIds": [
    "ac2164c7-ba3d-1bc2-912c-e35ceccbfaf2"
  ]
}

Response 201

Returns a newly created item, with server-controlled fields like 'id' populated

Headers
  • Location: required (string)

    URI to the created ledger item

Body

Media type: application/json

Type: any

Example:

{
  "id": "7cef8378-7cbd-1fae-bcdd-8b9d7c0af9de",
  "name": "Main Library",
  "code": "MAIN-LIB",
  "description": "This is the ledger for the Main Library",
  "fiscalYearOneId": "d875618b-7cf5-442f-a823-9814e7bce92a",
  "ledgerStatus": "Active",
  "allocated": 2000,
  "available": 1000,
  "unavailable": 1000,
  "currency": "USD",
  "restrictEncumbrance": false,
  "restrictExpenditures": false,
  "acqUnitIds": [
    "ac2164c7-ba3d-1bc2-912c-e35ceccbfaf2"
  ]
}

Response 400

Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response.

Body

Media type: text/plain

Type: any

Example:

"unable to add ledger -- malformed JSON at 13:3"

Response 401

Not authorized to perform requested action

Body

Media type: text/plain

Type: any

Example:

unable to create ledgers -- unauthorized

Response 422

Validation errors

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "A set of errors",
  "type": "object",
  "properties": {
    "errors": {
      "description": "List of errors",
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$ref": "error.schema"
      }
    },
    "total_records": {
      "description": "Total number of errors",
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /finance/ledgers

Retrieve a list of ledger items.

GET /finance/ledgers
Query Parameters
  • fiscalYear: (string - pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$)

    Fiscal Year Id

    Example:

    3defdcde-3002-41d3-a31c-1fb88288f872
  • offset: (integer - default: 0 - minimum: 0 - maximum: 2147483647)

    Skip over a number of elements by specifying an offset value for the query

    Example:

    0
  • limit: (integer - default: 10 - minimum: 0 - maximum: 2147483647)

    Limit the number of elements returned in the response

    Example:

    10
  • query: (string)

    A query expressed as a CQL string (see dev.folio.org/reference/glossary#cql) using valid searchable fields. The first example below shows the general form of a full CQL query, but those fields might not be relevant in this context.

    with valid searchable fields: for example code

    Example:

    (username=="ab*" or personal.firstName=="ab*" or personal.lastName=="ab*") and active=="true" sortby personal.lastName personal.firstName barcode
    
    ["code", "MEDGRANT", "="]
    
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Response 200

Returns a list of ledger items

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "A collection of ledgers",
  "type": "object",
  "properties": {
    "ledgers": {
      "description": "Collection of ledger records",
      "type": "array",
      "id": "ledgers",
      "items": {
        "type": "object",
        "$ref": "ledger.json"
      }
    },
    "totalRecords": {
      "description": "The number of objects contained in this collection",
      "type": "integer"
    }
  },
  "additionalProperties": false,
  "required": [
    "ledgers",
    "totalRecords"
  ]
}

Example:

{
  "ledgers": [
    {
      "id": "7cef8378-7cbd-1fae-bcdd-8b9d7c0af9de",
      "name": "Main Library",
      "code": "MAIN-LIB",
      "description": "This is the ledger for the Main Library",
      "fiscalYearOneId": "d875618b-7cf5-442f-a823-9814e7bce92a",
      "ledgerStatus": "Active",
      "allocated": 2000,
      "available": 1000,
      "unavailable": 1000,
      "currency": "USD",
      "restrictEncumbrance": false,
      "restrictExpenditures": false,
      "acqUnitIds": [
         "ac2164c7-ba3d-1bc2-b12c-e35ceccbfaf2"
      ]
     }
  ],
  "totalRecords": 1
}

Response 400

Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response.

Body

Media type: text/plain

Type: any

Example:

unable to list ledgers -- malformed parameter 'query', syntax error at column 6

Response 401

Not authorized to perform requested action

Body

Media type: text/plain

Type: any

Example:

unable to list ledgers -- unauthorized

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

internal server error, contact administrator

PUT /finance/ledgers/{id}

Update ledger item with given {ledgerId}

PUT /finance/ledgers/{id}
URI Parameters
  • id: required (string - pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$)

    The UUID of a ledger

Query Parameters
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "A financial ledger",
  "type": "object",
  "properties": {
    "id": {
      "description": "UUID of this ledger",
      "$ref": "../../common/schemas/uuid.json"
    },
    "name": {
      "description": "The name of the ledger",
      "type": "string"
    },
    "code": {
      "description": "The code for the ledger",
      "type": "string"
    },
    "description": {
      "description": "The description of the ledger",
      "type": "string"
    },
    "fiscalYearOneId": {
      "description": "UUID of the first fiscal year associated with this ledger",
      "$ref": "../../common/schemas/uuid.json"
    },
    "ledgerStatus": {
      "description": "The status of the ledger",
      "type": "string",
      "enum": [
        "Active",
        "Inactive",
        "Frozen"
      ]
    },
    "allocated": {
      "description": "The amount currently allocated to this ledger",
      "type": "number",
      "readonly": true
    },
    "available": {
      "description": "The amount currently available in this ledger",
      "type": "number",
      "readonly": true
    },
    "unavailable": {
      "description": "The amount already utilized from the allocated amount",
      "type": "number",
      "readonly": true
    },
    "currency": {
      "description": "The ISO code for currency",
      "type": "string"
    },
    "acqUnitIds": {
      "description": "acquisition unit ids associated with this ledger",
      "type": "array",
      "items": {
        "$ref": "../../common/schemas/uuid.json"
      }
    },
    "restrictEncumbrance": {
      "description": "If true, imposes restrictions on encumbrances",
      "type": "boolean",
      "default": true
    },
    "restrictExpenditures": {
      "description": "If true, imposes restrictions on payments",
      "type": "boolean",
      "default": true
    },
    "metadata": {
      "type": "object",
      "$ref": "../../../raml-util/schemas/metadata.schema",
      "readonly": true
    }
  },
  "additionalProperties": false,
  "required": [
    "name",
    "code",
    "fiscalYearOneId",
    "ledgerStatus",
    "restrictEncumbrance",
    "restrictExpenditures"
  ]
}

Example:

{
  "id": "7cef8378-7cbd-1fae-bcdd-8b9d7c0af9de",
  "name": "Main Library",
  "code": "MAIN-LIB",
  "description": "This is the ledger for the Main Library",
  "fiscalYearOneId": "d875618b-7cf5-442f-a823-9814e7bce92a",
  "ledgerStatus": "Active",
  "allocated": 2000,
  "available": 1000,
  "unavailable": 1000,
  "currency": "USD",
  "restrictEncumbrance": false,
  "restrictExpenditures": false,
  "acqUnitIds": [
    "ac2164c7-ba3d-1bc2-912c-e35ceccbfaf2"
  ]
}

Response 204

Item successfully updated

Response 400

Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response.

Body

Media type: text/plain

Type: any

Example:

"unable to update ledger -- malformed JSON at 13:4"

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"ledger not found"

Response 422

Validation errors

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "A set of errors",
  "type": "object",
  "properties": {
    "errors": {
      "description": "List of errors",
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$ref": "error.schema"
      }
    },
    "total_records": {
      "description": "Total number of errors",
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

internal server error, contact administrator

GET /finance/ledgers/{id}

Retrieve ledger item with given {ledgerId}

GET /finance/ledgers/{id}
URI Parameters
  • id: required (string - pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$)

    The UUID of a ledger

Query Parameters
  • fiscalYear: required (string - pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$)

    The UUID of a fiscal year

  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Response 200

Returns item with a given ID

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "A financial ledger",
  "type": "object",
  "properties": {
    "id": {
      "description": "UUID of this ledger",
      "$ref": "../../common/schemas/uuid.json"
    },
    "name": {
      "description": "The name of the ledger",
      "type": "string"
    },
    "code": {
      "description": "The code for the ledger",
      "type": "string"
    },
    "description": {
      "description": "The description of the ledger",
      "type": "string"
    },
    "fiscalYearOneId": {
      "description": "UUID of the first fiscal year associated with this ledger",
      "$ref": "../../common/schemas/uuid.json"
    },
    "ledgerStatus": {
      "description": "The status of the ledger",
      "type": "string",
      "enum": [
        "Active",
        "Inactive",
        "Frozen"
      ]
    },
    "allocated": {
      "description": "The amount currently allocated to this ledger",
      "type": "number",
      "readonly": true
    },
    "available": {
      "description": "The amount currently available in this ledger",
      "type": "number",
      "readonly": true
    },
    "unavailable": {
      "description": "The amount already utilized from the allocated amount",
      "type": "number",
      "readonly": true
    },
    "currency": {
      "description": "The ISO code for currency",
      "type": "string"
    },
    "acqUnitIds": {
      "description": "acquisition unit ids associated with this ledger",
      "type": "array",
      "items": {
        "$ref": "../../common/schemas/uuid.json"
      }
    },
    "restrictEncumbrance": {
      "description": "If true, imposes restrictions on encumbrances",
      "type": "boolean",
      "default": true
    },
    "restrictExpenditures": {
      "description": "If true, imposes restrictions on payments",
      "type": "boolean",
      "default": true
    },
    "metadata": {
      "type": "object",
      "$ref": "../../../raml-util/schemas/metadata.schema",
      "readonly": true
    }
  },
  "additionalProperties": false,
  "required": [
    "name",
    "code",
    "fiscalYearOneId",
    "ledgerStatus",
    "restrictEncumbrance",
    "restrictExpenditures"
  ]
}

Example:

{
  "id": "7cef8378-7cbd-1fae-bcdd-8b9d7c0af9de",
  "name": "Main Library",
  "code": "MAIN-LIB",
  "description": "This is the ledger for the Main Library",
  "fiscalYearOneId": "d875618b-7cf5-442f-a823-9814e7bce92a",
  "ledgerStatus": "Active",
  "allocated": 2000,
  "available": 1000,
  "unavailable": 1000,
  "currency": "USD",
  "restrictEncumbrance": false,
  "restrictExpenditures": false,
  "acqUnitIds": [
    "ac2164c7-ba3d-1bc2-912c-e35ceccbfaf2"
  ]
}

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"ledger not found"

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

internal server error, contact administrator

DELETE /finance/ledgers/{id}

Delete ledger item with given {ledgerId}

DELETE /finance/ledgers/{id}
URI Parameters
  • id: required (string - pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$)

    The UUID of a ledger

Query Parameters
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Response 204

Item deleted successfully

Response 400

Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response.

Body

Media type: text/plain

Type: any

Example:

"unable to delete ledger -- constraint violation"

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"ledger not found"

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /finance/ledgers/{id}/current-fiscal-year

Retrieve current-fiscal-year item with given {current-fiscal-yearId}

GET /finance/ledgers/{id}/current-fiscal-year
URI Parameters
  • id: required (string - pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$)

    The UUID of a ledger

Query Parameters
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Response 200

Returns item with a given ID

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "A fiscal year record",
  "type": "object",
  "properties": {
    "id": {
      "description": "UUID of the fiscal year record",
      "$ref": "../../common/schemas/uuid.json"
    },
    "acqUnitIds": {
      "description": "UUIDs of the acquisition units associated with this fiscal year",
      "type": "array",
      "items": {
        "$ref": "../../common/schemas/uuid.json"
      }
    },
    "name": {
      "description": "The name of the fiscal year",
      "type": "string"
    },
    "code": {
      "description": "The code of the fiscal year",
      "type": "string",
      "pattern": "^[a-zA-Z]+[0-9]{4}$"
    },
    "currency": {
      "description": "Currency code which is recorded when the FY ends, otherwise the system currency can be assumed",
      "type": "string"
    },
    "description": {
      "description": "The description of the fiscal year",
      "type": "string"
    },
    "periodStart": {
      "description": "The start date of the fiscal year",
      "type": "string",
      "format": "date-time"
    },
    "periodEnd": {
      "description": "The end date of the fiscal year",
      "type": "string",
      "format": "date-time"
    },
    "series": {
      "description": "The fiscal year series",
      "type": "string"
    },
    "metadata": {
      "type": "object",
      "$ref": "../../../raml-util/schemas/metadata.schema",
      "readonly": true
    }
  },
  "additionalProperties": false,
  "required": [
    "code",
    "name",
    "periodStart",
    "periodEnd"
  ]
}

Example:

{
  "id": "ac2164c7-ba3d-1bc2-a12c-e35ceccbfaf2",
  "name": "Fiscal Year 2020",
  "acqUnitIds": [
    "1895e539-8dac-441e-b1f5-aab62b3fde60",
    "47f504bd-0c1b-498e-a2ae-e2f0a0cea273"
  ],
  "code": "FY2020",
  "description": "January 1 - December 30",
  "periodStart": "2020-01-01T00:00:00Z",
  "periodEnd": "2020-12-30T23:59:59Z",
  "series": "FY",
  "metadata": {
    "createdDate": "2019-06-17T14:12:42.497+0000",
    "createdByUserId": "498492aa-f909-42f6-b154-5bf66e6486ba",
    "updatedDate": "2019-08-28T08:37:19.263+0000",
    "updatedByUserId": "7ec56c96-e9f2-4079-9509-86b00f8dacd5"
  }
}

Response 401

Not authorized to perform requested action

Body

Media type: text/plain

Type: any

Example:

unable to get retrieve current-fiscal-year -- unauthorized

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"current-fiscal-year not found"

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

internal server error, contact administrator