foliolib.folio.api.finance.Ledgers

class foliolib.folio.api.finance.Ledgers(tenant: str, okapi: Optional[foliolib.okapi.okapiClient.OkapiClient] = None)

Bases: foliolib.folio.FolioApi

Ledger API

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

Parameters
  • tenant (str) – Tenant id

  • okapi (OkapiClient, optional) – Instance of OkapiClient. Defaults to None.

Methods

delete_ledger(ledgersId)

Delete ledger item with given {ledgerId}

get_currentFiscalYear_by_ledger(ledgersId)

Retrieve currentFiscalYear item with given {currentFiscalYearId}

get_ledger(ledgersId)

Retrieve ledger item with given {ledgerId}

get_ledgers(**kwargs)

Retrieve a list of ledger items.

modify_ledger(ledgersId, ledger)

Update ledger item with given {ledgerId}

set_ledger(ledger)

Create a new ledger item.

delete_ledger(ledgersId: str)

Delete ledger item with given {ledgerId}

DELETE /finance/ledgers/{ledgersId}

Parameters

ledgersId (str) –

Raises
  • OkapiRequestNotFound – Not Found

  • OkapiRequestError – Bad Request

  • OkapiFatalError – Server Error

get_currentFiscalYear_by_ledger(ledgersId: str)

Retrieve currentFiscalYear item with given {currentFiscalYearId}

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

Parameters

ledgersId (str) –

Returns

See Schema below

Return type

dict

Raises
  • OkapiRequestUnauthorized – Authentication is required

  • OkapiRequestNotFound – Not Found

  • OkapiFatalError – Server Error

Schema

{
  "$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"
    },
    "_version": {
      "type": "integer",
      "description": "Record version for optimistic locking"
    },
    "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"
    },
    "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"
    },
    "financialSummary": {
      "description": "Includes Funding information and Financial activity",
      "$ref": "fiscal_year_financial_summary.json"
    },
    "metadata": {
      "type": "object",
      "$ref": "../../../raml-util/schemas/metadata.schema",
      "readonly": true
    }
  },
  "additionalProperties": false,
  "required": [
    "code",
    "name",
    "periodStart",
    "periodEnd"
  ]
}
get_ledger(ledgersId: str)

Retrieve ledger item with given {ledgerId}

GET /finance/ledgers/{ledgersId}

Parameters

ledgersId (str) –

Returns

See Schema below

Return type

dict

Raises
  • OkapiRequestNotFound – Not Found

  • OkapiFatalError – Server Error

Schema

{
  "$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"
    },
    "_version": {
      "type": "integer",
      "description": "Record version for optimistic locking"
    },
    "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
    },
    "netTransfers": {
      "description": "Summing all the transfers from/to this ledger. Amount can be negative",
      "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
    },
    "initialAllocation": {
      "description": "Summary of all related to this ledger budgets initialAllocation",
      "type": "number",
      "readonly": true
    },
    "allocationTo": {
      "description": "Summary of all related to this ledger budgets allocationTo",
      "type": "number",
      "readonly": true
    },
    "allocationFrom": {
      "description": "Summary of all related to this ledger budgets allocationFrom",
      "type": "number",
      "readonly": true
    },
    "totalFunding": {
      "description": "Summary of all related to this ledger budgets totalFunding",
      "type": "number",
      "readonly": true
    },
    "cashBalance": {
      "description": "Summary of all related to this ledger budgets cashBalance",
      "type": "number",
      "readonly": true
    },
    "awaitingPayment": {
      "description": "Summary of all related to this ledger budgets awaitingPayment",
      "type": "number",
      "readonly": true
    },
    "encumbered": {
      "description": "Summary of all related to this ledger budgets encumbered",
      "type": "number",
      "readonly": true
    },
    "expenditures": {
      "description": "Summary of all related to this ledger budgets expenditures",
      "type": "number",
      "readonly": true
    },
    "overEncumbrance": {
      "description": "Summary of all related to this ledger budgets overEncumbrance",
      "type": "number",
      "readonly": true
    },
    "overExpended": {
      "description": "Summary of all related to this ledger budgets overExpended",
      "type": "number",
      "readonly": true
    }
  },
  "additionalProperties": false,
  "required": [
    "name",
    "code",
    "fiscalYearOneId",
    "ledgerStatus",
    "restrictEncumbrance",
    "restrictExpenditures"
  ]
}
get_ledgers(**kwargs)

Retrieve a list of ledger items.

GET /finance/ledgers

Parameters

**kwargs (properties) – Keyword Arguments

