@classytic/ledger-bd 0.2.1 → 0.2.2

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,51 @@
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.2.2]
7
+
8
+ ### Added
9
+
10
+ **`BD_ACCOUNT_CODES` map** — canonical export of domain-meaningful keys
11
+ to 4-digit chart codes (e.g. `BD_ACCOUNT_CODES.AR === '1141'`). Hosts
12
+ build their posting contracts against this map instead of hand-coding
13
+ chart-code literals. The map covers the codes most posting layers
14
+ reference (cash/AR/AP/inventory/COGS/revenue/tax/clearings) and is
15
+ typed with `BDAccountCode` and `BDAccountKey` helpers.
16
+
17
+ Hosts that need different default mappings (e.g. a manufacturer
18
+ defaulting `MERCHANDISE → FINISHED_GOODS`) layer their own thin alias
19
+ module on top — the chart is the same; the host's "default inventory
20
+ account" is policy. See `BDAccountCode` for the typed key list.
21
+
22
+ **Two clearing-account codes** in the liability section (2125 / 2126),
23
+ matching SAP / Oracle / ERPNext placement (clearings have credit-natural
24
+ balances, so they belong in 2xxx, not 1xxx):
25
+
26
+ - **`2125` — Goods Received / Invoice Received (GR/IR)** — accrued
27
+ liability for physical goods receipt pending vendor invoice. Decouples
28
+ physical receipt from financial posting:
29
+ - Receipt: `Dr Inventory / Cr 2125`
30
+ - Vendor bill: `Dr 2125 / Cr AP`
31
+ - Period-end balance = receipts pending invoice (accrual reportable
32
+ on the balance sheet). Cleared on 3-way match (PO ↔ receipt ↔
33
+ invoice).
34
+
35
+ - **`2126` — Transfer Cost Clearing (Inter-Branch)** — accrued liability
36
+ for inter-branch transit costs capitalized into receiver inventory per
37
+ IAS 2:
38
+ - Receive leg: `Dr 1164 (goods + transit) / Cr 1179 (goods) / Cr 2126 (transit)`
39
+ - Host clears against actual freight invoice: `Dr 2126 / Cr AP`
40
+
41
+ Both codes slot into the previously-empty 2125–2126 gap in the chart
42
+ (between 2124 Freight & Shipping Payable and 2131 Income Tax Payable),
43
+ so no existing seeded codes shift.
44
+
45
+ ### Migration
46
+
47
+ Pure additive change. Run `seedAccounts()` once after upgrade to pick up
48
+ the two new codes — `accountRepository.seedAccounts()` is idempotent and
49
+ will not modify pre-existing accounts.
50
+
6
51
  ## [0.2.1]
7
52
 
8
53
  ### Added
package/dist/index.d.mts CHANGED
@@ -49,6 +49,106 @@ declare const TDS_LIABILITY_ACCOUNTS: AccountType[];
49
49
  declare const VDS_LIABILITY_ACCOUNTS: AccountType[];
50
50
  declare const ALL_TAX_ACCOUNTS: AccountType[];
51
51
  //#endregion
