@classytic/bd-tax
v0.1.1
Published
Bangladesh tax engine — VAT, SD, TDS, VDS, income tax, Mushak forms, BIN validation, fiscal positions, and NBR return aggregation. Pure calculation library with pluggable account mapping for any ledger system.
Downloads
280
Readme
@classytic/bd-tax
Bangladesh tax engine — VAT, SD, TDS, VDS, income tax, Mushak forms, BIN validation, fiscal positions, and NBR return aggregation.
Pure calculation library. No database, no HTTP framework, no hard
dependencies on any ledger system. Composable with any accounting backend
(@classytic/ledger-bd, QuickBooks, Xero, ERPNext, or custom).
Install
npm install @classytic/bd-taxPeer dependency: zod >= 4.0.0.
Use
Prefer subpath imports — each concern is its own entry point.
// VAT and invoice-level calculation
import { calculateVAT, calculateInvoiceTax } from '@classytic/bd-tax/calc';
// Mushak forms and BIN validation
import { buildMushak63, validateBIN } from '@classytic/bd-tax/musok';
// Rate tables and regime config
import { VAT_RATES, TURNOVER_THRESHOLDS } from '@classytic/bd-tax/config';
// Personal income tax (FY2025-26 slabs)
import { computeIncomeTax } from '@classytic/bd-tax/income-tax';
// TDS / VDS withholding matrices
import { calculateTds } from '@classytic/bd-tax/tds';
import { calculateVdsDeduction } from '@classytic/bd-tax/vds';
// Account mapping (ledger-bd chart defaults; override at will)
import { accountFor, createAccountMapper, BD_VAT_ACCOUNT_CODES } from '@classytic/bd-tax/accounts';The root entry re-exports the most common symbols as a convenience, but subpaths are the canonical way and keep bundles tight.
What's inside
| Subpath | Ships |
|---|---|
| ./calc | calculateVAT, extractVAT, roundPaisa, calculateSD, calculateSdThenVat, calculateTOT, determineTaxRegime, isTotEligible, calculateLineItem, calculateInvoiceTax |
| ./musok | Mushak 4.3 / 6.3 builders, BIN validation helpers, line-item aggregation |
| ./config | VAT rate table, SD rate table, turnover/registration thresholds, regime constants |
| ./income-tax | Personal income tax — slabs, surcharge, investment rebate (§78), advance tax (§64-65), zakat deduction, freelancer adjustments, depreciation helpers |
| ./tds | TDS withholding matrix (contractor, professional, rent, interest, dividend, commission, advertisement, import) |
| ./vds | VDS withholding matrix |
| ./accounts | accountFor, ancillaryAccounts, createAccountMapper, BD_VAT_ACCOUNT_CODES — BFRS chart mapping with override hook |
Design
- Pure functions on plain data. No I/O, no persistence, no events.
- Deterministic. Same inputs → same outputs. Clocks injected explicitly.
- Integer minor-unit arithmetic. Money stays in paisa; float math is
isolated to ratio/percent calculations using
decimal.js. - Zod schemas at the seams. Input validation is opt-in — import schemas
from
./musok/./configwhen wiring untrusted payloads. - Pluggable account mapping. The default
BD_VAT_ACCOUNT_CODESmatches@classytic/ledger-bdchart codes (2132 VAT payable, 1150 VAT receivable, 1157 transition, 2135 TDS, 2136 VDS). Override per-deployment viacreateAccountMapper({ overrides }).
Testing
npm test # unit + integration (566 tests, ~5 s)
npm run test:unit # pure calculation tests
npm run test:integration # cross-module scenarios (invoice totals, returns)
npm run typecheck
npm run lintLicense
MIT — see LICENSE.
