pakdatakit 2.2.1 → 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 +512 -34
- package/LICENSE +1 -1
- package/NOTICE +14 -0
- package/README.md +472 -28
- package/dist/address.cjs +6 -5
- package/dist/address.js +4 -3
- 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-4VSGCQ6K.cjs → chunk-2OBKPYJZ.cjs} +3 -3
- package/dist/chunk-33GOK7EE.cjs +5312 -0
- package/dist/chunk-33QMFE2Z.js +21244 -0
- 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-TTARJWGT.js → chunk-7DY26QPN.js} +2 -2
- package/dist/chunk-7E7L3NYS.cjs +11 -0
- package/dist/{chunk-3ZA265SK.cjs → chunk-AUQFA7EE.cjs} +172 -4
- package/dist/{chunk-QKH7W2CC.js → chunk-B7DOQ5QF.js} +6 -5
- package/dist/{chunk-HBOZIITD.js → chunk-CADQM4ZN.js} +14 -14
- package/dist/chunk-CF6AMRBU.cjs +198 -0
- package/dist/chunk-CZOZB4K3.js +61 -0
- package/dist/{chunk-3IARSCO6.cjs → chunk-DHOP7LQX.cjs} +25 -14
- package/dist/chunk-E2XU6NOW.js +909 -0
- package/dist/chunk-E6GWBOKV.cjs +911 -0
- package/dist/chunk-E6HSKRAE.js +9 -0
- package/dist/chunk-EA3SIHYT.js +313 -0
- package/dist/{chunk-33FXHM2E.cjs → chunk-ESKXG7Y6.cjs} +5 -5
- package/dist/chunk-I7UUPD3G.cjs +21252 -0
- package/dist/{chunk-YPPKY5XZ.js → chunk-IBZPJS4H.js} +26 -15
- package/dist/chunk-IDTRFOQW.js +35 -0
- package/dist/{chunk-XCXFGTHW.cjs → chunk-J5ZF46NZ.cjs} +14 -14
- package/dist/{chunk-NZQ47NWD.js → chunk-KRYHLYN2.js} +1 -1
- package/dist/{chunk-RXNYY5K5.js → chunk-LQHM3ADX.js} +172 -4
- package/dist/{chunk-HTERSQGF.cjs → chunk-MTS6SVNP.cjs} +4 -4
- package/dist/chunk-OTI7HY55.js +297 -0
- package/dist/{chunk-6IPPANNX.js → chunk-P7LVE2TF.js} +2 -2
- package/dist/{chunk-47P7HILD.cjs → chunk-QFPEFD67.cjs} +9 -8
- package/dist/chunk-RZQJAZKC.js +22 -0
- package/dist/{chunk-PLDVGOKZ.js → chunk-S274QFFB.js} +2 -2
- package/dist/chunk-SF4ECUZ6.cjs +56 -0
- package/dist/chunk-SQIHFEXI.cjs +25 -0
- package/dist/{chunk-NAJGGUAM.cjs → chunk-TC3VRWZV.cjs} +2 -2
- package/dist/{chunk-U7MWHXMF.cjs → chunk-TVL6RDAU.cjs} +4 -4
- package/dist/chunk-UYFTXD4P.js +168 -0
- package/dist/{chunk-AZV45DMG.js → chunk-V2XE3NCG.js} +2 -2
- package/dist/chunk-XCFZKCV2.cjs +37 -0
- package/dist/chunk-XOTCIXY6.js +5301 -0
- 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/{chunk-NTD4JLDW.cjs → chunk-YTLE5K7G.cjs} +1 -1
- package/dist/{chunk-EMH4IP2U.js → chunk-ZRONAQBV.js} +1 -1
- package/dist/class-validator.cjs +65 -0
- package/dist/class-validator.d.cts +63 -0
- package/dist/class-validator.d.ts +63 -0
- package/dist/class-validator.js +54 -0
- 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 +23 -6
- package/dist/geo.d.cts +56 -1
- package/dist/geo.d.ts +56 -1
- package/dist/geo.js +2 -1
- package/dist/holidays.cjs +4 -4
- package/dist/holidays.js +1 -1
- package/dist/iban.cjs +5 -5
- package/dist/iban.d.cts +8 -6
- package/dist/iban.d.ts +8 -6
- package/dist/iban.js +1 -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 +253 -111
- package/dist/index.d.cts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +25 -15
- package/dist/input.cjs +9 -9
- package/dist/input.js +3 -3
- package/dist/joi.cjs +43 -0
- package/dist/joi.d.cts +25 -0
- package/dist/joi.d.ts +25 -0
- package/dist/joi.js +37 -0
- package/dist/networks.cjs +3 -3
- package/dist/networks.js +2 -2
- package/dist/numbers.cjs +6 -6
- package/dist/numbers.js +2 -2
- package/dist/passport.cjs +11 -0
- package/dist/passport.d.cts +27 -0
- package/dist/passport.d.ts +27 -0
- package/dist/passport.js +2 -0
- package/dist/phone.cjs +8 -8
- package/dist/phone.js +3 -3
- package/dist/postal.cjs +14 -6
- package/dist/postal.d.cts +54 -2
- package/dist/postal.d.ts +54 -2
- package/dist/postal.js +1 -1
- 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/raast.cjs +6 -6
- package/dist/raast.js +2 -2
- 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 +41 -0
- package/dist/superstruct.d.cts +25 -0
- package/dist/superstruct.d.ts +25 -0
- package/dist/superstruct.js +39 -0
- 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 +18 -8
- package/dist/valibot.d.cts +3 -0
- package/dist/valibot.d.ts +3 -0
- package/dist/valibot.js +17 -7
- package/dist/vehicle.cjs +15 -0
- package/dist/vehicle.d.cts +43 -0
- package/dist/vehicle.d.ts +43 -0
- package/dist/vehicle.js +2 -0
- package/dist/whatsapp.cjs +3 -3
- package/dist/whatsapp.js +2 -2
- package/dist/yup.cjs +18 -8
- package/dist/yup.d.cts +3 -0
- package/dist/yup.d.ts +3 -0
- package/dist/yup.js +17 -7
- package/dist/zod.cjs +18 -8
- package/dist/zod.d.cts +3 -0
- package/dist/zod.d.ts +3 -0
- package/dist/zod.js +17 -7
- package/package.json +167 -6
- package/dist/chunk-34CJGJ67.cjs +0 -1697
- package/dist/chunk-4VVFS6FN.cjs +0 -715
- package/dist/chunk-E6DT2DWQ.js +0 -1689
- package/dist/chunk-GJENL6VK.cjs +0 -22
- package/dist/chunk-HUQY2WR5.js +0 -20
- package/dist/chunk-JKE4AMSZ.js +0 -47
- package/dist/chunk-KEHCTYLO.cjs +0 -52
- package/dist/chunk-LIYNKIKS.js +0 -709
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkVPBMIYO2_cjs = require('./chunk-VPBMIYO2.cjs');
|
|
4
|
+
|
|
5
|
+
// src/bills.ts
|
|
6
|
+
var SEPARATORS = /[\s\-‐‑‒–—./]/g;
|
|
7
|
+
function parseElectricityRef(input) {
|
|
8
|
+
if (typeof input !== "string") return null;
|
|
9
|
+
let text = chunkVPBMIYO2_cjs.toAsciiDigits(input).replace(SEPARATORS, "").toUpperCase();
|
|
10
|
+
let urbanRural = null;
|
|
11
|
+
const letter = /^(\d{14})([UR])$/.exec(text);
|
|
12
|
+
if (letter) {
|
|
13
|
+
text = letter[1];
|
|
14
|
+
urbanRural = letter[2];
|
|
15
|
+
}
|
|
16
|
+
if (!/^\d+$/.test(text)) return null;
|
|
17
|
+
if (text.length === 14) {
|
|
18
|
+
const formatted = `${text.slice(0, 2)} ${text.slice(2, 7)} ${text.slice(7)}`;
|
|
19
|
+
return {
|
|
20
|
+
type: "reference",
|
|
21
|
+
digits: text,
|
|
22
|
+
formatted: urbanRural ? `${formatted} ${urbanRural}` : formatted,
|
|
23
|
+
urbanRural,
|
|
24
|
+
disco: null
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (urbanRural !== null) return null;
|
|
28
|
+
if (text.length === 13 && text.startsWith("04000")) {
|
|
29
|
+
return {
|
|
30
|
+
type: "k-electric",
|
|
31
|
+
digits: text,
|
|
32
|
+
formatted: text,
|
|
33
|
+
urbanRural: null,
|
|
34
|
+
disco: "K-Electric"
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (text.length === 10 || text.length === 11) {
|
|
38
|
+
return {
|
|
39
|
+
type: "customer-id",
|
|
40
|
+
digits: text,
|
|
41
|
+
formatted: text,
|
|
42
|
+
urbanRural: null,
|
|
43
|
+
disco: null
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
function validateElectricityRef(input) {
|
|
49
|
+
return parseElectricityRef(input) !== null;
|
|
50
|
+
}
|
|
51
|
+
var GAS_DIGITS = {
|
|
52
|
+
SNGPL: 11,
|
|
53
|
+
SSGC: 10
|
|
54
|
+
};
|
|
55
|
+
function validateGasConsumerNumber(input, company) {
|
|
56
|
+
if (typeof input !== "string" || typeof company !== "string") return false;
|
|
57
|
+
const digits = GAS_DIGITS[company.toUpperCase()];
|
|
58
|
+
if (digits === void 0) return false;
|
|
59
|
+
const text = chunkVPBMIYO2_cjs.toAsciiDigits(input).replace(SEPARATORS, "");
|
|
60
|
+
return text.length === digits && /^\d+$/.test(text);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
exports.parseElectricityRef = parseElectricityRef;
|
|
64
|
+
exports.validateElectricityRef = validateElectricityRef;
|
|
65
|
+
exports.validateGasConsumerNumber = validateGasConsumerNumber;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkXCFZKCV2_cjs = require('./chunk-XCFZKCV2.cjs');
|
|
4
|
+
require('./chunk-ESKXG7Y6.cjs');
|
|
5
|
+
require('./chunk-YDUXIENX.cjs');
|
|
6
|
+
require('./chunk-H6M6L26S.cjs');
|
|
7
|
+
require('./chunk-SQIHFEXI.cjs');
|
|
8
|
+
require('./chunk-DHOP7LQX.cjs');
|
|
9
|
+
require('./chunk-MTS6SVNP.cjs');
|
|
10
|
+
require('./chunk-AUQFA7EE.cjs');
|
|
11
|
+
require('./chunk-YTLE5K7G.cjs');
|
|
12
|
+
require('./chunk-7E7L3NYS.cjs');
|
|
13
|
+
require('./chunk-QFPEFD67.cjs');
|
|
14
|
+
require('./chunk-I7UUPD3G.cjs');
|
|
15
|
+
require('./chunk-HTCSHHOR.cjs');
|
|
16
|
+
require('./chunk-33GOK7EE.cjs');
|
|
17
|
+
require('./chunk-E6GWBOKV.cjs');
|
|
18
|
+
require('./chunk-VPBMIYO2.cjs');
|
|
19
|
+
var classValidator = require('class-validator');
|
|
20
|
+
|
|
21
|
+
function decorator(name) {
|
|
22
|
+
const rule = chunkXCFZKCV2_cjs.RULES[name];
|
|
23
|
+
return (options = {}) => (target, propertyName) => {
|
|
24
|
+
classValidator.registerDecorator({
|
|
25
|
+
name: `pk-${name}`,
|
|
26
|
+
target: target.constructor,
|
|
27
|
+
propertyName,
|
|
28
|
+
options: { ...options, message: options.message ?? rule.message },
|
|
29
|
+
validator: {
|
|
30
|
+
validate: (value) => typeof value === "string" && rule.test(value)
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
var pk = {
|
|
36
|
+
cnic: decorator("cnic"),
|
|
37
|
+
phone: decorator("phone"),
|
|
38
|
+
iban: decorator("iban"),
|
|
39
|
+
ntn: decorator("ntn"),
|
|
40
|
+
strn: decorator("strn"),
|
|
41
|
+
landline: decorator("landline"),
|
|
42
|
+
passport: decorator("passport"),
|
|
43
|
+
vehiclePlate: decorator("vehiclePlate"),
|
|
44
|
+
codPhone: decorator("codPhone")
|
|
45
|
+
};
|
|
46
|
+
var IsCNIC = pk.cnic;
|
|
47
|
+
var IsPakPhone = pk.phone;
|
|
48
|
+
var IsPakIBAN = pk.iban;
|
|
49
|
+
var IsNTN = pk.ntn;
|
|
50
|
+
var IsSTRN = pk.strn;
|
|
51
|
+
var IsPakLandline = pk.landline;
|
|
52
|
+
var IsPakPassport = pk.passport;
|
|
53
|
+
var IsVehiclePlate = pk.vehiclePlate;
|
|
54
|
+
var IsCodPhone = pk.codPhone;
|
|
55
|
+
|
|
56
|
+
exports.IsCNIC = IsCNIC;
|
|
57
|
+
exports.IsCodPhone = IsCodPhone;
|
|
58
|
+
exports.IsNTN = IsNTN;
|
|
59
|
+
exports.IsPakIBAN = IsPakIBAN;
|
|
60
|
+
exports.IsPakLandline = IsPakLandline;
|
|
61
|
+
exports.IsPakPassport = IsPakPassport;
|
|
62
|
+
exports.IsPakPhone = IsPakPhone;
|
|
63
|
+
exports.IsSTRN = IsSTRN;
|
|
64
|
+
exports.IsVehiclePlate = IsVehiclePlate;
|
|
65
|
+
exports.pk = pk;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ValidationOptions } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Options for the decorators: class-validator's own options (`groups`,
|
|
5
|
+
* `each`, `always`, `context`), plus a custom `message`.
|
|
6
|
+
*/
|
|
7
|
+
type DecoratorOptions = ValidationOptions;
|
|
8
|
+
/**
|
|
9
|
+
* class-validator decorators for Pakistani identifiers. They work in NestJS
|
|
10
|
+
* DTOs with the built-in `ValidationPipe`; no NestJS package is needed.
|
|
11
|
+
* Combine with `@IsOptional()` for optional fields.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { IsOptional } from 'class-validator';
|
|
15
|
+
* import { IsCNIC, IsPakPhone } from 'pakdatakit/class-validator';
|
|
16
|
+
*
|
|
17
|
+
* class CreateCustomerDto {
|
|
18
|
+
* @IsCNIC()
|
|
19
|
+
* cnic!: string;
|
|
20
|
+
*
|
|
21
|
+
* @IsOptional()
|
|
22
|
+
* @IsPakPhone({ message: 'Enter a Pakistani mobile number' })
|
|
23
|
+
* phone?: string;
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
declare const pk: {
|
|
27
|
+
cnic: (options?: DecoratorOptions) => PropertyDecorator;
|
|
28
|
+
phone: (options?: DecoratorOptions) => PropertyDecorator;
|
|
29
|
+
iban: (options?: DecoratorOptions) => PropertyDecorator;
|
|
30
|
+
ntn: (options?: DecoratorOptions) => PropertyDecorator;
|
|
31
|
+
strn: (options?: DecoratorOptions) => PropertyDecorator;
|
|
32
|
+
landline: (options?: DecoratorOptions) => PropertyDecorator;
|
|
33
|
+
passport: (options?: DecoratorOptions) => PropertyDecorator;
|
|
34
|
+
vehiclePlate: (options?: DecoratorOptions) => PropertyDecorator;
|
|
35
|
+
codPhone: (options?: DecoratorOptions) => PropertyDecorator;
|
|
36
|
+
};
|
|
37
|
+
/** Validates a CNIC. See {@link pk}. */
|
|
38
|
+
declare const IsCNIC: (options?: DecoratorOptions) => PropertyDecorator;
|
|
39
|
+
/** Validates a Pakistani mobile number. See {@link pk}. */
|
|
40
|
+
declare const IsPakPhone: (options?: DecoratorOptions) => PropertyDecorator;
|
|
41
|
+
/**
|
|
42
|
+
* Validates a Pakistani IBAN. Named `IsPakIBAN` so it does not clash with
|
|
43
|
+
* class-validator's own `IsIBAN`. See {@link pk}.
|
|
44
|
+
*/
|
|
45
|
+
declare const IsPakIBAN: (options?: DecoratorOptions) => PropertyDecorator;
|
|
46
|
+
/** Validates an NTN. See {@link pk}. */
|
|
47
|
+
declare const IsNTN: (options?: DecoratorOptions) => PropertyDecorator;
|
|
48
|
+
/** Validates an STRN. See {@link pk}. */
|
|
49
|
+
declare const IsSTRN: (options?: DecoratorOptions) => PropertyDecorator;
|
|
50
|
+
/** Validates a Pakistani landline number. See {@link pk}. */
|
|
51
|
+
declare const IsPakLandline: (options?: DecoratorOptions) => PropertyDecorator;
|
|
52
|
+
/** Validates the format of a Pakistani passport number. See {@link pk}. */
|
|
53
|
+
declare const IsPakPassport: (options?: DecoratorOptions) => PropertyDecorator;
|
|
54
|
+
/** Validates the format of a vehicle registration number. See {@link pk}. */
|
|
55
|
+
declare const IsVehiclePlate: (options?: DecoratorOptions) => PropertyDecorator;
|
|
56
|
+
/**
|
|
57
|
+
* Validates a mobile number a courier can call: valid, and with no
|
|
58
|
+
* `phoneRiskSignals` flag. See {@link pk}.
|
|
59
|
+
*/
|
|
60
|
+
declare const IsCodPhone: (options?: DecoratorOptions) => PropertyDecorator;
|
|
61
|
+
|
|
62
|
+
export { IsCNIC, IsCodPhone, IsNTN, IsPakIBAN, IsPakLandline, IsPakPassport, IsPakPhone, IsSTRN, IsVehiclePlate, pk };
|
|
63
|
+
export type { DecoratorOptions };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ValidationOptions } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Options for the decorators: class-validator's own options (`groups`,
|
|
5
|
+
* `each`, `always`, `context`), plus a custom `message`.
|
|
6
|
+
*/
|
|
7
|
+
type DecoratorOptions = ValidationOptions;
|
|
8
|
+
/**
|
|
9
|
+
* class-validator decorators for Pakistani identifiers. They work in NestJS
|
|
10
|
+
* DTOs with the built-in `ValidationPipe`; no NestJS package is needed.
|
|
11
|
+
* Combine with `@IsOptional()` for optional fields.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { IsOptional } from 'class-validator';
|
|
15
|
+
* import { IsCNIC, IsPakPhone } from 'pakdatakit/class-validator';
|
|
16
|
+
*
|
|
17
|
+
* class CreateCustomerDto {
|
|
18
|
+
* @IsCNIC()
|
|
19
|
+
* cnic!: string;
|
|
20
|
+
*
|
|
21
|
+
* @IsOptional()
|
|
22
|
+
* @IsPakPhone({ message: 'Enter a Pakistani mobile number' })
|
|
23
|
+
* phone?: string;
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
declare const pk: {
|
|
27
|
+
cnic: (options?: DecoratorOptions) => PropertyDecorator;
|
|
28
|
+
phone: (options?: DecoratorOptions) => PropertyDecorator;
|
|
29
|
+
iban: (options?: DecoratorOptions) => PropertyDecorator;
|
|
30
|
+
ntn: (options?: DecoratorOptions) => PropertyDecorator;
|
|
31
|
+
strn: (options?: DecoratorOptions) => PropertyDecorator;
|
|
32
|
+
landline: (options?: DecoratorOptions) => PropertyDecorator;
|
|
33
|
+
passport: (options?: DecoratorOptions) => PropertyDecorator;
|
|
34
|
+
vehiclePlate: (options?: DecoratorOptions) => PropertyDecorator;
|
|
35
|
+
codPhone: (options?: DecoratorOptions) => PropertyDecorator;
|
|
36
|
+
};
|
|
37
|
+
/** Validates a CNIC. See {@link pk}. */
|
|
38
|
+
declare const IsCNIC: (options?: DecoratorOptions) => PropertyDecorator;
|
|
39
|
+
/** Validates a Pakistani mobile number. See {@link pk}. */
|
|
40
|
+
declare const IsPakPhone: (options?: DecoratorOptions) => PropertyDecorator;
|
|
41
|
+
/**
|
|
42
|
+
* Validates a Pakistani IBAN. Named `IsPakIBAN` so it does not clash with
|
|
43
|
+
* class-validator's own `IsIBAN`. See {@link pk}.
|
|
44
|
+
*/
|
|
45
|
+
declare const IsPakIBAN: (options?: DecoratorOptions) => PropertyDecorator;
|
|
46
|
+
/** Validates an NTN. See {@link pk}. */
|
|
47
|
+
declare const IsNTN: (options?: DecoratorOptions) => PropertyDecorator;
|
|
48
|
+
/** Validates an STRN. See {@link pk}. */
|
|
49
|
+
declare const IsSTRN: (options?: DecoratorOptions) => PropertyDecorator;
|
|
50
|
+
/** Validates a Pakistani landline number. See {@link pk}. */
|
|
51
|
+
declare const IsPakLandline: (options?: DecoratorOptions) => PropertyDecorator;
|
|
52
|
+
/** Validates the format of a Pakistani passport number. See {@link pk}. */
|
|
53
|
+
declare const IsPakPassport: (options?: DecoratorOptions) => PropertyDecorator;
|
|
54
|
+
/** Validates the format of a vehicle registration number. See {@link pk}. */
|
|
55
|
+
declare const IsVehiclePlate: (options?: DecoratorOptions) => PropertyDecorator;
|
|
56
|
+
/**
|
|
57
|
+
* Validates a mobile number a courier can call: valid, and with no
|
|
58
|
+
* `phoneRiskSignals` flag. See {@link pk}.
|
|
59
|
+
*/
|
|
60
|
+
declare const IsCodPhone: (options?: DecoratorOptions) => PropertyDecorator;
|
|
61
|
+
|
|
62
|
+
export { IsCNIC, IsCodPhone, IsNTN, IsPakIBAN, IsPakLandline, IsPakPassport, IsPakPhone, IsSTRN, IsVehiclePlate, pk };
|
|
63
|
+
export type { DecoratorOptions };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { RULES } from './chunk-IDTRFOQW.js';
|
|
2
|
+
import './chunk-S274QFFB.js';
|
|
3
|
+
import './chunk-UYFTXD4P.js';
|
|
4
|
+
import './chunk-CEPNSHIC.js';
|
|
5
|
+
import './chunk-RZQJAZKC.js';
|
|
6
|
+
import './chunk-IBZPJS4H.js';
|
|
7
|
+
import './chunk-V2XE3NCG.js';
|
|
8
|
+
import './chunk-LQHM3ADX.js';
|
|
9
|
+
import './chunk-P7LVE2TF.js';
|
|
10
|
+
import './chunk-E6HSKRAE.js';
|
|
11
|
+
import './chunk-B7DOQ5QF.js';
|
|
12
|
+
import './chunk-33QMFE2Z.js';
|
|
13
|
+
import './chunk-EEVNLTB4.js';
|
|
14
|
+
import './chunk-XOTCIXY6.js';
|
|
15
|
+
import './chunk-E2XU6NOW.js';
|
|
16
|
+
import './chunk-ENQ7O7VW.js';
|
|
17
|
+
import { registerDecorator } from 'class-validator';
|
|
18
|
+
|
|
19
|
+
function decorator(name) {
|
|
20
|
+
const rule = RULES[name];
|
|
21
|
+
return (options = {}) => (target, propertyName) => {
|
|
22
|
+
registerDecorator({
|
|
23
|
+
name: `pk-${name}`,
|
|
24
|
+
target: target.constructor,
|
|
25
|
+
propertyName,
|
|
26
|
+
options: { ...options, message: options.message ?? rule.message },
|
|
27
|
+
validator: {
|
|
28
|
+
validate: (value) => typeof value === "string" && rule.test(value)
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
var pk = {
|
|
34
|
+
cnic: decorator("cnic"),
|
|
35
|
+
phone: decorator("phone"),
|
|
36
|
+
iban: decorator("iban"),
|
|
37
|
+
ntn: decorator("ntn"),
|
|
38
|
+
strn: decorator("strn"),
|
|
39
|
+
landline: decorator("landline"),
|
|
40
|
+
passport: decorator("passport"),
|
|
41
|
+
vehiclePlate: decorator("vehiclePlate"),
|
|
42
|
+
codPhone: decorator("codPhone")
|
|
43
|
+
};
|
|
44
|
+
var IsCNIC = pk.cnic;
|
|
45
|
+
var IsPakPhone = pk.phone;
|
|
46
|
+
var IsPakIBAN = pk.iban;
|
|
47
|
+
var IsNTN = pk.ntn;
|
|
48
|
+
var IsSTRN = pk.strn;
|
|
49
|
+
var IsPakLandline = pk.landline;
|
|
50
|
+
var IsPakPassport = pk.passport;
|
|
51
|
+
var IsVehiclePlate = pk.vehiclePlate;
|
|
52
|
+
var IsCodPhone = pk.codPhone;
|
|
53
|
+
|
|
54
|
+
export { IsCNIC, IsCodPhone, IsNTN, IsPakIBAN, IsPakLandline, IsPakPassport, IsPakPhone, IsSTRN, IsVehiclePlate, pk };
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { normalizeRomanUrdu, formatHijri, toHijri, formatPKR, formatLakh, parseAddress, getCityByPostalCode, getPostalCode, getProvince, getBankFromIBAN, validateIBAN, analyzePhone, validatePhone, validateCNIC } from 'pakdatakit';
|
|
3
3
|
|
|
4
4
|
// package.json
|
|
5
|
-
var version = "2.
|
|
5
|
+
var version = "2.5.0";
|
|
6
6
|
var EXIT_OK = 0;
|
|
7
7
|
var EXIT_NEGATIVE = 1;
|
|
8
8
|
var EXIT_USAGE = 2;
|
package/dist/courier.cjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkYPAWNWFD_cjs = require('./chunk-YPAWNWFD.cjs');
|
|
4
|
+
require('./chunk-E6GWBOKV.cjs');
|
|
5
|
+
require('./chunk-VPBMIYO2.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "mapCourierStatus", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunkYPAWNWFD_cjs.mapCourierStatus; }
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "normalizeCityForCourier", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return chunkYPAWNWFD_cjs.normalizeCityForCourier; }
|
|
16
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** Couriers that {@link mapCourierStatus} knows about. */
|
|
2
|
+
type Courier = 'TCS' | 'Leopards' | 'PostEx' | 'M&P' | 'Trax' | 'BlueEx';
|
|
3
|
+
/**
|
|
4
|
+
* A courier's status in one vocabulary, from order to delivery or return.
|
|
5
|
+
*
|
|
6
|
+
* @experimental The set of values may change in a minor release while more
|
|
7
|
+
* couriers' status lists are added.
|
|
8
|
+
*/
|
|
9
|
+
type CourierStatus = 'pending' | 'booked' | 'picked-up' | 'in-transit' | 'out-for-delivery' | 'attempted' | 'under-review' | 'delivered' | 'returning' | 'returned' | 'cancelled';
|
|
10
|
+
/**
|
|
11
|
+
* Maps a courier's own status (its name, numeric ID or code, as the courier
|
|
12
|
+
* documents it) to a {@link CourierStatus}.
|
|
13
|
+
*
|
|
14
|
+
* Matching ignores case and extra spaces. PostEx's "Attempt Made: <reason>"
|
|
15
|
+
* history messages map to `attempted`.
|
|
16
|
+
*
|
|
17
|
+
* Only statuses the courier documents publicly are mapped: PostEx's API
|
|
18
|
+
* guide and one Leopards status. TCS, M&P, Trax and BlueEx publish no list,
|
|
19
|
+
* so they always return `null`, as does any status not in the list. No API
|
|
20
|
+
* is called.
|
|
21
|
+
*
|
|
22
|
+
* @param courier - `TCS`, `Leopards`, `PostEx`, `M&P`, `Trax` or `BlueEx`
|
|
23
|
+
* (case-insensitive; `LCS`, `MnP` and `Blue Ex` are accepted)
|
|
24
|
+
* @param raw - The status as the courier returned it
|
|
25
|
+
* @returns The status, or `null`. Never throws.
|
|
26
|
+
* @experimental Only PostEx and one Leopards status are mapped so far. The
|
|
27
|
+
* mapping and the {@link CourierStatus} values may change in a minor release
|
|
28
|
+
* as other couriers' lists are added.
|
|
29
|
+
*/
|
|
30
|
+
declare function mapCourierStatus(courier: string, raw: string | number): CourierStatus | null;
|
|
31
|
+
/**
|
|
32
|
+
* Maps the way a customer or a courier writes a city to the city's name in
|
|
33
|
+
* pakdatakit's city list, so orders can be matched against a courier's
|
|
34
|
+
* service list.
|
|
35
|
+
*
|
|
36
|
+
* Accepts the exact name in any case, short forms (`LHR`, `Khi`, `Pindi`,
|
|
37
|
+
* `Isb`, `FSD`), the old name Lyallpur, a trailing "city", and the main
|
|
38
|
+
* cities in Urdu script.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* normalizeCityForCourier('LHR'); // "Lahore"
|
|
42
|
+
* normalizeCityForCourier('lyallpur'); // "Faisalabad"
|
|
43
|
+
* normalizeCityForCourier('Karachi City'); // "Karachi"
|
|
44
|
+
* normalizeCityForCourier('Atlantis'); // null
|
|
45
|
+
*
|
|
46
|
+
* @returns A city from the city list, or `null`. Never throws.
|
|
47
|
+
*/
|
|
48
|
+
declare function normalizeCityForCourier(input: string): string | null;
|
|
49
|
+
|
|
50
|
+
export { mapCourierStatus, normalizeCityForCourier };
|
|
51
|
+
export type { Courier, CourierStatus };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** Couriers that {@link mapCourierStatus} knows about. */
|
|
2
|
+
type Courier = 'TCS' | 'Leopards' | 'PostEx' | 'M&P' | 'Trax' | 'BlueEx';
|
|
3
|
+
/**
|
|
4
|
+
* A courier's status in one vocabulary, from order to delivery or return.
|
|
5
|
+
*
|
|
6
|
+
* @experimental The set of values may change in a minor release while more
|
|
7
|
+
* couriers' status lists are added.
|
|
8
|
+
*/
|
|
9
|
+
type CourierStatus = 'pending' | 'booked' | 'picked-up' | 'in-transit' | 'out-for-delivery' | 'attempted' | 'under-review' | 'delivered' | 'returning' | 'returned' | 'cancelled';
|
|
10
|
+
/**
|
|
11
|
+
* Maps a courier's own status (its name, numeric ID or code, as the courier
|
|
12
|
+
* documents it) to a {@link CourierStatus}.
|
|
13
|
+
*
|
|
14
|
+
* Matching ignores case and extra spaces. PostEx's "Attempt Made: <reason>"
|
|
15
|
+
* history messages map to `attempted`.
|
|
16
|
+
*
|
|
17
|
+
* Only statuses the courier documents publicly are mapped: PostEx's API
|
|
18
|
+
* guide and one Leopards status. TCS, M&P, Trax and BlueEx publish no list,
|
|
19
|
+
* so they always return `null`, as does any status not in the list. No API
|
|
20
|
+
* is called.
|
|
21
|
+
*
|
|
22
|
+
* @param courier - `TCS`, `Leopards`, `PostEx`, `M&P`, `Trax` or `BlueEx`
|
|
23
|
+
* (case-insensitive; `LCS`, `MnP` and `Blue Ex` are accepted)
|
|
24
|
+
* @param raw - The status as the courier returned it
|
|
25
|
+
* @returns The status, or `null`. Never throws.
|
|
26
|
+
* @experimental Only PostEx and one Leopards status are mapped so far. The
|
|
27
|
+
* mapping and the {@link CourierStatus} values may change in a minor release
|
|
28
|
+
* as other couriers' lists are added.
|
|
29
|
+
*/
|
|
30
|
+
declare function mapCourierStatus(courier: string, raw: string | number): CourierStatus | null;
|
|
31
|
+
/**
|
|
32
|
+
* Maps the way a customer or a courier writes a city to the city's name in
|
|
33
|
+
* pakdatakit's city list, so orders can be matched against a courier's
|
|
34
|
+
* service list.
|
|
35
|
+
*
|
|
36
|
+
* Accepts the exact name in any case, short forms (`LHR`, `Khi`, `Pindi`,
|
|
37
|
+
* `Isb`, `FSD`), the old name Lyallpur, a trailing "city", and the main
|
|
38
|
+
* cities in Urdu script.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* normalizeCityForCourier('LHR'); // "Lahore"
|
|
42
|
+
* normalizeCityForCourier('lyallpur'); // "Faisalabad"
|
|
43
|
+
* normalizeCityForCourier('Karachi City'); // "Karachi"
|
|
44
|
+
* normalizeCityForCourier('Atlantis'); // null
|
|
45
|
+
*
|
|
46
|
+
* @returns A city from the city list, or `null`. Never throws.
|
|
47
|
+
*/
|
|
48
|
+
declare function normalizeCityForCourier(input: string): string | null;
|
|
49
|
+
|
|
50
|
+
export { mapCourierStatus, normalizeCityForCourier };
|
|
51
|
+
export type { Courier, CourierStatus };
|
package/dist/courier.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk5UCRHVI4_cjs = require('./chunk-5UCRHVI4.cjs');
|
|
4
|
+
require('./chunk-CF6AMRBU.cjs');
|
|
5
|
+
require('./chunk-SF4ECUZ6.cjs');
|
|
6
|
+
require('./chunk-VPBMIYO2.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, "FBR_DI_SPEC_VERSION", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return chunk5UCRHVI4_cjs.FBR_DI_SPEC_VERSION; }
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "buildFbrInvoice", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return chunk5UCRHVI4_cjs.buildFbrInvoice; }
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "expectedSalesTax", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return chunk5UCRHVI4_cjs.expectedSalesTax; }
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(exports, "validateFbrInvoice", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return chunk5UCRHVI4_cjs.validateFbrInvoice; }
|
|
25
|
+
});
|
|
@@ -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 };
|