52
+ //#region src/accounts/codes.d.ts
53
+ /**
54
+ * Canonical BD chart account codes — domain-meaningful keys to the
55
+ * 4-digit chart codes that posting layers reference.
56
+ *
57
+ * This is the **fact** layer (chart of accounts is what it is). Hosts
58
+ * import these to write posting contracts:
59
+ *
60
+ * ```typescript
61
+ * import { BD_ACCOUNT_CODES as BD } from '@classytic/ledger-bd';
62
+ *
63
+ * { accountCode: BD.AR, debit: 1000, credit: 0 } // 1141 Accounts Receivable
64
+ * ```
65
+ *
66
+ * Hosts that want different default mappings (e.g. a manufacturer
67
+ * defaulting to `FINISHED_GOODS` instead of `MERCHANDISE` for "the
68
+ * inventory account") layer their own thin alias module on top —
69
+ * never edit this file. It's the chart, not policy.
70
+ *
71
+ * Pinned to the codes seeded by `BD_ACCOUNT_TYPES` in this same package.
72
+ * Adding a code here without seeding it via the chart will cause
73
+ * `accountRepository.resolveAccountId(code)` to fail at runtime.
74
+ */
75
+ declare const BD_ACCOUNT_CODES: {
76
+ /**
77
+ * 1113 — Cash at Bank (Current Account). The normal default for
78
+ * "where receipts land". NOT 1112 — that's "Cash in Hand (Foreign
79
+ * Currency)" in this chart, a common mis-mapping in BD ERP setups.
80
+ */
81
+ readonly CASH: "1113"; /** 1111 — Cash in Hand (Petty Cash). Use for petty-cash accounts only. */
82
+ readonly PETTY_CASH: "1111"; /** 1123 — Per-register POS till float (cash drawer). */
83
+ readonly POS_DRAWER: "1123"; /** 1124 — POS reconciliation variance (over/short clearing). */
84
+ readonly POS_OVER_SHORT: "1124"; /** 1125 — Payment gateway proceeds awaiting bank settlement. */
85
+ readonly GATEWAY_CLEARING: "1125"; /** 1126 — Mobile money merchant balance (bKash/Nagad/Rocket merchant). */
86
+ readonly MOBILE_MONEY_MERCHANT: "1126"; /** 1127 — COD cash held by courier awaiting remittance. */
87
+ readonly COD_CLEARING: "1127";
88
+ readonly AR: "1141"; /** 1158 — Net amount due from marketplaces (Daraz/Chaldal/Pickaboo). */
89
+ readonly MARKETPLACE_RECEIVABLE: "1158";
90
+ /**
91
+ * 1145 — Receivable from Related Parties.
92
+ * Used as inter-branch receivable when consolidated reporting needs
93
+ * explicit settlement balances. For standard inter-branch transfers
94
+ * the `1179` clearing path is sufficient.
95
+ */
96
+ readonly INTER_BRANCH_RECEIVABLE: "1145";
97
+ readonly VAT_RECEIVABLE: "1150";
98
+ readonly ADVANCE_INCOME_TAX: "1151";
99
+ readonly VAT_CASH_BASIS_TRANSITION: "1157";
100
+ readonly RAW_MATERIALS: "1161";
101
+ readonly WIP: "1162";
102
+ readonly FINISHED_GOODS: "1163";
103
+ /**
104
+ * 1164 — Merchandise / Trading Goods. The retail default for stock
105
+ * movements (procurement, sales COGS, transfers, adjustments). NOTE:
106
+ * earlier (pre-0.2.2) BFRS audits sometimes confused this with 1165;
107
+ * `1165` is Packing Materials in this chart.
108
+ */
109
+ readonly MERCHANDISE: "1164";
110
+ readonly PACKING_MATERIALS: "1165";
111
+ readonly INVENTORY_IN_TRANSIT: "1179";
112
+ readonly AP: "2111";
113
+ readonly BILLS_PAYABLE: "2112";
114
+ /**
115
+ * 2113 — Payable to Related Parties.
116
+ * Mirror of 1145 for intra-company settlements.
117
+ */
118
+ readonly INTER_BRANCH_PAYABLE: "2113";
119
+ readonly ACCRUED_EXPENSES: "2114";
120
+ readonly FREIGHT_PAYABLE: "2124";
121
+ /**
122
+ * 2125 — Goods Received / Invoice Received (GR/IR).
123
+ * Accrued liability for goods physically received but not yet
124
+ * billed. Receipt: `Dr Inventory / Cr 2125`. Bill: `Dr 2125 / Cr AP`.
125
+ * Cleared on 3-way match. SAP/Oracle/ERPNext-aligned placement.
126
+ */
127
+ readonly GR_IR_CLEARING: "2125";
128
+ /**
129
+ * 2126 — Transfer Cost Clearing (Inter-Branch).
130
+ * Capitalization clearing for inter-branch transit costs into
131
+ * receiver inventory per IAS 2. Receive: `Dr 1164 (goods + transit)
132
+ * / Cr 1179 (goods) / Cr 2126 (transit)`. Cleared by host against
133
+ * actual freight invoices.
134
+ */
135
+ readonly TRANSFER_COST_CLEARING: "2126"; /** 2127 — Goods returned in transit, awaiting RMA receipt + inspection. */
136
+ readonly SALES_RETURN_CLEARING: "2127"; /** 2128 — Approved customer refund authorized but not yet remitted. */
137
+ readonly REFUND_PAYABLE: "2128"; /** 2129 — Customer pre-paid balance (gift cards, vouchers). */
138
+ readonly GIFT_CARD_LIABILITY: "2129"; /** 2130 — Customer in-store credit balance. */
139
+ readonly STORE_CREDIT_LIABILITY: "2130"; /** 2160 — Outstanding loyalty points valued per IFRS 15. */
140
+ readonly LOYALTY_POINT_LIABILITY: "2160";
141
+ readonly INCOME_TAX_PAYABLE: "2131";
142
+ readonly VAT_OUTPUT_PAYABLE: "2132";
143
+ readonly TDS_PAYABLE: "2135";
144
+ readonly SALES_REVENUE: "4111"; /** 5111 — Cost of Goods Sold — Raw Materials */
145
+ readonly COGS_MATERIALS: "5111"; /** 6703 — Inventory Write-down / Obsolescence (slow-moving / expired). */
146
+ readonly OBSOLESCENCE: "6703"; /** 6711 — Inventory Shrinkage / Theft / Loss (audit shortfall). */
147
+ readonly SHRINKAGE: "6711";
148
+ };
149
+ type BDAccountCode = (typeof BD_ACCOUNT_CODES)[keyof typeof BD_ACCOUNT_CODES];
150
+ type BDAccountKey = keyof typeof BD_ACCOUNT_CODES;
151
+ //#endregion
52
152
  //#region src/accounts/index.d.ts
53
153
  /** Complete flat array of all BD account types + tax sub-accounts + group labels */
54
154
  declare const BD_ACCOUNT_TYPES: readonly AccountType[];
@@ -176,4 +276,4 @@ declare const ALL_DIVISIONS: ("Dhaka" | "Chittagong" | "Rajshahi" | "Khulna" | "
176
276
  */
177
277
  declare const bangladeshPack: _$_classytic_ledger0.CountryPack;
178
278
  //#endregion
179
- export { ADMIN_EXPENSES, ALL_DIVISIONS, ALL_TAX_ACCOUNTS, ASSETS, BANKING_REVENUE, 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 };
279
+ 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 };