@ripwords/myinvois-client 0.2.34 → 0.2.36
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/dist/api/documentManagement.d.ts +2 -2
- package/dist/api/documentSubmission.d.ts +2 -2
- package/dist/api/documentSubmission.js +2 -2
- package/dist/api/documentTypeManagement.d.ts +2 -2
- package/dist/api/notificationManagement.d.ts +2 -2
- package/dist/api/platformLogin.d.ts +2 -2
- package/dist/api/taxpayerValidation.d.ts +2 -2
- package/dist/{document-DWsGewNs.cjs → document-CCza2JPL.cjs} +30 -4
- package/dist/document-CCza2JPL.cjs.map +1 -0
- package/dist/{document-DI6hw1MO.js → document-DLFdGSK1.js} +29 -3
- package/dist/{documentSubmission-YwuM4ap1.cjs → documentSubmission-BBg9_Fqr.cjs} +2 -2
- package/dist/{documentSubmission-YwuM4ap1.cjs.map → documentSubmission-BBg9_Fqr.cjs.map} +1 -1
- package/dist/{documentSubmission-CgW1Cm0W.js → documentSubmission-jWGDM-Cv.js} +1 -1
- package/dist/{documents-BWpJ0B3C.d.cts → documents-DCZ3Ffya.d.cts} +40 -2
- package/dist/{documents-DRQ6_toX.d.ts → documents-DzZA3NHj.d.ts} +39 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index18.cjs +2 -2
- package/dist/index23.cjs +207 -3
- package/dist/index23.cjs.map +1 -0
- package/dist/index24.cjs +105 -9
- package/dist/index24.cjs.map +1 -1
- package/dist/index25.cjs +136 -4
- package/dist/{index33.cjs.map → index25.cjs.map} +1 -1
- package/dist/index26.cjs +63 -21
- package/dist/index26.cjs.map +1 -0
- package/dist/index27.cjs +266 -2
- package/dist/{index35.cjs.map → index27.cjs.map} +1 -1
- package/dist/index28.cjs +78 -2
- package/dist/{index36.cjs.map → index28.cjs.map} +1 -1
- package/dist/index29.cjs +103 -326
- package/dist/index29.cjs.map +1 -1
- package/dist/index30.cjs +69 -189
- package/dist/index30.cjs.map +1 -1
- package/dist/index31.cjs +107 -203
- package/dist/index31.cjs.map +1 -1
- package/dist/index32.cjs +95 -104
- package/dist/index32.cjs.map +1 -1
- package/dist/index33.cjs +3 -136
- package/dist/index34.cjs +9 -60
- package/dist/index34.cjs.map +1 -1
- package/dist/index35.cjs +4 -266
- package/dist/index36.cjs +21 -78
- package/dist/index37.cjs +2 -106
- package/dist/index38.cjs +2 -72
- package/dist/index39.cjs +326 -108
- package/dist/index39.cjs.map +1 -1
- package/dist/index40.cjs +189 -96
- package/dist/index40.cjs.map +1 -1
- package/dist/index71.cts.map +1 -1
- package/dist/{taxpayer-DtyHXKwz.d.ts → taxpayer-DmHW0m7o.d.ts} +1 -1
- package/dist/{taxpayer-CApK7x_O.d.cts → taxpayer-Pm90MrPj.d.cts} +2 -2
- package/dist/types/documents.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/taxpayer.d.ts +2 -2
- package/dist/utils/document.d.ts +6 -2
- package/dist/utils/document.js +1 -1
- package/dist/utils/signature-diagnostics.d.ts +2 -2
- package/dist/utils/signature-diagnostics.js +1 -1
- package/dist/utils/validation.d.ts +2 -2
- package/package.json +1 -1
- package/dist/document-DWsGewNs.cjs.map +0 -1
- package/dist/index37.cjs.map +0 -1
- package/dist/index38.cjs.map +0 -1
package/dist/index40.cjs
CHANGED
|
@@ -1,100 +1,193 @@
|
|
|
1
1
|
|
|
2
|
-
//#region src/
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
2
|
+
//#region src/utils/validation.ts
|
|
3
|
+
/**
|
|
4
|
+
* Validates TIN format based on registration type
|
|
5
|
+
*/
|
|
6
|
+
const validateTIN = (tin, registrationType) => {
|
|
7
|
+
const errors = [];
|
|
8
|
+
if (!tin) {
|
|
9
|
+
errors.push({
|
|
10
|
+
field: "tin",
|
|
11
|
+
code: "TIN_REQUIRED",
|
|
12
|
+
message: "TIN is required",
|
|
13
|
+
severity: "error"
|
|
14
|
+
});
|
|
15
|
+
return errors;
|
|
16
|
+
}
|
|
17
|
+
if (registrationType === "BRN" && !tin.startsWith("C")) errors.push({
|
|
18
|
+
field: "tin",
|
|
19
|
+
code: "TIN_FORMAT_INVALID",
|
|
20
|
+
message: "Company TIN should start with \"C\" for BRN registration",
|
|
21
|
+
severity: "warning"
|
|
22
|
+
});
|
|
23
|
+
if (registrationType === "NRIC" && !tin.startsWith("IG")) errors.push({
|
|
24
|
+
field: "tin",
|
|
25
|
+
code: "TIN_FORMAT_INVALID",
|
|
26
|
+
message: "Individual TIN should start with \"IG\" for NRIC registration",
|
|
27
|
+
severity: "warning"
|
|
28
|
+
});
|
|
29
|
+
if (tin.length > 14) errors.push({
|
|
30
|
+
field: "tin",
|
|
31
|
+
code: "TIN_LENGTH_INVALID",
|
|
32
|
+
message: "TIN cannot exceed 14 characters",
|
|
33
|
+
severity: "error"
|
|
34
|
+
});
|
|
35
|
+
return errors;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Validates contact number format (E.164 standard)
|
|
39
|
+
*/
|
|
40
|
+
const validateContactNumber = (contactNumber) => {
|
|
41
|
+
const errors = [];
|
|
42
|
+
if (!contactNumber || contactNumber === "NA") return errors;
|
|
43
|
+
const e164Regex = /^\+[1-9]\d{1,14}$/;
|
|
44
|
+
if (!e164Regex.test(contactNumber)) errors.push({
|
|
45
|
+
field: "contactNumber",
|
|
46
|
+
code: "CONTACT_FORMAT_INVALID",
|
|
47
|
+
message: "Contact number must be in E.164 format (e.g., +60123456789)",
|
|
48
|
+
severity: "error"
|
|
49
|
+
});
|
|
50
|
+
if (contactNumber.length < 8) errors.push({
|
|
51
|
+
field: "contactNumber",
|
|
52
|
+
code: "CONTACT_LENGTH_INVALID",
|
|
53
|
+
message: "Contact number must be at least 8 characters",
|
|
54
|
+
severity: "error"
|
|
55
|
+
});
|
|
56
|
+
return errors;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Validates monetary amounts
|
|
60
|
+
*/
|
|
61
|
+
const validateMonetaryAmount = (amount, fieldName, maxDigits = 18, maxDecimals = 2) => {
|
|
62
|
+
const errors = [];
|
|
63
|
+
if (amount < 0) errors.push({
|
|
64
|
+
field: fieldName,
|
|
65
|
+
code: "AMOUNT_NEGATIVE",
|
|
66
|
+
message: `${fieldName} cannot be negative`,
|
|
67
|
+
severity: "error"
|
|
68
|
+
});
|
|
69
|
+
const amountStr = amount.toString();
|
|
70
|
+
const [integerPart, decimalPart] = amountStr.split(".");
|
|
71
|
+
if (integerPart && integerPart.length > maxDigits - maxDecimals) errors.push({
|
|
72
|
+
field: fieldName,
|
|
73
|
+
code: "AMOUNT_DIGITS_EXCEEDED",
|
|
74
|
+
message: `${fieldName} exceeds maximum ${maxDigits} digits`,
|
|
75
|
+
severity: "error"
|
|
76
|
+
});
|
|
77
|
+
if (decimalPart && decimalPart.length > maxDecimals) errors.push({
|
|
78
|
+
field: fieldName,
|
|
79
|
+
code: "AMOUNT_DECIMALS_EXCEEDED",
|
|
80
|
+
message: `${fieldName} exceeds maximum ${maxDecimals} decimal places`,
|
|
81
|
+
severity: "error"
|
|
82
|
+
});
|
|
83
|
+
return errors;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Validates line item tax calculation consistency for both fixed rate and percentage taxation
|
|
87
|
+
*/
|
|
88
|
+
const validateLineItemTax = (item, index) => {
|
|
89
|
+
const errors = [];
|
|
90
|
+
const tolerance = .01;
|
|
91
|
+
const hasFixedRate = item.taxPerUnitAmount !== void 0 && item.baseUnitMeasure !== void 0;
|
|
92
|
+
const hasPercentageRate = item.taxRate !== void 0;
|
|
93
|
+
if (!hasFixedRate && !hasPercentageRate) {
|
|
94
|
+
errors.push({
|
|
95
|
+
field: `lineItem[${index}]`,
|
|
96
|
+
code: "TAX_METHOD_MISSING",
|
|
97
|
+
message: `Line item ${index + 1} must specify either taxRate (for percentage) or taxPerUnitAmount + baseUnitMeasure (for fixed rate)`,
|
|
98
|
+
severity: "error"
|
|
99
|
+
});
|
|
100
|
+
return errors;
|
|
101
|
+
}
|
|
102
|
+
if (hasFixedRate && hasPercentageRate) errors.push({
|
|
103
|
+
field: `lineItem[${index}]`,
|
|
104
|
+
code: "TAX_METHOD_CONFLICT",
|
|
105
|
+
message: `Line item ${index + 1} cannot have both percentage and fixed rate tax methods`,
|
|
106
|
+
severity: "error"
|
|
107
|
+
});
|
|
108
|
+
if (hasFixedRate) {
|
|
109
|
+
if (item.baseUnitMeasureCode === void 0) errors.push({
|
|
110
|
+
field: `lineItem[${index}].baseUnitMeasureCode`,
|
|
111
|
+
code: "UNIT_CODE_MISSING",
|
|
112
|
+
message: `Line item ${index + 1} with fixed rate tax must specify baseUnitMeasureCode`,
|
|
113
|
+
severity: "error"
|
|
114
|
+
});
|
|
115
|
+
const expectedTaxAmount = item.taxPerUnitAmount * item.baseUnitMeasure;
|
|
116
|
+
if (Math.abs(item.taxAmount - expectedTaxAmount) > tolerance) errors.push({
|
|
117
|
+
field: `lineItem[${index}].taxAmount`,
|
|
118
|
+
code: "FIXED_TAX_CALCULATION_MISMATCH",
|
|
119
|
+
message: `Line item ${index + 1} tax amount (${item.taxAmount}) doesn't match fixed rate calculation (${item.taxPerUnitAmount} × ${item.baseUnitMeasure} = ${expectedTaxAmount})`,
|
|
120
|
+
severity: "error"
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
if (hasPercentageRate && !hasFixedRate) {
|
|
124
|
+
const expectedTaxAmount = item.totalTaxableAmountPerLine * item.taxRate / 100;
|
|
125
|
+
if (Math.abs(item.taxAmount - expectedTaxAmount) > tolerance) errors.push({
|
|
126
|
+
field: `lineItem[${index}].taxAmount`,
|
|
127
|
+
code: "PERCENTAGE_TAX_CALCULATION_MISMATCH",
|
|
128
|
+
message: `Line item ${index + 1} tax amount (${item.taxAmount}) doesn't match percentage calculation (${item.totalTaxableAmountPerLine} × ${item.taxRate}% = ${expectedTaxAmount})`,
|
|
129
|
+
severity: "error"
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return errors;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Validates tax calculation consistency
|
|
136
|
+
*/
|
|
137
|
+
const validateTaxCalculations = (invoice) => {
|
|
138
|
+
const errors = [];
|
|
139
|
+
invoice.invoiceLineItems.forEach((item, index) => {
|
|
140
|
+
errors.push(...validateLineItemTax(item, index));
|
|
141
|
+
});
|
|
142
|
+
const expectedTaxExclusive = invoice.invoiceLineItems.reduce((sum, item) => sum + item.totalTaxableAmountPerLine, 0);
|
|
143
|
+
const expectedTaxAmount = invoice.invoiceLineItems.reduce((sum, item) => sum + item.taxAmount, 0);
|
|
144
|
+
const tolerance = .01;
|
|
145
|
+
if (Math.abs(invoice.legalMonetaryTotal.taxExclusiveAmount - expectedTaxExclusive) > tolerance) errors.push({
|
|
146
|
+
field: "legalMonetaryTotal.taxExclusiveAmount",
|
|
147
|
+
code: "TAX_EXCLUSIVE_MISMATCH",
|
|
148
|
+
message: `Tax exclusive amount (${invoice.legalMonetaryTotal.taxExclusiveAmount}) doesn't match sum of line items (${expectedTaxExclusive})`,
|
|
149
|
+
severity: "error"
|
|
150
|
+
});
|
|
151
|
+
if (Math.abs(invoice.taxTotal.taxAmount - expectedTaxAmount) > tolerance) errors.push({
|
|
152
|
+
field: "taxTotal.taxAmount",
|
|
153
|
+
code: "TAX_AMOUNT_MISMATCH",
|
|
154
|
+
message: `Tax amount (${invoice.taxTotal.taxAmount}) doesn't match sum of line item taxes (${expectedTaxAmount})`,
|
|
155
|
+
severity: "error"
|
|
156
|
+
});
|
|
157
|
+
return errors;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Main validation function for complete invoice
|
|
161
|
+
*/
|
|
162
|
+
const validateInvoice = (invoice) => {
|
|
163
|
+
const allErrors = [];
|
|
164
|
+
allErrors.push(...validateTIN(invoice.supplier.tin, invoice.supplier.registrationType));
|
|
165
|
+
allErrors.push(...validateTIN(invoice.buyer.tin, invoice.buyer.registrationType));
|
|
166
|
+
allErrors.push(...validateContactNumber(invoice.supplier.contactNumber));
|
|
167
|
+
allErrors.push(...validateContactNumber(invoice.buyer.contactNumber));
|
|
168
|
+
allErrors.push(...validateMonetaryAmount(invoice.legalMonetaryTotal.taxExclusiveAmount, "taxExclusiveAmount"));
|
|
169
|
+
allErrors.push(...validateMonetaryAmount(invoice.legalMonetaryTotal.payableAmount, "payableAmount"));
|
|
170
|
+
allErrors.push(...validateMonetaryAmount(invoice.taxTotal.taxAmount, "taxAmount"));
|
|
171
|
+
invoice.invoiceLineItems.forEach((item, index) => {
|
|
172
|
+
allErrors.push(...validateMonetaryAmount(item.unitPrice, `lineItem[${index}].unitPrice`));
|
|
173
|
+
allErrors.push(...validateMonetaryAmount(item.taxAmount, `lineItem[${index}].taxAmount`));
|
|
174
|
+
allErrors.push(...validateMonetaryAmount(item.totalTaxableAmountPerLine, `lineItem[${index}].totalTaxableAmountPerLine`));
|
|
175
|
+
});
|
|
176
|
+
allErrors.push(...validateTaxCalculations(invoice));
|
|
177
|
+
const errors = allErrors.filter((e) => e.severity === "error");
|
|
178
|
+
const warnings = allErrors.filter((e) => e.severity === "warning");
|
|
179
|
+
return {
|
|
180
|
+
isValid: errors.length === 0,
|
|
181
|
+
errors,
|
|
182
|
+
warnings
|
|
183
|
+
};
|
|
184
|
+
};
|
|
97
185
|
|
|
98
186
|
//#endregion
|
|
99
|
-
exports.
|
|
187
|
+
exports.validateContactNumber = validateContactNumber;
|
|
188
|
+
exports.validateInvoice = validateInvoice;
|
|
189
|
+
exports.validateLineItemTax = validateLineItemTax;
|
|
190
|
+
exports.validateMonetaryAmount = validateMonetaryAmount;
|
|
191
|
+
exports.validateTIN = validateTIN;
|
|
192
|
+
exports.validateTaxCalculations = validateTaxCalculations;
|
|
100
193
|
//# sourceMappingURL=index40.cjs.map
|
package/dist/index40.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index40.cjs","names":[],"sources":["../src/types/msic/9X.d.ts"],"sourcesContent":["export type MSIC_9X_CODE =\n | '90001'\n | '90002'\n | '90003'\n | '90004'\n | '90005'\n | '90006'\n | '90007'\n | '90009'\n | '91011'\n | '91012'\n | '91021'\n | '91022'\n | '91031'\n | '91032'\n | '92000'\n | '93111'\n | '93112'\n | '93113'\n | '93114'\n | '93115'\n | '93116'\n | '93117'\n | '93118'\n | '93119'\n | '93120'\n | '93191'\n | '93192'\n | '93193'\n | '93199'\n | '93210'\n | '93291'\n | '93292'\n | '93293'\n | '93294'\n | '93295'\n | '93296'\n | '93297'\n | '93299'\n | '94110'\n | '94120'\n | '94200'\n | '94910'\n | '94920'\n | '94990'\n | '95111'\n | '95112'\n | '95113'\n | '95121'\n | '95122'\n | '95123'\n | '95124'\n | '95125'\n | '95126'\n | '95127'\n | '95211'\n | '95212'\n | '95213'\n | '95214'\n | '95221'\n | '95222'\n | '95230'\n | '95240'\n | '95291'\n | '95292'\n | '95293'\n | '95294'\n | '95295'\n | '95296'\n | '95299'\n | '96011'\n | '96012'\n | '96013'\n | '96014'\n | '96020'\n | '96031'\n | '96032'\n | '96033'\n | '96034'\n | '96035'\n | '96091'\n | '96092'\n | '96093'\n | '96094'\n | '96095'\n | '96096'\n | '96097'\n | '96099'\n | '97000'\n | '98100'\n | '98200'\n | '99000'\n\nexport enum MSIC_9X {\n THEATRICAL_PRODUCTION = '90001',\n CONCERT_HALLS = '90002',\n VISUAL_ARTISTS = '90003',\n WRITERS = '90004',\n JOURNALISTS = '90005',\n ART_RESTORATION = '90006',\n ARTS_EVENT_PRODUCTION = '90007',\n OTHER_CREATIVE_ARTS = '90009',\n LIBRARIES = '91011',\n PHOTO_LIBRARIES = '91012',\n MUSEUMS = '91021',\n HISTORICAL_SITES = '91022',\n BOTANICAL_ZOOLOGICAL = '91031',\n NATURE_RESERVES = '91032',\n GAMBLING = '92000',\n SPORTS_FACILITIES = '93111',\n AUTO_RACING = '93112',\n EQUESTRIAN = '93113',\n SWIMMING_FACILITIES = '93114',\n ATHLETICS_FACILITIES = '93115',\n GOLF_COURSES = '93116',\n BOWLING_CENTRES = '93117',\n FITNESS_CENTRES = '93118',\n SPORTS_EVENTS = '93119',\n SPORTS_CLUBS = '93120',\n SPORTS_PROMOTERS = '93191',\n SPORTS_REGULATORS = '93192',\n SPORTS_PROMOTION = '93193',\n OTHER_SPORTS = '93199',\n AMUSEMENT_PARKS = '93210',\n RECREATION_PARKS = '93291',\n RECREATIONAL_TRANSPORT = '93292',\n LEISURE_EQUIPMENT_RENTAL = '93293',\n RECREATIONAL_FAIRS = '93294',\n DISCOTHEQUES = '93295',\n EVENT_PRODUCTION = '93296',\n CYBER_CAFE = '93297',\n OTHER_RECREATION = '93299',\n BUSINESS_ORGANIZATIONS = '94110',\n PROFESSIONAL_ORGANIZATIONS = '94120',\n TRADE_UNIONS = '94200',\n RELIGIOUS_ORGANIZATIONS = '94910',\n POLITICAL_ORGANIZATIONS = '94920',\n OTHER_ORGANIZATIONS = '94990',\n ELECTRONIC_REPAIR = '95111',\n COMPUTER_REPAIR = '95112',\n PDA_REPAIR = '95113',\n CORDLESS_PHONE_REPAIR = '95121',\n MOBILE_PHONE_REPAIR = '95122',\n MODEM_REPAIR = '95123',\n FAX_REPAIR = '95124',\n COMMUNICATIONS_REPAIR = '95125',\n RADIO_REPAIR = '95126',\n CAMERA_REPAIR = '95127',\n TV_REPAIR = '95211',\n VIDEO_PLAYER_REPAIR = '95212',\n CD_PLAYER_REPAIR = '95213',\n VIDEO_CAMERA_REPAIR = '95214',\n APPLIANCE_REPAIR = '95221',\n GARDEN_EQUIPMENT_REPAIR = '95222',\n FOOTWEAR_REPAIR = '95230',\n FURNITURE_REPAIR = '95240',\n BICYCLE_REPAIR = '95291',\n CLOTHING_REPAIR = '95292',\n JEWELRY_REPAIR = '95293',\n WATCH_REPAIR = '95294',\n SPORTS_EQUIPMENT_REPAIR = '95295',\n MUSICAL_INSTRUMENT_REPAIR = '95296',\n OTHER_REPAIRS = '95299',\n LAUNDRY = '96011',\n CARPET_CLEANING = '96012',\n UNIFORM_RENTAL = '96013',\n DIAPER_SERVICE = '96014',\n BEAUTY_SERVICES = '96020',\n MORTUARY_SERVICES = '96031',\n FUNERAL_SERVICES = '96032',\n FUNERAL_PARLOUR_RENTAL = '96033',\n GRAVE_SALES = '96034',\n GRAVE_MAINTENANCE = '96035',\n WELLNESS_SERVICES = '96091',\n ASTROLOGY_SERVICES = '96092',\n DATING_SERVICES = '96093',\n PET_CARE = '96094',\n GENEALOGY = '96095',\n PERSONAL_SERVICES = '96096',\n VENDING_MACHINES = '96097',\n OTHER_SERVICES = '96099',\n DOMESTIC_PERSONNEL = '97000',\n HOUSEHOLD_GOODS_PRODUCTION = '98100',\n HOUSEHOLD_SERVICES = '98200',\n EXTRATERRITORIAL_ORGANIZATIONS = '99000',\n}\n"],"mappings":";;AA6FA,IAAY,8CAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACD"}
|
|
1
|
+
{"version":3,"file":"index40.cjs","names":["tin: string","registrationType?: string","errors: ValidationError[]","contactNumber: string","amount: number","fieldName: string","item: InvoiceLineItem","index: number","invoice: InvoiceV1_1","allErrors: ValidationError[]"],"sources":["../src/utils/validation.ts"],"sourcesContent":["import type { InvoiceV1_1, InvoiceLineItem } from '../types'\n\n/**\n * MyInvois Invoice Validation Utilities\n *\n * Provides comprehensive validation for invoice data before document generation\n * and submission to ensure compliance with MyInvois business rules and format requirements.\n */\n\nexport interface ValidationResult {\n isValid: boolean\n errors: ValidationError[]\n warnings: ValidationWarning[]\n}\n\nexport interface ValidationError {\n field: string\n code: string\n message: string\n severity: 'error' | 'warning'\n}\n\nexport interface ValidationWarning extends ValidationError {\n severity: 'warning'\n}\n\n/**\n * Validates TIN format based on registration type\n */\nexport const validateTIN = (\n tin: string,\n registrationType?: string,\n): ValidationError[] => {\n const errors: ValidationError[] = []\n\n if (!tin) {\n errors.push({\n field: 'tin',\n code: 'TIN_REQUIRED',\n message: 'TIN is required',\n severity: 'error',\n })\n return errors\n }\n\n // TIN format validation based on type\n if (registrationType === 'BRN' && !tin.startsWith('C')) {\n errors.push({\n field: 'tin',\n code: 'TIN_FORMAT_INVALID',\n message: 'Company TIN should start with \"C\" for BRN registration',\n severity: 'warning',\n })\n }\n\n if (registrationType === 'NRIC' && !tin.startsWith('IG')) {\n errors.push({\n field: 'tin',\n code: 'TIN_FORMAT_INVALID',\n message: 'Individual TIN should start with \"IG\" for NRIC registration',\n severity: 'warning',\n })\n }\n\n // Length validation\n if (tin.length > 14) {\n errors.push({\n field: 'tin',\n code: 'TIN_LENGTH_INVALID',\n message: 'TIN cannot exceed 14 characters',\n severity: 'error',\n })\n }\n\n return errors\n}\n\n/**\n * Validates contact number format (E.164 standard)\n */\nexport const validateContactNumber = (\n contactNumber: string,\n): ValidationError[] => {\n const errors: ValidationError[] = []\n\n if (!contactNumber || contactNumber === 'NA') {\n return errors // Allow NA for consolidated e-invoices\n }\n\n // E.164 format validation\n const e164Regex = /^\\+[1-9]\\d{1,14}$/\n if (!e164Regex.test(contactNumber)) {\n errors.push({\n field: 'contactNumber',\n code: 'CONTACT_FORMAT_INVALID',\n message: 'Contact number must be in E.164 format (e.g., +60123456789)',\n severity: 'error',\n })\n }\n\n if (contactNumber.length < 8) {\n errors.push({\n field: 'contactNumber',\n code: 'CONTACT_LENGTH_INVALID',\n message: 'Contact number must be at least 8 characters',\n severity: 'error',\n })\n }\n\n return errors\n}\n\n/**\n * Validates monetary amounts\n */\nexport const validateMonetaryAmount = (\n amount: number,\n fieldName: string,\n maxDigits = 18,\n maxDecimals = 2,\n): ValidationError[] => {\n const errors: ValidationError[] = []\n\n if (amount < 0) {\n errors.push({\n field: fieldName,\n code: 'AMOUNT_NEGATIVE',\n message: `${fieldName} cannot be negative`,\n severity: 'error',\n })\n }\n\n // Check total digits\n const amountStr = amount.toString()\n const [integerPart, decimalPart] = amountStr.split('.')\n\n if (integerPart && integerPart.length > maxDigits - maxDecimals) {\n errors.push({\n field: fieldName,\n code: 'AMOUNT_DIGITS_EXCEEDED',\n message: `${fieldName} exceeds maximum ${maxDigits} digits`,\n severity: 'error',\n })\n }\n\n if (decimalPart && decimalPart.length > maxDecimals) {\n errors.push({\n field: fieldName,\n code: 'AMOUNT_DECIMALS_EXCEEDED',\n message: `${fieldName} exceeds maximum ${maxDecimals} decimal places`,\n severity: 'error',\n })\n }\n\n return errors\n}\n\n/**\n * Validates line item tax calculation consistency for both fixed rate and percentage taxation\n */\nexport const validateLineItemTax = (\n item: InvoiceLineItem,\n index: number,\n): ValidationError[] => {\n const errors: ValidationError[] = []\n const tolerance = 0.01\n\n // Check if tax calculation method is specified\n const hasFixedRate =\n item.taxPerUnitAmount !== undefined && item.baseUnitMeasure !== undefined\n const hasPercentageRate = item.taxRate !== undefined\n\n if (!hasFixedRate && !hasPercentageRate) {\n errors.push({\n field: `lineItem[${index}]`,\n code: 'TAX_METHOD_MISSING',\n message: `Line item ${index + 1} must specify either taxRate (for percentage) or taxPerUnitAmount + baseUnitMeasure (for fixed rate)`,\n severity: 'error',\n })\n return errors\n }\n\n if (hasFixedRate && hasPercentageRate) {\n errors.push({\n field: `lineItem[${index}]`,\n code: 'TAX_METHOD_CONFLICT',\n message: `Line item ${index + 1} cannot have both percentage and fixed rate tax methods`,\n severity: 'error',\n })\n }\n\n // Validate fixed rate tax calculation\n if (hasFixedRate) {\n if (item.baseUnitMeasureCode === undefined) {\n errors.push({\n field: `lineItem[${index}].baseUnitMeasureCode`,\n code: 'UNIT_CODE_MISSING',\n message: `Line item ${index + 1} with fixed rate tax must specify baseUnitMeasureCode`,\n severity: 'error',\n })\n }\n\n const expectedTaxAmount = item.taxPerUnitAmount! * item.baseUnitMeasure!\n if (Math.abs(item.taxAmount - expectedTaxAmount) > tolerance) {\n errors.push({\n field: `lineItem[${index}].taxAmount`,\n code: 'FIXED_TAX_CALCULATION_MISMATCH',\n message: `Line item ${index + 1} tax amount (${item.taxAmount}) doesn't match fixed rate calculation (${item.taxPerUnitAmount} × ${item.baseUnitMeasure} = ${expectedTaxAmount})`,\n severity: 'error',\n })\n }\n }\n\n // Validate percentage tax calculation\n if (hasPercentageRate && !hasFixedRate) {\n const expectedTaxAmount =\n (item.totalTaxableAmountPerLine * item.taxRate!) / 100\n if (Math.abs(item.taxAmount - expectedTaxAmount) > tolerance) {\n errors.push({\n field: `lineItem[${index}].taxAmount`,\n code: 'PERCENTAGE_TAX_CALCULATION_MISMATCH',\n message: `Line item ${index + 1} tax amount (${item.taxAmount}) doesn't match percentage calculation (${item.totalTaxableAmountPerLine} × ${item.taxRate}% = ${expectedTaxAmount})`,\n severity: 'error',\n })\n }\n }\n\n return errors\n}\n\n/**\n * Validates tax calculation consistency\n */\nexport const validateTaxCalculations = (\n invoice: InvoiceV1_1,\n): ValidationError[] => {\n const errors: ValidationError[] = []\n\n // Validate individual line item tax calculations\n invoice.invoiceLineItems.forEach((item, index) => {\n errors.push(...validateLineItemTax(item, index))\n })\n\n // Calculate expected totals from line items\n const expectedTaxExclusive = invoice.invoiceLineItems.reduce(\n (sum, item) => sum + item.totalTaxableAmountPerLine,\n 0,\n )\n const expectedTaxAmount = invoice.invoiceLineItems.reduce(\n (sum, item) => sum + item.taxAmount,\n 0,\n )\n\n // Allow small rounding differences (0.01)\n const tolerance = 0.01\n\n if (\n Math.abs(\n invoice.legalMonetaryTotal.taxExclusiveAmount - expectedTaxExclusive,\n ) > tolerance\n ) {\n errors.push({\n field: 'legalMonetaryTotal.taxExclusiveAmount',\n code: 'TAX_EXCLUSIVE_MISMATCH',\n message: `Tax exclusive amount (${invoice.legalMonetaryTotal.taxExclusiveAmount}) doesn't match sum of line items (${expectedTaxExclusive})`,\n severity: 'error',\n })\n }\n\n if (Math.abs(invoice.taxTotal.taxAmount - expectedTaxAmount) > tolerance) {\n errors.push({\n field: 'taxTotal.taxAmount',\n code: 'TAX_AMOUNT_MISMATCH',\n message: `Tax amount (${invoice.taxTotal.taxAmount}) doesn't match sum of line item taxes (${expectedTaxAmount})`,\n severity: 'error',\n })\n }\n\n return errors\n}\n\n/**\n * Main validation function for complete invoice\n */\nexport const validateInvoice = (invoice: InvoiceV1_1): ValidationResult => {\n const allErrors: ValidationError[] = []\n\n // Core field validations\n allErrors.push(\n ...validateTIN(invoice.supplier.tin, invoice.supplier.registrationType),\n )\n allErrors.push(\n ...validateTIN(invoice.buyer.tin, invoice.buyer.registrationType),\n )\n\n allErrors.push(...validateContactNumber(invoice.supplier.contactNumber))\n allErrors.push(...validateContactNumber(invoice.buyer.contactNumber))\n\n // Monetary validations\n allErrors.push(\n ...validateMonetaryAmount(\n invoice.legalMonetaryTotal.taxExclusiveAmount,\n 'taxExclusiveAmount',\n ),\n )\n allErrors.push(\n ...validateMonetaryAmount(\n invoice.legalMonetaryTotal.payableAmount,\n 'payableAmount',\n ),\n )\n allErrors.push(\n ...validateMonetaryAmount(invoice.taxTotal.taxAmount, 'taxAmount'),\n )\n\n // Line item validations\n invoice.invoiceLineItems.forEach((item, index) => {\n allErrors.push(\n ...validateMonetaryAmount(item.unitPrice, `lineItem[${index}].unitPrice`),\n )\n allErrors.push(\n ...validateMonetaryAmount(item.taxAmount, `lineItem[${index}].taxAmount`),\n )\n allErrors.push(\n ...validateMonetaryAmount(\n item.totalTaxableAmountPerLine,\n `lineItem[${index}].totalTaxableAmountPerLine`,\n ),\n )\n })\n\n // Business rule validations\n allErrors.push(...validateTaxCalculations(invoice))\n\n // Separate errors and warnings\n const errors = allErrors.filter(e => e.severity === 'error')\n const warnings = allErrors.filter(\n e => e.severity === 'warning',\n ) as ValidationWarning[]\n\n return {\n isValid: errors.length === 0,\n errors,\n warnings,\n }\n}\n"],"mappings":"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"}
|
package/dist/index71.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index71.cts","names":[],"sources":["../src/utils/document.d.ts"],"sourcesContent":["import { InvoiceSubmission, AllDocumentsV1_1, SigningCredentials, SignedPropertiesObject, UBLDocument, CompleteInvoice, SignedInfoObject, UnitTypeCode, InvoiceLineItem } from '../types';\nimport type { ClassificationCode } from '../types';\nimport type { TaxTypeCode } from '../types';\n/**\n * MyInvois v1.1 Document Generation and Signing Utilities\n * Strictly follows: https://sdk.myinvois.hasil.gov.my/documents/invoice-v1-1\n * JSON Signature Guide: https://sdk.myinvois.hasil.gov.my/signature-creation-json/\n */\n/**\n * Determines if a line item uses fixed rate taxation\n */\nexport declare const isFixedRateTax: (item: InvoiceLineItem) => boolean;\n/**\n * Determines if a line item uses percentage taxation\n */\nexport declare const isPercentageTax: (item: InvoiceLineItem) => boolean;\n/**\n * Calculates expected tax amount for a line item based on its tax type\n */\nexport declare const calculateExpectedTaxAmount: (item: InvoiceLineItem) => number;\n/**\n * Helper function to recursively sort object keys for JSON canonicalization\n */\nexport declare function sortObjectKeys(obj: unknown): unknown;\n/**\n * Enhanced canonicalization following MyInvois specification exactly\n * Key changes: ensure consistent ordering and formatting\n */\nexport declare const canonicalizeJSON: (obj: unknown) => string;\n/**\n * Generates a clean invoice object following MyInvois v1.1 specification exactly\n * This is the base invoice structure WITHOUT signature elements (for hash calculation)\n *\n * Key requirements from working documents:\n * - All mandatory fields must be present\n * - Many optional fields must be present even if empty\n * - Specific field ordering and structure\n * - Correct listID values (e.g., \"3166-1\" not \"ISO3166-1\")\n */\nexport declare const generateCleanInvoiceObject: (invoice: AllDocumentsV1_1) => InvoiceSubmission;\n/**\n * Generates the complete UBL document structure with namespace declarations\n */\nexport declare const generateCleanUBLDocument: (invoices: AllDocumentsV1_1[]) => UBLDocument;\n/**\n * Step 1: Transform the document for hashing or transmission\n * Removes UBLExtensions and Signature, and minifies the JSON\n * Returns the minified, cleaned JSON string\n *\n * FIXED: Use regex-based minification to match PowerShell script exactly\n */\nexport declare const transformDocumentForHashing: (invoices: AllDocumentsV1_1[]) => string;\n/**\n * Step 2: Calculate Document Digest\n * FIXED: Remove UBLExtensions and Signature before hashing (DS322)\n * Based on working implementation pattern\n */\nexport declare const calculateDocumentDigest: (invoices: AllDocumentsV1_1[]) => string;\n/**\n * Step 4: Calculate Certificate Digest\n * Enhanced to handle certificate content properly\n * FIXED: Match PowerShell script exactly - use raw certificate data like $cert.RawData\n */\nexport declare const calculateCertificateDigest: (certificatePem: string) => string;\n/**\n * Enhanced certificate info extraction with better error handling\n * FIXED: Normalize issuer name format to match MyInvois expectations (DS326)\n */\nexport declare const extractCertificateInfo: (certificatePem: string) => {\n issuerName: string;\n serialNumber: string;\n subjectName: string;\n};\n/**\n * Step 5: Create SignedProperties with enhanced structure\n * FIXED: Simplified structure to match MyInvois expectations (DS320)\n * Following MyInvois JSON signature specification exactly\n */\nexport declare const createSignedProperties: (certificateDigest: string, signingTime: string, issuerName: string, serialNumber: string) => SignedPropertiesObject;\n/**\n * Step 6: Calculate SignedProperties Digest\n * Calculates the digest over the correct structure for validator compliance.\n * FIXED: Calculate digest from SignedProperties only (without Target wrapper)\n */\nexport declare const calculateSignedPropertiesDigest: (signedProperties: SignedPropertiesObject, useTargetWrapper?: boolean) => string;\n/**\n * Step 3: Create SignedInfo and calculate signature\n * Enhanced with better structure and signature generation\n */\nexport declare const createSignedInfoAndSign: (docDigest: string, propsDigest: string, privateKeyPem: string) => {\n signedInfo: SignedInfoObject;\n signatureValue: string;\n};\n/**\n * Signs the minified document string using the provided private key PEM\n * Returns the signature as a base64 string\n * FIXED: Match PowerShell script exactly - first compute hash, then sign the hash\n */\nexport declare const signDocumentString: (documentString: string, privateKeyPem: string) => string;\n/**\n * Complete document generation with signatures\n * Follows the complete MyInvois JSON signature creation process (Steps 1-7)\n */\nexport declare const generateCompleteDocument: (invoices: AllDocumentsV1_1[], signingCredentials: SigningCredentials) => CompleteInvoice;\n/**\n * Creates a line item with percentage-based taxation (e.g., SST, GST)\n */\nexport declare const createPercentageTaxLineItem: (params: {\n itemClassificationCode: ClassificationCode;\n itemDescription: string;\n unitPrice: number;\n quantity?: number;\n taxType: TaxTypeCode;\n taxRate: number;\n totalTaxableAmountPerLine?: number;\n}) => InvoiceLineItem;\n/**\n * Creates a line item with fixed rate taxation (e.g., Tourism Tax)\n */\nexport declare const createFixedRateTaxLineItem: (params: {\n itemClassificationCode: ClassificationCode;\n itemDescription: string;\n unitPrice: number;\n quantity?: number;\n taxType: TaxTypeCode;\n taxPerUnitAmount: number;\n baseUnitMeasure: number;\n baseUnitMeasureCode: UnitTypeCode;\n totalTaxableAmountPerLine?: number;\n}) => InvoiceLineItem;\n/**\n * Calculates invoice totals from line items\n */\nexport declare const calculateInvoiceTotals: (lineItems: InvoiceLineItem[]) => {\n legalMonetaryTotal: {\n taxExclusiveAmount: number;\n taxInclusiveAmount: number;\n payableAmount: number;\n };\n taxTotal: {\n taxAmount: number;\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAE,iBAAA,CAAA,KAAA,MAAA,eAAA;AACF,IAAW,kBAAkB,CAAC,KAAK,MAAM,eAAgB;AACzD,IAAW,6BAA6B,CAAC,KAAK,MAAM,eAAgB;AACpE,IAAW,iBAAiB,CAAC,GAAI;AACjC,IAAE,mBAAA,CAAA,GAAA;AACF,IAAE,6BAAA;CAAA;CAAA,MAAA;CAAA,MAAA;AAAA;AACF,IAAW,2BAA2B;CAAC;CAAK,MAAM;CAAE,MAAA;AAAA;AACpD,IAAE,8BAAA,CAAA,KAAA,MAAA,gBAAA;AACF,IAAW,0BAA0B,CAAC,KAAK,MAAM,gBAAiB;AAClE,IAAE,6BAAA,CAAA,GAAA;AACF,IAAW,yBAAyB,CAAC,GAAI;AACzC,IAAE,yBAAA,CAAA,KAAA,MAAA,sBAAA;AACF,IAAW,kCAAkC,CAAC,KAAK,MAAM,sBAAe;AACxE,IAAE,0BAAA,CAAA,KAAA,MAAA,gBAAA;AACF,IAAW,qBAAqB,CAAC,GAAI;AACrC,IAAE,2BAAA;CAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;AAAA;AACF,IAAW,8BAA8B;CAAC;CAAK,MAAM;CAAoB,MAAM;CAAG,MAAA;AAAA;AAClF,IAAE,6BAAA;CAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;AAAA;AACF,IAAW,yBAAyB,CAAC,KAAK,MAAM,eAAgB"}
|
|
1
|
+
{"version":3,"file":"index71.cts","names":[],"sources":["../src/utils/document.d.ts"],"sourcesContent":["import { InvoiceSubmission, AllDocumentsV1_1, SigningCredentials, SignedPropertiesObject, UBLDocument, CompleteInvoice, SignedInfoObject, UnitTypeCode, InvoiceLineItem } from '../types';\nimport type { ClassificationCode } from '../types';\nimport type { TaxTypeCode } from '../types';\n/**\n * MyInvois v1.1 Document Generation and Signing Utilities\n * Strictly follows: https://sdk.myinvois.hasil.gov.my/documents/invoice-v1-1\n * JSON Signature Guide: https://sdk.myinvois.hasil.gov.my/signature-creation-json/\n */\n/**\n * Determines if a line item uses fixed rate taxation\n */\nexport declare const isFixedRateTax: (item: InvoiceLineItem) => boolean;\n/**\n * Determines if a line item uses percentage taxation\n */\nexport declare const isPercentageTax: (item: InvoiceLineItem) => boolean;\n/**\n * Calculates expected tax amount for a line item based on its tax type\n */\nexport declare const calculateExpectedTaxAmount: (item: InvoiceLineItem) => number;\n/**\n * Helper function to recursively sort object keys for JSON canonicalization\n */\nexport declare function sortObjectKeys(obj: unknown): unknown;\n/**\n * Enhanced canonicalization following MyInvois specification exactly\n * Key changes: ensure consistent ordering and formatting\n */\nexport declare const canonicalizeJSON: (obj: unknown) => string;\n/**\n * Generates a clean invoice object following MyInvois v1.1 specification exactly\n * This is the base invoice structure WITHOUT signature elements (for hash calculation)\n *\n * Key requirements from working documents:\n * - All mandatory fields must be present\n * - Many optional fields must be present even if empty\n * - Specific field ordering and structure\n * - Correct listID values (e.g., \"3166-1\" not \"ISO3166-1\")\n */\nexport declare const generateCleanInvoiceObject: (invoice: AllDocumentsV1_1) => InvoiceSubmission;\n/**\n * Generates the complete UBL document structure with namespace declarations\n */\nexport declare const generateCleanUBLDocument: (invoices: AllDocumentsV1_1[]) => UBLDocument;\n/**\n * Step 1: Transform the document for hashing or transmission\n * Removes UBLExtensions and Signature, and minifies the JSON\n * Returns the minified, cleaned JSON string\n *\n * FIXED: Use regex-based minification to match PowerShell script exactly\n */\nexport declare const transformDocumentForHashing: (invoices: AllDocumentsV1_1[]) => string;\n/**\n * Step 2: Calculate Document Digest\n * FIXED: Remove UBLExtensions and Signature before hashing (DS322)\n * Based on working implementation pattern\n */\nexport declare const calculateDocumentDigest: (invoices: AllDocumentsV1_1[]) => string;\n/**\n * Step 4: Calculate Certificate Digest\n * Enhanced to handle certificate content properly\n * FIXED: Match PowerShell script exactly - use raw certificate data like $cert.RawData\n */\nexport declare const calculateCertificateDigest: (certificatePem: string) => string;\n/**\n * Enhanced certificate info extraction with better error handling\n * FIXED: Normalize issuer name format to match MyInvois expectations (DS326)\n */\nexport declare const extractCertificateInfo: (certificatePem: string) => {\n issuerName: string;\n serialNumber: string;\n subjectName: string;\n};\n/**\n * Step 5: Create SignedProperties with enhanced structure\n * FIXED: Simplified structure to match MyInvois expectations (DS320)\n * Following MyInvois JSON signature specification exactly\n */\nexport declare const createSignedProperties: (certificateDigest: string, signingTime: string, issuerName: string, serialNumber: string) => SignedPropertiesObject;\n/**\n * Step 6: Calculate SignedProperties Digest\n * Calculates the digest over the correct structure for validator compliance.\n * FIXED: Calculate digest from SignedProperties only (without Target wrapper)\n */\nexport declare const calculateSignedPropertiesDigest: (signedProperties: SignedPropertiesObject, useTargetWrapper?: boolean) => string;\n/**\n * Step 3: Create SignedInfo and calculate signature\n * Enhanced with better structure and signature generation\n */\nexport declare const createSignedInfoAndSign: (docDigest: string, propsDigest: string, privateKeyPem: string) => {\n signedInfo: SignedInfoObject;\n signatureValue: string;\n};\n/**\n * Signs the minified document string using the provided private key PEM\n * Returns the signature as a base64 string\n * FIXED: Match PowerShell script exactly - first compute hash, then sign the hash\n */\nexport declare const signDocumentString: (documentString: string, privateKeyPem: string) => string;\n/**\n * Complete document generation with signatures\n * Follows the complete MyInvois JSON signature creation process (Steps 1-7)\n */\nexport declare const generateCompleteDocument: (invoices: AllDocumentsV1_1[], signingCredentials: SigningCredentials) => CompleteInvoice;\n/**\n * Creates a line item with percentage-based taxation (e.g., SST, GST)\n */\nexport declare const createPercentageTaxLineItem: (params: {\n itemClassificationCode: ClassificationCode;\n itemDescription: string;\n unitPrice: number;\n quantity?: number;\n taxType: TaxTypeCode;\n taxRate: number;\n totalTaxableAmountPerLine?: number;\n discountAmount?: number;\n discountRate?: number;\n}) => InvoiceLineItem;\n/**\n * Creates a line item with fixed rate taxation (e.g., Tourism Tax)\n */\nexport declare const createFixedRateTaxLineItem: (params: {\n itemClassificationCode: ClassificationCode;\n itemDescription: string;\n unitPrice: number;\n quantity?: number;\n taxType: TaxTypeCode;\n taxPerUnitAmount: number;\n baseUnitMeasure: number;\n baseUnitMeasureCode: UnitTypeCode;\n totalTaxableAmountPerLine?: number;\n discountAmount?: number;\n discountRate?: number;\n}) => InvoiceLineItem;\n/**\n * Calculates invoice totals from line items\n */\nexport declare const calculateInvoiceTotals: (lineItems: InvoiceLineItem[]) => {\n legalMonetaryTotal: {\n taxExclusiveAmount: number;\n taxInclusiveAmount: number;\n payableAmount: number;\n };\n taxTotal: {\n taxAmount: number;\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAE,iBAAA,CAAA,KAAA,MAAA,eAAA;AACF,IAAW,kBAAkB,CAAC,KAAK,MAAM,eAAgB;AACzD,IAAW,6BAA6B,CAAC,KAAK,MAAM,eAAgB;AACpE,IAAW,iBAAiB,CAAC,GAAI;AACjC,IAAE,mBAAA,CAAA,GAAA;AACF,IAAE,6BAAA;CAAA;CAAA,MAAA;CAAA,MAAA;AAAA;AACF,IAAW,2BAA2B;CAAC;CAAK,MAAM;CAAE,MAAA;AAAA;AACpD,IAAE,8BAAA,CAAA,KAAA,MAAA,gBAAA;AACF,IAAW,0BAA0B,CAAC,KAAK,MAAM,gBAAiB;AAClE,IAAE,6BAAA,CAAA,GAAA;AACF,IAAW,yBAAyB,CAAC,GAAI;AACzC,IAAE,yBAAA,CAAA,KAAA,MAAA,sBAAA;AACF,IAAW,kCAAkC,CAAC,KAAK,MAAM,sBAAe;AACxE,IAAE,0BAAA,CAAA,KAAA,MAAA,gBAAA;AACF,IAAW,qBAAqB,CAAC,GAAI;AACrC,IAAE,2BAAA;CAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;AAAA;AACF,IAAW,8BAA8B;CAAC;CAAK,MAAM;CAAoB,MAAM;CAAG,MAAA;AAAA;AAClF,IAAE,6BAAA;CAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;AAAA;AACF,IAAW,yBAAyB,CAAC,KAAK,MAAM,eAAgB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MSICCode } from "./msic-codes-CIKdPqag.cjs";
|
|
2
|
-
import { RegistrationType } from "./documents-
|
|
2
|
+
import { RegistrationType } from "./documents-DCZ3Ffya.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/types/taxpayer.d.ts
|
|
5
5
|
interface TaxpayerQRCodeResponse {
|
|
@@ -32,4 +32,4 @@ interface TinSearchResponse {
|
|
|
32
32
|
}
|
|
33
33
|
//#endregion
|
|
34
34
|
export { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse };
|
|
35
|
-
//# sourceMappingURL=taxpayer-
|
|
35
|
+
//# sourceMappingURL=taxpayer-Pm90MrPj.d.cts.map
|
|
@@ -51,5 +51,5 @@ import "../YX-F34sJ7Ik.js";
|
|
|
51
51
|
import "../ZX-CDQOfsHh.js";
|
|
52
52
|
import "../XX-DOA-10JW.js";
|
|
53
53
|
import "../unit-types-VgYXIwTT.js";
|
|
54
|
-
import { Address, AllDocumentsV1_1, Buyer, CompleteInvoice, CreditNoteV1_1, DebitNoteV1_1, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RefundNoteV1_1, RegistrationType, ResponseDocument, SelfBilledCreditNoteV1_1, SelfBilledInvoiceV1_1, SelfBilledRefundNoteV1_1, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter } from "../documents-
|
|
54
|
+
import { Address, AllDocumentsV1_1, Buyer, CompleteInvoice, CreditNoteV1_1, DebitNoteV1_1, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RefundNoteV1_1, RegistrationType, ResponseDocument, SelfBilledCreditNoteV1_1, SelfBilledInvoiceV1_1, SelfBilledRefundNoteV1_1, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter } from "../documents-DzZA3NHj.js";
|
|
55
55
|
export { Address, AllDocumentsV1_1, Buyer, CompleteInvoice, CreditNoteV1_1, DebitNoteV1_1, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RefundNoteV1_1, RegistrationType, ResponseDocument, SelfBilledCreditNoteV1_1, SelfBilledInvoiceV1_1, SelfBilledRefundNoteV1_1, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -51,11 +51,11 @@ import "../YX-F34sJ7Ik.js";
|
|
|
51
51
|
import "../ZX-CDQOfsHh.js";
|
|
52
52
|
import "../XX-DOA-10JW.js";
|
|
53
53
|
import { UnitType, UnitTypeCode } from "../unit-types-VgYXIwTT.js";
|
|
54
|
-
import { Address, AllDocumentsV1_1, Buyer, CompleteInvoice, CreditNoteV1_1, DebitNoteV1_1, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RefundNoteV1_1, RegistrationType, ResponseDocument, SelfBilledCreditNoteV1_1, SelfBilledInvoiceV1_1, SelfBilledRefundNoteV1_1, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter } from "../documents-
|
|
54
|
+
import { Address, AllDocumentsV1_1, Buyer, CompleteInvoice, CreditNoteV1_1, DebitNoteV1_1, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RefundNoteV1_1, RegistrationType, ResponseDocument, SelfBilledCreditNoteV1_1, SelfBilledInvoiceV1_1, SelfBilledRefundNoteV1_1, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter } from "../documents-DzZA3NHj.js";
|
|
55
55
|
import { PaymentMode, PaymentModeCode, PaymentModeCodeEnum } from "../payment-modes-g3DzLmWb.js";
|
|
56
56
|
import { CanonicalizationMethod, Cert, CertDigest, DigestMethod, IssuerDigitalSignature, IssuerSerial, KeyInfo, QualifyingProperties, Reference, SignatureMethod, SignedInfo, SignedProperties, SignedSignatureProperties, SigningCertificate, Transform, X509Data } from "../signatures-CerHUrj3.js";
|
|
57
57
|
import { Notification, NotificationDeliveryAttempt, NotificationMetadata, NotificationResponse, NotificationSearchParams, NotificationStatus, NotificationStatusEnum, NotificationType, NotificationTypeEnum } from "../notifications-sFhgh3rJ.js";
|
|
58
|
-
import { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from "../taxpayer-
|
|
58
|
+
import { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from "../taxpayer-DmHW0m7o.js";
|
|
59
59
|
import { Fetch } from "../utils-C4FoVKLq.js";
|
|
60
60
|
import { ClientCredentials, TokenResponse } from "../index-CygwSf0x.js";
|
|
61
61
|
export { Address, AllDocumentsV1_1, Buyer, CanonicalizationMethod, Cert, CertDigest, Classification, ClassificationCode, ClassificationCodeEnum, ClientCredentials, CompleteInvoice, Country, CountryCode, CountryCodeEnum, CountryNameEnum, CreditNoteV1_1, Currency, CurrencyCode, CurrencyCodeEnum, DebitNoteV1_1, DigestMethod, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, EInvoiceType, EInvoiceTypeCode, EInvoiceTypeCodeEnum, Fetch, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, IssuerDigitalSignature, IssuerSerial, KeyInfo, LegalMonetaryTotal, MSICCode, Notification, NotificationDeliveryAttempt, NotificationMetadata, NotificationResponse, NotificationSearchParams, NotificationStatus, NotificationStatusEnum, NotificationType, NotificationTypeEnum, PaymentMode, PaymentModeCode, PaymentModeCodeEnum, QualifyingProperties, Reference, RefundNoteV1_1, RegistrationType, ResponseDocument, SelfBilledCreditNoteV1_1, SelfBilledInvoiceV1_1, SelfBilledRefundNoteV1_1, SignatureMethod, SignedInfo, SignedInfoObject, SignedInvoiceSubmission, SignedProperties, SignedPropertiesData, SignedPropertiesObject, SignedSignatureProperties, SigningCertificate, SigningCredentials, StandardError, State, StateCode, StateCodeEnum, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, TaxType, TaxTypeCode, TaxTypeCodeEnum, TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse, TokenResponse, Transform, UBLDocument, UnitType, UnitTypeCode, WorkflowParameter, X509Data };
|
package/dist/types/taxpayer.d.ts
CHANGED
|
@@ -51,6 +51,6 @@ import "../YX-F34sJ7Ik.js";
|
|
|
51
51
|
import "../ZX-CDQOfsHh.js";
|
|
52
52
|
import "../XX-DOA-10JW.js";
|
|
53
53
|
import "../unit-types-VgYXIwTT.js";
|
|
54
|
-
import "../documents-
|
|
55
|
-
import { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from "../taxpayer-
|
|
54
|
+
import "../documents-DzZA3NHj.js";
|
|
55
|
+
import { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from "../taxpayer-DmHW0m7o.js";
|
|
56
56
|
export { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse };
|
package/dist/utils/document.d.ts
CHANGED
|
@@ -51,11 +51,11 @@ import "../YX-F34sJ7Ik.js";
|
|
|
51
51
|
import "../ZX-CDQOfsHh.js";
|
|
52
52
|
import "../XX-DOA-10JW.js";
|
|
53
53
|
import { UnitTypeCode } from "../unit-types-VgYXIwTT.js";
|
|
54
|
-
import { AllDocumentsV1_1, CompleteInvoice, InvoiceLineItem, InvoiceSubmission, SignedInfoObject, SignedPropertiesObject, SigningCredentials, UBLDocument } from "../documents-
|
|
54
|
+
import { AllDocumentsV1_1, CompleteInvoice, InvoiceLineItem, InvoiceSubmission, SignedInfoObject, SignedPropertiesObject, SigningCredentials, UBLDocument } from "../documents-DzZA3NHj.js";
|
|
55
55
|
import "../payment-modes-g3DzLmWb.js";
|
|
56
56
|
import "../signatures-CerHUrj3.js";
|
|
57
57
|
import "../notifications-sFhgh3rJ.js";
|
|
58
|
-
import "../taxpayer-
|
|
58
|
+
import "../taxpayer-DmHW0m7o.js";
|
|
59
59
|
import "../utils-C4FoVKLq.js";
|
|
60
60
|
import "../index-CygwSf0x.js";
|
|
61
61
|
|
|
@@ -172,6 +172,8 @@ declare const createPercentageTaxLineItem: (params: {
|
|
|
172
172
|
taxType: TaxTypeCode;
|
|
173
173
|
taxRate: number;
|
|
174
174
|
totalTaxableAmountPerLine?: number;
|
|
175
|
+
discountAmount?: number;
|
|
176
|
+
discountRate?: number;
|
|
175
177
|
}) => InvoiceLineItem;
|
|
176
178
|
/**
|
|
177
179
|
* Creates a line item with fixed rate taxation (e.g., Tourism Tax)
|
|
@@ -186,6 +188,8 @@ declare const createFixedRateTaxLineItem: (params: {
|
|
|
186
188
|
baseUnitMeasure: number;
|
|
187
189
|
baseUnitMeasureCode: UnitTypeCode;
|
|
188
190
|
totalTaxableAmountPerLine?: number;
|
|
191
|
+
discountAmount?: number;
|
|
192
|
+
discountRate?: number;
|
|
189
193
|
}) => InvoiceLineItem;
|
|
190
194
|
/**
|
|
191
195
|
* Calculates invoice totals from line items
|
package/dist/utils/document.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../formatIdValue-qTxJqj9o.js";
|
|
2
|
-
import { calculateCertificateDigest, calculateDocumentDigest, calculateExpectedTaxAmount, calculateInvoiceTotals, calculateSignedPropertiesDigest, canonicalizeJSON, createFixedRateTaxLineItem, createPercentageTaxLineItem, createSignedInfoAndSign, createSignedProperties, extractCertificateInfo, generateCleanInvoiceObject, generateCleanUBLDocument, generateCompleteDocument, isFixedRateTax, isPercentageTax, signDocumentString, sortObjectKeys, transformDocumentForHashing } from "../document-
|
|
2
|
+
import { calculateCertificateDigest, calculateDocumentDigest, calculateExpectedTaxAmount, calculateInvoiceTotals, calculateSignedPropertiesDigest, canonicalizeJSON, createFixedRateTaxLineItem, createPercentageTaxLineItem, createSignedInfoAndSign, createSignedProperties, extractCertificateInfo, generateCleanInvoiceObject, generateCleanUBLDocument, generateCompleteDocument, isFixedRateTax, isPercentageTax, signDocumentString, sortObjectKeys, transformDocumentForHashing } from "../document-DLFdGSK1.js";
|
|
3
3
|
|
|
4
4
|
export { calculateCertificateDigest, calculateDocumentDigest, calculateExpectedTaxAmount, calculateInvoiceTotals, calculateSignedPropertiesDigest, canonicalizeJSON, createFixedRateTaxLineItem, createPercentageTaxLineItem, createSignedInfoAndSign, createSignedProperties, extractCertificateInfo, generateCleanInvoiceObject, generateCleanUBLDocument, generateCompleteDocument, isFixedRateTax, isPercentageTax, signDocumentString, sortObjectKeys, transformDocumentForHashing };
|
|
@@ -51,11 +51,11 @@ import "../YX-F34sJ7Ik.js";
|
|
|
51
51
|
import "../ZX-CDQOfsHh.js";
|
|
52
52
|
import "../XX-DOA-10JW.js";
|
|
53
53
|
import "../unit-types-VgYXIwTT.js";
|
|
54
|
-
import { InvoiceV1_1 } from "../documents-
|
|
54
|
+
import { InvoiceV1_1 } from "../documents-DzZA3NHj.js";
|
|
55
55
|
import "../payment-modes-g3DzLmWb.js";
|
|
56
56
|
import "../signatures-CerHUrj3.js";
|
|
57
57
|
import "../notifications-sFhgh3rJ.js";
|
|
58
|
-
import "../taxpayer-
|
|
58
|
+
import "../taxpayer-DmHW0m7o.js";
|
|
59
59
|
import "../utils-C4FoVKLq.js";
|
|
60
60
|
import "../index-CygwSf0x.js";
|
|
61
61
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../formatIdValue-qTxJqj9o.js";
|
|
2
|
-
import { calculateCertificateDigest, calculateDocumentDigest, calculateSignedPropertiesDigest, createSignedProperties, extractCertificateInfo } from "../document-
|
|
2
|
+
import { calculateCertificateDigest, calculateDocumentDigest, calculateSignedPropertiesDigest, createSignedProperties, extractCertificateInfo } from "../document-DLFdGSK1.js";
|
|
3
3
|
import crypto from "crypto";
|
|
4
4
|
|
|
5
5
|
//#region src/utils/signature-diagnostics.ts
|
|
@@ -51,11 +51,11 @@ import "../YX-F34sJ7Ik.js";
|
|
|
51
51
|
import "../ZX-CDQOfsHh.js";
|
|
52
52
|
import "../XX-DOA-10JW.js";
|
|
53
53
|
import "../unit-types-VgYXIwTT.js";
|
|
54
|
-
import { InvoiceLineItem, InvoiceV1_1 } from "../documents-
|
|
54
|
+
import { InvoiceLineItem, InvoiceV1_1 } from "../documents-DzZA3NHj.js";
|
|
55
55
|
import "../payment-modes-g3DzLmWb.js";
|
|
56
56
|
import "../signatures-CerHUrj3.js";
|
|
57
57
|
import "../notifications-sFhgh3rJ.js";
|
|
58
|
-
import "../taxpayer-
|
|
58
|
+
import "../taxpayer-DmHW0m7o.js";
|
|
59
59
|
import "../utils-C4FoVKLq.js";
|
|
60
60
|
import "../index-CygwSf0x.js";
|
|
61
61
|
|