@classytic/ledger-bd 0.3.1 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,198 @@
3
3
  Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
4
4
  adhering to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
5
 
6
+ ## [0.5.0] - 2026-07-06
7
+
8
+ Seven opt-in vertical extensions plus an NBR canonical reporting-code
9
+ layer — the "become a standard for BD accountants" pass. Research-grounded
10
+ (4-5 Jul 2026 web research across NBR/BMDC/DGHS/MRA/NGOAB/Bangladesh Bank
11
+ sources), with confidence flags per account — see each vertical's README.
12
+
13
+ ### Added — vertical extensions (`src/verticals/`, subpath `./verticals`)
14
+
15
+ New, opt-in, additive-only (core chart files untouched); apply with
16
+ `applyVerticals(BD_ACCOUNT_TYPES, [...names])`:
17
+
18
+ - **`school`** (10 accounts) — development/session/hostel/transport fee
19
+ revenue, board-exam pass-through liability, two statutory teacher-fund
20
+ payables (Retirement Benefit Board + Welfare Trust — genuinely distinct
21
+ bodies), scholarship-waiver contra-revenue. Deliberately does NOT model
22
+ MPO as a ledger account — since the Jan 2025 EFT rollout the government
23
+ salary portion never touches the institution's own bank account.
24
+ - **`agro`** (12 accounts) — crop/jute/aquaculture WIP and inventory stages,
25
+ cold-storage receivable + sourced ~3.82% spoilage allowance, pledged-
26
+ produce financing under the Secured Transactions (Movable Property) Act
27
+ 2023 (NOT "warehouse receipt financing" — no such standalone BB scheme
28
+ could be confirmed), direct-cash agro-subsidy income.
29
+ - **`real-estate`** (4 accounts) — contract asset/unbilled revenue distinct
30
+ from retention receivable, landowner joint-venture unit-share payable,
31
+ contractor mobilization-advance-received, guarantee margin deposit. Flags
32
+ as explicitly open: no actual BD-listed developer's revenue-recognition
33
+ policy could be located.
34
+ - **`ngo-microfinance`** (13 accounts) — loan portfolio by product,
35
+ interest-in-suspense, PKSF per-tranche borrowing/fees (mirrors PKSF's own
36
+ audited "Schedule of Service Charge Receivables"), member savings
37
+ (compulsory/voluntary), NGOAB-mandated project-restricted bank account
38
+ and fund.
39
+ - **`restaurant`** (6 accounts) — service-charge payable/revenue (no BD
40
+ Labour Act mandate for staff distribution could be verified — modeled as
41
+ a policy choice, not compliance), cross-border franchise royalty payable
42
+ (20% WHT), aggregator-commission contra-revenue (confirmed net-settlement
43
+ via actual foodpanda invoice samples), beverage inventory.
44
+ - **`rmg-enhancement`** (5 accounts) — corrects two misconceptions from an
45
+ earlier draft: FDBP is bank bill-discounting/financing, NOT a "~0.6%
46
+ incentive"; UD (Utilization Declaration) is a compliance filing with no
47
+ cash event, NOT a subsidy trigger. Adds the genuine gap — a cash-incentive
48
+ receivable for the real, sourced 180-day+ realization-to-disbursement lag.
49
+ - **`hospital-enhancement`** (3 accounts) — consultant/doctor fee payable
50
+ (legitimate collect-and-remit model) and patient admission deposit.
51
+ Deliberately does NOT ship a "diagnostic referral commission" account —
52
+ real and material (20-50% of test cost, well-documented) but explicitly
53
+ prohibited under BMDC's Code of Professional Conduct §4.3.1; building
54
+ dedicated tooling for it would mean designing software to facilitate a
55
+ documented ethics violation.
56
+
57
+ ### Added — NBR canonical schedule (`src/reporting/nbr-schedule/`, subpath `./reporting/nbr-schedule`)
58
+
59
+ A fixed numeric reporting taxonomy — confirmed via research that no such
60
+ crosswalk exists anywhere in Bangladesh's legal lineage (Companies Act 1994
61
+ Schedule XI, like India's Schedule III and the UK's Schedule 4, uses
62
+ positional letter/Roman/Arabic outline labels, never a persistent numeric
63
+ code — the same role Canada's GIFI plays there has no BD equivalent to
64
+ adopt). Built against the closest real analog: NBR's IT-11GHA company tax
65
+ return, whose Part IV carries a fixed, currently-filed, numbered Balance
66
+ Sheet/P&L box schema (47-67) — hence the name.
67
+
68
+ - `resolveScheduleBox(account)` — classifies ANY `AccountType`, core chart
69
+ or vertical extension, onto a box. Covers the entire chart, not just new
70
+ accounts, per explicit design requirement.
71
+ - `buildNbrScheduleReport(trialBalance, accountTypes)` — aggregates a trial
72
+ balance into the schedule.
73
+ - `getUnmappedAccounts(accountTypes)` — coverage audit; the test suite
74
+ asserts zero unmapped accounts (excluding tax expense, which is computed
75
+ after Box 60 and has no box among 47-59) across the core chart AND all
76
+ seven verticals combined.
77
+ - Explicitly flagged as this package's own interpretive judgment, not a
78
+ government-published crosswalk — see `src/reporting/nbr-schedule/README.md`
79
+ for what's gazette/circular-verified vs. inferred.
80
+
81
+ ### Fixed — mapping refinements found via a full-chart audit
82
+
83
+ The initial mapping passed all narrow spot-check tests, but dumping the
84
+ resolved box for all 757 accounts and reviewing it end-to-end (not just the
85
+ handful of codes the first test pass happened to touch) surfaced 4 real
86
+ misclassifications, now fixed and covered by dedicated regression tests:
87
+
88
+ - Bonds/Debentures/Sukuk (2322/2323) were falling into the generic 65B
89
+ "long-term borrowings" bucket; the schedule has a dedicated 65A "Bonds/
90
+ Debentures" box that nothing was ever routed to.
91
+ - Current Portion of Long-Term Debt (2200) landed in 66D "other" instead of
92
+ 66A "short-term borrowings" — it's literally the current-year slice of
93
+ actual borrowings.
94
+ - L/C Margin Liability (2205) was swept into 66C "provisions" alongside
95
+ warranty/returns/legal-claims accruals, but it's a real bank-held deposit,
96
+ not an estimate.
97
+ - A blanket rule routing every account tagged `parentCode: 'Other Expenses'`
98
+ into box 57 (Financial expenses) incorrectly caught 7 non-financial
99
+ one-off losses (loss on sale of assets, penalties, demurrage, theft,
100
+ natural disaster, crop loss — 6810-6817) that share that parentCode with
101
+ genuine interest/FX-cost accounts in the core chart, but belong in 55
102
+ (Other operating expenses). Replaced with pure numeric-range classification
103
+ for the whole Income Statement-Expense category.
104
+
105
+ ### Tests
106
+
107
+ 68 passing (43 existing + 25 new: 6 vertical code-collision/composition
108
+ tests, 19 NBR canonical schedule mapping/coverage/report tests, including
109
+ 4 regression tests for the audit findings above).
110
+
111
+ ## [0.4.0] - 2026-07-02
112
+
113
+ Tax-layer sync with `@classytic/bd-tax` 0.3.0 — the code table, the Mushak
114
+ 9.1 template, and the chart now cover the same law the calculator does.
115
+
116
+ ### Added — tax codes
117
+
118
+ - **Trading-stage VAT codes**: `BD-VAT-4.5`, `BD-VAT-2.4`, `BD-VAT-2`,
119
+ `BD-VAT-1.5` (no input credit; report on the new template lines 20–23).
120
+ - **`BD-TOT-FIXED`** — the FY2026-27 fixed-amount turnover-tax model
121
+ (rate 0; post the assessed amount). `BD-TOT-4` stays for historical
122
+ postings, renamed "(historical)".
123
+ - **`BD-AT-IMP`** — advance VAT at customs (7.5% commercial / 2%
124
+ manufacturer), `recoverable`, reporting on line 24.
125
+ - **VDS codes** (`BD-VDS-15/10/7.5/5/2`) — percent of service value per
126
+ the VDS Rules 2025 service table, all reporting on line 25.
127
+ - **New TDS codes**: `BD-TDS-PROF-IND` (15%), `BD-TDS-INT-IND` (10%),
128
+ `BD-TDS-DIV-IND` (10%), `BD-TDS-TECH` (10%), `BD-TDS-TRANSPORT` (2%,
129
+ FY2026-27), `BD-TDS-EXP` (1%, s.123).
130
+
131
+ ### Fixed — TDS code rates (Income Tax Act 2023)
132
+
133
+ The table still carried ITO-1984-era rates that contradicted bd-tax's
134
+ matrix: `BD-TDS-PROF` 10% → **7.5%** (entities; s.90), `BD-TDS-RENT`
135
+ 5% → **10%** (s.109), `BD-TDS-INT` 10% → **20%** (companies; s.102),
136
+ `BD-TDS-DIV` 10% → **20%** (companies; s.117), `BD-TDS-ADV` 4% → **3%**.
137
+ 2135 TDS sub-account rates/descriptions updated to match, plus new
138
+ `2135.TDS.TECH` and `2135.TDS.TRANSPORT` accounts.
139
+
140
+ ### Added — receivable-side tax accounts (`TAX_RECEIVABLE_ACCOUNTS`)
141
+
142
+ `1151.AIT.IMPORT`, `1151.AIT.OTHER`, `1152.TDS.SUFFERED`,
143
+ `1153.VDS.SUFFERED`, `1153.AT.IMPORT` — the withholding-SUFFERED side.
144
+ Matters from 1 Jul 2026: the Finance Act 2026 withdrew minimum-tax
145
+ treatment, so TDS/AIT suffered is a true adjustable asset, not an expense.
146
+
147
+ ### Changed — Mushak 9.1 template
148
+
149
+ Lines **20–23** (trading-stage outputs, summed into line 9), **24** (AT
150
+ credit on imports) and **25** (VDS increasing adjustment) appended; line
151
+ 17 now computes `12 + 13 + 16 + 25 − 24`. Existing line numbers are
152
+ untouched and the old math is preserved when the new lines are absent.
153
+ Line 6 re-described for the fixed TOT model.
154
+
155
+ ### Gazette verification (3 Jul 2026)
156
+
157
+ `BD-TDS-ADV` corrected 3% → **5%** (ITA 2023 s.92 — media advertising
158
+ bills; media buying agents route via `BD-TDS-COMM`), with the matching
159
+ `2135.TDS.ADV` account update. All other 0.4.0 rates confirmed against
160
+ the verification pass (see `@classytic/bd-tax`
161
+ `research/FY2026-27/06-gazette-verification.md`).
162
+
163
+ ### Build
164
+
165
+ - tsdown → **^0.22.3**, aligned with `@classytic/arc`'s pattern:
166
+ `skipNodeModulesBundle: true` + `neverBundle: [/^@classytic\//]`
167
+ (a bundled second `@classytic/ledger` copy would break
168
+ `defineCountryPack` identity), explicit `target: node22`.
169
+ - Peer unchanged and verified: `@classytic/ledger >= 0.12.0` is the sole
170
+ runtime import (`defineCountryPack`); everything else is type-only.
171
+
172
+ ### Peers / dev stack (pre-publish refresh)
173
+
174
+ - Peer: `@classytic/ledger >= 0.15.0` (was >= 0.12.0) — validated against
175
+ the PUBLISHED 0.15.0 (43/43 on a clean registry install). Dev stack
176
+ refreshed to published lines: ledger ^0.15.0, repo-core ^0.7.0,
177
+ primitives ^0.9.1, mongokit ^3.17.0 (resolves 3.18).
178
+
179
+ ### Tests
180
+
181
+ 43 passing (15 existing + 28 new code/template/account pins).
182
+
183
+ ## [0.3.2] - 2026-07-02
184
+
185
+ ### Added
186
+
187
+ Four VAT-collected tax sub-accounts under 2132 matching `@classytic/bd-tax`
188
+ 0.2.0's new Third-Schedule trading-stage rate codes:
189
+
190
+ - `2132.VAT4.5.COLLECTED` — real estate >1,600 sqft
191
+ - `2132.VAT2.4.COLLECTED` — medicine trading stage (pharmacies)
192
+ - `2132.VAT2.COLLECTED` — petroleum trading / real estate ≤1,600 sqft
193
+ - `2132.VAT1.5.COLLECTED` — wholesale trading stage
194
+
195
+ `2132.TOT4.COLLECTED` description updated for the FY2026-27 fixed-amount
196
+ turnover-tax model (post assessed fixed amounts to the same head).
197
+
6
198
  ## [0.2.3]
