electric-bill-bd
v3.0.0
Published
Calculate the electricity bill in Bangladesh
Downloads
163
Maintainers
Readme
Bangladesh Electricity Bill Calculator
A TypeScript library to calculate electricity bills in Bangladesh based on standard tariff structures (DESCO/NESCO/BPDB). It supports both stepped (slab-based) rates for residential users and flat rates for other categories.
Features
- Residential Calculation: Supports slab-based billing (LifeLine, 0-75, 75-200, etc.).
- Commercial & Other Types: Supports flat rates, off-peak, and peak rates (where applicable).
- Demand Charge: Automatically adds demand charges based on the consumer type.
- VAT: Automatically calculates 5% VAT.
- Rounding: Implements specific rounding logic used in Bangladesh bills.
Installation
npm install electric-bill-bd
# or
yarn add electric-bill-bdUsage
Basic Example (Residential)
import { calculateBill, BILL_TYPE } from 'electric-bill-bd';
const bill = calculateBill({
classType: BILL_TYPE.Residential, // "LT-A"
unit: 100, // Consumed Units (kWh)
});
console.log(bill);
/*
Output:
{
unitPrice: 574.5, // Energy Cost
demand: 42, // Demand Charge
vat: 30.825, // 5% VAT
total: 647.325, // Total before rounding
totalFinal: 647 // Final Payable Bill
}
*/Supported User Types
Use BILL_TYPE constant to select the user category:
Residential(LT-A)AgriculturalPumps(LT-B)RetailIndustry(LT-C1)Construction(LT-C2)Educational,Religious,Charitable,Hospitals(LT-D1)StreetLights,WaterPumps(LT-D2)BatteryCharging(LT-D3)CommercialOffice(LT-E)Temporary(LT-T)
Custom Load
You can specify the sanctioned load (defaults to 1 kW/HP if not specified):
const bill = calculateBill({
classType: BILL_TYPE.CommercialOffice,
unit: 500,
load: 5, // 5 kW
});How Calculation Works
- Step Calculation: For residential users, the first 50 units (LifeLine) have a special rate if total consumption is <= 50. Otherwise, it uses a stepped slab system (0-75, 75-200, etc.).
- Demand Charge: Fixed rate per kW/HP of load depending on the user category.
- VAT: 5% of the (Energy Cost + Demand Charge).
- Rounding: Total bill is rounded. If decimal part <= 0.3 it rounds down, otherwise it rounds up.
License
MIT
