pakdatakit 2.3.0 → 2.5.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/DATA.md +212 -3
- package/LICENSE +1 -1
- package/NOTICE +14 -0
- package/README.md +304 -5
- package/dist/address.cjs +5 -4
- package/dist/address.js +3 -2
- package/dist/bills.cjs +19 -0
- package/dist/bills.d.cts +63 -0
- package/dist/bills.d.ts +63 -0
- package/dist/bills.js +2 -0
- package/dist/{chunk-OKMBYX3F.cjs → chunk-33GOK7EE.cjs} +2 -910
- package/dist/chunk-34U2ZMHR.js +194 -0
- package/dist/chunk-4GSBHJX6.js +165 -0
- package/dist/chunk-5DDHO5Z7.cjs +565 -0
- package/dist/chunk-5EY5DQS7.js +51 -0
- package/dist/chunk-5RGX4DWF.js +559 -0
- package/dist/chunk-5UCRHVI4.cjs +302 -0
- package/dist/{chunk-TQP2T33V.js → chunk-B7DOQ5QF.js} +2 -1
- package/dist/chunk-CF6AMRBU.cjs +198 -0
- package/dist/chunk-CZOZB4K3.js +61 -0
- package/dist/chunk-E2XU6NOW.js +909 -0
- package/dist/chunk-E6GWBOKV.cjs +911 -0
- package/dist/chunk-EA3SIHYT.js +313 -0
- package/dist/{chunk-YTSMFGTW.js → chunk-IDTRFOQW.js} +8 -3
- package/dist/chunk-OTI7HY55.js +297 -0
- package/dist/{chunk-J5ARB4TE.cjs → chunk-QFPEFD67.cjs} +5 -4
- package/dist/chunk-SF4ECUZ6.cjs +56 -0
- package/dist/chunk-UYFTXD4P.js +168 -0
- package/dist/{chunk-TBTWZC74.cjs → chunk-XCFZKCV2.cjs} +8 -3
- package/dist/{chunk-N4S22XX3.js → chunk-XOTCIXY6.js} +2 -909
- package/dist/chunk-XVEG53NN.cjs +322 -0
- package/dist/chunk-YDUXIENX.cjs +172 -0
- package/dist/chunk-YPAWNWFD.cjs +168 -0
- package/dist/chunk-YQFI7W3I.cjs +65 -0
- package/dist/class-validator.cjs +16 -8
- package/dist/class-validator.d.cts +7 -1
- package/dist/class-validator.d.ts +7 -1
- package/dist/class-validator.js +15 -8
- package/dist/cli.js +1 -1
- package/dist/courier.cjs +16 -0
- package/dist/courier.d.cts +51 -0
- package/dist/courier.d.ts +51 -0
- package/dist/courier.js +3 -0
- package/dist/fbr-invoice.cjs +25 -0
- package/dist/fbr-invoice.d.cts +170 -0
- package/dist/fbr-invoice.d.ts +170 -0
- package/dist/fbr-invoice.js +4 -0
- package/dist/geo.cjs +11 -10
- package/dist/geo.js +2 -1
- package/dist/incometax.cjs +27 -0
- package/dist/incometax.d.cts +91 -0
- package/dist/incometax.d.ts +91 -0
- package/dist/incometax.js +2 -0
- package/dist/index.cjs +227 -123
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +21 -13
- package/dist/input.cjs +8 -8
- package/dist/input.js +2 -2
- package/dist/joi.cjs +14 -8
- package/dist/joi.d.cts +1 -0
- package/dist/joi.d.ts +1 -0
- package/dist/joi.js +13 -7
- package/dist/quality.cjs +25 -0
- package/dist/quality.d.cts +62 -0
- package/dist/quality.d.ts +62 -0
- package/dist/quality.js +8 -0
- package/dist/salestax.cjs +20 -0
- package/dist/salestax.d.cts +106 -0
- package/dist/salestax.d.ts +106 -0
- package/dist/salestax.js +3 -0
- package/dist/superstruct.cjs +14 -8
- package/dist/superstruct.d.cts +1 -0
- package/dist/superstruct.d.ts +1 -0
- package/dist/superstruct.js +13 -7
- package/dist/text.cjs +21 -5
- package/dist/text.d.cts +90 -1
- package/dist/text.d.ts +90 -1
- package/dist/text.js +1 -1
- package/dist/valibot.cjs +14 -8
- package/dist/valibot.d.cts +1 -0
- package/dist/valibot.d.ts +1 -0
- package/dist/valibot.js +13 -7
- package/dist/yup.cjs +14 -8
- package/dist/yup.d.cts +1 -0
- package/dist/yup.d.ts +1 -0
- package/dist/yup.js +13 -7
- package/dist/zod.cjs +14 -8
- package/dist/zod.d.cts +1 -0
- package/dist/zod.d.ts +1 -0
- package/dist/zod.js +13 -7
- package/package.json +68 -5
- package/dist/chunk-JKE4AMSZ.js +0 -47
- package/dist/chunk-KEHCTYLO.cjs +0 -52
- package/dist/{chunk-A3HBEBXY.js → chunk-7DY26QPN.js} +1 -1
- package/dist/{chunk-FRBPAGEJ.cjs → chunk-TVL6RDAU.cjs} +1 -1
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/** Version of PRAL's technical specification this module follows. */
|
|
2
|
+
declare const FBR_DI_SPEC_VERSION = "1.12";
|
|
3
|
+
/** `invoiceType` values in the specification. */
|
|
4
|
+
type FbrInvoiceType = 'Sale Invoice' | 'Debit Note';
|
|
5
|
+
/** `buyerRegistrationType` values in the specification. */
|
|
6
|
+
type FbrRegistrationType = 'Registered' | 'Unregistered';
|
|
7
|
+
/** One line of an invoice (spec §4.1, `items`). Amounts are in rupees. */
|
|
8
|
+
interface FbrInvoiceItem {
|
|
9
|
+
/** HS code, e.g. `0101.2100`. */
|
|
10
|
+
hsCode: string;
|
|
11
|
+
productDescription: string;
|
|
12
|
+
/** Rate as FBR's SaleTypeToRate API describes it: `18%`, `Rs.3`, `Exempt` … */
|
|
13
|
+
rate: string;
|
|
14
|
+
/** Unit of measure as in FBR's UoM API, e.g. `Numbers, pieces, units`. */
|
|
15
|
+
uoM: string;
|
|
16
|
+
/** Up to 4 decimals. */
|
|
17
|
+
quantity: number;
|
|
18
|
+
/** "Total Sales Value (Including Tax)". FBR's own samples send 0. */
|
|
19
|
+
totalValues: number;
|
|
20
|
+
valueSalesExcludingST: number;
|
|
21
|
+
/** Notified or retail price; required for Third Schedule goods. */
|
|
22
|
+
fixedNotifiedValueOrRetailPrice: number;
|
|
23
|
+
salesTaxApplicable: number;
|
|
24
|
+
salesTaxWithheldAtSource: number;
|
|
25
|
+
extraTax?: number;
|
|
26
|
+
furtherTax?: number;
|
|
27
|
+
/** Required when the rate is not 18% (error 0077). */
|
|
28
|
+
sroScheduleNo?: string;
|
|
29
|
+
fedPayable?: number;
|
|
30
|
+
discount?: number;
|
|
31
|
+
/** Sale type as in FBR's transaction type API, e.g. `Goods at standard rate (default)`. */
|
|
32
|
+
saleType: string;
|
|
33
|
+
/** Required when `sroScheduleNo` is given (error 0078). */
|
|
34
|
+
sroItemSerialNo?: string;
|
|
35
|
+
}
|
|
36
|
+
/** The invoice body for `postinvoicedata` and `validateinvoicedata` (spec §4.1, §4.2). */
|
|
37
|
+
interface FbrInvoice {
|
|
38
|
+
invoiceType: FbrInvoiceType;
|
|
39
|
+
/** `YYYY-MM-DD`. */
|
|
40
|
+
invoiceDate: string;
|
|
41
|
+
/** 7-digit NTN or 13-digit CNIC. */
|
|
42
|
+
sellerNTNCNIC: string;
|
|
43
|
+
sellerBusinessName: string;
|
|
44
|
+
sellerProvince: string;
|
|
45
|
+
sellerAddress: string;
|
|
46
|
+
/** 7-digit NTN or 13-digit CNIC; may be empty for an unregistered buyer. */
|
|
47
|
+
buyerNTNCNIC: string;
|
|
48
|
+
buyerBusinessName: string;
|
|
49
|
+
buyerProvince: string;
|
|
50
|
+
buyerAddress: string;
|
|
51
|
+
buyerRegistrationType: FbrRegistrationType;
|
|
52
|
+
/** FBR invoice number of the original invoice; required for a debit note. */
|
|
53
|
+
invoiceRefNo: string;
|
|
54
|
+
/** Sandbox only: `SN001` to `SN028`. */
|
|
55
|
+
scenarioId?: string;
|
|
56
|
+
items: FbrInvoiceItem[];
|
|
57
|
+
}
|
|
58
|
+
/** An item for {@link buildFbrInvoice}: the tax may be left out. */
|
|
59
|
+
type FbrInvoiceItemInput = Omit<FbrInvoiceItem, 'salesTaxApplicable' | 'salesTaxWithheldAtSource' | 'totalValues' | 'fixedNotifiedValueOrRetailPrice'> & {
|
|
60
|
+
salesTaxApplicable?: number;
|
|
61
|
+
salesTaxWithheldAtSource?: number;
|
|
62
|
+
totalValues?: number;
|
|
63
|
+
fixedNotifiedValueOrRetailPrice?: number;
|
|
64
|
+
};
|
|
65
|
+
/** Input for {@link buildFbrInvoice}. */
|
|
66
|
+
type FbrInvoiceInput = Omit<FbrInvoice, 'items' | 'invoiceRefNo' | 'buyerNTNCNIC'> & {
|
|
67
|
+
invoiceRefNo?: string;
|
|
68
|
+
buyerNTNCNIC?: string;
|
|
69
|
+
items: FbrInvoiceItemInput[];
|
|
70
|
+
};
|
|
71
|
+
/** Column totals of an invoice, in rupees. Not sent to FBR. */
|
|
72
|
+
interface FbrInvoiceTotals {
|
|
73
|
+
quantity: number;
|
|
74
|
+
valueSalesExcludingST: number;
|
|
75
|
+
salesTaxApplicable: number;
|
|
76
|
+
salesTaxWithheldAtSource: number;
|
|
77
|
+
extraTax: number;
|
|
78
|
+
furtherTax: number;
|
|
79
|
+
fedPayable: number;
|
|
80
|
+
discount: number;
|
|
81
|
+
}
|
|
82
|
+
/** Result of {@link buildFbrInvoice}. */
|
|
83
|
+
interface FbrInvoiceBuild {
|
|
84
|
+
invoice: FbrInvoice;
|
|
85
|
+
totals: FbrInvoiceTotals;
|
|
86
|
+
}
|
|
87
|
+
/** One problem found by {@link validateFbrInvoice}. */
|
|
88
|
+
interface FbrInvoiceError {
|
|
89
|
+
/**
|
|
90
|
+
* FBR's error code (spec §7 and the Error Message Guide), or `null` for a
|
|
91
|
+
* required field the specification gives no code for.
|
|
92
|
+
*/
|
|
93
|
+
code: string | null;
|
|
94
|
+
/** Where: `invoiceDate`, `items[0].rate` … */
|
|
95
|
+
field: string;
|
|
96
|
+
message: string;
|
|
97
|
+
}
|
|
98
|
+
/** Result of {@link validateFbrInvoice}. */
|
|
99
|
+
interface FbrInvoiceValidation {
|
|
100
|
+
valid: boolean;
|
|
101
|
+
errors: FbrInvoiceError[];
|
|
102
|
+
}
|
|
103
|
+
/** Options for {@link validateFbrInvoice}. */
|
|
104
|
+
interface FbrInvoiceValidationOptions {
|
|
105
|
+
/** Today as `YYYY-MM-DD`, to reject invoices dated later (error 0043). Not checked when left out. */
|
|
106
|
+
today?: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The sales tax FBR expects on a line, in rupees, or `null` when the rate is
|
|
110
|
+
* not a plain percentage or per-unit amount (spec §7, errors 0102, 0104,
|
|
111
|
+
* 0105):
|
|
112
|
+
*
|
|
113
|
+
* - `N%` on Third Schedule goods: retail price × rate (0102);
|
|
114
|
+
* - `N%` otherwise: value excluding sales tax × rate (0104);
|
|
115
|
+
* - `Rs.N`: quantity × N (0105).
|
|
116
|
+
*
|
|
117
|
+
* Rounded half up to the paisa (the specification allows 2 decimals and
|
|
118
|
+
* gives no rounding rule).
|
|
119
|
+
*/
|
|
120
|
+
declare function expectedSalesTax(item: {
|
|
121
|
+
rate: string;
|
|
122
|
+
saleType?: string;
|
|
123
|
+
quantity?: number;
|
|
124
|
+
valueSalesExcludingST?: number;
|
|
125
|
+
fixedNotifiedValueOrRetailPrice?: number;
|
|
126
|
+
}): number | null;
|
|
127
|
+
/**
|
|
128
|
+
* Builds an FBR digital invoice from your own fields, working out
|
|
129
|
+
* `salesTaxApplicable` on each line where you leave it out (see
|
|
130
|
+
* {@link expectedSalesTax}; uses `calculateSalesTax`). Lines with a rate
|
|
131
|
+
* that is neither `N%` nor `Rs.N` (`Exempt`, combined rates) get 0 unless you
|
|
132
|
+
* give the tax.
|
|
133
|
+
*
|
|
134
|
+
* `salesTaxWithheldAtSource`, `totalValues` and
|
|
135
|
+
* `fixedNotifiedValueOrRetailPrice` default to 0, and `invoiceRefNo` and
|
|
136
|
+
* `buyerNTNCNIC` to `""`, as in FBR's samples. Nothing else is filled in or
|
|
137
|
+
* changed; check the result with {@link validateFbrInvoice}.
|
|
138
|
+
*
|
|
139
|
+
* Also returns column totals, which are for your own records: the
|
|
140
|
+
* specification has no invoice-level totals.
|
|
141
|
+
*
|
|
142
|
+
* @returns The invoice and totals, or `null` if `input` is not an object
|
|
143
|
+
* with an `items` array. Never throws.
|
|
144
|
+
*/
|
|
145
|
+
declare function buildFbrInvoice(input: FbrInvoiceInput): FbrInvoiceBuild | null;
|
|
146
|
+
/**
|
|
147
|
+
* Checks an FBR digital invoice against the rules of PRAL's specification
|
|
148
|
+
* (v1.12) and Error Message Guide that need no call to FBR, and returns every
|
|
149
|
+
* problem with FBR's error code.
|
|
150
|
+
*
|
|
151
|
+
* Checked: invoice type (0003, 0011), date format (0005, 0042, 0113) and,
|
|
152
|
+
* with `options.today`, a future date (0043); seller and buyer NTN/CNIC
|
|
153
|
+
* (0401, 0402, 0009), self-invoicing (0058), names, provinces (0073, 0074),
|
|
154
|
+
* addresses, buyer registration type (0012), the reference number of a debit
|
|
155
|
+
* note (0026), the sandbox scenario, and on each line: HS code (0044), rate
|
|
156
|
+
* (0020), unit, sale type (0013), required and valid amounts (0021, 0023,
|
|
157
|
+
* 0024, 0098, 0300, 0302), SRO schedule and serial (0077, 0078), Third
|
|
158
|
+
* Schedule retail price (0090), extra tax on reduced-rate goods (0091) and
|
|
159
|
+
* the sales tax arithmetic (0102, 0104, 0105, to within one paisa).
|
|
160
|
+
*
|
|
161
|
+
* Not checked, because they need FBR's data: registration status, whether a
|
|
162
|
+
* province, HS code, unit, rate, sale type or SRO is in FBR's lists or fits
|
|
163
|
+
* the others, and the original invoice of a debit note.
|
|
164
|
+
*
|
|
165
|
+
* @returns `{ valid, errors }`. Never throws.
|
|
166
|
+
*/
|
|
167
|
+
declare function validateFbrInvoice(invoice: FbrInvoice, options?: FbrInvoiceValidationOptions): FbrInvoiceValidation;
|
|
168
|
+
|
|
169
|
+
export { FBR_DI_SPEC_VERSION, buildFbrInvoice, expectedSalesTax, validateFbrInvoice };
|
|
170
|
+
export type { FbrInvoice, FbrInvoiceBuild, FbrInvoiceError, FbrInvoiceInput, FbrInvoiceItem, FbrInvoiceItemInput, FbrInvoiceTotals, FbrInvoiceType, FbrInvoiceValidation, FbrInvoiceValidationOptions, FbrRegistrationType };
|
package/dist/geo.cjs
CHANGED
|
@@ -1,43 +1,44 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk33GOK7EE_cjs = require('./chunk-33GOK7EE.cjs');
|
|
4
|
+
require('./chunk-E6GWBOKV.cjs');
|
|
4
5
|
require('./chunk-VPBMIYO2.cjs');
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
Object.defineProperty(exports, "getDistrictProvince", {
|
|
9
10
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunk33GOK7EE_cjs.getDistrictProvince; }
|
|
11
12
|
});
|
|
12
13
|
Object.defineProperty(exports, "getDistrictsByProvince", {
|
|
13
14
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunk33GOK7EE_cjs.getDistrictsByProvince; }
|
|
15
16
|
});
|
|
16
17
|
Object.defineProperty(exports, "getDivisionOfDistrict", {
|
|
17
18
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunk33GOK7EE_cjs.getDivisionOfDistrict; }
|
|
19
20
|
});
|
|
20
21
|
Object.defineProperty(exports, "getDivisions", {
|
|
21
22
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunk33GOK7EE_cjs.getDivisions; }
|
|
23
24
|
});
|
|
24
25
|
Object.defineProperty(exports, "getProvince", {
|
|
25
26
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
27
|
+
get: function () { return chunk33GOK7EE_cjs.getProvince; }
|
|
27
28
|
});
|
|
28
29
|
Object.defineProperty(exports, "getTehsilDistrict", {
|
|
29
30
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
31
|
+
get: function () { return chunk33GOK7EE_cjs.getTehsilDistrict; }
|
|
31
32
|
});
|
|
32
33
|
Object.defineProperty(exports, "getTehsils", {
|
|
33
34
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
35
|
+
get: function () { return chunk33GOK7EE_cjs.getTehsils; }
|
|
35
36
|
});
|
|
36
37
|
Object.defineProperty(exports, "searchCities", {
|
|
37
38
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
39
|
+
get: function () { return chunk33GOK7EE_cjs.searchCities; }
|
|
39
40
|
});
|
|
40
41
|
Object.defineProperty(exports, "searchDistricts", {
|
|
41
42
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
43
|
+
get: function () { return chunk33GOK7EE_cjs.searchDistricts; }
|
|
43
44
|
});
|
package/dist/geo.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { getDistrictProvince, getDistrictsByProvince, getDivisionOfDistrict, getDivisions, getProvince, getTehsilDistrict, getTehsils, searchCities, searchDistricts } from './chunk-
|
|
1
|
+
export { getDistrictProvince, getDistrictsByProvince, getDivisionOfDistrict, getDivisions, getProvince, getTehsilDistrict, getTehsils, searchCities, searchDistricts } from './chunk-XOTCIXY6.js';
|
|
2
|
+
import './chunk-E2XU6NOW.js';
|
|
2
3
|
import './chunk-ENQ7O7VW.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk5DDHO5Z7_cjs = require('./chunk-5DDHO5Z7.cjs');
|
|
4
|
+
require('./chunk-SF4ECUZ6.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "calculateMonthlySalaryTax", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunk5DDHO5Z7_cjs.calculateMonthlySalaryTax; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "calculateSalaryTax", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunk5DDHO5Z7_cjs.calculateSalaryTax; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "getSalaryTaxSlabs", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunk5DDHO5Z7_cjs.getSalaryTaxSlabs; }
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "getSalaryTaxYears", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return chunk5DDHO5Z7_cjs.getSalaryTaxYears; }
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "getTaxYear", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return chunk5DDHO5Z7_cjs.getTaxYear; }
|
|
27
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One band of the salaried rate table: income above `over` (and up to
|
|
3
|
+
* `upTo`) pays `fixed` plus `rate` percent of the amount above `over`.
|
|
4
|
+
*/
|
|
5
|
+
interface SalaryTaxSlab {
|
|
6
|
+
/** Lower bound in rupees (income must exceed it). */
|
|
7
|
+
over: number;
|
|
8
|
+
/** Upper bound in rupees, or `null` for the top band. */
|
|
9
|
+
upTo: number | null;
|
|
10
|
+
/** Tax on the income up to `over`, in rupees. */
|
|
11
|
+
fixed: number;
|
|
12
|
+
/** Percent of the income above `over`. */
|
|
13
|
+
rate: number;
|
|
14
|
+
}
|
|
15
|
+
/** The salaried rate table for one tax year (1 July to 30 June). */
|
|
16
|
+
interface SalaryTaxYear {
|
|
17
|
+
/** The tax year, named after the June it ends in: 2026 is 1 July 2025 to 30 June 2026. */
|
|
18
|
+
taxYear: number;
|
|
19
|
+
/** `YYYY-MM-DD`, always 1 July. */
|
|
20
|
+
from: string;
|
|
21
|
+
/** `YYYY-MM-DD`, always 30 June. */
|
|
22
|
+
to: string;
|
|
23
|
+
/** The law that sets the table. */
|
|
24
|
+
law: string;
|
|
25
|
+
/** Official document. */
|
|
26
|
+
source: string;
|
|
27
|
+
slabs: SalaryTaxSlab[];
|
|
28
|
+
}
|
|
29
|
+
/** Options for {@link calculateSalaryTax} and {@link calculateMonthlySalaryTax}. */
|
|
30
|
+
interface SalaryTaxOptions {
|
|
31
|
+
/** Tax year, e.g. `2026`. Takes precedence over `date`. */
|
|
32
|
+
taxYear?: number;
|
|
33
|
+
/** A day in the tax year (`YYYY-MM-DD` or a `Date`). Defaults to today. */
|
|
34
|
+
date?: string | Date;
|
|
35
|
+
}
|
|
36
|
+
/** Result of {@link calculateSalaryTax}. */
|
|
37
|
+
interface SalaryTax {
|
|
38
|
+
/** Tax for the year, in rupees, rounded half up to the paisa. */
|
|
39
|
+
tax: number;
|
|
40
|
+
/** `tax / 12`, rounded half up to the paisa. */
|
|
41
|
+
monthly: number;
|
|
42
|
+
/** `tax` as a percent of the income, rounded half up to 2 decimals. */
|
|
43
|
+
effectiveRate: number;
|
|
44
|
+
/** The band the income falls in. */
|
|
45
|
+
slab: SalaryTaxSlab;
|
|
46
|
+
taxYear: number;
|
|
47
|
+
}
|
|
48
|
+
/** The tax year (July to June) that contains a date, or `null` for an invalid date. */
|
|
49
|
+
declare function getTaxYear(date?: string | Date): number | null;
|
|
50
|
+
/**
|
|
51
|
+
* Returns the salaried rate table for a tax year: Division I of Part I of
|
|
52
|
+
* the First Schedule to the Income Tax Ordinance 2001, clause (2), which
|
|
53
|
+
* applies when salary is more than 75% of taxable income.
|
|
54
|
+
*
|
|
55
|
+
* Covers tax years 2020 to 2027, each from FBR's consolidated Ordinance.
|
|
56
|
+
*
|
|
57
|
+
* @param taxYear - e.g. `2026` (1 July 2025 to 30 June 2026). Defaults to
|
|
58
|
+
* the current tax year.
|
|
59
|
+
* @returns The table, or `null` for a year that is not covered. Never throws.
|
|
60
|
+
*/
|
|
61
|
+
declare function getSalaryTaxSlabs(taxYear?: number): SalaryTaxYear | null;
|
|
62
|
+
/** Which tax years {@link getSalaryTaxSlabs} covers, oldest first. */
|
|
63
|
+
declare function getSalaryTaxYears(): number[];
|
|
64
|
+
/**
|
|
65
|
+
* Income tax on a salaried individual's taxable income for a tax year, from
|
|
66
|
+
* the salaried rate table (see {@link getSalaryTaxSlabs}).
|
|
67
|
+
*
|
|
68
|
+
* The rate table only: the surcharge, tax credits, exemptions, the separate
|
|
69
|
+
* pension rate and withholding adjustments are not applied.
|
|
70
|
+
*
|
|
71
|
+
* @param annualIncome - Taxable income for the year in rupees, 0 to 1
|
|
72
|
+
* trillion (at most 2 decimals count)
|
|
73
|
+
* @returns The tax, or `null` for an invalid amount or a tax year that is
|
|
74
|
+
* not covered. Never throws.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* calculateSalaryTax(1_800_000, { taxYear: 2026 });
|
|
78
|
+
* // { tax: 72000, monthly: 6000, effectiveRate: 4, slab: { over: 1200000, … }, taxYear: 2026 }
|
|
79
|
+
*/
|
|
80
|
+
declare function calculateSalaryTax(annualIncome: number, options?: SalaryTaxOptions): SalaryTax | null;
|
|
81
|
+
/**
|
|
82
|
+
* {@link calculateSalaryTax} for a monthly salary: the income is
|
|
83
|
+
* `monthlySalary × 12`, and `monthly` is the tax to withhold each month.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* calculateMonthlySalaryTax(150_000, { taxYear: 2026 })?.monthly; // 6000
|
|
87
|
+
*/
|
|
88
|
+
declare function calculateMonthlySalaryTax(monthlySalary: number, options?: SalaryTaxOptions): SalaryTax | null;
|
|
89
|
+
|
|
90
|
+
export { calculateMonthlySalaryTax, calculateSalaryTax, getSalaryTaxSlabs, getSalaryTaxYears, getTaxYear };
|
|
91
|
+
export type { SalaryTax, SalaryTaxOptions, SalaryTaxSlab, SalaryTaxYear };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One band of the salaried rate table: income above `over` (and up to
|
|
3
|
+
* `upTo`) pays `fixed` plus `rate` percent of the amount above `over`.
|
|
4
|
+
*/
|
|
5
|
+
interface SalaryTaxSlab {
|
|
6
|
+
/** Lower bound in rupees (income must exceed it). */
|
|
7
|
+
over: number;
|
|
8
|
+
/** Upper bound in rupees, or `null` for the top band. */
|
|
9
|
+
upTo: number | null;
|
|
10
|
+
/** Tax on the income up to `over`, in rupees. */
|
|
11
|
+
fixed: number;
|
|
12
|
+
/** Percent of the income above `over`. */
|
|
13
|
+
rate: number;
|
|
14
|
+
}
|
|
15
|
+
/** The salaried rate table for one tax year (1 July to 30 June). */
|
|
16
|
+
interface SalaryTaxYear {
|
|
17
|
+
/** The tax year, named after the June it ends in: 2026 is 1 July 2025 to 30 June 2026. */
|
|
18
|
+
taxYear: number;
|
|
19
|
+
/** `YYYY-MM-DD`, always 1 July. */
|
|
20
|
+
from: string;
|
|
21
|
+
/** `YYYY-MM-DD`, always 30 June. */
|
|
22
|
+
to: string;
|
|
23
|
+
/** The law that sets the table. */
|
|
24
|
+
law: string;
|
|
25
|
+
/** Official document. */
|
|
26
|
+
source: string;
|
|
27
|
+
slabs: SalaryTaxSlab[];
|
|
28
|
+
}
|
|
29
|
+
/** Options for {@link calculateSalaryTax} and {@link calculateMonthlySalaryTax}. */
|
|
30
|
+
interface SalaryTaxOptions {
|
|
31
|
+
/** Tax year, e.g. `2026`. Takes precedence over `date`. */
|
|
32
|
+
taxYear?: number;
|
|
33
|
+
/** A day in the tax year (`YYYY-MM-DD` or a `Date`). Defaults to today. */
|
|
34
|
+
date?: string | Date;
|
|
35
|
+
}
|
|
36
|
+
/** Result of {@link calculateSalaryTax}. */
|
|
37
|
+
interface SalaryTax {
|
|
38
|
+
/** Tax for the year, in rupees, rounded half up to the paisa. */
|
|
39
|
+
tax: number;
|
|
40
|
+
/** `tax / 12`, rounded half up to the paisa. */
|
|
41
|
+
monthly: number;
|
|
42
|
+
/** `tax` as a percent of the income, rounded half up to 2 decimals. */
|
|
43
|
+
effectiveRate: number;
|
|
44
|
+
/** The band the income falls in. */
|
|
45
|
+
slab: SalaryTaxSlab;
|
|
46
|
+
taxYear: number;
|
|
47
|
+
}
|
|
48
|
+
/** The tax year (July to June) that contains a date, or `null` for an invalid date. */
|
|
49
|
+
declare function getTaxYear(date?: string | Date): number | null;
|
|
50
|
+
/**
|
|
51
|
+
* Returns the salaried rate table for a tax year: Division I of Part I of
|
|
52
|
+
* the First Schedule to the Income Tax Ordinance 2001, clause (2), which
|
|
53
|
+
* applies when salary is more than 75% of taxable income.
|
|
54
|
+
*
|
|
55
|
+
* Covers tax years 2020 to 2027, each from FBR's consolidated Ordinance.
|
|
56
|
+
*
|
|
57
|
+
* @param taxYear - e.g. `2026` (1 July 2025 to 30 June 2026). Defaults to
|
|
58
|
+
* the current tax year.
|
|
59
|
+
* @returns The table, or `null` for a year that is not covered. Never throws.
|
|
60
|
+
*/
|
|
61
|
+
declare function getSalaryTaxSlabs(taxYear?: number): SalaryTaxYear | null;
|
|
62
|
+
/** Which tax years {@link getSalaryTaxSlabs} covers, oldest first. */
|
|
63
|
+
declare function getSalaryTaxYears(): number[];
|
|
64
|
+
/**
|
|
65
|
+
* Income tax on a salaried individual's taxable income for a tax year, from
|
|
66
|
+
* the salaried rate table (see {@link getSalaryTaxSlabs}).
|
|
67
|
+
*
|
|
68
|
+
* The rate table only: the surcharge, tax credits, exemptions, the separate
|
|
69
|
+
* pension rate and withholding adjustments are not applied.
|
|
70
|
+
*
|
|
71
|
+
* @param annualIncome - Taxable income for the year in rupees, 0 to 1
|
|
72
|
+
* trillion (at most 2 decimals count)
|
|
73
|
+
* @returns The tax, or `null` for an invalid amount or a tax year that is
|
|
74
|
+
* not covered. Never throws.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* calculateSalaryTax(1_800_000, { taxYear: 2026 });
|
|
78
|
+
* // { tax: 72000, monthly: 6000, effectiveRate: 4, slab: { over: 1200000, … }, taxYear: 2026 }
|
|
79
|
+
*/
|
|
80
|
+
declare function calculateSalaryTax(annualIncome: number, options?: SalaryTaxOptions): SalaryTax | null;
|
|
81
|
+
/**
|
|
82
|
+
* {@link calculateSalaryTax} for a monthly salary: the income is
|
|
83
|
+
* `monthlySalary × 12`, and `monthly` is the tax to withhold each month.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* calculateMonthlySalaryTax(150_000, { taxYear: 2026 })?.monthly; // 6000
|
|
87
|
+
*/
|
|
88
|
+
declare function calculateMonthlySalaryTax(monthlySalary: number, options?: SalaryTaxOptions): SalaryTax | null;
|
|
89
|
+
|
|
90
|
+
export { calculateMonthlySalaryTax, calculateSalaryTax, getSalaryTaxSlabs, getSalaryTaxYears, getTaxYear };
|
|
91
|
+
export type { SalaryTax, SalaryTaxOptions, SalaryTaxSlab, SalaryTaxYear };
|