ceylon-devkit 0.0.0-stage → 1.0.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 +22 -0
- package/README.md +144 -2
- package/dist/index.d.mts +200 -0
- package/dist/index.d.ts +200 -0
- package/dist/index.js +612 -0
- package/dist/index.mjs +570 -0
- package/package.json +44 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 CeylonDevKit Contributors
|
|
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.
|
|
22
|
+
|
package/README.md
CHANGED
|
@@ -1,3 +1,145 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 🇱🇰 CeylonDevKit
|
|
2
|
+
|
|
3
|
+
> The all-in-one Sri Lankan developer toolkit for Node.js and TypeScript.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/ceylon-devkit)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
**CeylonDevKit** brings essential Sri Lanka-specific business and financial tools into a single, zero-dependency, type-safe library:
|
|
9
|
+
|
|
10
|
+
1. 💵 **LKR Currency to Words & Formatter** (Sinhala & English words, Cheque writing, Lakhs & Crores).
|
|
11
|
+
2. 🏦 **Sri Lanka Bank & Branch Lookup** (Codes for BOC, Commercial Bank, Sampath, HNB, People's Bank, etc.).
|
|
12
|
+
3. 📑 **TIN & VAT Validator + Tax Calculator** (9-digit IRD TIN validator, VAT number validator, and automated 18% VAT & 2.5% SSCL calculator).
|
|
13
|
+
4. 📅 **CBSL Working Days & Holidays Calculator** (Bank, Mercantile, and Public holidays filter, working days duration, and payment due date calculator).
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 📦 Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install ceylon-devkit
|
|
21
|
+
# or
|
|
22
|
+
yarn add ceylon-devkit
|
|
23
|
+
# or
|
|
24
|
+
pnpm add ceylon-devkit
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 🚀 Quick Start & Usage
|
|
30
|
+
|
|
31
|
+
### 1. Currency to Words (English & Sinhala)
|
|
32
|
+
|
|
33
|
+
Convert numbers to currency words for Invoices, Receipts, and Cheques:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { lkrToWords, formatLKR } from 'ceylon-devkit';
|
|
37
|
+
|
|
38
|
+
// English
|
|
39
|
+
lkrToWords(1550.50);
|
|
40
|
+
// => "One Thousand Five Hundred Fifty Rupees and Fifty Cents Only"
|
|
41
|
+
|
|
42
|
+
// Sinhala (සිංහල)
|
|
43
|
+
lkrToWords(1550.50, { lang: 'si' });
|
|
44
|
+
// => "රුපියල් එක්දහස් පන්සිය පනහයි ශත පනහයි පමණි"
|
|
45
|
+
|
|
46
|
+
// Cheque printing format
|
|
47
|
+
lkrToWords(50000, { chequeFormat: true });
|
|
48
|
+
// => "*** Fifty Thousand Rupees Only ***"
|
|
49
|
+
|
|
50
|
+
// South Asian Number Formatter (Lakhs & Crores)
|
|
51
|
+
formatLKR(1500000, { compact: true });
|
|
52
|
+
// => "Rs. 15.00 Lakhs"
|
|
53
|
+
|
|
54
|
+
formatLKR(25000000, { compact: true, compactLang: 'si' });
|
|
55
|
+
// => "රු. 2.50 කෝටි"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### 2. Bank & Branch Codes Lookup
|
|
61
|
+
|
|
62
|
+
Lookup official 4-digit bank codes, SWIFT codes, and branches:
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { findBank, getBanks, getBranches } from 'ceylon-devkit';
|
|
66
|
+
|
|
67
|
+
// Find bank by 4-digit code or name
|
|
68
|
+
findBank('7056');
|
|
69
|
+
// => { code: '7056', name: 'Commercial Bank of Ceylon PLC', shortName: 'Commercial Bank', swiftCode: 'CCEYLKLX' }
|
|
70
|
+
|
|
71
|
+
findBank('Sampath');
|
|
72
|
+
// => { code: '7278', name: 'Sampath Bank PLC', shortName: 'Sampath Bank', swiftCode: 'BSAMLKLX' }
|
|
73
|
+
|
|
74
|
+
// Get branches for a bank
|
|
75
|
+
const branches = getBranches('7056');
|
|
76
|
+
// => [{ code: '001', name: 'Colombo Fort / Head Office', ... }, ...]
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
### 3. TIN / VAT Validator & Tax Calculator (VAT & SSCL)
|
|
82
|
+
|
|
83
|
+
Validate Inland Revenue Department (IRD) TIN numbers and calculate taxes:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { validateTIN, validateVAT, calculateTax } from 'ceylon-devkit';
|
|
87
|
+
|
|
88
|
+
// Validate 9-digit IRD TIN
|
|
89
|
+
validateTIN('123456789');
|
|
90
|
+
// => { isValid: true, tin: '123456789', formatted: '123-456-789' }
|
|
91
|
+
|
|
92
|
+
// Validate VAT Number
|
|
93
|
+
validateVAT('123456789-7000');
|
|
94
|
+
// => { isValid: true, baseTin: '123456789', branchCode: '7000' }
|
|
95
|
+
|
|
96
|
+
// Calculate 18% VAT and 2.5% SSCL according to Sri Lankan tax laws
|
|
97
|
+
const tax = calculateTax({
|
|
98
|
+
amount: 10000,
|
|
99
|
+
includeSSCL: true // Calculates SSCL 2.5% + VAT 18%
|
|
100
|
+
});
|
|
101
|
+
/*
|
|
102
|
+
Output:
|
|
103
|
+
{
|
|
104
|
+
baseAmount: 10000,
|
|
105
|
+
ssclAmount: 250,
|
|
106
|
+
vatAmount: 1845,
|
|
107
|
+
totalTax: 2095,
|
|
108
|
+
totalAmount: 12095
|
|
109
|
+
}
|
|
110
|
+
*/
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
### 4. Working Days & Holidays Calculator
|
|
116
|
+
|
|
117
|
+
Calculate actual working days excluding weekends and statutory Sri Lankan holidays:
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
import { isWorkingDay, getWorkingDays, addWorkingDays } from 'ceylon-devkit';
|
|
121
|
+
|
|
122
|
+
// Check if a date is a working day
|
|
123
|
+
isWorkingDay(new Date('2025-04-14'));
|
|
124
|
+
// => false (Sinhala & Tamil New Year Day)
|
|
125
|
+
|
|
126
|
+
// Calculate total working days in a date range
|
|
127
|
+
const workingDays = getWorkingDays(new Date('2025-04-01'), new Date('2025-04-30'));
|
|
128
|
+
// => Returns number of working days excluding weekends and statutory holidays
|
|
129
|
+
|
|
130
|
+
// Calculate payment due date after 14 working days
|
|
131
|
+
const invoiceDueDate = addWorkingDays(new Date(), 14);
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 🛠️ TypeScript & ESM Support
|
|
137
|
+
|
|
138
|
+
`ceylon-devkit` comes with full TypeScript definitions out of the box and supports both **CommonJS (`require`)** and **ES Modules (`import`)**.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## 📄 License
|
|
143
|
+
|
|
144
|
+
MIT License © 2026. Made with ❤️ in Sri Lanka.
|
|
2
145
|
|
|
3
|
-
This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for converting LKR currency to words.
|
|
3
|
+
*/
|
|
4
|
+
interface ToWordsOptions {
|
|
5
|
+
/** Language output: 'en' for English, 'si' for Sinhala (Default: 'en') */
|
|
6
|
+
lang?: 'en' | 'si';
|
|
7
|
+
/** Whether to append 'Only' / 'පමණයි' at the end (Default: true) */
|
|
8
|
+
showOnly?: boolean;
|
|
9
|
+
/** Format suitable for cheques, wrapped with asterisks (Default: false) */
|
|
10
|
+
chequeFormat?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Options for South Asian LKR currency formatting.
|
|
14
|
+
*/
|
|
15
|
+
interface FormatLKROptions {
|
|
16
|
+
/** Symbol prefix: 'Rs.' or 'රු.' or 'LKR' (Default: 'Rs. ') */
|
|
17
|
+
prefix?: string;
|
|
18
|
+
/** Decimal places (Default: 2) */
|
|
19
|
+
decimals?: number;
|
|
20
|
+
/** Format in South Asian grouping (Lakhs and Crores) */
|
|
21
|
+
compact?: boolean;
|
|
22
|
+
/** Language for compact text ('en' for Lakhs/Crores, 'si' for ලක්ෂ/කෝටි) */
|
|
23
|
+
compactLang?: 'en' | 'si';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Converts an LKR numeric amount into English or Sinhala words.
|
|
27
|
+
*/
|
|
28
|
+
declare function lkrToWords(amount: number, options?: ToWordsOptions): string;
|
|
29
|
+
/**
|
|
30
|
+
* Formats a number into LKR currency or South Asian compact format (Lakhs / Crores).
|
|
31
|
+
*/
|
|
32
|
+
declare function formatLKR(amount: number, options?: FormatLKROptions): string;
|
|
33
|
+
|
|
34
|
+
interface Bank {
|
|
35
|
+
code: string;
|
|
36
|
+
name: string;
|
|
37
|
+
shortName: string;
|
|
38
|
+
swiftCode?: string;
|
|
39
|
+
headOffice?: string;
|
|
40
|
+
}
|
|
41
|
+
interface Branch {
|
|
42
|
+
code: string;
|
|
43
|
+
name: string;
|
|
44
|
+
bankCode: string;
|
|
45
|
+
district?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* List of registered commercial and specialized banks in Sri Lanka (CBSL).
|
|
49
|
+
*/
|
|
50
|
+
declare const SRI_LANKAN_BANKS: Bank[];
|
|
51
|
+
/**
|
|
52
|
+
* Common major branch codes across Sri Lankan districts.
|
|
53
|
+
*/
|
|
54
|
+
declare const SRI_LANKAN_BRANCHES: Branch[];
|
|
55
|
+
/**
|
|
56
|
+
* Returns the list of all registered Sri Lankan banks.
|
|
57
|
+
*/
|
|
58
|
+
declare function getBanks(): Bank[];
|
|
59
|
+
/**
|
|
60
|
+
* Search for a bank by its 4-digit code, name, or short name.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* findBank('7056'); // => Commercial Bank of Ceylon PLC
|
|
65
|
+
* findBank('Sampath'); // => Sampath Bank PLC
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
declare function findBank(query: string): Bank | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Returns branches for a given bank code.
|
|
71
|
+
*/
|
|
72
|
+
declare function getBranches(bankCode: string): Branch[];
|
|
73
|
+
/**
|
|
74
|
+
* Search for a branch by branch code or branch name within a bank.
|
|
75
|
+
*/
|
|
76
|
+
declare function findBranch(bankCode: string, query: string): Branch | undefined;
|
|
77
|
+
|
|
78
|
+
interface TinValidationResult {
|
|
79
|
+
isValid: boolean;
|
|
80
|
+
tin?: string;
|
|
81
|
+
formatted?: string;
|
|
82
|
+
error?: string;
|
|
83
|
+
}
|
|
84
|
+
interface VatValidationResult {
|
|
85
|
+
isValid: boolean;
|
|
86
|
+
vatNumber?: string;
|
|
87
|
+
baseTin?: string;
|
|
88
|
+
branchCode?: string;
|
|
89
|
+
error?: string;
|
|
90
|
+
}
|
|
91
|
+
interface TaxCalculationOptions {
|
|
92
|
+
/** The monetary amount */
|
|
93
|
+
amount: number;
|
|
94
|
+
/** Whether the amount provided is already inclusive of taxes (Default: false) */
|
|
95
|
+
isInclusive?: boolean;
|
|
96
|
+
/** VAT rate percentage (Default: 18%) */
|
|
97
|
+
vatRate?: number;
|
|
98
|
+
/** Whether to calculate Social Security Contribution Levy (SSCL) (Default: false) */
|
|
99
|
+
includeSSCL?: boolean;
|
|
100
|
+
/** SSCL rate percentage (Default: 2.5%) */
|
|
101
|
+
ssclRate?: number;
|
|
102
|
+
}
|
|
103
|
+
interface TaxBreakdown {
|
|
104
|
+
baseAmount: number;
|
|
105
|
+
ssclAmount: number;
|
|
106
|
+
vatAmount: number;
|
|
107
|
+
totalTax: number;
|
|
108
|
+
totalAmount: number;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Validates a Sri Lankan Taxpayer Identification Number (TIN) issued by IRD.
|
|
112
|
+
* Standard format is a 9-digit numeric sequence.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* validateTIN('123456789'); // => { isValid: true, tin: '123456789', formatted: '123-456-789' }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
declare function validateTIN(input: string | number): TinValidationResult;
|
|
120
|
+
/**
|
|
121
|
+
* Validates a Sri Lankan VAT Registration Number.
|
|
122
|
+
* Format is typically 9 digits followed by a 4-digit code (e.g., 123456789-7000) or 9 digits.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* validateVAT('123456789-7000'); // => { isValid: true, baseTin: '123456789', branchCode: '7000' }
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
declare function validateVAT(input: string): VatValidationResult;
|
|
130
|
+
/**
|
|
131
|
+
* Calculate Sri Lanka VAT (18%) and optional SSCL (2.5%) for invoicing.
|
|
132
|
+
* Supports both tax-exclusive and tax-inclusive calculations.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* calculateTax({ amount: 10000, includeSSCL: true });
|
|
137
|
+
* // => { baseAmount: 10000, ssclAmount: 250, vatAmount: 1845, totalAmount: 12095 }
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
declare function calculateTax(options: TaxCalculationOptions): TaxBreakdown;
|
|
141
|
+
|
|
142
|
+
type HolidayCategory = 'public' | 'bank' | 'mercantile';
|
|
143
|
+
interface Holiday {
|
|
144
|
+
date: string;
|
|
145
|
+
name: string;
|
|
146
|
+
categories: HolidayCategory[];
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Standard Sri Lankan Statutory & Public/Bank/Mercantile Holidays.
|
|
150
|
+
* Covers official annual holidays recognized by CBSL and the Ministry of Public Administration.
|
|
151
|
+
*/
|
|
152
|
+
declare const SRI_LANKAN_HOLIDAYS: Holiday[];
|
|
153
|
+
interface WorkingDaysOptions {
|
|
154
|
+
/** Check against Bank holidays (Default: true) */
|
|
155
|
+
bankHolidays?: boolean;
|
|
156
|
+
/** Check against Mercantile holidays (for private sector) (Default: false) */
|
|
157
|
+
mercantileOnly?: boolean;
|
|
158
|
+
/** Treat Saturdays as working days (Default: false) */
|
|
159
|
+
saturdayWorking?: boolean;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Check if a date is a weekend.
|
|
163
|
+
*/
|
|
164
|
+
declare function isWeekend(date: Date, saturdayWorking?: boolean): boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Returns holiday details if the given date is a Sri Lankan statutory holiday.
|
|
167
|
+
*/
|
|
168
|
+
declare function getHoliday(date: Date): Holiday | undefined;
|
|
169
|
+
/**
|
|
170
|
+
* Check if a given date is a Sri Lankan working day.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* isWorkingDay(new Date('2025-04-14')); // => false (New Year Day)
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
declare function isWorkingDay(date: Date, options?: WorkingDaysOptions): boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Calculates the number of working days between two dates (inclusive),
|
|
180
|
+
* excluding weekends and statutory Sri Lankan holidays.
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```ts
|
|
184
|
+
* getWorkingDays(new Date('2025-04-01'), new Date('2025-04-30'));
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
declare function getWorkingDays(startDate: Date, endDate: Date, options?: WorkingDaysOptions): number;
|
|
188
|
+
/**
|
|
189
|
+
* Adds a specific number of working days to a given start date.
|
|
190
|
+
* Useful for calculating invoice payment due dates or credit terms.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```ts
|
|
194
|
+
* // Calculate due date after 10 working days:
|
|
195
|
+
* const dueDate = addWorkingDays(new Date(), 10);
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
declare function addWorkingDays(startDate: Date, daysToAdd: number, options?: WorkingDaysOptions): Date;
|
|
199
|
+
|
|
200
|
+
export { type Bank, type Branch, type FormatLKROptions, type Holiday, type HolidayCategory, SRI_LANKAN_BANKS, SRI_LANKAN_BRANCHES, SRI_LANKAN_HOLIDAYS, type TaxBreakdown, type TaxCalculationOptions, type TinValidationResult, type ToWordsOptions, type VatValidationResult, type WorkingDaysOptions, addWorkingDays, calculateTax, findBank, findBranch, formatLKR, getBanks, getBranches, getHoliday, getWorkingDays, isWeekend, isWorkingDay, lkrToWords, validateTIN, validateVAT };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for converting LKR currency to words.
|
|
3
|
+
*/
|
|
4
|
+
interface ToWordsOptions {
|
|
5
|
+
/** Language output: 'en' for English, 'si' for Sinhala (Default: 'en') */
|
|
6
|
+
lang?: 'en' | 'si';
|
|
7
|
+
/** Whether to append 'Only' / 'පමණයි' at the end (Default: true) */
|
|
8
|
+
showOnly?: boolean;
|
|
9
|
+
/** Format suitable for cheques, wrapped with asterisks (Default: false) */
|
|
10
|
+
chequeFormat?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Options for South Asian LKR currency formatting.
|
|
14
|
+
*/
|
|
15
|
+
interface FormatLKROptions {
|
|
16
|
+
/** Symbol prefix: 'Rs.' or 'රු.' or 'LKR' (Default: 'Rs. ') */
|
|
17
|
+
prefix?: string;
|
|
18
|
+
/** Decimal places (Default: 2) */
|
|
19
|
+
decimals?: number;
|
|
20
|
+
/** Format in South Asian grouping (Lakhs and Crores) */
|
|
21
|
+
compact?: boolean;
|
|
22
|
+
/** Language for compact text ('en' for Lakhs/Crores, 'si' for ලක්ෂ/කෝටි) */
|
|
23
|
+
compactLang?: 'en' | 'si';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Converts an LKR numeric amount into English or Sinhala words.
|
|
27
|
+
*/
|
|
28
|
+
declare function lkrToWords(amount: number, options?: ToWordsOptions): string;
|
|
29
|
+
/**
|
|
30
|
+
* Formats a number into LKR currency or South Asian compact format (Lakhs / Crores).
|
|
31
|
+
*/
|
|
32
|
+
declare function formatLKR(amount: number, options?: FormatLKROptions): string;
|
|
33
|
+
|
|
34
|
+
interface Bank {
|
|
35
|
+
code: string;
|
|
36
|
+
name: string;
|
|
37
|
+
shortName: string;
|
|
38
|
+
swiftCode?: string;
|
|
39
|
+
headOffice?: string;
|
|
40
|
+
}
|
|
41
|
+
interface Branch {
|
|
42
|
+
code: string;
|
|
43
|
+
name: string;
|
|
44
|
+
bankCode: string;
|
|
45
|
+
district?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* List of registered commercial and specialized banks in Sri Lanka (CBSL).
|
|
49
|
+
*/
|
|
50
|
+
declare const SRI_LANKAN_BANKS: Bank[];
|
|
51
|
+
/**
|
|
52
|
+
* Common major branch codes across Sri Lankan districts.
|
|
53
|
+
*/
|
|
54
|
+
declare const SRI_LANKAN_BRANCHES: Branch[];
|
|
55
|
+
/**
|
|
56
|
+
* Returns the list of all registered Sri Lankan banks.
|
|
57
|
+
*/
|
|
58
|
+
declare function getBanks(): Bank[];
|
|
59
|
+
/**
|
|
60
|
+
* Search for a bank by its 4-digit code, name, or short name.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* findBank('7056'); // => Commercial Bank of Ceylon PLC
|
|
65
|
+
* findBank('Sampath'); // => Sampath Bank PLC
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
declare function findBank(query: string): Bank | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Returns branches for a given bank code.
|
|
71
|
+
*/
|
|
72
|
+
declare function getBranches(bankCode: string): Branch[];
|
|
73
|
+
/**
|
|
74
|
+
* Search for a branch by branch code or branch name within a bank.
|
|
75
|
+
*/
|
|
76
|
+
declare function findBranch(bankCode: string, query: string): Branch | undefined;
|
|
77
|
+
|
|
78
|
+
interface TinValidationResult {
|
|
79
|
+
isValid: boolean;
|
|
80
|
+
tin?: string;
|
|
81
|
+
formatted?: string;
|
|
82
|
+
error?: string;
|
|
83
|
+
}
|
|
84
|
+
interface VatValidationResult {
|
|
85
|
+
isValid: boolean;
|
|
86
|
+
vatNumber?: string;
|
|
87
|
+
baseTin?: string;
|
|
88
|
+
branchCode?: string;
|
|
89
|
+
error?: string;
|
|
90
|
+
}
|
|
91
|
+
interface TaxCalculationOptions {
|
|
92
|
+
/** The monetary amount */
|
|
93
|
+
amount: number;
|
|
94
|
+
/** Whether the amount provided is already inclusive of taxes (Default: false) */
|
|
95
|
+
isInclusive?: boolean;
|
|
96
|
+
/** VAT rate percentage (Default: 18%) */
|
|
97
|
+
vatRate?: number;
|
|
98
|
+
/** Whether to calculate Social Security Contribution Levy (SSCL) (Default: false) */
|
|
99
|
+
includeSSCL?: boolean;
|
|
100
|
+
/** SSCL rate percentage (Default: 2.5%) */
|
|
101
|
+
ssclRate?: number;
|
|
102
|
+
}
|
|
103
|
+
interface TaxBreakdown {
|
|
104
|
+
baseAmount: number;
|
|
105
|
+
ssclAmount: number;
|
|
106
|
+
vatAmount: number;
|
|
107
|
+
totalTax: number;
|
|
108
|
+
totalAmount: number;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Validates a Sri Lankan Taxpayer Identification Number (TIN) issued by IRD.
|
|
112
|
+
* Standard format is a 9-digit numeric sequence.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* validateTIN('123456789'); // => { isValid: true, tin: '123456789', formatted: '123-456-789' }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
declare function validateTIN(input: string | number): TinValidationResult;
|
|
120
|
+
/**
|
|
121
|
+
* Validates a Sri Lankan VAT Registration Number.
|
|
122
|
+
* Format is typically 9 digits followed by a 4-digit code (e.g., 123456789-7000) or 9 digits.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* validateVAT('123456789-7000'); // => { isValid: true, baseTin: '123456789', branchCode: '7000' }
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
declare function validateVAT(input: string): VatValidationResult;
|
|
130
|
+
/**
|
|
131
|
+
* Calculate Sri Lanka VAT (18%) and optional SSCL (2.5%) for invoicing.
|
|
132
|
+
* Supports both tax-exclusive and tax-inclusive calculations.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* calculateTax({ amount: 10000, includeSSCL: true });
|
|
137
|
+
* // => { baseAmount: 10000, ssclAmount: 250, vatAmount: 1845, totalAmount: 12095 }
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
declare function calculateTax(options: TaxCalculationOptions): TaxBreakdown;
|
|
141
|
+
|
|
142
|
+
type HolidayCategory = 'public' | 'bank' | 'mercantile';
|
|
143
|
+
interface Holiday {
|
|
144
|
+
date: string;
|
|
145
|
+
name: string;
|
|
146
|
+
categories: HolidayCategory[];
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Standard Sri Lankan Statutory & Public/Bank/Mercantile Holidays.
|
|
150
|
+
* Covers official annual holidays recognized by CBSL and the Ministry of Public Administration.
|
|
151
|
+
*/
|
|
152
|
+
declare const SRI_LANKAN_HOLIDAYS: Holiday[];
|
|
153
|
+
interface WorkingDaysOptions {
|
|
154
|
+
/** Check against Bank holidays (Default: true) */
|
|
155
|
+
bankHolidays?: boolean;
|
|
156
|
+
/** Check against Mercantile holidays (for private sector) (Default: false) */
|
|
157
|
+
mercantileOnly?: boolean;
|
|
158
|
+
/** Treat Saturdays as working days (Default: false) */
|
|
159
|
+
saturdayWorking?: boolean;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Check if a date is a weekend.
|
|
163
|
+
*/
|
|
164
|
+
declare function isWeekend(date: Date, saturdayWorking?: boolean): boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Returns holiday details if the given date is a Sri Lankan statutory holiday.
|
|
167
|
+
*/
|
|
168
|
+
declare function getHoliday(date: Date): Holiday | undefined;
|
|
169
|
+
/**
|
|
170
|
+
* Check if a given date is a Sri Lankan working day.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* isWorkingDay(new Date('2025-04-14')); // => false (New Year Day)
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
declare function isWorkingDay(date: Date, options?: WorkingDaysOptions): boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Calculates the number of working days between two dates (inclusive),
|
|
180
|
+
* excluding weekends and statutory Sri Lankan holidays.
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```ts
|
|
184
|
+
* getWorkingDays(new Date('2025-04-01'), new Date('2025-04-30'));
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
declare function getWorkingDays(startDate: Date, endDate: Date, options?: WorkingDaysOptions): number;
|
|
188
|
+
/**
|
|
189
|
+
* Adds a specific number of working days to a given start date.
|
|
190
|
+
* Useful for calculating invoice payment due dates or credit terms.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```ts
|
|
194
|
+
* // Calculate due date after 10 working days:
|
|
195
|
+
* const dueDate = addWorkingDays(new Date(), 10);
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
declare function addWorkingDays(startDate: Date, daysToAdd: number, options?: WorkingDaysOptions): Date;
|
|
199
|
+
|
|
200
|
+
export { type Bank, type Branch, type FormatLKROptions, type Holiday, type HolidayCategory, SRI_LANKAN_BANKS, SRI_LANKAN_BRANCHES, SRI_LANKAN_HOLIDAYS, type TaxBreakdown, type TaxCalculationOptions, type TinValidationResult, type ToWordsOptions, type VatValidationResult, type WorkingDaysOptions, addWorkingDays, calculateTax, findBank, findBranch, formatLKR, getBanks, getBranches, getHoliday, getWorkingDays, isWeekend, isWorkingDay, lkrToWords, validateTIN, validateVAT };
|