7
199
 
8
200
  ### Added
package/README.md CHANGED
@@ -104,6 +104,36 @@ All 8 Bangladesh divisions with tax-code mappings:
104
104
  import { DIVISIONS, ALL_DIVISIONS } from '@classytic/ledger-bd';
105
105
  ```
106
106
 
107
+ ### Vertical Extensions (opt-in industry overlays)
108
+
109
+ The core chart above is a comprehensive commerce/ecommerce/light-manufacturing
110
+ (RMG) chart. Seven opt-in vertical overlays add industry-specific accounts on
111
+ top — school/education, agro/agriculture, real estate/construction, NGO/
112
+ microfinance, restaurant/hospitality, plus RMG and hospital enhancements. Not
113
+ seeded by default; see [`src/verticals/README.md`](src/verticals/README.md).
114
+
115
+ ```typescript
116
+ import { BD_ACCOUNT_TYPES } from '@classytic/ledger-bd';
117
+ import { applyVerticals } from '@classytic/ledger-bd/verticals';
118
+
119
+ const schoolChart = applyVerticals(BD_ACCOUNT_TYPES, ['school']);
120
+ ```
121
+
122
+ ### NBR Canonical Schedule (canonical reporting-code layer)
123
+
124
+ A fixed numeric taxonomy that maps ANY chart of accounts — core or with
125
+ verticals applied — onto Bangladesh's closest real analog for this kind of
126
+ crosswalk: NBR's IT-11GHA company tax-return schedule (boxes 47-67). See
127
+ [`src/reporting/nbr-schedule/README.md`](src/reporting/nbr-schedule/README.md)
128
+ for what's verified vs. this package's own interpretive judgment.
129
+
130
+ ```typescript
131
+ import { BD_ACCOUNT_TYPES } from '@classytic/ledger-bd';
132
+ import { buildNbrScheduleReport } from '@classytic/ledger-bd/reporting/nbr-schedule';
133
+
134
+ const report = buildNbrScheduleReport(trialBalanceRows, BD_ACCOUNT_TYPES);
135
+ ```
136
+
107
137
  ## Documentation
108
138
 
109
139
  See the [@classytic/ledger](https://github.com/classytic/fajr/tree/main/packages/ledger) package for full engine documentation.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,4 @@
1
- import * as _$_classytic_ledger0 from "@classytic/ledger";
2
- import { AccountType } from "@classytic/ledger";
1
+ import { AccountResolverConfig, AccountType } from "@classytic/ledger";
3
2
 
4
3
  //#region src/accounts/assets.d.ts
5
4
  declare const CURRENT_ASSETS: AccountType[];
@@ -47,6 +46,7 @@ declare const VAT_LIABILITY_ACCOUNTS: AccountType[];
47
46
  declare const VAT_ASSET_ACCOUNTS: AccountType[];
48
47
  declare const TDS_LIABILITY_ACCOUNTS: AccountType[];
49
48
  declare const VDS_LIABILITY_ACCOUNTS: AccountType[];
49
+ declare const TAX_RECEIVABLE_ACCOUNTS: AccountType[];
50
50
  declare const ALL_TAX_ACCOUNTS: AccountType[];
51
51
  //#endregion
52
52
  //#region src/accounts/codes.d.ts
@@ -102,7 +102,9 @@ declare const BD_ACCOUNT_CODES: {
102
102
  */
103
103
  readonly INTER_BRANCH_RECEIVABLE: "1145";
104
104
  readonly VAT_RECEIVABLE: "1150";
105
- readonly ADVANCE_INCOME_TAX: "1151";
105
+ readonly ADVANCE_INCOME_TAX: "1151"; /** 1152 — TDS Receivable. Income tax deducted at source by our customers/payers. */
106
+ readonly TDS_RECEIVABLE: "1152"; /** 1200 — Advance Tax / VAT paid to government (offsettable at filing). */
107
+ readonly ADVANCE_TAX_PAID: "1200";
106
108
  /**
107
109
  * 1153 — VDS Receivable. The portion of output VAT withheld by a
108
110
  * designated buyer (govt entity / large corporate) and deposited to
@@ -174,7 +176,8 @@ declare const BD_ACCOUNT_CODES: {
174
176
  */
175
177
  readonly CUSTOMER_ADVANCE: "2191";
176
178
  readonly INCOME_TAX_PAYABLE: "2131";
177
- readonly VAT_OUTPUT_PAYABLE: "2132";
179
+ readonly VAT_OUTPUT_PAYABLE: "2132"; /** 2133 — Supplementary Duty (SD) Payable on specified goods/services. */
180
+ readonly SD_OUTPUT_PAYABLE: "2133";
178
181
  readonly TDS_PAYABLE: "2135";
179
182
  /**
180
183
  * 2136 — VDS Payable. Amount we must remit to NBR when we withhold VDS
@@ -182,7 +185,9 @@ declare const BD_ACCOUNT_CODES: {
182
185
  * Distinct from 2135 (TDS) — VDS is VAT-side withholding, TDS is income-tax-side.
183
186
  */
184
187
  readonly VDS_PAYABLE: "2136";
185
- readonly SALES_REVENUE: "4111";
188
+ readonly SALES_REVENUE: "4111"; /** 4114 — Sales Returns & Allowances. Contra-revenue for customer returns. */
189
+ readonly SALES_RETURNS: "4114"; /** 4115 — Sales Discount. Contra-revenue for cash / settlement discounts given. */
190
+ readonly SALES_DISCOUNT: "4115";
186
191
  /**
187
192
  * 4147 — Transport / Freight Revenue. When delivery is sold as a
188
193
  * line-item (Tk 60 delivery charge on the invoice) instead of being
@@ -226,7 +231,8 @@ declare const BD_ACCOUNT_CODES: {
226
231
  * on a Loss account and inflates profit.
227
232
  */
228
233
  readonly INVENTORY_GAIN: "4317"; /** 5111 — Cost of Goods Sold — Raw Materials */
229
- readonly COGS_MATERIALS: "5111";
234
+ readonly COGS_MATERIALS: "5111"; /** 5503 — Purchase Returns & Allowances. Contra-COGS for returns to vendors. */
235
+ readonly PURCHASE_RETURNS: "5503";
230
236
  /**
231
237
  * 5116 — Import Cost (duty + freight + insurance). Capitalized to
232
238
  * inventory at landed cost. Use this when a CIF/FOB import flow needs
@@ -365,6 +371,9 @@ declare const BD_ACCOUNT_CODES: {
365
371
  type BDAccountCode = (typeof BD_ACCOUNT_CODES)[keyof typeof BD_ACCOUNT_CODES];
366
372
  type BDAccountKey = keyof typeof BD_ACCOUNT_CODES;
367
373
  //#endregion
374
+ //#region src/accounts/account-rules.d.ts
375
+ declare const BD_ACCOUNT_RULES: AccountResolverConfig;
376
+ //#endregion
368
377
  //#region src/accounts/index.d.ts
369
378
  /** Complete flat array of all BD account types + tax sub-accounts + group labels */
370
379
  declare const BD_ACCOUNT_TYPES: readonly AccountType[];
@@ -490,6 +499,6 @@ declare const ALL_DIVISIONS: ("Dhaka" | "Chittagong" | "Rajshahi" | "Khulna" | "
490
499
  *
491
500
  * @module @classytic/ledger-bd
492
501
  */
493
- declare const bangladeshPack: _$_classytic_ledger0.CountryPack;
502
+ declare const bangladeshPack: import("@classytic/ledger").CountryPack;
494
503
  //#endregion
495
- export { ADMIN_EXPENSES, ALL_DIVISIONS, ALL_TAX_ACCOUNTS, ASSETS, BANKING_REVENUE, type BDAccountCode, type BDAccountKey, BD_ACCOUNT_CODES, BD_ACCOUNT_TYPES, BD_DIVISIONS, COGS, COST_OF_SERVICES, CURRENT_ASSETS, CURRENT_LIABILITIES, DEPRECIATION, DIRECT_LABOR, DIRECT_MATERIALS, DIVISIONS, EMPLOYEE_COSTS, EQUITY, EXPENSES, FINANCIAL_EXPENSES, INDUSTRY_REVENUE, LIABILITIES, MANUFACTURING_OVERHEAD, NGO_REVENUE, NON_CURRENT_ASSETS, NON_CURRENT_LIABILITIES, OTHER_INCOME, OTHER_OPERATING, PREMISES_COSTS, PROVISIONS, PURCHASES, REVENUE, SALES_REVENUE, SELLING_DISTRIBUTION, ALL_TAX_CODES as TAX_CODES, TAX_CODES_BY_DIVISION, TAX_EXPENSE, TDS_LIABILITY_ACCOUNTS, VAT_ASSET_ACCOUNTS, VAT_LIABILITY_ACCOUNTS, VDS_LIABILITY_ACCOUNTS, bangladeshPack, getTaxCodeDetails, mushakReturnTemplate };
504
+ export { ADMIN_EXPENSES, ALL_DIVISIONS, ALL_TAX_ACCOUNTS, ASSETS, BANKING_REVENUE, type BDAccountCode, type BDAccountKey, BD_ACCOUNT_CODES, BD_ACCOUNT_RULES, BD_ACCOUNT_TYPES, BD_DIVISIONS, COGS, COST_OF_SERVICES, CURRENT_ASSETS, CURRENT_LIABILITIES, DEPRECIATION, DIRECT_LABOR, DIRECT_MATERIALS, DIVISIONS, EMPLOYEE_COSTS, EQUITY, EXPENSES, FINANCIAL_EXPENSES, INDUSTRY_REVENUE, LIABILITIES, MANUFACTURING_OVERHEAD, NGO_REVENUE, NON_CURRENT_ASSETS, NON_CURRENT_LIABILITIES, OTHER_INCOME, OTHER_OPERATING, PREMISES_COSTS, PROVISIONS, PURCHASES, REVENUE, SALES_REVENUE, SELLING_DISTRIBUTION, ALL_TAX_CODES as TAX_CODES, TAX_CODES_BY_DIVISION, TAX_EXPENSE, TAX_RECEIVABLE_ACCOUNTS, TDS_LIABILITY_ACCOUNTS, VAT_ASSET_ACCOUNTS, VAT_LIABILITY_ACCOUNTS, VDS_LIABILITY_ACCOUNTS, bangladeshPack, getTaxCodeDetails, mushakReturnTemplate };