Skip to content

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" error

Use 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" status

Postpaid Options:

SettingDescription
postpaid_subscriber_balance_required = 0Either reseller OR subscriber balance is enough (Default)
postpaid_subscriber_balance_required = 1Subscriber 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 Used

Example:

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 BDT

Use 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

FieldDescription
priceCost price from parent (what you pay)
profitProfit margin from subscriber
reseller_profitProfit margin from downstream resellers
total_priceprice + profit (subscriber selling price)

Price Validation Rules

The system validates package pricing to ensure:

  1. Price ≥ 0 - Price cannot be negative
  2. Profit ≥ 0 - Profit cannot be negative
  3. Price ≥ Parent Price - Cannot sell below cost

Validation Indicators:

IconMeaning
✅ GreenValid price (> 0)
⚠️ OrangeWarning - Price is 0 (free package)
❌ RedInvalid - 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 date

Invoice Data Structure

FieldDescription
subscriber_idSubscriber receiving service
package_idPackage being activated
billing_total_amountTotal amount charged
billing_package_amountBase package price
billing_extra_fee_amountExtra fees (VAT, etc.)
billing_discount_amountDiscount applied
invoice_status1=Paid, 2=Unpaid, 6=Due, 7=Reversed
activation_status1=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:

UserPriceProfitTotal
Admin1005105
Reseller10510115
Sub-Reseller11510125
Retailer1255130

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

IDMethodBalance Change
1CashNo (tracking only)
2Bank TransferNo (tracking only)
3ChequeNo (tracking only)
4BalanceYes (deduct from balance)
11+Online GatewaysYes (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 = true for 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 BDT

Discount 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 TypeDescription
VATValue Added Tax
Service ChargeService/maintenance fee
InstallationOne-time installation fee
EquipmentRouter/modem rental

Fee Calculation

Base Package Price: 100 BDT
VAT (15%): 15 BDT
Service Charge: 10 BDT
─────────────────────
Total: 125 BDT

Subscriber 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 notification

Auto-Renewal Settings

SettingDescription
auto_renewEnable/disable for subscriber
billing_typePrepaid (1) or Postpaid (2)
postpaid_subscriber_balance_requiredRequire subscriber balance for postpaid

Invoice Reversal

Invoice reversal allows undoing an invoice and all related transactions. See Invoice Reversal for detailed documentation.

Reversal Types

TypeRefundUse Case
Full100%Mistake, wrong package
PartialPro-rataEarly 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

TypeIDDescription
Payment1Balance top-up
Expense2Balance deduction
Invoice3Invoice payment
Profit4Profit distribution

Ledger Fields

FieldDescription
to_profile_type1=User, 2=Subscriber
to_idRecipient ID
amountTransaction amount
balanceRunning balance after transaction
no_balance_changeTrue for tracking-only entries

Best Practices

Package Pricing

  1. Set realistic margins - Ensure each tier has reasonable profit
  2. Validate pricing - Check for red/orange warnings
  3. Consider extra fees - Include VAT in calculations
  4. Test activations - Verify pricing before going live

Balance Management

  1. Monitor reseller balances - Ensure sufficient funds
  2. Set balance limits - Prevent over-spending
  3. Regular reconciliation - Match ledger with actual balances
  4. Track cash payments - Ensure physical cash is collected

Invoice Management

  1. Review before activation - Verify amounts
  2. Use proper payment methods - Cash vs Balance
  3. Document reversals - Always provide reason
  4. Keep audit trail - Don't delete records

Summary

FeatureDescription
Billing TypesPrepaid, Postpaid, Pro-rated
Pricing ModelMulti-tier with profit margins
Profit DistributionAutomatic upstream distribution
Payment MethodsCash, Balance, Online gateways
Invoice ReversalFull and partial with pro-rata
Ledger SystemComplete transaction tracking
Auto-RenewalAutomatic subscription renewal

The billing system ensures accurate financial tracking across all levels of your ISP business! 💰

www.onezeroart.com