Keyword Arguments
  • totalRecords (str) –

    (default=auto) How to calculate the totalRecords property. “exact” for the correct number, “estimated” for an estimation, “auto” to automatically select “exact” or “estimated”, “none” for suppressing the totalRecords property. For details see https://github.com/folio-org/raml-module-builder#estimated-totalrecords

    Example

    • none

  • offset (int) –

    (default=0) Skip over a number of elements by specifying an offset value for the query

    Example

    • 0

  • limit (int) –

    (default=10) Limit the number of elements returned in the response

    Example

    • 10

  • query (str) –

    A query expressed as a CQL string (see [dev.folio.org/reference/glossary#cql](https://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”, “=”]

Returns

See Schema below

Return type

dict

Raises
  • OkapiRequestError – Bad Request

  • OkapiRequestUnauthorized – Authentication is required

  • OkapiFatalError – Server Error

Schema

{
  "$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"
  ]
}
modify_ledger(ledgersId: str, ledger: dict)

Update ledger item with given {ledgerId}

PUT /finance/ledgers/{ledgersId}

Parameters
  • ledgersId (str) –

  • ledger (dict) – See Schema below

Raises
  • OkapiRequestNotFound – Not Found

  • OkapiRequestError – Bad Request

  • OkapiRequestConflict – Conflict

  • OkapiFatalError – Server Error

  • OkapiRequestUnprocessableEntity – Unprocessable Entity

Schema

{
  "$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"
    },
    "_version": {
      "type": "integer",
      "description": "Record version for optimistic locking"
    },
    "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
    },
    "netTransfers": {
      "description": "Summing all the transfers from/to this ledger. Amount can be negative",
      "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
    },
    "initialAllocation": {
      "description": "Summary of all related to this ledger budgets initialAllocation",
      "type": "number",
      "readonly": true
    },
    "allocationTo": {
      "description": "Summary of all related to this ledger budgets allocationTo",
      "type": "number",
      "readonly": true
    },
    "allocationFrom": {
      "description": "Summary of all related to this ledger budgets allocationFrom",
      "type": "number",
      "readonly": true
    },
    "totalFunding": {
      "description": "Summary of all related to this ledger budgets totalFunding",
      "type": "number",
      "readonly": true
    },
    "cashBalance": {
      "description": "Summary of all related to this ledger budgets cashBalance",
      "type": "number",
      "readonly": true
    },
    "awaitingPayment": {
      "description": "Summary of all related to this ledger budgets awaitingPayment",
      "type": "number",
      "readonly": true
    },
    "encumbered": {
      "description": "Summary of all related to this ledger budgets encumbered",
      "type": "number",
      "readonly": true
    },
    "expenditures": {
      "description": "Summary of all related to this ledger budgets expenditures",
      "type": "number",
      "readonly": true
    },
    "overEncumbrance": {
      "description": "Summary of all related to this ledger budgets overEncumbrance",
      "type": "number",
      "readonly": true
    },
    "overExpended": {
      "description": "Summary of all related to this ledger budgets overExpended",
      "type": "number",
      "readonly": true
    }
  },
  "additionalProperties": false,
  "required": [
    "name",
    "code",
    "fiscalYearOneId",
    "ledgerStatus",
    "restrictEncumbrance",
    "restrictExpenditures"
  ]
}
set_ledger(ledger: dict)

Create a new ledger item.

POST /finance/ledgers

Parameters

ledger (dict) – See Schema below

Raises
  • OkapiRequestError – Bad Request

  • OkapiRequestUnauthorized – Authentication is required

  • OkapiFatalError – Server Error

  • OkapiRequestUnprocessableEntity – Unprocessable Entity

Headers

  • Location - URI to the created ledger item

Schema

{
  "$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"
    },
    "_version": {
      "type": "integer",
      "description": "Record version for optimistic locking"
    },
    "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
    },
    "netTransfers": {
      "description": "Summing all the transfers from/to this ledger. Amount can be negative",
      "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
    },
    "initialAllocation": {
      "description": "Summary of all related to this ledger budgets initialAllocation",
      "type": "number",
      "readonly": true
    },
    "allocationTo": {
      "description": "Summary of all related to this ledger budgets allocationTo",
      "type": "number",
      "readonly": true
    },
    "allocationFrom": {
      "description": "Summary of all related to this ledger budgets allocationFrom",
      "type": "number",
      "readonly": true
    },
    "totalFunding": {
      "description": "Summary of all related to this ledger budgets totalFunding",
      "type": "number",
      "readonly": true
    },
    "cashBalance": {
      "description": "Summary of all related to this ledger budgets cashBalance",
      "type": "number",
      "readonly": true
    },
    "awaitingPayment": {
      "description": "Summary of all related to this ledger budgets awaitingPayment",
      "type": "number",
      "readonly": true
    },
    "encumbered": {
      "description": "Summary of all related to this ledger budgets encumbered",
      "type": "number",
      "readonly": true
    },
    "expenditures": {
      "description": "Summary of all related to this ledger budgets expenditures",
      "type": "number",
      "readonly": true
    },
    "overEncumbrance": {
      "description": "Summary of all related to this ledger budgets overEncumbrance",
      "type": "number",
      "readonly": true
    },
    "overExpended": {
      "description": "Summary of all related to this ledger budgets overExpended",
      "type": "number",
      "readonly": true
    }
  },
  "additionalProperties": false,
  "required": [
    "name",
    "code",
    "fiscalYearOneId",
    "ledgerStatus",
    "restrictEncumbrance",
    "restrictExpenditures"
  ]
}