Resource quotas – data model and adjustment

Grant and movement rows of the central resource ledger, the effect of a manual adjustment on the grant, the movement types and the permission keys.

Overview

A client's quantity quotas come from the grant rows of the central resource ledger (dlbtresource). Every change is written as a movement; the grant row is a cache of the movements.

Data model

Table names carry the installation's own prefix in the database.

TableRoleMain fields
resource_grantgrantclient, object (feature, product, service), unit, quantity_granted, quantity_used, source, validity, carry-over, status
resource_movementmovementtype, signed quantity, source, state, note, actor
resource_movement_allocationsplit of a movement across grantsmovement, grant, quantity

Movement types include RECEIPT, SALE, SUBSCRIPTION_GRANT, USAGE_CONSUMPTION, ADJUSTMENT, EXPIRY, REVERSAL.

Manual adjustment

  1. balance.adjust&grant_id= with POST quantity, note; a zero quantity is an error.
  2. The grant must be in the caller's scope (getGrant($id, $allowed)).
  3. An ADJUSTMENT movement via dlbtresource->movement() (source manual, actor = the user).
  4. The grant cache is updated: a positive quantity raises quantity_granted, a negative one raises quantity_used, at most up to the granted amount.

Permissions

  • Both screens are classified SYSTEM (install/commerce_v1.sql); they are not in the function catalogue file.
  • resource/balance: list, adjust, debug; resource/movement: list, debug. The movement link shows only with resource/movement::list.
  • Content scope in the model query (getAllowedCompanyIds); the company picker endpoints (balance.companies, movement.companies) use the list permission.
Related topics: resource quota permissions