lanka-kit 0.0.0-stage → 1.1.0
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/LICENSE +21 -0
- package/README.md +328 -2
- package/lib/banks.d.ts +41 -0
- package/lib/banks.js +136 -0
- package/lib/currency.d.ts +25 -0
- package/lib/currency.js +251 -0
- package/lib/geo.d.ts +18 -0
- package/lib/geo.js +197 -0
- package/lib/identity-extra.d.ts +42 -0
- package/lib/identity-extra.js +146 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +16 -0
- package/lib/lankaqr.d.ts +13 -0
- package/lib/lankaqr.js +113 -0
- package/lib/license.d.ts +16 -0
- package/lib/license.js +42 -0
- package/lib/nic.d.ts +38 -0
- package/lib/nic.js +268 -0
- package/lib/phone.d.ts +24 -0
- package/lib/phone.js +158 -0
- package/lib/types.d.ts +81 -0
- package/lib/types.js +4 -0
- package/lib/unicode.d.ts +29 -0
- package/lib/unicode.js +70 -0
- package/lib/vehicle.d.ts +28 -0
- package/lib/vehicle.js +146 -0
- package/lib/zod.d.ts +69 -0
- package/lib/zod.js +98 -0
- package/package.json +43 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lanka Developer Community
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,329 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 🇱🇰 LankaKit (`lanka-kit`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **The Ultimate Sri Lankan Developer Toolkit**
|
|
4
|
+
> *Zero runtime dependencies. First-class support for TypeScript / Node.js, Flutter / Dart, Java (Swing & Maven), Python (FastAPI/Django), and PHP (Laravel).*
|
|
5
|
+
|
|
6
|
+
[](#)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](#)
|
|
9
|
+
[](#)
|
|
10
|
+
[](#)
|
|
11
|
+
[](#)
|
|
12
|
+
[](#)
|
|
13
|
+
[](#)
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 💡 Why LankaKit?
|
|
18
|
+
|
|
19
|
+
Building applications in Sri Lanka—whether it is an e-commerce checkout, fintech KYC, ride-hailing app, invoicing platform, or government registration system—requires handling unique local data structures and edge cases.
|
|
20
|
+
|
|
21
|
+
Prior to **LankaKit**, developers had to juggle multiple unmaintained, fragmented libraries or write error-prone regex from scratch. **LankaKit solves all of this in a single, zero-dependency suite**:
|
|
22
|
+
|
|
23
|
+
1. **Accurate NIC Engine**: Fixes the infamous "1-day off" leap-year bug caused by the Sri Lankan Department of Registration of Persons (DRP) 366-day calendar convention, with bidirectional Old (9-digit) $\leftrightarrow$ New (12-digit) conversions.
|
|
24
|
+
2. **Mobile Telco Normalization**: Formats Dialog, Mobitel, Hutch, and Airtel numbers into E.164 (`+94771234567`) for SMS gateways (Notify.lk, Ideamart, Twilio).
|
|
25
|
+
3. **CBSL Bank & Branch Directory**: Instant lookup of routing codes and branches for Commercial Bank (`7010`), BOC (`7083`), Sampath (`7278`), Peoples (`7135`), HNB (`7092`), and more.
|
|
26
|
+
4. **LKR Currency Words Generator**: Converts numeric amounts directly into formal words for invoices, receipts, and bank cheques (e.g. `1540.50` $\rightarrow$ *"One Thousand Five Hundred Forty Rupees and Fifty Cents Only"*, with Sinhala language support).
|
|
27
|
+
5. **Vehicle Number Plates**: Identifies modern provincial plates (`WP CAB-1234`), vintage series (`64-1234`), and Sri series (`14 ශ්රී 1234`), automatically classifying vehicle types (Cars, Bikes, Three-wheelers).
|
|
28
|
+
6. **Passports, TIN & Business Registrations**: Validates citizen Passports (`N` series), Inland Revenue Department TINs (9/10 digits), and Registrar of Companies PV numbers (`PV 12345`).
|
|
29
|
+
7. **Sinhala Unicode Normalizer**: Fixes the notorious Zero Width Joiner (`\u200D`) bugs that break database searches in MySQL/PostgreSQL.
|
|
30
|
+
8. **Postal Codes & LankaQR**: Complete database of 25 administrative districts and CBSL-compliant EMVCo QR code parsing.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 📦 Installation Across Platforms
|
|
35
|
+
|
|
36
|
+
### 1. Node.js / TypeScript / React / Next.js
|
|
37
|
+
```bash
|
|
38
|
+
npm install lanka-kit
|
|
39
|
+
# or
|
|
40
|
+
pnpm add lanka-kit
|
|
41
|
+
# or
|
|
42
|
+
yarn add lanka-kit
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 2. Flutter / Dart
|
|
46
|
+
```bash
|
|
47
|
+
flutter pub add lanka_kit
|
|
48
|
+
# or use local path / git dependency in pubspec.yaml:
|
|
49
|
+
# lanka_kit:
|
|
50
|
+
# path: ./ports/dart
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 3. Java / Maven / Java Swing / Spring Boot
|
|
54
|
+
Add the dependency to your `pom.xml`:
|
|
55
|
+
```xml
|
|
56
|
+
<dependency>
|
|
57
|
+
<groupId>com.lankakit</groupId>
|
|
58
|
+
<artifactId>lanka-kit</artifactId>
|
|
59
|
+
<version>1.1.0</version>
|
|
60
|
+
</dependency>
|
|
61
|
+
```
|
|
62
|
+
*Or copy [`ports/java/src/main/java/com/lankakit/LankaKit.java`](ports/java/src/main/java/com/lankakit/LankaKit.java) directly into your Java project (zero dependencies, works on Java 8 through 21).*
|
|
63
|
+
|
|
64
|
+
### 4. Python / FastAPI / Django
|
|
65
|
+
```bash
|
|
66
|
+
pip install lanka-kit
|
|
67
|
+
# or install from ports directory:
|
|
68
|
+
# pip install ./ports/python
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 5. PHP / Laravel / Composer
|
|
72
|
+
```bash
|
|
73
|
+
composer require lanka-kit/lanka-kit
|
|
74
|
+
# or include ports/php/LankaKit.php
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 🚀 Quick Start Examples
|
|
80
|
+
|
|
81
|
+
### 🪪 1. Sri Lankan NIC Parsing & Form Auto-Fill
|
|
82
|
+
```typescript
|
|
83
|
+
import { validateNic } from 'lanka-kit';
|
|
84
|
+
|
|
85
|
+
const identity = validateNic('931451234V');
|
|
86
|
+
|
|
87
|
+
if (identity.isValid) {
|
|
88
|
+
console.log(identity.gender); // "Male"
|
|
89
|
+
console.log(identity.dateOfBirthFormatted); // "1993-05-24" (Accurate DRP Leap-year calculation!)
|
|
90
|
+
console.log(identity.age); // 33
|
|
91
|
+
console.log(identity.isVoter); // true (based on 'V' letter)
|
|
92
|
+
console.log(identity.equivalentNic); // "199314501234" (Auto-converted to New NIC)
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 📱 2. Phone Carrier Detection & E.164 Normalization
|
|
97
|
+
```typescript
|
|
98
|
+
import { validatePhone } from 'lanka-kit';
|
|
99
|
+
|
|
100
|
+
const phone = validatePhone('077 123 4567');
|
|
101
|
+
if (phone.isValid) {
|
|
102
|
+
console.log(phone.carrier); // "Dialog"
|
|
103
|
+
console.log(phone.e164); // "+94771234567" (Ready for SMS gateways!)
|
|
104
|
+
console.log(phone.national); // "077 123 4567"
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 🏦 3. CBSL Bank & Branch Directory
|
|
109
|
+
```typescript
|
|
110
|
+
import { lookupBank, getBranches, getBanks } from 'lanka-kit';
|
|
111
|
+
|
|
112
|
+
// Lookup by code or name
|
|
113
|
+
const bank = lookupBank('7010');
|
|
114
|
+
console.log(bank?.name); // "Commercial Bank of Ceylon PLC"
|
|
115
|
+
|
|
116
|
+
// Get popular branch codes
|
|
117
|
+
const branches = getBranches('7010');
|
|
118
|
+
console.log(branches[0]); // { branchCode: "001", name: "City Office (Colombo Fort)" }
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### 💵 4. LKR Currency Words (Cheques, Invoices & Receipts)
|
|
122
|
+
```typescript
|
|
123
|
+
import { formatLkr, amountToWords } from 'lanka-kit';
|
|
124
|
+
|
|
125
|
+
formatLkr(1540.5);
|
|
126
|
+
// "Rs. 1,540.50"
|
|
127
|
+
|
|
128
|
+
amountToWords(1540.5);
|
|
129
|
+
// "One Thousand Five Hundred Forty Rupees and Fifty Cents Only"
|
|
130
|
+
|
|
131
|
+
// Sinhala cheque format
|
|
132
|
+
amountToWords(1540.5, { language: 'si' });
|
|
133
|
+
// "රුපියල් එක්දහස් පන්සිය හතළිහයි ශත පනහයි පමණි"
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### 🚗 5. Vehicle Registration Number Plate Validator
|
|
137
|
+
```typescript
|
|
138
|
+
import { validateVehiclePlate } from 'lanka-kit';
|
|
139
|
+
|
|
140
|
+
// Modern Provincial Car
|
|
141
|
+
const car = validateVehiclePlate('WP CAB-1234');
|
|
142
|
+
console.log(car.category); // "Motor Car"
|
|
143
|
+
console.log(car.province); // { code: "WP", name: "Western Province" }
|
|
144
|
+
|
|
145
|
+
// Modern Provincial Motor Cycle
|
|
146
|
+
const bike = validateVehiclePlate('CP BAA-5678');
|
|
147
|
+
console.log(bike.category); // "Motor Cycle"
|
|
148
|
+
|
|
149
|
+
// Vintage "Sri" (ශ්රී) Series
|
|
150
|
+
const vintage = validateVehiclePlate('14 Sri 1234');
|
|
151
|
+
console.log(vintage.clean); // "14 ශ්රී 1234"
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 🛂 6. Passports, TIN & Business Registration
|
|
155
|
+
```typescript
|
|
156
|
+
import { validatePassport, validateTin, validateBrn } from 'lanka-kit';
|
|
157
|
+
|
|
158
|
+
// Passport (Citizen N-series & Biometric PA-series)
|
|
159
|
+
validatePassport('N1234567').isValid; // true
|
|
160
|
+
|
|
161
|
+
// Taxpayer Identification Number (IRD 9/10 digits)
|
|
162
|
+
validateTin('1234567890').isValid; // true
|
|
163
|
+
|
|
164
|
+
// Registrar of Companies PV Number
|
|
165
|
+
validateBrn('PV 12345').isValid; // true
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 🔤 7. Sinhala Unicode & Database Search Normalizer
|
|
169
|
+
```typescript
|
|
170
|
+
import { normalizeSinhala, stripZwj, sanitizeSearchQuery } from 'lanka-kit';
|
|
171
|
+
|
|
172
|
+
// Fixes duplicate Zero Width Joiners (\u200D) and phantom zero-width spaces
|
|
173
|
+
const cleanText = normalizeSinhala('ප්ර\u200Dවෘත්ති');
|
|
174
|
+
|
|
175
|
+
// Strips ZWJ so database queries like 'LIKE %ප්ර%' match 'ප්ර' consistently:
|
|
176
|
+
const searchQuery = sanitizeSearchQuery('ප්රවෘත්ති');
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### 🛡️ 8. Zod Schema Integration
|
|
180
|
+
```typescript
|
|
181
|
+
import { z } from 'zod';
|
|
182
|
+
import { nicRefinement, phoneRefinement, vehiclePlateRefinement } from 'lanka-kit';
|
|
183
|
+
|
|
184
|
+
const RegisterSchema = z.object({
|
|
185
|
+
nic: z.string().refine(nicRefinement.validator, { message: nicRefinement.message }),
|
|
186
|
+
phone: z.string().refine(phoneRefinement.validator, { message: phoneRefinement.message }),
|
|
187
|
+
vehiclePlate: z.string().refine(vehiclePlateRefinement.validator, { message: vehiclePlateRefinement.message }).optional(),
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## 🎯 Flutter / Dart Integration
|
|
194
|
+
|
|
195
|
+
In your Flutter widget forms:
|
|
196
|
+
|
|
197
|
+
```dart
|
|
198
|
+
import 'package:flutter/material.dart';
|
|
199
|
+
import 'package:lanka_kit/lanka_kit.dart';
|
|
200
|
+
|
|
201
|
+
class RegistrationScreen extends StatelessWidget {
|
|
202
|
+
@override
|
|
203
|
+
Widget build(BuildContext context) {
|
|
204
|
+
return Form(
|
|
205
|
+
child: Column(
|
|
206
|
+
children: [
|
|
207
|
+
// Built-in TextFormField validator
|
|
208
|
+
TextFormField(
|
|
209
|
+
decoration: InputDecoration(labelText: 'Sri Lankan NIC'),
|
|
210
|
+
validator: nicFormFieldValidator(),
|
|
211
|
+
),
|
|
212
|
+
TextFormField(
|
|
213
|
+
decoration: InputDecoration(labelText: 'Mobile Phone'),
|
|
214
|
+
validator: phoneFormFieldValidator(),
|
|
215
|
+
),
|
|
216
|
+
],
|
|
217
|
+
),
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## ☕ Java Swing & Spring Boot Integration
|
|
226
|
+
|
|
227
|
+
### In Java Swing Form Auto-Fill:
|
|
228
|
+
```java
|
|
229
|
+
import com.lankakit.LankaKit;
|
|
230
|
+
import javax.swing.JTextField;
|
|
231
|
+
import javax.swing.event.DocumentEvent;
|
|
232
|
+
import javax.swing.event.DocumentListener;
|
|
233
|
+
|
|
234
|
+
JTextField nicField = new JTextField();
|
|
235
|
+
JTextField dobField = new JTextField();
|
|
236
|
+
JTextField genderField = new JTextField();
|
|
237
|
+
|
|
238
|
+
// Automatically derives and fills Date of Birth & Gender as the user types their NIC
|
|
239
|
+
nicField.getDocument().addDocumentListener(new DocumentListener() {
|
|
240
|
+
private void update() {
|
|
241
|
+
LankaKit.NicResult res = LankaKit.validateNic(nicField.getText());
|
|
242
|
+
if (res.isValid) {
|
|
243
|
+
dobField.setText(res.dateOfBirth); // e.g. "1993-05-24"
|
|
244
|
+
genderField.setText(res.gender); // e.g. "Male"
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
public void insertUpdate(DocumentEvent e) { update(); }
|
|
248
|
+
public void removeUpdate(DocumentEvent e) { update(); }
|
|
249
|
+
public void changedUpdate(DocumentEvent e) { update(); }
|
|
250
|
+
});
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## 🐍 Python / FastAPI Integration
|
|
256
|
+
|
|
257
|
+
```python
|
|
258
|
+
from fastapi import FastAPI, HTTPException
|
|
259
|
+
from pydantic import BaseModel
|
|
260
|
+
from lanka_kit import validate_nic, validate_phone, lookup_bank
|
|
261
|
+
|
|
262
|
+
app = FastAPI()
|
|
263
|
+
|
|
264
|
+
class UserRegister(BaseModel):
|
|
265
|
+
nic: str
|
|
266
|
+
phone: str
|
|
267
|
+
|
|
268
|
+
@app.post("/register")
|
|
269
|
+
def register(user: UserRegister):
|
|
270
|
+
nic_data = validate_nic(user.nic)
|
|
271
|
+
if not nic_data["isValid"]:
|
|
272
|
+
raise HTTPException(status_code=400, detail=nic_data["error"])
|
|
273
|
+
|
|
274
|
+
phone_data = validate_phone(user.phone)
|
|
275
|
+
if not phone_data["isValid"]:
|
|
276
|
+
raise HTTPException(status_code=400, detail=phone_data["error"])
|
|
277
|
+
|
|
278
|
+
return {
|
|
279
|
+
"gender": nic_data["gender"],
|
|
280
|
+
"date_of_birth": nic_data["dateOfBirth"],
|
|
281
|
+
"carrier": phone_data["carrier"],
|
|
282
|
+
"e164": phone_data["e164"]
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## 🧪 Testing
|
|
289
|
+
|
|
290
|
+
Run the built-in test suite (33 unit tests):
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
npm test
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Test coverage includes:
|
|
297
|
+
- Male & Female Old NIC validation & 500-day offset check
|
|
298
|
+
- New 12-digit NIC validation
|
|
299
|
+
- Department of Registration of Persons (DRP) Day 60 / Day 61 Leap Year handling
|
|
300
|
+
- Bidirectional Old $\leftrightarrow$ New NIC conversions
|
|
301
|
+
- Sri Lankan Mobile Operator prefixes (Dialog, Mobitel, Hutch, Airtel) & Fixed Lines (SLT)
|
|
302
|
+
- CBSL registered bank codes and branch directory lookups
|
|
303
|
+
- LKR Currency formatting and English & Sinhala numbers to words
|
|
304
|
+
- Vehicle plate modern provincial, transitional, vintage, and Sri series
|
|
305
|
+
- Passports, Tax Identification Numbers (TIN), and ROC Business Registrations (PV numbers)
|
|
306
|
+
- Sinhala Unicode Normalizer and ZWJ stripping for search indexing
|
|
307
|
+
- 25 Administrative Districts and Postal Code lookups
|
|
308
|
+
- LANKAQR EMVCo Tag-Length-Value (TLV) parsing & CRC-16 validation
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## 💻 Local Interactive Playground
|
|
313
|
+
|
|
314
|
+
To launch the interactive demo and documentation web app:
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
npm run dev
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Open `http://127.0.0.1:5173/` in your browser.
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## 🤝 Contributing
|
|
325
|
+
|
|
326
|
+
Contributions, issues, and feature requests are welcome.
|
|
327
|
+
|
|
328
|
+
### License
|
|
329
|
+
MIT License. Free to use in open-source and commercial products.
|
package/lib/banks.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bank and branch routing directory for Sri Lanka.
|
|
3
|
+
*/
|
|
4
|
+
export interface BankInfo {
|
|
5
|
+
code: string;
|
|
6
|
+
name: string;
|
|
7
|
+
shortName: string;
|
|
8
|
+
popular: boolean;
|
|
9
|
+
swiftCode?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface BranchInfo {
|
|
12
|
+
bankCode: string;
|
|
13
|
+
branchCode: string;
|
|
14
|
+
name: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const SRI_LANKA_BANKS: BankInfo[];
|
|
17
|
+
export declare const COMMON_BRANCHES: Record<string, BranchInfo[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Returns all registered Sri Lankan commercial, specialized and foreign banks.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getBanks(): BankInfo[];
|
|
22
|
+
/**
|
|
23
|
+
* Returns the most frequently used commercial banks in Sri Lanka.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getPopularBanks(): BankInfo[];
|
|
26
|
+
/**
|
|
27
|
+
* Checks whether a given 4-digit code is a valid registered bank code.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isValidBankCode(code: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Lookup a bank by its 4-digit code, short name, or full name (case-insensitive).
|
|
32
|
+
*/
|
|
33
|
+
export declare function lookupBank(query: string): BankInfo | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Search banks matching query keyword.
|
|
36
|
+
*/
|
|
37
|
+
export declare function searchBanks(query: string): BankInfo[];
|
|
38
|
+
/**
|
|
39
|
+
* Get common branches for a given bank code.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getBranches(bankCode: string): BranchInfo[];
|
package/lib/banks.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bank and branch routing directory for Sri Lanka.
|
|
3
|
+
*/
|
|
4
|
+
export const SRI_LANKA_BANKS = [
|
|
5
|
+
{ code: '7010', name: 'Commercial Bank of Ceylon PLC', shortName: 'Commercial Bank', popular: true, swiftCode: 'CCEYLKAX' },
|
|
6
|
+
{ code: '7083', name: 'Bank of Ceylon', shortName: 'BOC', popular: true, swiftCode: 'BCEYLKLX' },
|
|
7
|
+
{ code: '7135', name: "People's Bank", shortName: "People's Bank", popular: true, swiftCode: 'PSBLLKLX' },
|
|
8
|
+
{ code: '7092', name: 'Hatton National Bank PLC', shortName: 'HNB', popular: true, swiftCode: 'HBLILKLX' },
|
|
9
|
+
{ code: '7278', name: 'Sampath Bank PLC', shortName: 'Sampath Bank', popular: true, swiftCode: 'BSAMLKLX' },
|
|
10
|
+
{ code: '7169', name: 'National Development Bank PLC', shortName: 'NDB Bank', popular: true, swiftCode: 'NDBLLKLX' },
|
|
11
|
+
{ code: '7214', name: 'Nations Trust Bank PLC', shortName: 'NTB', popular: true, swiftCode: 'NTBLLKLX' },
|
|
12
|
+
{ code: '7205', name: 'Seylan Bank PLC', shortName: 'Seylan Bank', popular: true, swiftCode: 'SEYBLKLX' },
|
|
13
|
+
{ code: '7311', name: 'DFCC Bank PLC', shortName: 'DFCC Bank', popular: true, swiftCode: 'DFCCLKLX' },
|
|
14
|
+
{ code: '7719', name: 'National Savings Bank', shortName: 'NSB', popular: true, swiftCode: 'NSBLLKLX' },
|
|
15
|
+
{ code: '7463', name: 'Cargills Bank Limited', shortName: 'Cargills Bank', popular: true, swiftCode: 'CBKLLKLX' },
|
|
16
|
+
{ code: '7144', name: 'Union Bank of Colombo PLC', shortName: 'Union Bank', popular: false, swiftCode: 'UBLKLKLX' },
|
|
17
|
+
{ code: '7287', name: 'Pan Asia Banking Corporation PLC', shortName: 'Pan Asia Bank', popular: false, swiftCode: 'PASLLKLX' },
|
|
18
|
+
{ code: '7384', name: 'Amana Bank PLC', shortName: 'Amana Bank', popular: false, swiftCode: 'AMNALKLX' },
|
|
19
|
+
{ code: '7728', name: 'Sanasa Development Bank PLC', shortName: 'SDB Bank', popular: false, swiftCode: 'SNDBLKLX' },
|
|
20
|
+
{ code: '7737', name: 'Regional Development Bank', shortName: 'RDB', popular: false, swiftCode: 'RDBLLKLX' },
|
|
21
|
+
{ code: '7056', name: 'Standard Chartered Bank', shortName: 'Standard Chartered', popular: false, swiftCode: 'SCBLLKLX' },
|
|
22
|
+
{ code: '7074', name: 'The Hongkong and Shanghai Banking Corporation Ltd', shortName: 'HSBC', popular: true, swiftCode: 'HSBCLKLX' },
|
|
23
|
+
{ code: '7038', name: 'Citibank N.A.', shortName: 'Citibank', popular: false, swiftCode: 'CITILKLX' },
|
|
24
|
+
{ code: '7047', name: 'Indian Bank', shortName: 'Indian Bank', popular: false, swiftCode: 'IDIBLKLX' },
|
|
25
|
+
{ code: '7108', name: 'Indian Overseas Bank', shortName: 'IOB', popular: false, swiftCode: 'IOBALKLX' },
|
|
26
|
+
{ code: '7269', name: 'MCB Bank Limited', shortName: 'MCB Bank', popular: false, swiftCode: 'MCBBLKLX' },
|
|
27
|
+
{ code: '7302', name: 'Habib Bank Limited', shortName: 'Habib Bank', popular: false, swiftCode: 'HBBLLKLX' },
|
|
28
|
+
{ code: '7472', name: 'State Bank of India', shortName: 'SBI', popular: false, swiftCode: 'SBINLKLX' },
|
|
29
|
+
{ code: '7481', name: 'Public Bank Berhad', shortName: 'Public Bank', popular: false, swiftCode: 'PBLKLKLX' },
|
|
30
|
+
{ code: '7490', name: 'Deutsche Bank AG', shortName: 'Deutsche Bank', popular: false, swiftCode: 'DEUTLKLX' },
|
|
31
|
+
{ code: '7746', name: 'State Mortgage & Investment Bank', shortName: 'SMIB', popular: false },
|
|
32
|
+
{ code: '7755', name: 'Housing Development Finance Corporation Bank', shortName: 'HDFC Bank', popular: false },
|
|
33
|
+
{ code: '7782', name: 'Sri Lanka Savings Bank Limited', shortName: 'SLSB', popular: false },
|
|
34
|
+
];
|
|
35
|
+
export const COMMON_BRANCHES = {
|
|
36
|
+
// Commercial Bank
|
|
37
|
+
'7010': [
|
|
38
|
+
{ bankCode: '7010', branchCode: '001', name: 'City Office (Colombo Fort)' },
|
|
39
|
+
{ bankCode: '7010', branchCode: '002', name: 'Foreign Branch' },
|
|
40
|
+
{ bankCode: '7010', branchCode: '005', name: 'Kollupitiya' },
|
|
41
|
+
{ bankCode: '7010', branchCode: '010', name: 'Kandy' },
|
|
42
|
+
{ bankCode: '7010', branchCode: '015', name: 'Galle' },
|
|
43
|
+
{ bankCode: '7010', branchCode: '020', name: 'Kurunegala' },
|
|
44
|
+
{ bankCode: '7010', branchCode: '025', name: 'Jaffna' },
|
|
45
|
+
{ bankCode: '7010', branchCode: '030', name: 'Nugegoda' },
|
|
46
|
+
{ bankCode: '7010', branchCode: '035', name: 'Negombo' },
|
|
47
|
+
{ bankCode: '7010', branchCode: '040', name: 'Gampaha' },
|
|
48
|
+
],
|
|
49
|
+
// Bank of Ceylon
|
|
50
|
+
'7083': [
|
|
51
|
+
{ bankCode: '7083', branchCode: '001', name: 'Corporate Branch (BOC Tower)' },
|
|
52
|
+
{ bankCode: '7083', branchCode: '002', name: 'Colombo Fort' },
|
|
53
|
+
{ bankCode: '7083', branchCode: '005', name: 'Pettah' },
|
|
54
|
+
{ bankCode: '7083', branchCode: '010', name: 'Kandy Super Grade' },
|
|
55
|
+
{ bankCode: '7083', branchCode: '015', name: 'Galle Fort' },
|
|
56
|
+
{ bankCode: '7083', branchCode: '020', name: 'Kurunegala' },
|
|
57
|
+
{ bankCode: '7083', branchCode: '025', name: 'Jaffna Super Grade' },
|
|
58
|
+
{ bankCode: '7083', branchCode: '030', name: 'Nugegoda' },
|
|
59
|
+
],
|
|
60
|
+
// People's Bank
|
|
61
|
+
'7135': [
|
|
62
|
+
{ bankCode: '7135', branchCode: '001', name: 'Corporate Banking Division' },
|
|
63
|
+
{ bankCode: '7135', branchCode: '002', name: 'Colombo Fort' },
|
|
64
|
+
{ bankCode: '7135', branchCode: '010', name: 'Kandy City' },
|
|
65
|
+
{ bankCode: '7135', branchCode: '015', name: 'Galle City' },
|
|
66
|
+
{ bankCode: '7135', branchCode: '020', name: 'Kurunegala Town' },
|
|
67
|
+
],
|
|
68
|
+
// Sampath Bank
|
|
69
|
+
'7278': [
|
|
70
|
+
{ bankCode: '7278', branchCode: '001', name: 'Head Office (Colombo 02)' },
|
|
71
|
+
{ bankCode: '7278', branchCode: '005', name: 'Colombo Fort' },
|
|
72
|
+
{ bankCode: '7278', branchCode: '010', name: 'Kandy Super Grade' },
|
|
73
|
+
{ bankCode: '7278', branchCode: '015', name: 'Galle Super Grade' },
|
|
74
|
+
{ bankCode: '7278', branchCode: '030', name: 'Nugegoda Super Grade' },
|
|
75
|
+
],
|
|
76
|
+
// HNB
|
|
77
|
+
'7092': [
|
|
78
|
+
{ bankCode: '7092', branchCode: '001', name: 'Head Office (HNB Towers)' },
|
|
79
|
+
{ bankCode: '7092', branchCode: '002', name: 'Colombo Fort' },
|
|
80
|
+
{ bankCode: '7092', branchCode: '010', name: 'Kandy' },
|
|
81
|
+
{ bankCode: '7092', branchCode: '015', name: 'Galle' },
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Returns all registered Sri Lankan commercial, specialized and foreign banks.
|
|
86
|
+
*/
|
|
87
|
+
export function getBanks() {
|
|
88
|
+
return [...SRI_LANKA_BANKS];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Returns the most frequently used commercial banks in Sri Lanka.
|
|
92
|
+
*/
|
|
93
|
+
export function getPopularBanks() {
|
|
94
|
+
return SRI_LANKA_BANKS.filter((b) => b.popular);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Checks whether a given 4-digit code is a valid registered bank code.
|
|
98
|
+
*/
|
|
99
|
+
export function isValidBankCode(code) {
|
|
100
|
+
if (!code || typeof code !== 'string')
|
|
101
|
+
return false;
|
|
102
|
+
const clean = code.trim();
|
|
103
|
+
return SRI_LANKA_BANKS.some((b) => b.code === clean);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Lookup a bank by its 4-digit code, short name, or full name (case-insensitive).
|
|
107
|
+
*/
|
|
108
|
+
export function lookupBank(query) {
|
|
109
|
+
if (!query || typeof query !== 'string')
|
|
110
|
+
return undefined;
|
|
111
|
+
const clean = query.trim().toLowerCase();
|
|
112
|
+
return SRI_LANKA_BANKS.find((b) => b.code === clean ||
|
|
113
|
+
b.shortName.toLowerCase() === clean ||
|
|
114
|
+
b.name.toLowerCase() === clean ||
|
|
115
|
+
(b.swiftCode && b.swiftCode.toLowerCase() === clean));
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Search banks matching query keyword.
|
|
119
|
+
*/
|
|
120
|
+
export function searchBanks(query) {
|
|
121
|
+
if (!query || typeof query !== 'string')
|
|
122
|
+
return [];
|
|
123
|
+
const clean = query.trim().toLowerCase();
|
|
124
|
+
return SRI_LANKA_BANKS.filter((b) => b.code.includes(clean) ||
|
|
125
|
+
b.name.toLowerCase().includes(clean) ||
|
|
126
|
+
b.shortName.toLowerCase().includes(clean));
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Get common branches for a given bank code.
|
|
130
|
+
*/
|
|
131
|
+
export function getBranches(bankCode) {
|
|
132
|
+
if (!bankCode || typeof bankCode !== 'string')
|
|
133
|
+
return [];
|
|
134
|
+
const clean = bankCode.trim();
|
|
135
|
+
return COMMON_BRANCHES[clean] || [];
|
|
136
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LKR currency formatting and amount-to-words converter.
|
|
3
|
+
*/
|
|
4
|
+
export interface CurrencyFormatOptions {
|
|
5
|
+
prefix?: string;
|
|
6
|
+
suffix?: string;
|
|
7
|
+
decimals?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface AmountToWordsOptions {
|
|
10
|
+
language?: 'en' | 'si';
|
|
11
|
+
includeCurrency?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Format a numeric amount to Sri Lankan Rupee standard display.
|
|
15
|
+
* Example: 1540000.5 -> "Rs. 1,540,000.50"
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatLkr(amount: number, options?: CurrencyFormatOptions): string;
|
|
18
|
+
/**
|
|
19
|
+
* Convert numeric amount into formal words.
|
|
20
|
+
*
|
|
21
|
+
* @param amount - Monetary number (e.g., 1540.50)
|
|
22
|
+
* @param options - Language and formatting options
|
|
23
|
+
* @returns Standard phrase (e.g., "One Thousand Five Hundred Forty Rupees and Fifty Cents Only")
|
|
24
|
+
*/
|
|
25
|
+
export declare function amountToWords(amount: number, options?: AmountToWordsOptions): string;
|