Appearance
Billing & Accounting Overview
Introduction
Zal Ultra provides a comprehensive billing and accounting system designed for ISPs with multi-tier reseller networks. This guide explains how billing works, from package pricing to profit distribution across all user levels.
Billing Types
Zal Ultra supports three billing types that determine how and when subscribers are charged:
1. Prepaid Billing
How it works:
- Subscriber must have sufficient balance before activation
- Payment is deducted immediately upon activation
- Service is provided after payment confirmation
Balance Check Flow:
Subscriber Balance ≥ Package Price?
├── YES → Deduct balance → Activate service
└── NO → Activation blocked → "Insufficient Balance" errorUse Cases:
- Pay-as-you-go subscribers
- New subscribers without credit history
- Subscribers who prefer to pay upfront
2. Postpaid Billing
How it works:
- Subscriber can be activated without immediate payment
- Invoice is generated but payment can be collected later
- Reseller's balance is used to cover the cost
Balance Check Flow:
Postpaid Activation:
├── Check Reseller Balance ≥ Package Cost
│ ├── YES → Deduct from Reseller → Activate service
│ └── NO → Check if Admin/Staff (no limit)
│ ├── YES → Activate service
│ └── NO → "Insufficient Reseller Balance" error
└── Invoice created with "Due" statusPostpaid Options:
| Setting | Description |
|---|---|
postpaid_subscriber_balance_required = 0 | Either reseller OR subscriber balance is enough (Default) |
postpaid_subscriber_balance_required = 1 | Subscriber MUST have balance (Strict Mode) |
Use Cases:
- Corporate/business subscribers
- Trusted long-term subscribers
- Monthly billing cycles
3. Pro-Rated Billing
How it works:
- Charges are calculated based on actual days of service
- Used for custom expiry dates or mid-cycle activations
- Automatically calculates per-day pricing
Calculation:
Per Day Fee = Package Price / Package Duration (days)
Pro-Rated Amount = Per Day Fee × Actual Days UsedExample:
Package: 30 days for 300 BDT
Custom Expiry: 15 days from now
Per Day Fee = 300 / 30 = 10 BDT/day
Pro-Rated Amount = 10 × 15 = 150 BDTUse Cases:
- Custom expiry date activations
- Fixed billing date alignment
- Partial month activations
Package Pricing Structure
Multi-Tier Pricing Model
Zal Ultra uses a hierarchical pricing model where each level adds their profit margin:
Admin (Base Price: 100 BDT)
│
├── Sets base price for package
├── Assigns to Reseller with price + profit margin
│
▼
Reseller (Price: 100 BDT + Profit: 10 BDT = 110 BDT)
│
├── Receives package at 100 BDT
├── Adds 10 BDT profit margin
├── Assigns to Sub-Reseller at 110 BDT + profit
│
▼
Sub-Reseller (Price: 110 BDT + Profit: 10 BDT = 120 BDT)
│
├── Receives package at 110 BDT
├── Adds 10 BDT profit margin
├── Assigns to Retailer at 120 BDT + profit
│
▼
Retailer (Price: 120 BDT + Profit: 10 BDT = 130 BDT)
│
├── Receives package at 120 BDT
├── Adds 10 BDT profit margin
├── Sells to Subscriber at 130 BDT
│
▼
Subscriber (Final Price: 130 BDT)Package Accounting Fields
| Field | Description |
|---|---|
price | Cost price from parent (what you pay) |
profit | Profit margin from subscriber |
reseller_profit | Profit margin from downstream resellers |
total_price | price + profit (subscriber selling price) |
Price Validation Rules
The system validates package pricing to ensure:
- Price ≥ 0 - Price cannot be negative
- Profit ≥ 0 - Profit cannot be negative
- Price ≥ Parent Price - Cannot sell below cost
Validation Indicators:
| Icon | Meaning |
|---|---|
| ✅ Green | Valid price (> 0) |
| ⚠️ Orange | Warning - Price is 0 (free package) |
| ❌ Red | Invalid - Price below parent cost |
Invoice Generation During Activation
Activation Flow
When a subscriber is activated, the following happens:
1. Validate Request
├── Check subscriber exists
├── Check package exists
├── Verify permissions
└── Validate custom expiry (if any)
2. Pre-Activation Calculation
├── Calculate package fee (with pro-rating if needed)
├── Calculate extra fees (VAT, service charges)
├── Apply subscriber discount
├── Calculate salesperson profit
└── Determine total activation fee
3. Balance Validation
├── Prepaid: Check subscriber balance
└── Postpaid: Check reseller balance
4. Generate Invoice
├── Create invoice record
├── Add extra fee items
├── Set invoice status (Paid/Due)
└── Link to subscriber
5. Process Payment
├── Deduct from subscriber/reseller balance
├── Create ledger entries
├── Create payment record
└── Update cashflow
6. Profit Distribution
├── Calculate each tier's profit
├── Add profit to parent resellers
└── Create distribution records
7. RADIUS Activation
├── Set expiration date
├── Update user group
└── Apply bandwidth policy
8. Update Subscriber
├── Set profile status to Active
├── Update package assignment
└── Set expiration dateInvoice Data Structure
| Field | Description |
|---|---|
subscriber_id | Subscriber receiving service |
package_id | Package being activated |
billing_total_amount | Total amount charged |
billing_package_amount | Base package price |
billing_extra_fee_amount | Extra fees (VAT, etc.) |
billing_discount_amount | Discount applied |
invoice_status | 1=Paid, 2=Unpaid, 6=Due, 7=Reversed |
activation_status | 1=Activated (prevents cancellation) |
Profit Distribution
How Profits Flow
When a subscriber pays, profits are distributed up the chain:
Subscriber pays 130 BDT to Retailer
│
├── Retailer keeps 10 BDT profit
├── Retailer pays 120 BDT upstream
│
▼
Sub-Reseller receives 120 BDT
│
├── Sub-Reseller keeps 10 BDT profit
├── Sub-Reseller pays 110 BDT upstream
│
▼
Reseller receives 110 BDT
│
├── Reseller keeps 10 BDT profit
├── Reseller pays 100 BDT upstream
│
▼
Admin receives 100 BDT (base price)
│
└── Admin keeps 5 BDT profit (if configured)Distribution Records
Each activation creates distribution records:
| User | Price | Profit | Total |
|---|---|---|---|
| Admin | 100 | 5 | 105 |
| Reseller | 105 | 10 | 115 |
| Sub-Reseller | 115 | 10 | 125 |
| Retailer | 125 | 5 | 130 |
Profit Ledger Entries
Profits are recorded in the ledger system:
Ledger Entry:
Type: Profit (4)
To: Parent Reseller
Amount: Profit Amount
Note: "Profit from subscriber activation"Payment Methods
Supported Payment Methods
| ID | Method | Balance Change |
|---|---|---|
| 1 | Cash | No (tracking only) |
| 2 | Bank Transfer | No (tracking only) |
| 3 | Cheque | No (tracking only) |
| 4 | Balance | Yes (deduct from balance) |
| 11+ | Online Gateways | Yes (add to balance) |
Cash vs Balance Payments
Cash Payments (1, 2, 3):
- Money exchanged outside the system
- System only tracks the transaction
- Reseller's balance is cut to pay upstream
no_balance_change = truefor subscriber
Balance/Online Payments (4, 11+):
- Money flows through the system
- Subscriber balance is deducted
- Reseller balance is not cut (already paid)
no_balance_change = false
Subscriber Discounts
How Discounts Work
Subscribers can have a discount percentage that reduces their package price:
Package Price: 130 BDT
Subscriber Discount: 10%
Discount Amount: 13 BDT
Final Price: 117 BDTDiscount Validation
The system ensures discounts don't exceed the salesperson's profit:
If Discount > Salesperson Profit:
└── Error: "Discount cannot exceed profit margin"This prevents selling at a loss.
Extra Fees
Package Extra Fees
Additional charges can be added to packages:
| Fee Type | Description |
|---|---|
| VAT | Value Added Tax |
| Service Charge | Service/maintenance fee |
| Installation | One-time installation fee |
| Equipment | Router/modem rental |
Fee Calculation
Base Package Price: 100 BDT
VAT (15%): 15 BDT
Service Charge: 10 BDT
─────────────────────
Total: 125 BDTSubscriber Extra Services
One-time or recurring services for individual subscribers:
- Custom IP address
- Static IP fee
- Priority support
- Additional bandwidth
Auto-Renewal
How Auto-Renewal Works
The system can automatically renew expired subscribers:
1. Check subscriber expiration
2. Verify auto-renew enabled
3. Check balance (prepaid) or reseller balance (postpaid)
4. Generate invoice
5. Process payment
6. Distribute profits
7. Update expiration
8. Send notificationAuto-Renewal Settings
| Setting | Description |
|---|---|
auto_renew | Enable/disable for subscriber |
billing_type | Prepaid (1) or Postpaid (2) |
postpaid_subscriber_balance_required | Require subscriber balance for postpaid |
Invoice Reversal
Invoice reversal allows undoing an invoice and all related transactions. See Invoice Reversal for detailed documentation.
Reversal Types
| Type | Refund | Use Case |
|---|---|---|
| Full | 100% | Mistake, wrong package |
| Partial | Pro-rata | Early cancellation |
What Gets Reversed
- Subscriber profile restored
- Balances refunded
- Profits reversed
- RADIUS configuration updated
- Payment records marked as reversed
Ledger System
The ledger tracks all financial transactions:
Ledger Types
| Type | ID | Description |
|---|---|---|
| Payment | 1 | Balance top-up |
| Expense | 2 | Balance deduction |
| Invoice | 3 | Invoice payment |
| Profit | 4 | Profit distribution |
Ledger Fields
| Field | Description |
|---|---|
to_profile_type | 1=User, 2=Subscriber |
to_id | Recipient ID |
amount | Transaction amount |
balance | Running balance after transaction |
no_balance_change | True for tracking-only entries |
Best Practices
Package Pricing
- Set realistic margins - Ensure each tier has reasonable profit
- Validate pricing - Check for red/orange warnings
- Consider extra fees - Include VAT in calculations
- Test activations - Verify pricing before going live
Balance Management
- Monitor reseller balances - Ensure sufficient funds
- Set balance limits - Prevent over-spending
- Regular reconciliation - Match ledger with actual balances
- Track cash payments - Ensure physical cash is collected
Invoice Management
- Review before activation - Verify amounts
- Use proper payment methods - Cash vs Balance
- Document reversals - Always provide reason
- Keep audit trail - Don't delete records
Summary
| Feature | Description |
|---|---|
| Billing Types | Prepaid, Postpaid, Pro-rated |
| Pricing Model | Multi-tier with profit margins |
| Profit Distribution | Automatic upstream distribution |
| Payment Methods | Cash, Balance, Online gateways |
| Invoice Reversal | Full and partial with pro-rata |
| Ledger System | Complete transaction tracking |
| Auto-Renewal | Automatic subscription renewal |
The billing system ensures accurate financial tracking across all levels of your ISP business! 💰
