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.
Files changed (96) hide show
  1. package/DATA.md +212 -3
  2. package/LICENSE +1 -1
  3. package/NOTICE +14 -0
  4. package/README.md +304 -5
  5. package/dist/address.cjs +5 -4
  6. package/dist/address.js +3 -2
  7. package/dist/bills.cjs +19 -0
  8. package/dist/bills.d.cts +63 -0
  9. package/dist/bills.d.ts +63 -0
  10. package/dist/bills.js +2 -0
  11. package/dist/{chunk-OKMBYX3F.cjs → chunk-33GOK7EE.cjs} +2 -910
  12. package/dist/chunk-34U2ZMHR.js +194 -0
  13. package/dist/chunk-4GSBHJX6.js +165 -0
  14. package/dist/chunk-5DDHO5Z7.cjs +565 -0
  15. package/dist/chunk-5EY5DQS7.js +51 -0
  16. package/dist/chunk-5RGX4DWF.js +559 -0
  17. package/dist/chunk-5UCRHVI4.cjs +302 -0
  18. package/dist/{chunk-TQP2T33V.js → chunk-B7DOQ5QF.js} +2 -1
  19. package/dist/chunk-CF6AMRBU.cjs +198 -0
  20. package/dist/chunk-CZOZB4K3.js +61 -0
  21. package/dist/chunk-E2XU6NOW.js +909 -0
  22. package/dist/chunk-E6GWBOKV.cjs +911 -0
  23. package/dist/chunk-EA3SIHYT.js +313 -0
  24. package/dist/{chunk-YTSMFGTW.js → chunk-IDTRFOQW.js} +8 -3
  25. package/dist/chunk-OTI7HY55.js +297 -0
  26. package/dist/{chunk-J5ARB4TE.cjs → chunk-QFPEFD67.cjs} +5 -4
  27. package/dist/chunk-SF4ECUZ6.cjs +56 -0
  28. package/dist/chunk-UYFTXD4P.js +168 -0
  29. package/dist/{chunk-TBTWZC74.cjs → chunk-XCFZKCV2.cjs} +8 -3
  30. package/dist/{chunk-N4S22XX3.js → chunk-XOTCIXY6.js} +2 -909
  31. package/dist/chunk-XVEG53NN.cjs +322 -0
  32. package/dist/chunk-YDUXIENX.cjs +172 -0
  33. package/dist/chunk-YPAWNWFD.cjs +168 -0
  34. package/dist/chunk-YQFI7W3I.cjs +65 -0
  35. package/dist/class-validator.cjs +16 -8
  36. package/dist/class-validator.d.cts +7 -1
  37. package/dist/class-validator.d.ts +7 -1
  38. package/dist/class-validator.js +15 -8
  39. package/dist/cli.js +1 -1
  40. package/dist/courier.cjs +16 -0
  41. package/dist/courier.d.cts +51 -0
  42. package/dist/courier.d.ts +51 -0
  43. package/dist/courier.js +3 -0
  44. package/dist/fbr-invoice.cjs +25 -0
  45. package/dist/fbr-invoice.d.cts +170 -0
  46. package/dist/fbr-invoice.d.ts +170 -0
  47. package/dist/fbr-invoice.js +4 -0
  48. package/dist/geo.cjs +11 -10
  49. package/dist/geo.js +2 -1
  50. package/dist/incometax.cjs +27 -0
  51. package/dist/incometax.d.cts +91 -0
  52. package/dist/incometax.d.ts +91 -0
  53. package/dist/incometax.js +2 -0
  54. package/dist/index.cjs +227 -123
  55. package/dist/index.d.cts +8 -2
  56. package/dist/index.d.ts +8 -2
  57. package/dist/index.js +21 -13
  58. package/dist/input.cjs +8 -8
  59. package/dist/input.js +2 -2
  60. package/dist/joi.cjs +14 -8
  61. package/dist/joi.d.cts +1 -0
  62. package/dist/joi.d.ts +1 -0
  63. package/dist/joi.js +13 -7
  64. package/dist/quality.cjs +25 -0
  65. package/dist/quality.d.cts +62 -0
  66. package/dist/quality.d.ts +62 -0
  67. package/dist/quality.js +8 -0
  68. package/dist/salestax.cjs +20 -0
  69. package/dist/salestax.d.cts +106 -0
  70. package/dist/salestax.d.ts +106 -0
  71. package/dist/salestax.js +3 -0
  72. package/dist/superstruct.cjs +14 -8
  73. package/dist/superstruct.d.cts +1 -0
  74. package/dist/superstruct.d.ts +1 -0
  75. package/dist/superstruct.js +13 -7
  76. package/dist/text.cjs +21 -5
  77. package/dist/text.d.cts +90 -1
  78. package/dist/text.d.ts +90 -1
  79. package/dist/text.js +1 -1
  80. package/dist/valibot.cjs +14 -8
  81. package/dist/valibot.d.cts +1 -0
  82. package/dist/valibot.d.ts +1 -0
  83. package/dist/valibot.js +13 -7
  84. package/dist/yup.cjs +14 -8
  85. package/dist/yup.d.cts +1 -0
  86. package/dist/yup.d.ts +1 -0
  87. package/dist/yup.js +13 -7
  88. package/dist/zod.cjs +14 -8
  89. package/dist/zod.d.cts +1 -0
  90. package/dist/zod.d.ts +1 -0
  91. package/dist/zod.js +13 -7
  92. package/package.json +68 -5
  93. package/dist/chunk-JKE4AMSZ.js +0 -47
  94. package/dist/chunk-KEHCTYLO.cjs +0 -52
  95. package/dist/{chunk-A3HBEBXY.js → chunk-7DY26QPN.js} +1 -1
  96. package/dist/{chunk-FRBPAGEJ.cjs → chunk-TVL6RDAU.cjs} +1 -1
