Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Response example:

Code Block
languagetextjs
{
  "automatedPatronBlocks": [
    {
      "blockBorrowing": true,
      "blockRenewalblockRenewals": false,
      "blockRequestblockRequests": false,
      "message": "Patron has reached maximum allowed number of items charged out"
    },
    {
      "blockBorrowing": false,
      "blockRenewalblockRenewals": false,
      "blockRequestblockRequests": true,
      "message": "Patron has reached maximum allowed outstanding fee/fine balance for his/her patron group"
    }
  ]
}

...

Module

Publish/subscribe

Event type

Payload

mod-feesfines

publish

PATRON_FEE_FINE_BALANCE_CHANGE_EVENTCHANGED

{
"accountIdfeeFineId": string,
  "userId": string,
  "balance": numeric,
"feeFineIdfeeFineTypeId": string,
"status": string
}

Example:
{
"accountIdfeeFineId": "82d804b9-8a73-4d9d-bf9b-78f751758420",
  "userId": "4f0e711c-d583-41e0-9555-b62f1725023f",
  "balance": 15.45,
"feeFineIdfeeFineTypeId": "95df458a-5a01-4f9a-99e1-64d5657d8379",
"status": "Open"
}
mod-circulationpublish

ITEM_CHECKCHECKED_OUT_EVENT

{
  "patronIduserId": string,
  "loanId": string,
  "dueDate": string
}
mod-circulationpublishITEM_CHECKCHECKED_IN_EVENT
{
  "patronIduserId": string,
"loanId": string,
"returnedDatereturnDate": string
}
mod-circulationpublishITEM_DECLARED_LOST_EVENT
{
  "patronIduserId": string,
"loanId": string
}
mod-circulationpublishLOAN_DUE_DATE_UPDATE_EVENTCHANGED
{
  "patronIduserId": string,
  "loanId": string,
  "dueDate": string,
"recalldueDateChangedByRecall": boolean
}
mod-automatedblockssubscribe

PATRON_FEE_FINE_BALANCE_CHANGE_EVENTCHANGED
ITEM_CHECKCHECKED_OUT_EVENT
ITEM_CHECKCHECKED_IN_EVENT
ITEM_DECLARED_LOST_EVENT
LOAN_DUE_DATE_UPDATE_EVENTCHANGED


DB

Using the info from events mod-automated-blocks is subscribed to, we need to maintain one object per patron in the DB:

Code Block
languagetextjs
{
  "patronIdid": string,
  "outstandingFeeFineBalanceuserId": numericstring,
  "numberOfOpenFeesFinesForLostItemsoutstandingFeeFineBalance": numeric,
  "numberOfLostItems": numeric,
  "openLoans": [
    {
      "loanId": string,
      "dueDate": string,
      "returnedDate": string,
      "recall": boolean
    }
  ],
  "openAccountsopenFeesFines": [
    {
      "accountIdfeeFineId": string,
      "balance": numeric,
      "feeFineIdfeeFineTypeId": string
    }
  ]
}

This object allows to check each of the block conditions for a patron:

ConditionCheck against

Maximum outstanding fee/fine balance

.outstandingFeeFineBalance

Maximum number of items charged out

number of .openLoans objects

Maximum number of lost items

.numberOfOpenFeesFinesForLostItemsnumberOfLostItems

Maximum number of overdue items

number of .openLoans[dueDate < returnedDate]

Maximum number of overdue recalled items

number of .openLoans[dueDate < returnedDate AND recall == true]

Maximum number of overdue days for recalled item

max of .openLoans[dueDate < returnedDate AND recall == true].(returnedDate - dueDate)

...

Response example:

Code Block
languagetextjs
{
  "automatedPatronBlocks": [
    {
      "patronBlockConditionId": "2149fff5-a64c-4943-aa79-bb1d09511382",
      "blockBorrowing": true,
      "blockRenewalblockRenewals": false,
      "blockRequestblockRequests": false,
      "message": "Patron has reached maximum allowed number of items charged out"
    },
    {
      "patronBlockConditionId": "ac13a725-b25f-48fa-84a6-4af021d13afe",
      "blockBorrowing": false,
      "blockRenewalblockRenewals": false,
      "blockRequestblockRequests": true,
      "message": "Patron has reached maximum allowed outstanding fee/fine balance for his/her patron group"
    }
  ]
}

GET

...

/patron-block-condition
GET /patron-block-conditions/{patronBlockConditionId}
PUT /patron-block-conditions/{patronBlockConditionId}

...

GET /patron-block-limits
POST /patron-block-limits
GET /patron-block-limits/{patronBlockLimitId}
PUT /patron-block-limits/{patronBlockLimitId}
DELETE /patron-block-limits/{patronBlockLimitId}

These endpoints will be moved from mod-users. This allows to avoid mod-automated-blocks dependency on mod-users.

...

ModuleEndpointPurpose
mod-circulation → mod-automated-blocks
GET /automated-patron-blocks/{patronId}
Check if action is allowed before borrowing, renewing and/or requesting items.

mod-automated-blocks → mod-users

GET /users/{id}
To determine which patron group a patron belongs to.