Prioritization of multiple credit grants
If more than one grant can apply to an invoice or usage event, Stigg selects grants in the following order:-
Priority
Grants with a higher priority apply first.
Lower numeric value = higher priority. -
Expiration date (
expires_at)
Grants that expire sooner are consumed before later-expiring or non-expiring grants. -
Category
Among grants with the same expiration date, promotional credits are consumed before paid credits. -
Effective date (
effective_at)
Grants that became effective earlier apply first. -
Created date (
created_at)
If all other attributes match, older grants are consumed before newer ones.
Deductions that span multiple grants
If a single usage event requires more credits than are available in one grant:- Stigg deducts from the highest-ranked grant until its balance is zero,
- Then continues with the next eligible grant according to the same prioritization order,
- Creating a separate ledger entry for each consumed grant.
Example
A customer has these credit grants:| Grant | Priority | Expires | Category | Balance |
|---|---|---|---|---|
| A | 1 | Sep 1 | paid | 50 |
| B | 1 | Sep 1 | promotional | 20 |
| C | 2 | Aug 15 | promotional | 100 |
- Priority → only A and B (priority 1).
- Expiration → both expire Sep 1.
- Category → promotional before paid → B then A.
Deduction result
- 20 credits deducted from B
- 40 credits deducted from A
- Grant C is not used
When credits are depleted
When a usage event requires more credits than are available across all active grants, Stigg handles the deficit using an overdraft grant rather than rejecting the event. Example: A customer has one active grant with 10 credits remaining. A usage event costs 25 credits.- The system deducts 10 credits from the existing grant (fully consumed).
- The remaining 15 credits are tracked in a new overdraft grant.
- The customer’s effective balance is now -15 credits.
Automatic overdraft settlement
When new credits are granted to a customer who has an active overdraft, Stigg automatically settles the deficit:- The new grant is created.
- The system checks for an active overdraft in the same currency.
- Credits are transferred from the overdraft to the new grant (up to the new grant’s available capacity).
- If fully settled, the overdraft grant is voided.
- The 50-credit grant is created.
- 15 credits of consumption are transferred from the overdraft to the new grant.
- The overdraft is fully settled and voided.
- The new grant now shows: 50 total, 15 consumed, 35 remaining.