@@ -0,0 +1,194 @@
1
+ import { isoDate, toUnits, divideHalfUp, fromPaisa } from './chunk-5EY5DQS7.js';
2
+ import { normalizeKey } from './chunk-ENQ7O7VW.js';
3
+
4
+ // data/sales-tax-rates.json
5
+ var sales_tax_rates_default = [
6
+ {
7
+ kind: "goods",
8
+ authority: "FBR",
9
+ province: null,
10
+ rate: 17,
11
+ from: "2019-07-01",
12
+ to: "2023-02-22",
13
+ law: "Sales Tax Act 1990, s. 3(1)",
14
+ source: "https://download1.fbr.gov.pk/Docs/20232231921422957Finance(Supplementary)Act,2023.pdf"
15
+ },
16
+ {
17
+ kind: "goods",
18
+ authority: "FBR",
19
+ province: null,
20
+ rate: 18,
21
+ from: "2023-02-23",
22
+ to: null,
23
+ law: "Sales Tax Act 1990, s. 3(1), as amended by the Finance (Supplementary) Act 2023",
24
+ source: "https://download1.fbr.gov.pk/Docs/20267171373418951SalesTaxAct1990updatedupto30.06.2026.pdf"
25
+ },
26
+ {
27
+ kind: "services",
28
+ authority: "PRA",
29
+ province: "Punjab",
30
+ rate: 16,
31
+ from: "2019-07-01",
32
+ to: null,
33
+ law: "Punjab Sales Tax on Services Act 2012, s. 2(41A) and Second Schedule",
34
+ source: "https://pra.punjab.gov.pk/Downloads/THE-PUNJAB-SALES-TAX-ON-SERVICES-ACT-2012-17th-Edition-2026-2027.pdf"
35
+ },
36
+ {
37
+ kind: "services",
38
+ authority: "SRB",
39
+ province: "Sindh",
40
+ rate: 13,
41
+ from: "2019-07-01",
42
+ to: "2024-06-30",
43
+ law: "Sindh Sales Tax on Services Act 2011, Second Schedule",
44
+ source: "https://www.pas.gov.pk/uploads/acts/Sindh%20Act%20No.II%20of%202024.pdf"
45
+ },
46
+ {
47
+ kind: "services",
48
+ authority: "SRB",
49
+ province: "Sindh",
50
+ rate: 15,
51
+ from: "2024-07-01",
52
+ to: null,
53
+ law: "Sindh Sales Tax on Services Act 2011, s. 8(1), as amended by the Sindh Finance Acts 2024 and 2025",
54
+ source: "https://www.srb.gos.pk/srb/wp-content/uploads/2026/01/Sindh-Sales-Tax-Act-2011-25-26-2.pdf"
55
+ },
56
+ {
57
+ kind: "services",
58
+ authority: "KPRA",
59
+ province: "Khyber Pakhtunkhwa",
60
+ rate: 15,
61
+ from: "2019-07-01",
62
+ to: null,
63
+ law: "Khyber Pakhtunkhwa Finance Act 2019, Second Schedule; Khyber Pakhtunkhwa Sales Tax on Services Act 2022, s. 9(1)",
64
+ source: "https://kpra.gov.pk/wp-content/uploads/2026/09/KPSTSA-2022-Updated-Finance-act-2026.pdf"
65
+ },
66
+ {
67
+ kind: "services",
68
+ authority: "BRA",
69
+ province: "Balochistan",
70
+ rate: 15,
71
+ from: "2019-07-01",
72
+ to: null,
73
+ law: "Balochistan Sales Tax on Services Act 2015, s. 10(1) and Second Schedule",
74
+ source: "https://bra.gob.pk/NewsDirectory/2015_BSTS_Act_Ver01.pdf"
75
+ },
76
+ {
77
+ kind: "services",
78
+ authority: "FBR",
79
+ province: "Islamabad Capital Territory",
80
+ rate: 16,
81
+ from: "2019-07-01",
82
+ to: "2022-06-30",
83
+ law: "Islamabad Capital Territory (Tax on Services) Ordinance 2001, Schedule, Table 1",
84
+ source: "https://fbr.gov.pk/Budget2022-23/FinanceAct/Finance-Act-2022.pdf"
85
+ },
86
+ {
87
+ kind: "services",
88
+ authority: "FBR",
89
+ province: "Islamabad Capital Territory",
90
+ rate: 15,
91
+ from: "2022-07-01",
92
+ to: null,
93
+ law: "Islamabad Capital Territory (Tax on Services) Ordinance 2001, Schedule, Table 1, as amended by the Finance Act 2022",
94
+ source: "https://download1.fbr.gov.pk/Docs/2025711172945966ICTOUpdatedupto30.06.2025.pdf"
95
+ }
96
+ ];
97
+
98
+ // src/salestax.ts
99
+ var RATES = sales_tax_rates_default;
100
+ var PROVINCES = {
101
+ punjab: "Punjab",
102
+ sindh: "Sindh",
103
+ "khyber pakhtunkhwa": "Khyber Pakhtunkhwa",
104
+ kp: "Khyber Pakhtunkhwa",
105
+ kpk: "Khyber Pakhtunkhwa",
106
+ balochistan: "Balochistan",
107
+ baluchistan: "Balochistan",
108
+ "islamabad capital territory": "Islamabad Capital Territory",
109
+ ict: "Islamabad Capital Territory",
110
+ islamabad: "Islamabad Capital Territory",
111
+ "azad jammu and kashmir": "Azad Jammu and Kashmir",
112
+ ajk: "Azad Jammu and Kashmir",
113
+ "gilgit-baltistan": "Gilgit-Baltistan",
114
+ "gilgit baltistan": "Gilgit-Baltistan",
115
+ gb: "Gilgit-Baltistan"
116
+ };
117
+ var OUTSIDE_FEDERAL = /* @__PURE__ */ new Set(["Azad Jammu and Kashmir", "Gilgit-Baltistan"]);
118
+ function provinceName(input) {
119
+ if (typeof input !== "string") return null;
120
+ const key = normalizeKey(input);
121
+ return Object.prototype.hasOwnProperty.call(PROVINCES, key) ? PROVINCES[key] : null;
122
+ }
123
+ function getSalesTaxRate(query) {
124
+ if (query === null || typeof query !== "object") return null;
125
+ const { kind } = query;
126
+ if (kind !== "goods" && kind !== "services") return null;
127
+ const date = query.date === void 0 ? isoDate(/* @__PURE__ */ new Date()) : isoDate(query.date);
128
+ if (date === null) return null;
129
+ let province = null;
130
+ if (query.province !== void 0 && query.province !== null) {
131
+ province = provinceName(query.province);
132
+ if (province === null) return null;
133
+ }
134
+ if (kind === "goods") {
135
+ if (province !== null && OUTSIDE_FEDERAL.has(province)) return null;
136
+ } else if (province === null) {
137
+ return null;
138
+ }
139
+ const entry = RATES.find(
140
+ (r) => r.kind === kind && (kind === "goods" || r.province === province) && r.from <= date && (r.to === null || date <= r.to)
141
+ );
142
+ return entry ? { ...entry } : null;
143
+ }
144
+ function basisPoints(rate) {
145
+ if (typeof rate !== "number" || !Number.isFinite(rate) || rate < 0 || rate > 100) {
146
+ return null;
147
+ }
148
+ const exact = toUnits(rate, 4);
149
+ if (exact === null || exact % 100 !== 0) return null;
150
+ return exact / 100;
151
+ }
152
+ function amounts(netPaisa, taxPaisa, bp) {
153
+ return {
154
+ net: fromPaisa(netPaisa),
155
+ tax: fromPaisa(taxPaisa),
156
+ gross: fromPaisa(netPaisa + taxPaisa),
157
+ rate: bp / 100
158
+ };
159
+ }
160
+ function splitInclusive(gross, rate) {
161
+ const grossPaisa = toUnits(gross, 2);
162
+ const bp = basisPoints(rate);
163
+ if (grossPaisa === null || bp === null) return null;
164
+ const netPaisa = divideHalfUp(
165
+ BigInt(grossPaisa) * 10000n,
166
+ BigInt(1e4 + bp)
167
+ );
168
+ return amounts(netPaisa, grossPaisa - netPaisa, bp);
169
+ }
170
+ function calculateSalesTax(amount, options) {
171
+ if (options === null || typeof options !== "object") return null;
172
+ let rate;
173
+ if (options.rate !== void 0 && options.rate !== null) {
174
+ rate = options.rate;
175
+ } else {
176
+ const kind = options.kind ?? (options.province !== void 0 ? "services" : void 0);
177
+ if (kind === void 0) return null;
178
+ const found = getSalesTaxRate({
179
+ kind,
180
+ ...options.province !== void 0 ? { province: options.province } : {},
181
+ ...options.date !== void 0 ? { date: options.date } : {}
182
+ });
183
+ if (found === null) return null;
184
+ rate = found.rate;
185
+ }
186
+ if (options.inclusive === true) return splitInclusive(amount, rate);
187
+ const netPaisa = toUnits(amount, 2);
188
+ const bp = basisPoints(rate);
189
+ if (netPaisa === null || bp === null) return null;
190
+ const taxPaisa = divideHalfUp(BigInt(netPaisa) * BigInt(bp), 10000n);
191
+ return amounts(netPaisa, taxPaisa, bp);
192
+ }
193
+
194
+ export { calculateSalesTax, getSalesTaxRate, splitInclusive };
@@ -0,0 +1,165 @@
1
+ import { cities_default } from './chunk-E2XU6NOW.js';
2
+ import { normalizeKey, lazy } from './chunk-ENQ7O7VW.js';
3
+
4
+ // src/courier.ts
5
+ var STATUSES = {
6
+ PostEx: {
7
+ // Order status IDs and names (§3.15).
8
+ "1": "pending",
9
+ unbooked: "pending",
10
+ "2": "booked",
11
+ booked: "booked",
12
+ "3": "in-transit",
13
+ "postex warehouse": "in-transit",
14
+ "4": "out-for-delivery",
15
+ "out for delivery": "out-for-delivery",
16
+ "5": "delivered",
17
+ delivered: "delivered",
18
+ "6": "returned",
19
+ returned: "returned",
20
+ "7": "cancelled",
21
+ "un-assigned by me": "cancelled",
22
+ "8": "cancelled",
23
+ expired: "cancelled",
24
+ "9": "under-review",
25
+ "delivery under review": "under-review",
26
+ "15": "picked-up",
27
+ "picked by postex": "picked-up",
28
+ "16": "returning",
29
+ "out for return": "returning",
30
+ "17": "attempted",
31
+ attempted: "attempted",
32
+ "18": "in-transit",
33
+ "en-route to postex warehouse": "in-transit",
34
+ // Tracking history codes and messages (§3.8).
35
+ "0001": "booked",
36
+ "at merchant's warehouse": "booked",
37
+ "0002": "returned",
38
+ "0003": "in-transit",
39
+ "at postex warehouse": "in-transit",
40
+ "0004": "in-transit",
41
+ "package on root": "in-transit",
42
+ "package on route": "in-transit",
43
+ "0005": "delivered",
44
+ "0006": "returned",
45
+ "0007": "returned",
46
+ "0008": "under-review",
47
+ "0013": "attempted"
48
+ },
49
+ Leopards: {
50
+ "returned to shipper": "returned"
51
+ },
52
+ TCS: {},
53
+ "M&P": {},
54
+ Trax: {},
55
+ BlueEx: {}
56
+ };
57
+ var COURIER_NAMES = {
58
+ tcs: "TCS",
59
+ leopards: "Leopards",
60
+ "leopards courier": "Leopards",
61
+ lcs: "Leopards",
62
+ postex: "PostEx",
63
+ "m&p": "M&P",
64
+ mnp: "M&P",
65
+ "m and p": "M&P",
66
+ "muller & phipps": "M&P",
67
+ "muller and phipps": "M&P",
68
+ trax: "Trax",
69
+ blueex: "BlueEx",
70
+ "blue ex": "BlueEx",
71
+ "blue-ex": "BlueEx"
72
+ };
73
+ var statusKey = (text) => normalizeKey(text.replace(/[‘’`]/g, "'"));
74
+ function mapCourierStatus(courier, raw) {
75
+ if (typeof courier !== "string") return null;
76
+ const courierKey = statusKey(courier);
77
+ if (!Object.prototype.hasOwnProperty.call(COURIER_NAMES, courierKey)) {
78
+ return null;
79
+ }
80
+ const name = COURIER_NAMES[courierKey];
81
+ let key;
82
+ if (typeof raw === "number") {
83
+ if (!Number.isInteger(raw) || raw < 0) return null;
84
+ key = String(raw);
85
+ } else if (typeof raw === "string") {
86
+ key = statusKey(raw);
87
+ } else {
88
+ return null;
89
+ }
90
+ const table = STATUSES[name];
91
+ if (Object.prototype.hasOwnProperty.call(table, key)) {
92
+ return table[key];
93
+ }
94
+ if (name === "PostEx" && /^attempt made\b/.test(key)) return "attempted";
95
+ return null;
96
+ }
97
+ var CITY_ALIASES = {
98
+ lhr: "Lahore",
99
+ lhe: "Lahore",
100
+ lahor: "Lahore",
101
+ \u0644\u0627\u06C1\u0648\u0631: "Lahore",
102
+ khi: "Karachi",
103
+ krachi: "Karachi",
104
+ \u06A9\u0631\u0627\u0686\u06CC: "Karachi",
105
+ pindi: "Rawalpindi",
106
+ rwp: "Rawalpindi",
107
+ "rawal pindi": "Rawalpindi",
108
+ \u0631\u0627\u0648\u0644\u067E\u0646\u0688\u06CC: "Rawalpindi",
109
+ isb: "Islamabad",
110
+ isl: "Islamabad",
111
+ "\u0627\u0633\u0644\u0627\u0645 \u0622\u0628\u0627\u062F": "Islamabad",
112
+ lyallpur: "Faisalabad",
113
+ lyp: "Faisalabad",
114
+ fsd: "Faisalabad",
115
+ "faisal abad": "Faisalabad",
116
+ "\u0641\u06CC\u0635\u0644 \u0622\u0628\u0627\u062F": "Faisalabad",
117
+ mux: "Multan",
118
+ mtn: "Multan",
119
+ \u0645\u0644\u062A\u0627\u0646: "Multan",
120
+ pew: "Peshawar",
121
+ psh: "Peshawar",
122
+ \u067E\u0634\u0627\u0648\u0631: "Peshawar",
123
+ uet: "Quetta",
124
+ qta: "Quetta",
125
+ \u06A9\u0648\u0626\u0679\u06C1: "Quetta",
126
+ hyd: "Hyderabad",
127
+ \u062D\u06CC\u062F\u0631\u0622\u0628\u0627\u062F: "Hyderabad",
128
+ "\u062D\u06CC\u062F\u0631 \u0622\u0628\u0627\u062F": "Hyderabad",
129
+ skt: "Sialkot",
130
+ \u0633\u06CC\u0627\u0644\u06A9\u0648\u0679: "Sialkot",
131
+ grw: "Gujranwala",
132
+ \u06AF\u0648\u062C\u0631\u0627\u0646\u0648\u0627\u0644\u06C1: "Gujranwala",
133
+ dgk: "Dera Ghazi Khan",
134
+ "dg khan": "Dera Ghazi Khan",
135
+ "d g khan": "Dera Ghazi Khan",
136
+ dik: "Dera Ismail Khan",
137
+ "di khan": "Dera Ismail Khan",
138
+ "d i khan": "Dera Ismail Khan",
139
+ ryk: "Rahim Yar Khan",
140
+ bwp: "Bahawalpur",
141
+ sgd: "Sargodha",
142
+ mzd: "Muzaffarabad"
143
+ };
144
+ var cityByKey = /* @__PURE__ */ lazy(() => {
145
+ const map = /* @__PURE__ */ new Map();
146
+ for (const { city } of cities_default) {
147
+ map.set(normalizeKey(city), city);
148
+ }
149
+ return map;
150
+ });
151
+ var cityKey = (text) => normalizeKey(text.replace(/[.,]/g, " "));
152
+ function normalizeCityForCourier(input) {
153
+ if (typeof input !== "string") return null;
154
+ let key = cityKey(input);
155
+ if (key.length === 0) return null;
156
+ for (let pass = 0; pass < 2; pass += 1) {
157
+ const city = cityByKey().get(key) ?? (Object.prototype.hasOwnProperty.call(CITY_ALIASES, key) ? CITY_ALIASES[key] : void 0);
158
+ if (city !== void 0) return city;
159
+ if (!key.endsWith(" city")) break;
160
+ key = key.slice(0, -" city".length).trim();
161
+ }
162
+ return null;
163
+ }
164
+
165
+ export { mapCourierStatus, normalizeCityForCourier };