Account Hierarchy
Opencell uses a hierarchical account structure to manage customers, billing, and subscriptions.
Account Structure
Provider (Tenant)
└── Seller
└── Customer
└── CustomerAccount (payment level)
└── BillingAccount (invoice level) ← BillingCycle assigned here
└── UserAccount (consumption level)
└── Subscription → Services → Charges
Provider
The top-level tenant entity representing the billing platform instance.
Key Fields:
code- Unique identifiercurrency- Default currencycountry- Default countrylanguage- Default languageroundingMode- How amounts are rounded
Note: Provider.CURRENT_PROVIDER_ID = 1L is hardcoded per schema for multi-tenancy.
Seller
Sales entity representing a business unit or reseller.
Key Fields:
code- Unique identifiertradingCountry- Country for tax purposestradingCurrency- Currency for transactionstradingLanguage- Language for documents
Customer
The end customer being billed.
Key Fields:
code- Unique identifiercustomerCategory- Classification (PROSPECT, CUSTOMER, etc.)customerBrand- Brand associationseller- Parent seller
CustomerAccount
Payment-level account for receivables management.
Key Fields:
customer- Parent customercurrency- Account currencystatus- ACTIVE → CLOSEpaymentMethods- Payment methods (credit card, direct debit, etc.)
BillingAccount
Invoice-level account where billing cycles are configured.
Key Fields:
customerAccount- Parent customer accountbillingCycle- CRITICAL: Determines when invoicing happensinvoicingThreshold- Minimum amount to invoicecountry- Tax countrylanguage- Invoice languageelectronicBilling- Enable eInvoicing
UserAccount
Consumption-level account for tracking usage.
Key Fields:
billingAccount- Parent billing accountstatus- ACTIVE → CANCELED → TERMINATED → CLOSEDsubscriptions- Child subscriptions
Status Lifecycles
CustomerAccount Status
ACTIVE → CLOSE
BillingAccount/UserAccount Status
ACTIVE → CANCELED → TERMINATED → CLOSED
Invoicing Thresholds
The IInvoicingMinimumApplicable interface defines threshold behavior at multiple levels:
| Level | Field |
|---|---|
| Customer | invoicingThreshold |
| CustomerAccount | invoicingThreshold |
| BillingAccount | invoicingThreshold |
| BillingCycle | invoicingThreshold |
Threshold Options (ThresholdOptionsEnum):
BEFORE_DISCOUNT- Check threshold before discountsAFTER_DISCOUNT- Check threshold after discountsPOSITIVE_RT- Only positive rated transactionsPOSITIVE_IL- Only positive invoice lines
Multi-Tenancy
Provider-Based Isolation
Each Provider gets a separate database schema:
opencell_provider_1opencell_provider_2
Seller-Based Logical Isolation
Within a Provider, Sellers provide logical separation:
- Same schema, different business units
- Not GDPR-compliant (shared database)
See Multi-Tenancy Architecture for detailed deployment patterns.
Creating Account Hierarchy
Option 1: Step-by-Step API Calls
# 1. Create Customer
POST /api/rest/v2/account/customer
# 2. Create CustomerAccount
POST /api/rest/v2/account/customerAccount
# 3. Create BillingAccount
POST /api/rest/v2/account/billingAccount
# 4. Create UserAccount
POST /api/rest/v2/account/userAccount
Option 2: Full Hierarchy in One Call (Recommended)
POST /api/rest/v2/account/accountHierarchy/customerHierarchyUpdate
See Customer Hierarchy API for details.