mod-orders-storage (v2)

http://github.com/folio-org/mod-orders-storage

Table of contents

Purchase Order

This module implements the CRUD interface

/orders-storage/purchase_orders

Collection of purchase_order items.

GET /orders-storage/purchase_orders

Get list of purchase orders

GET /orders-storage/purchase_orders
Query Parameters
  • 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", "="]
    
  • 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
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Response 200

Returns a list of purchase_order items

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "collection of purchase order records",
  "type": "object",
  "properties": {
    "purchase_orders": {
      "description": "collection of purchase order records",
      "type": "array",
      "id": "purchase_orders",
      "items": {
        "type": "object",
        "$ref": "purchase_order.json"
      }
    },
    "total_records": {
      "description": "The number of objects contained in this collection",
      "type": "integer"
    }
  },
  "additionalProperties": false,
  "required": [
    "purchase_orders",
    "total_records"
  ]
}

Example:

{
  "purchase_orders": [
    {
      "id": "0804ddec-6545-404a-b54d-a693f505681d",
      "adjustment": "9b3be694-6716-4e14-b81d-8d76f0ae4146",
      "approved": true,
      "assigned_to": "ab18897b-0e40-4f31-896b-9c9adc979a88",
      "close_reason": {
        "reason" : "No longer available",
        "note" : "Items are no longer available to purchase"
      },
      "manual_po": false,
      "notes": [
        "ABCDEFGHIJKLMNO",
        "ABCDEFGHIJKLMNOPQRST",
        "ABCDEFGHIJKLMNOPQRSTUV"
      ],
      "order_type": "Ongoing",
      "po_number": "ABC268758XYZ",
      "re_encumber": false,
      "renewal": {
         "cycle": "6 Months",
         "interval": 182,
         "manual_renewal": true,
         "review_period": 30,
         "renewal_date": "2019-04-09T00:00:00.000Z"
      },
      "total_estimated_price": 49.98,
      "total_items": 2,
      "vendor": "168f8a86-d26c-406e-813f-c7527f241ac3",
      "workflow_status": "Pending",
      "metadata": {
        "createdDate": "2018-07-19T00:00:00.000+0000",
        "createdByUserId": "28d1057c-d137-11e8-a8d5-f2801f1b9fd1"
      }
    }
  ],
  "total_records": 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 purchase_orders -- 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 purchase_orders -- unauthorized

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

internal server error, contact administrator

POST /orders-storage/purchase_orders

Create a new purchase_order item.

POST /orders-storage/purchase_orders
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": "purchase order",
  "type": "object",
  "properties": {
    "id": {
      "description": "UUID of this purchase order",
      "type": "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}$"
    },
    "adjustment": {
      "description": "UUID of the adjustment record associated with this order",
      "type": "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}$"
    },
    "approved": {
      "description": "whether or not the purchase order has been approved",
      "type": "boolean"
    },
    "assigned_to": {
      "description": "UUID of the user this purchase order his assigned to",
      "type": "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}$"
    },
    "close_reason": {
      "description": "Close reason for purchase order",
      "type": "object",
      "$ref": "close_reason.json"
    },
    "dateOrdered": {
      "description": "Date and time when purchase order was opened",
      "type": "string",
      "format": "date-time"
    },
    "manual_po": {
      "description": "if true, order cannot be sent automatically, e.g. via EDI",
      "type": "boolean"
    },
    "notes": {
      "description": "free-form notes associated with this purchase order",
      "id": "notes",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "po_number": {
      "description": "A human readable ID assigned to this purchase order",
      "type": "string",
      "pattern": "^[a-zA-Z0-9]{5,16}$"
    },
    "order_type": {
      "description": "the purchase order type",
      "type": "string",
      "enum": [
        "One-Time",
        "Ongoing"
      ]
    },
    "re_encumber": {
      "description": "indicates this purchase order should be re-encumbered each fiscal year. Only applies to ongoing orders",
      "type": "boolean"
    },
    "renewal": {
      "description": "Renewal information associated with this order",
      "type": "object",
      "$ref": "renewal.json"
    },
    "total_estimated_price": {
      "description": "total estimated price of this purchase order",
      "type": "number"
    },
    "total_items": {
      "description": "total number of items included in the purchase order",
      "type": "integer"
    },
    "vendor": {
      "description": "UUID of the vendor_details record",
      "type": "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}$"
    },
    "workflow_status": {
      "description": "the workflow status for this purchase order",
      "type": "string",
      "enum": [
        "Pending",
        "Open",
        "Closed"
      ],
      "default": "Pending"
    },
    "metadata": {
      "type": "object",
      "$ref": "../../../raml-util/schemas/metadata.schema",
      "readonly": true
    }
  },
  "additionalProperties": false
}

Example:

{
  "id": "0804ddec-6545-404a-b54d-a693f505681d",
  "adjustment": "9b3be694-6716-4e14-b81d-8d76f0ae4146",
  "approved": true,
  "assigned_to": "ab18897b-0e40-4f31-896b-9c9adc979a88",
  "close_reason": {
    "reason" : "Shipping delay",
    "note" : "Two years is too long for shipping of 'Calendar for Year 2017'"
  },
  "dateOrdered": "2018-08-20T00:00:00.000+0000",
  "manual_po": false,
  "notes": [
    "ABCDEFGHIJKLMNO",
    "ABCDEFGHIJKLMNOPQRST",
    "ABCDEFGHIJKLMNOPQRSTUV"
  ],
  "order_type": "Ongoing",
  "po_number": "AB268758XYZ",
  "re_encumber": false,
  "renewal": {
     "cycle": "6 Months",
     "interval": 182,
     "manual_renewal": true,
     "review_period": 30,
     "renewal_date": "2019-04-09T00:00:00.000Z"
  },
  "total_estimated_price": 49.98,
  "total_items": 2,
  "vendor": "168f8a86-d26c-406e-813f-c7527f241ac3",
  "workflow_status": "Closed",
  "metadata": {
    "createdDate": "2018-08-19T00:00:00.000+0000",
    "createdByUserId": "28d1057c-d137-11e8-a8d5-f2801f1b9fd1"
  }
}

Response 201

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

Headers
  • Location: required (string)

    URI to the created purchase_order item

Body

Media type: application/json

Type: any

Example:

{
  "id": "0804ddec-6545-404a-b54d-a693f505681d",
  "adjustment": "9b3be694-6716-4e14-b81d-8d76f0ae4146",
  "approved": true,
  "assigned_to": "ab18897b-0e40-4f31-896b-9c9adc979a88",
  "close_reason": {
    "reason" : "Shipping delay",
    "note" : "Two years is too long for shipping of 'Calendar for Year 2017'"
  },
  "dateOrdered": "2018-08-20T00:00:00.000+0000",
  "manual_po": false,
  "notes": [
    "ABCDEFGHIJKLMNO",
    "ABCDEFGHIJKLMNOPQRST",
    "ABCDEFGHIJKLMNOPQRSTUV"
  ],
  "order_type": "Ongoing",
  "po_number": "AB268758XYZ",
  "re_encumber": false,
  "renewal": {
     "cycle": "6 Months",
     "interval": 182,
     "manual_renewal": true,
     "review_period": 30,
     "renewal_date": "2019-04-09T00:00:00.000Z"
  },
  "total_estimated_price": 49.98,
  "total_items": 2,
  "vendor": "168f8a86-d26c-406e-813f-c7527f241ac3",
  "workflow_status": "Closed",
  "metadata": {
    "createdDate": "2018-08-19T00:00:00.000+0000",
    "createdByUserId": "28d1057c-d137-11e8-a8d5-f2801f1b9fd1"
  }
}

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 purchase_order -- malformed JSON at 13:3"

Response 401

Not authorized to perform requested action

Body

Media type: text/plain

Type: any

Example:

unable to create purchase_orders -- unauthorized

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /orders-storage/purchase_orders/{id}

Retrieve purchase_order item with given {purchase_orderId}

GET /orders-storage/purchase_orders/{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 Purchase Order

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": "purchase order",
  "type": "object",
  "properties": {
    "id": {
      "description": "UUID of this purchase order",
      "type": "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}$"
    },
    "adjustment": {
      "description": "UUID of the adjustment record associated with this order",
      "type": "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}$"
    },
    "approved": {
      "description": "whether or not the purchase order has been approved",
      "type": "boolean"
    },
    "assigned_to": {
      "description": "UUID of the user this purchase order his assigned to",
      "type": "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}$"
    },
    "close_reason": {
      "description": "Close reason for purchase order",
      "type": "object",
      "$ref": "close_reason.json"
    },
    "dateOrdered": {
      "description": "Date and time when purchase order was opened",
      "type": "string",
      "format": "date-time"
    },
    "manual_po": {
      "description": "if true, order cannot be sent automatically, e.g. via EDI",
      "type": "boolean"
    },
    "notes": {
      "description": "free-form notes associated with this purchase order",
      "id": "notes",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "po_number": {
      "description": "A human readable ID assigned to this purchase order",
      "type": "string",
      "pattern": "^[a-zA-Z0-9]{5,16}$"
    },
    "order_type": {
      "description": "the purchase order type",
      "type": "string",
      "enum": [
        "One-Time",
        "Ongoing"
      ]
    },
    "re_encumber": {
      "description": "indicates this purchase order should be re-encumbered each fiscal year. Only applies to ongoing orders",
      "type": "boolean"
    },
    "renewal": {
      "description": "Renewal information associated with this order",
      "type": "object",
      "$ref": "renewal.json"
    },
    "total_estimated_price": {
      "description": "total estimated price of this purchase order",
      "type": "number"
    },
    "total_items": {
      "description": "total number of items included in the purchase order",
      "type": "integer"
    },
    "vendor": {
      "description": "UUID of the vendor_details record",
      "type": "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}$"
    },
    "workflow_status": {
      "description": "the workflow status for this purchase order",
      "type": "string",
      "enum": [
        "Pending",
        "Open",
        "Closed"
      ],
      "default": "Pending"
    },
    "metadata": {
      "type": "object",
      "$ref": "../../../raml-util/schemas/metadata.schema",
      "readonly": true
    }
  },
  "additionalProperties": false
}

Example:

{
  "id": "0804ddec-6545-404a-b54d-a693f505681d",
  "adjustment": "9b3be694-6716-4e14-b81d-8d76f0ae4146",
  "approved": true,
  "assigned_to": "ab18897b-0e40-4f31-896b-9c9adc979a88",
  "close_reason": {
    "reason" : "Shipping delay",
    "note" : "Two years is too long for shipping of 'Calendar for Year 2017'"
  },
  "dateOrdered": "2018-08-20T00:00:00.000+0000",
  "manual_po": false,
  "notes": [
    "ABCDEFGHIJKLMNO",
    "ABCDEFGHIJKLMNOPQRST",
    "ABCDEFGHIJKLMNOPQRSTUV"
  ],
  "order_type": "Ongoing",
  "po_number": "AB268758XYZ",
  "re_encumber": false,
  "renewal": {
     "cycle": "6 Months",
     "interval": 182,
     "manual_renewal": true,
     "review_period": 30,
     "renewal_date": "2019-04-09T00:00:00.000Z"
  },
  "total_estimated_price": 49.98,
  "total_items": 2,
  "vendor": "168f8a86-d26c-406e-813f-c7527f241ac3",
  "workflow_status": "Closed",
  "metadata": {
    "createdDate": "2018-08-19T00:00:00.000+0000",
    "createdByUserId": "28d1057c-d137-11e8-a8d5-f2801f1b9fd1"
  }
}

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"purchase_order 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 /orders-storage/purchase_orders/{id}

Delete purchase_order item with given {purchase_orderId}

DELETE /orders-storage/purchase_orders/{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 Purchase Order

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 purchase_order -- constraint violation"

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"purchase_order 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

PUT /orders-storage/purchase_orders/{id}

Update purchase_order item with given {purchase_orderId}

PUT /orders-storage/purchase_orders/{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 Purchase Order

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": "purchase order",
  "type": "object",
  "properties": {
    "id": {
      "description": "UUID of this purchase order",
      "type": "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}$"
    },
    "adjustment": {
      "description": "UUID of the adjustment record associated with this order",
      "type": "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}$"
    },
    "approved": {
      "description": "whether or not the purchase order has been approved",
      "type": "boolean"
    },
    "assigned_to": {
      "description": "UUID of the user this purchase order his assigned to",
      "type": "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}$"
    },
    "close_reason": {
      "description": "Close reason for purchase order",
      "type": "object",
      "$ref": "close_reason.json"
    },
    "dateOrdered": {
      "description": "Date and time when purchase order was opened",
      "type": "string",
      "format": "date-time"
    },
    "manual_po": {
      "description": "if true, order cannot be sent automatically, e.g. via EDI",
      "type": "boolean"
    },
    "notes": {
      "description": "free-form notes associated with this purchase order",
      "id": "notes",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "po_number": {
      "description": "A human readable ID assigned to this purchase order",
      "type": "string",
      "pattern": "^[a-zA-Z0-9]{5,16}$"
    },
    "order_type": {
      "description": "the purchase order type",
      "type": "string",
      "enum": [
        "One-Time",
        "Ongoing"
      ]
    },
    "re_encumber": {
      "description": "indicates this purchase order should be re-encumbered each fiscal year. Only applies to ongoing orders",
      "type": "boolean"
    },
    "renewal": {
      "description": "Renewal information associated with this order",
      "type": "object",
      "$ref": "renewal.json"
    },
    "total_estimated_price": {
      "description": "total estimated price of this purchase order",
      "type": "number"
    },
    "total_items": {
      "description": "total number of items included in the purchase order",
      "type": "integer"
    },
    "vendor": {
      "description": "UUID of the vendor_details record",
      "type": "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}$"
    },
    "workflow_status": {
      "description": "the workflow status for this purchase order",
      "type": "string",
      "enum": [
        "Pending",
        "Open",
        "Closed"
      ],
      "default": "Pending"
    },
    "metadata": {
      "type": "object",
      "$ref": "../../../raml-util/schemas/metadata.schema",
      "readonly": true
    }
  },
  "additionalProperties": false
}

Example:

{
  "id": "0804ddec-6545-404a-b54d-a693f505681d",
  "adjustment": "9b3be694-6716-4e14-b81d-8d76f0ae4146",
  "approved": true,
  "assigned_to": "ab18897b-0e40-4f31-896b-9c9adc979a88",
  "close_reason": {
    "reason" : "Shipping delay",
    "note" : "Two years is too long for shipping of 'Calendar for Year 2017'"
  },
  "dateOrdered": "2018-08-20T00:00:00.000+0000",
  "manual_po": false,
  "notes": [
    "ABCDEFGHIJKLMNO",
    "ABCDEFGHIJKLMNOPQRST",
    "ABCDEFGHIJKLMNOPQRSTUV"
  ],
  "order_type": "Ongoing",
  "po_number": "AB268758XYZ",
  "re_encumber": false,
  "renewal": {
     "cycle": "6 Months",
     "interval": 182,
     "manual_renewal": true,
     "review_period": 30,
     "renewal_date": "2019-04-09T00:00:00.000Z"
  },
  "total_estimated_price": 49.98,
  "total_items": 2,
  "vendor": "168f8a86-d26c-406e-813f-c7527f241ac3",
  "workflow_status": "Closed",
  "metadata": {
    "createdDate": "2018-08-19T00:00:00.000+0000",
    "createdByUserId": "28d1057c-d137-11e8-a8d5-f2801f1b9fd1"
  }
}

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 purchase_order -- malformed JSON at 13:4"

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"purchase_order 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