@ripwords/myinvois-client 0.2.9 → 0.2.11
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/documentSubmission.js +1 -1
- package/dist/api/platformLogin.js +1 -1
- package/dist/api/taxpayerValidation.js +1 -1
- package/dist/{documentSubmission-DGviQ6GN.js → documentSubmission-BPDiODUd.js} +35 -22
- package/dist/{documentSubmission-BzNsx6qa.cjs → documentSubmission-DvCgvq28.cjs} +36 -23
- package/dist/documentSubmission-DvCgvq28.cjs.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.js +3 -3
- package/dist/index23.cjs +204 -9
- package/dist/index23.cjs.map +1 -1
- package/dist/index24.cjs +108 -3
- package/dist/index24.cjs.map +1 -0
- package/dist/index25.cjs +136 -19
- package/dist/index25.cjs.map +1 -0
- package/dist/index26.cjs +63 -2
- package/dist/index26.cjs.map +1 -0
- package/dist/index27.cjs +266 -2
- package/dist/{index34.cjs.map → index27.cjs.map} +1 -1
- package/dist/index28.cjs +75 -326
- package/dist/index28.cjs.map +1 -1
- package/dist/index29.cjs +103 -189
- package/dist/index29.cjs.map +1 -1
- package/dist/index3.cjs +1 -1
- package/dist/index30.cjs +68 -203
- package/dist/index30.cjs.map +1 -1
- package/dist/index31.cjs +107 -104
- package/dist/index31.cjs.map +1 -1
- package/dist/index32.cjs +95 -132
- package/dist/index32.cjs.map +1 -1
- package/dist/index33.cjs +9 -60
- package/dist/index33.cjs.map +1 -1
- package/dist/index34.cjs +3 -266
- package/dist/index35.cjs +19 -78
- package/dist/index36.cjs +2 -106
- package/dist/index37.cjs +2 -72
- package/dist/index38.cjs +326 -108
- package/dist/index38.cjs.map +1 -1
- package/dist/index39.cjs +189 -96
- package/dist/index39.cjs.map +1 -1
- package/dist/index6.cjs +1 -1
- package/dist/index7.cjs +1 -1
- package/dist/{platformLogin-7RwW1qjT.cjs → platformLogin-Ch6hFKoU.cjs} +10 -1
- package/dist/platformLogin-Ch6hFKoU.cjs.map +1 -0
- package/dist/{platformLogin-2sZ4O_lY.js → platformLogin-CqI9OLYP.js} +9 -0
- package/dist/{taxpayerValidation-B5548fbY.cjs → taxpayerValidation-D_jGaVty.cjs} +3 -2
- package/dist/{taxpayerValidation-B5548fbY.cjs.map → taxpayerValidation-D_jGaVty.cjs.map} +1 -1
- package/dist/{taxpayerValidation-Dpk228M0.js → taxpayerValidation-y6P-Es0S.js} +2 -1
- package/package.json +1 -1
- package/dist/documentSubmission-BzNsx6qa.cjs.map +0 -1
- package/dist/index35.cjs.map +0 -1
- package/dist/index36.cjs.map +0 -1
- package/dist/index37.cjs.map +0 -1
- package/dist/platformLogin-7RwW1qjT.cjs.map +0 -1
package/dist/index39.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=index39.cjs.map
|
package/dist/index39.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index39.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":"index39.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":";;;;;AA6BA,MAAa,cAAc,CACzBA,KACAC,qBACsB;CACtB,MAAMC,SAA4B,CAAE;AAEpC,MAAK,KAAK;AACR,SAAO,KAAK;GACV,OAAO;GACP,MAAM;GACN,SAAS;GACT,UAAU;EACX,EAAC;AACF,SAAO;CACR;AAGD,KAAI,qBAAqB,UAAU,IAAI,WAAW,IAAI,CACpD,QAAO,KAAK;EACV,OAAO;EACP,MAAM;EACN,SAAS;EACT,UAAU;CACX,EAAC;AAGJ,KAAI,qBAAqB,WAAW,IAAI,WAAW,KAAK,CACtD,QAAO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AM,aAAa,CAC1E;AACD,YAAU,KACR,GAAG,uBACD,KAAK,4BACJ,WAAW,MAAM,6BACnB,CACF;CACF,EAAC;AAGF,WAAU,KAAK,GAAG,wBAAwB,QAAQ,CAAC;CAGnD,MAAM,SAAS,UAAU,OAAO,OAAK,EAAE,aAAa,QAAQ;CAC5D,MAAM,WAAW,UAAU,OACzB,OAAK,EAAE,aAAa,UACrB;AAED,QAAO;EACL,SAAS,OAAO,WAAW;EAC3B;EACA;CACD;AACF"}
|
package/dist/index6.cjs
CHANGED
package/dist/index7.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require('./formatIdValue-i67o4kyD.cjs');
|
|
2
|
-
const require_taxpayerValidation = require('./taxpayerValidation-
|
|
2
|
+
const require_taxpayerValidation = require('./taxpayerValidation-D_jGaVty.cjs');
|
|
3
3
|
|
|
4
4
|
exports.taxpayerQRCode = require_taxpayerValidation.taxpayerQRCode;
|
|
5
5
|
exports.tinSearch = require_taxpayerValidation.tinSearch;
|
|
@@ -16,7 +16,16 @@ const platformLogin = async (client) => {
|
|
|
16
16
|
scope: "InvoicingAPI"
|
|
17
17
|
})
|
|
18
18
|
});
|
|
19
|
+
if (!response.ok) {
|
|
20
|
+
let errorBody;
|
|
21
|
+
try {
|
|
22
|
+
errorBody = await response.json();
|
|
23
|
+
} catch {}
|
|
24
|
+
const errorMessage = typeof errorBody === "object" && errorBody !== null && "error_description" in errorBody ? errorBody.error_description : `Platform login failed with status ${response.status}`;
|
|
25
|
+
throw new Error(errorMessage);
|
|
26
|
+
}
|
|
19
27
|
const tokenResponse = await response.json();
|
|
28
|
+
if (!tokenResponse.access_token) throw new Error("Platform login response did not include an access_token");
|
|
20
29
|
return {
|
|
21
30
|
token: tokenResponse.access_token,
|
|
22
31
|
tokenExpiration: new Date(Date.now() + tokenResponse.expires_in * 1e3)
|
|
@@ -34,4 +43,4 @@ Object.defineProperty(exports, 'platformLogin', {
|
|
|
34
43
|
return platformLogin;
|
|
35
44
|
}
|
|
36
45
|
});
|
|
37
|
-
//# sourceMappingURL=platformLogin-
|
|
46
|
+
//# sourceMappingURL=platformLogin-Ch6hFKoU.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platformLogin-Ch6hFKoU.cjs","names":["client: ClientCredentials","errorBody: unknown","tokenResponse: TokenResponse"],"sources":["../src/api/platformLogin.ts"],"sourcesContent":["import type { ClientCredentials, TokenResponse } from '../types'\n\nexport const platformLogin = async (\n client: ClientCredentials,\n): Promise<{\n token: string\n tokenExpiration: Date\n}> => {\n const { clientId, clientSecret, baseUrl, onBehalfOf, debug } = client\n try {\n const response = await fetch(`${baseUrl}/connect/token`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n ...(onBehalfOf ? { onbehalfof: onBehalfOf } : {}),\n },\n body: new URLSearchParams({\n grant_type: 'client_credentials',\n client_id: clientId,\n client_secret: clientSecret,\n scope: 'InvoicingAPI',\n }),\n })\n\n // If authentication fails, surface the error details immediately\n if (!response.ok) {\n let errorBody: unknown\n try {\n errorBody = await response.json()\n } catch {\n /* ignored */\n }\n\n const errorMessage =\n typeof errorBody === 'object' &&\n errorBody !== null &&\n 'error_description' in errorBody\n ? (errorBody as { error_description: string }).error_description\n : `Platform login failed with status ${response.status}`\n\n throw new Error(errorMessage)\n }\n\n const tokenResponse: TokenResponse = await response.json()\n\n if (!tokenResponse.access_token) {\n throw new Error('Platform login response did not include an access_token')\n }\n\n return {\n token: tokenResponse.access_token,\n tokenExpiration: new Date(Date.now() + tokenResponse.expires_in * 1000),\n }\n } catch (error) {\n if (debug) console.error(error)\n throw error\n }\n}\n"],"mappings":";;AAEA,MAAa,gBAAgB,OAC3BA,WAII;CACJ,MAAM,EAAE,UAAU,cAAc,SAAS,YAAY,OAAO,GAAG;AAC/D,KAAI;EACF,MAAM,WAAW,MAAM,OAAO,EAAE,QAAQ,iBAAiB;GACvD,QAAQ;GACR,SAAS;IACP,gBAAgB;IAChB,GAAI,aAAa,EAAE,YAAY,WAAY,IAAG,CAAE;GACjD;GACD,MAAM,IAAI,gBAAgB;IACxB,YAAY;IACZ,WAAW;IACX,eAAe;IACf,OAAO;GACR;EACF,EAAC;AAGF,OAAK,SAAS,IAAI;GAChB,IAAIC;AACJ,OAAI;AACF,gBAAY,MAAM,SAAS,MAAM;GAClC,QAAO,CAEP;GAED,MAAM,sBACG,cAAc,YACrB,cAAc,QACd,uBAAuB,YAClB,UAA4C,qBAC5C,oCAAoC,SAAS,OAAO;AAE3D,SAAM,IAAI,MAAM;EACjB;EAED,MAAMC,gBAA+B,MAAM,SAAS,MAAM;AAE1D,OAAK,cAAc,aACjB,OAAM,IAAI,MAAM;AAGlB,SAAO;GACL,OAAO,cAAc;GACrB,iBAAiB,IAAI,KAAK,KAAK,KAAK,GAAG,cAAc,aAAa;EACnE;CACF,SAAQ,OAAO;AACd,MAAI,MAAO,SAAQ,MAAM,MAAM;AAC/B,QAAM;CACP;AACF"}
|
|
@@ -15,7 +15,16 @@ const platformLogin = async (client) => {
|
|
|
15
15
|
scope: "InvoicingAPI"
|
|
16
16
|
})
|
|
17
17
|
});
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
let errorBody;
|
|
20
|
+
try {
|
|
21
|
+
errorBody = await response.json();
|
|
22
|
+
} catch {}
|
|
23
|
+
const errorMessage = typeof errorBody === "object" && errorBody !== null && "error_description" in errorBody ? errorBody.error_description : `Platform login failed with status ${response.status}`;
|
|
24
|
+
throw new Error(errorMessage);
|
|
25
|
+
}
|
|
18
26
|
const tokenResponse = await response.json();
|
|
27
|
+
if (!tokenResponse.access_token) throw new Error("Platform login response did not include an access_token");
|
|
19
28
|
return {
|
|
20
29
|
token: tokenResponse.access_token,
|
|
21
30
|
tokenExpiration: new Date(Date.now() + tokenResponse.expires_in * 1e3)
|
|
@@ -25,7 +25,8 @@ async function verifyTin(context, tin, idType, idValue) {
|
|
|
25
25
|
const { fetch, debug } = context;
|
|
26
26
|
try {
|
|
27
27
|
const response = await fetch(`/api/v1.0/taxpayer/validate/${tin}?idType=${idType}&idValue=${require_formatIdValue.formatIdValue(idValue)}`, { method: "GET" });
|
|
28
|
-
if (response
|
|
28
|
+
if (!response) return false;
|
|
29
|
+
if (response.ok || response.status === 200) return true;
|
|
29
30
|
return false;
|
|
30
31
|
} catch (error) {
|
|
31
32
|
if (debug) console.error(error);
|
|
@@ -58,4 +59,4 @@ Object.defineProperty(exports, 'verifyTin', {
|
|
|
58
59
|
return verifyTin;
|
|
59
60
|
}
|
|
60
61
|
});
|
|
61
|
-
//# sourceMappingURL=taxpayerValidation-
|
|
62
|
+
//# sourceMappingURL=taxpayerValidation-D_jGaVty.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taxpayerValidation-
|
|
1
|
+
{"version":3,"file":"taxpayerValidation-D_jGaVty.cjs","names":["context: TaxpayerContext","params: TinSearchParams","tin: string","idType: RegistrationType","idValue: string","qrCodeText: string"],"sources":["../src/api/taxpayerValidation.ts"],"sourcesContent":["import { formatIdValue } from 'src/utils/formatIdValue'\nimport type {\n Fetch,\n RegistrationType,\n TaxpayerQRCodeResponse,\n TinSearchParams,\n TinSearchResponse,\n} from '../types'\n\ninterface TaxpayerContext {\n fetch: Fetch\n debug: boolean\n}\n\nexport async function tinSearch(\n context: TaxpayerContext,\n params: TinSearchParams,\n): Promise<TinSearchResponse> {\n const { fetch, debug } = context\n const { taxpayerName, idType, idValue } = params\n\n // Validate input parameters according to API requirements\n if (!taxpayerName && (!idType || !idValue)) {\n throw new Error(\n 'Either taxpayerName must be provided, or both idType and idValue must be provided',\n )\n }\n\n if ((idType && !idValue) || (!idType && idValue)) {\n throw new Error('idType and idValue must be provided together')\n }\n\n // Build query parameters\n const queryParams = new URLSearchParams()\n\n if (taxpayerName) {\n queryParams.append('taxpayerName', taxpayerName)\n }\n\n if (idType && idValue) {\n queryParams.append('idType', idType)\n queryParams.append('idValue', formatIdValue(idValue))\n }\n\n const queryString = queryParams.toString()\n\n try {\n const response = await fetch(\n `/api/v1.0/taxpayer/search/tin?${queryString}`,\n {\n method: 'GET',\n },\n )\n return (await response.json()) as TinSearchResponse\n } catch (error) {\n if (debug) {\n console.error('TIN search error:', error)\n }\n throw error\n }\n}\n\nexport async function verifyTin(\n context: TaxpayerContext,\n tin: string,\n idType: RegistrationType,\n idValue: string,\n): Promise<boolean> {\n const { fetch, debug } = context\n\n try {\n const response = await fetch(\n `/api/v1.0/taxpayer/validate/${tin}?idType=${idType}&idValue=${formatIdValue(idValue)}`,\n {\n method: 'GET',\n },\n )\n\n if (!response) {\n // Fetch was stubbed to return undefined or network error occurred\n return false\n }\n\n if (response.ok || response.status === 200) {\n return true\n }\n\n return false\n } catch (error) {\n if (debug) {\n console.error(error)\n }\n return false\n }\n}\n\nexport async function taxpayerQRCode(\n context: TaxpayerContext,\n qrCodeText: string,\n): Promise<TaxpayerQRCodeResponse> {\n const { fetch } = context\n\n const base64EncodedQRCodeText = Buffer.from(qrCodeText).toString('base64')\n\n const response = await fetch(\n `/api/v1.0/taxpayer/qrcodeinfo/${base64EncodedQRCodeText}`,\n )\n\n return response.json()\n}\n"],"mappings":";;;AAcA,eAAsB,UACpBA,SACAC,QAC4B;CAC5B,MAAM,EAAE,OAAO,OAAO,GAAG;CACzB,MAAM,EAAE,cAAc,QAAQ,SAAS,GAAG;AAG1C,MAAK,kBAAkB,WAAW,SAChC,OAAM,IAAI,MACR;AAIJ,KAAK,WAAW,YAAc,UAAU,QACtC,OAAM,IAAI,MAAM;CAIlB,MAAM,cAAc,IAAI;AAExB,KAAI,aACF,aAAY,OAAO,gBAAgB,aAAa;AAGlD,KAAI,UAAU,SAAS;AACrB,cAAY,OAAO,UAAU,OAAO;AACpC,cAAY,OAAO,WAAW,oCAAc,QAAQ,CAAC;CACtD;CAED,MAAM,cAAc,YAAY,UAAU;AAE1C,KAAI;EACF,MAAM,WAAW,MAAM,OACpB,gCAAgC,YAAY,GAC7C,EACE,QAAQ,MACT,EACF;AACD,SAAQ,MAAM,SAAS,MAAM;CAC9B,SAAQ,OAAO;AACd,MAAI,MACF,SAAQ,MAAM,qBAAqB,MAAM;AAE3C,QAAM;CACP;AACF;AAED,eAAsB,UACpBD,SACAE,KACAC,QACAC,SACkB;CAClB,MAAM,EAAE,OAAO,OAAO,GAAG;AAEzB,KAAI;EACF,MAAM,WAAW,MAAM,OACpB,8BAA8B,IAAI,UAAU,OAAO,WAAW,oCAAc,QAAQ,CAAC,GACtF,EACE,QAAQ,MACT,EACF;AAED,OAAK,SAEH,QAAO;AAGT,MAAI,SAAS,MAAM,SAAS,WAAW,IACrC,QAAO;AAGT,SAAO;CACR,SAAQ,OAAO;AACd,MAAI,MACF,SAAQ,MAAM,MAAM;AAEtB,SAAO;CACR;AACF;AAED,eAAsB,eACpBJ,SACAK,YACiC;CACjC,MAAM,EAAE,OAAO,GAAG;CAElB,MAAM,0BAA0B,OAAO,KAAK,WAAW,CAAC,SAAS,SAAS;CAE1E,MAAM,WAAW,MAAM,OACpB,gCAAgC,wBAAwB,EAC1D;AAED,QAAO,SAAS,MAAM;AACvB"}
|
|
@@ -25,7 +25,8 @@ async function verifyTin(context, tin, idType, idValue) {
|
|
|
25
25
|
const { fetch, debug } = context;
|
|
26
26
|
try {
|
|
27
27
|
const response = await fetch(`/api/v1.0/taxpayer/validate/${tin}?idType=${idType}&idValue=${formatIdValue(idValue)}`, { method: "GET" });
|
|
28
|
-
if (response
|
|
28
|
+
if (!response) return false;
|
|
29
|
+
if (response.ok || response.status === 200) return true;
|
|
29
30
|
return false;
|
|
30
31
|
} catch (error) {
|
|
31
32
|
if (debug) console.error(error);
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"documentSubmission-BzNsx6qa.cjs","names":["context: SubmissionContext","documents: AllDocumentsV1_1[]","context: Pick<SubmissionContext, 'fetch' | 'debug'>","submissionUid: string","pollInterval: number","maxRetries: number","documentUid: string","status: 'rejected' | 'cancelled'","reason: string"],"sources":["../src/api/documentSubmission.ts"],"sourcesContent":["import type {\n AllDocumentsV1_1,\n SubmissionResponse,\n SigningCredentials,\n SubmissionStatus,\n DocumentSummary,\n Fetch,\n StandardError,\n} from '../types'\nimport { generateCompleteDocument } from '../utils/document'\n\ninterface SubmissionContext {\n fetch: Fetch\n debug: boolean\n signingCredentials: SigningCredentials\n}\n\nexport async function submitDocument(\n context: SubmissionContext,\n documents: AllDocumentsV1_1[],\n): Promise<{\n data: SubmissionResponse\n status: number\n}> {\n const { fetch, debug, signingCredentials } = context\n\n if (debug) {\n console.log(`📦 Preparing to submit ${documents.length} document(s)...`)\n }\n\n // Generate the complete signed document structure first\n const completeDocument = generateCompleteDocument(\n documents,\n signingCredentials,\n )\n\n if (debug) {\n console.log('✅ Documents signed successfully')\n console.log('📄 Document structure keys:', Object.keys(completeDocument))\n console.log('📊 Number of invoices:', completeDocument.Invoice.length)\n }\n\n // Convert the complete document to JSON string\n const documentJson = JSON.stringify(completeDocument)\n\n if (debug) {\n console.log(`📏 Document JSON size: ${documentJson.length} bytes`)\n }\n\n // Generate SHA256 hash of the JSON document\n const crypto = await import('crypto')\n const documentHash = crypto\n .createHash('sha256')\n .update(documentJson, 'utf8')\n .digest('hex')\n\n // Base64 encode the JSON document\n const documentBase64 = Buffer.from(documentJson, 'utf8').toString('base64')\n\n if (debug) {\n console.log(`🔒 Document hash: ${documentHash.substring(0, 16)}...`)\n console.log(`📦 Base64 size: ${documentBase64.length} bytes`)\n }\n\n // Build the submission payload according to MyInvois API format\n const submissionPayload = {\n documents: documents.map(doc => ({\n format: 'JSON', // We're submitting JSON format\n document: documentBase64, // Base64 encoded complete document\n documentHash: documentHash, // SHA256 hash of the JSON\n codeNumber: doc.eInvoiceCodeOrNumber, // Document reference number\n })),\n }\n\n if (debug) {\n console.log('🚀 Submission payload structure:')\n console.log('- Format: JSON')\n console.log('- Documents count:', submissionPayload.documents.length)\n console.log(\n '- Total payload size:',\n JSON.stringify(submissionPayload).length,\n 'bytes',\n )\n\n // Validate submission constraints\n const payloadSize = JSON.stringify(submissionPayload).length\n if (payloadSize > 5 * 1024 * 1024) {\n // 5MB\n console.warn('⚠️ WARNING: Payload size exceeds 5MB limit')\n }\n\n if (documents.length > 100) {\n console.warn('⚠️ WARNING: Document count exceeds 100 document limit')\n }\n\n if (documentJson.length > 300 * 1024) {\n // 300KB per document\n console.warn('⚠️ WARNING: Document size exceeds 300KB limit')\n }\n }\n\n // Submit to MyInvois API with proper headers\n const response = await fetch('/api/v1.0/documentsubmissions', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(submissionPayload),\n })\n\n if (debug) {\n console.log(`📡 API Response status: ${response.status}`)\n }\n\n const data = (await response.json()) as SubmissionResponse\n\n if (debug) {\n if (response.status !== 202) {\n console.error('❌ Submission failed with status:', response.status)\n console.error('❌ Response data:', data)\n } else {\n console.log('✅ Submission successful!')\n console.log(`📋 Submission UID: ${data.submissionUid}`)\n console.log(\n `✅ Accepted documents: ${data.acceptedDocuments?.length || 0}`,\n )\n console.log(\n `❌ Rejected documents: ${data.rejectedDocuments?.length || 0}`,\n )\n }\n }\n\n return {\n data,\n status: response.status,\n }\n}\n\nexport async function getSubmissionStatus(\n context: Pick<SubmissionContext, 'fetch' | 'debug'>,\n submissionUid: string,\n pollInterval: number = 1000,\n maxRetries: number = 10,\n): Promise<{\n status: SubmissionStatus\n documentSummary?: DocumentSummary[]\n error?: {\n code: string\n message: string | null\n target: string\n details: {\n code: string\n message: string\n target: string\n }[]\n }\n}> {\n const { fetch, debug } = context\n\n try {\n const response = await fetch(\n `/api/v1.0/documentsubmissions/${submissionUid}`,\n )\n\n const data = await response.json()\n\n if (debug) {\n console.log('Submission:', data)\n if (data.error) {\n console.log('Submission error details:', data.error.details)\n }\n }\n\n // If we have a successful response and status is completed, return success\n if (data.overallStatus === 'Valid') {\n return {\n status: data.overallStatus,\n documentSummary: data.documentSummary,\n }\n }\n if (data.overallStatus === 'Invalid') {\n return {\n status: 'Invalid',\n documentSummary: data.documentSummary,\n }\n }\n\n // If we have retries left, continue polling for any non-completed status or errors\n if (maxRetries > 0) {\n await new Promise(resolve => setTimeout(resolve, pollInterval))\n return await getSubmissionStatus(\n context,\n submissionUid,\n pollInterval,\n maxRetries - 1,\n )\n }\n\n // No retries left - return timeout\n return {\n status: 'Invalid',\n error: {\n code: 'Timeout',\n message: 'Submission timed out',\n target: 'submission',\n details: [],\n },\n }\n } catch (error) {\n // Handle any request errors by retrying if we have retries left\n if (maxRetries > 0) {\n if (debug) {\n console.log('Request error, retrying...', error)\n }\n await new Promise(resolve => setTimeout(resolve, pollInterval))\n return await getSubmissionStatus(\n context,\n submissionUid,\n pollInterval,\n maxRetries - 1,\n )\n }\n\n // No retries left - return timeout\n return {\n status: 'Invalid',\n error: {\n code: 'Timeout',\n message: 'Submission timed out after request errors',\n target: 'submission',\n details: [],\n },\n }\n }\n}\n\nexport async function performDocumentAction(\n documentUid: string,\n status: 'rejected' | 'cancelled',\n reason: string,\n): Promise<{\n uuid: string\n status: string\n error: StandardError\n}> {\n const response = await fetch(\n `/api/v1.0/documents/state/${documentUid}/state`,\n {\n method: 'POST',\n body: JSON.stringify({\n status,\n reason,\n }),\n },\n )\n\n const data = (await response.json()) as {\n uuid: string\n status: string\n error: StandardError\n }\n\n return data\n}\n"],"mappings":";;;AAiBA,eAAsB,eACpBA,SACAC,WAIC;CACD,MAAM,EAAE,gBAAO,OAAO,oBAAoB,GAAG;AAE7C,KAAI,MACF,SAAQ,KAAK,yBAAyB,UAAU,OAAO,iBAAiB;CAI1E,MAAM,mBAAmB,0CACvB,WACA,mBACD;AAED,KAAI,OAAO;AACT,UAAQ,IAAI,kCAAkC;AAC9C,UAAQ,IAAI,+BAA+B,OAAO,KAAK,iBAAiB,CAAC;AACzE,UAAQ,IAAI,0BAA0B,iBAAiB,QAAQ,OAAO;CACvE;CAGD,MAAM,eAAe,KAAK,UAAU,iBAAiB;AAErD,KAAI,MACF,SAAQ,KAAK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BACpBC,aACAC,QACAC,QAKC;CACD,MAAM,WAAW,MAAM,OACpB,4BAA4B,YAAY,SACzC;EACE,QAAQ;EACR,MAAM,KAAK,UAAU;GACnB;GACA;EACD,EAAC;CACH,EACF;CAED,MAAM,OAAQ,MAAM,SAAS,MAAM;AAMnC,QAAO;AACR"}
|
package/dist/index35.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index35.cjs","names":[],"sources":["../src/types/msic/5X.d.ts"],"sourcesContent":["export type MSIC_5X_CODE =\n | '50111'\n | '50112'\n | '50113'\n | '50121'\n | '50122'\n | '50211'\n | '50212'\n | '50220'\n | '51101'\n | '51102'\n | '51103'\n | '51201'\n | '51202'\n | '51203'\n | '52100'\n | '52211'\n | '52212'\n | '52213'\n | '52214'\n | '52219'\n | '52221'\n | '52222'\n | '52229'\n | '52231'\n | '52232'\n | '52233'\n | '52234'\n | '52239'\n | '52241'\n | '52249'\n | '52291'\n | '52292'\n | '52299'\n | '53100'\n | '53200'\n | '55101'\n | '55102'\n | '55103'\n | '55104'\n | '55105'\n | '55106'\n | '55107'\n | '55108'\n | '55109'\n | '55200'\n | '55900'\n | '56103'\n | '56104'\n | '56105'\n | '56106'\n | '56107'\n | '56210'\n | '56290'\n | '56301'\n | '56302'\n | '56303'\n | '56304'\n | '56309'\n | '58110'\n | '58120'\n | '58130'\n | '58190'\n | '58201'\n | '58202'\n | '58203'\n | '59110'\n | '59120'\n | '59130'\n | '59140'\n | '59200'\n\nexport enum MSIC_5X {\n CRUISE_OPERATIONS = '50111',\n FERRY_OPERATIONS = '50112',\n BOAT_RENTAL_WITH_CREW = '50113',\n SEA_FREIGHT_TRANSPORT = '50121',\n BARGE_TOWING = '50122',\n RIVER_PASSENGER_TRANSPORT = '50211',\n RIVER_BOAT_RENTAL = '50212',\n RIVER_FREIGHT_TRANSPORT = '50220',\n SCHEDULED_AIR_TRANSPORT = '51101',\n UNSCHEDULED_AIR_TRANSPORT = '51102',\n AIR_TRANSPORT_RENTAL = '51103',\n SCHEDULED_AIR_FREIGHT = '51201',\n UNSCHEDULED_AIR_FREIGHT = '51202',\n AIR_FREIGHT_RENTAL = '51203',\n WAREHOUSING = '52100',\n TERMINAL_OPERATIONS = '52211',\n ROAD_ASSISTANCE = '52212',\n PARKING_OPERATIONS = '52213',\n HIGHWAY_OPERATIONS = '52214',\n LAND_TRANSPORT_SUPPORT = '52219',\n PORT_OPERATIONS = '52221',\n VESSEL_SALVAGE = '52222',\n WATER_TRANSPORT_SUPPORT = '52229',\n AIR_TERMINAL_OPERATIONS = '52231',\n AIR_TRAFFIC_CONTROL = '52232',\n GROUND_SERVICES = '52233',\n AIRPORT_FIRE_SERVICES = '52234',\n AIR_TRANSPORT_SUPPORT = '52239',\n STEVEDORING = '52241',\n CARGO_HANDLING = '52249',\n FREIGHT_FORWARDING = '52291',\n TRANSPORT_BROKERAGE = '52292',\n TRANSPORT_SUPPORT = '52299',\n POSTAL_SERVICES = '53100',\n COURIER_SERVICES = '53200',\n HOTELS = '55101',\n MOTELS = '55102',\n APARTMENT_HOTELS = '55103',\n CHALETS = '55104',\n GUEST_HOUSES = '55105',\n BED_AND_BREAKFAST = '55106',\n HOSTELS = '55107',\n HOME_STAY = '55108',\n SHORT_TERM_ACCOMMODATION = '55109',\n CAMPING_GROUNDS = '55200',\n OTHER_ACCOMMODATION = '55900',\n FAST_FOOD = '56103',\n ICE_CREAM_PARLOURS = '56104',\n FOOD_CARTS = '56105',\n FOOD_STALLS = '56106',\n MARKET_FOOD_STALLS = '56107',\n EVENT_CATERING = '56210',\n OTHER_FOOD_SERVICES = '56290',\n BARS_AND_PUBS = '56301',\n COFFEE_SHOPS = '56302',\n DRINK_STALLS = '56303',\n MOBILE_BEVERAGES = '56304',\n OTHER_DRINKING_PLACES = '56309',\n BOOK_PUBLISHING = '58110',\n DIRECTORY_PUBLISHING = '58120',\n NEWSPAPER_PUBLISHING = '58130',\n OTHER_PUBLISHING = '58190',\n BUSINESS_SOFTWARE = '58201',\n GAME_SOFTWARE = '58202',\n OPERATING_SYSTEMS = '58203',\n FILM_PRODUCTION = '59110',\n FILM_POST_PRODUCTION = '59120',\n FILM_DISTRIBUTION = '59130',\n FILM_PROJECTION = '59140',\n SOUND_RECORDING = '59200',\n}\n"],"mappings":";;AAwEA,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;;AACD"}
|
package/dist/index36.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index36.cjs","names":[],"sources":["../src/types/msic/6X.d.ts"],"sourcesContent":["export type MSIC_6X_CODE =\n | '60100'\n | '60200'\n | '61101'\n | '61102'\n | '61201'\n | '61202'\n | '61300'\n | '61901'\n | '61902'\n | '61903'\n | '61904'\n | '61905'\n | '61909'\n | '62010'\n | '62021'\n | '62022'\n | '62091'\n | '62099'\n | '63111'\n | '63112'\n | '63120'\n | '63910'\n | '63990'\n | '64110'\n | '64191'\n | '64192'\n | '64193'\n | '64194'\n | '64195'\n | '64199'\n | '64200'\n | '64301'\n | '64302'\n | '64303'\n | '64304'\n | '64309'\n | '64910'\n | '64921'\n | '64922'\n | '64923'\n | '64924'\n | '64925'\n | '64929'\n | '64991'\n | '64992'\n | '64993'\n | '64999'\n | '65111'\n | '65112'\n | '65121'\n | '65122'\n | '65123'\n | '65124'\n | '65125'\n | '65201'\n | '65202'\n | '65203'\n | '65204'\n | '65205'\n | '65206'\n | '65207'\n | '65301'\n | '65302'\n | '66111'\n | '66112'\n | '66113'\n | '66114'\n | '66119'\n | '66121'\n | '66122'\n | '66123'\n | '66124'\n | '66125'\n | '66129'\n | '66191'\n | '66192'\n | '66199'\n | '66211'\n | '66212'\n | '66221'\n | '66222'\n | '66223'\n | '66224'\n | '66290'\n | '66301'\n | '66302'\n | '66303'\n | '68101'\n | '68102'\n | '68103'\n | '68104'\n | '68109'\n | '68201'\n | '68202'\n | '68203'\n | '68209'\n | '69100'\n | '69200'\n\nexport enum MSIC_6X {\n RADIO_BROADCASTING = '60100',\n TELEVISION_PROGRAMMING = '60200',\n WIRED_TELECOMMUNICATIONS = '61101',\n WIRED_INTERNET_PROVIDERS = '61102',\n WIRELESS_TELECOMMUNICATIONS = '61201',\n WIRELESS_INTERNET_PROVIDERS = '61202',\n SATELLITE_TELECOMMUNICATIONS = '61300',\n THIRD_PARTY_INTERNET_ACCESS = '61901',\n TELECOM_SERVICES_EXISTING = '61902',\n TELECOM_RESELLERS = '61903',\n VOIP_SERVICES = '61904',\n SPECIALIZED_TELECOM = '61905',\n OTHER_TELECOM = '61909',\n COMPUTER_PROGRAMMING = '62010',\n COMPUTER_CONSULTANCY = '62021',\n COMPUTER_FACILITIES_MANAGEMENT = '62022',\n ICT_SECURITY = '62091',\n OTHER_IT_SERVICES = '62099',\n HOSTING_INFRASTRUCTURE = '63111',\n DATA_PROCESSING = '63112',\n WEB_PORTALS = '63120',\n NEWS_AGENCIES = '63910',\n OTHER_INFORMATION_SERVICES = '63990',\n CENTRAL_BANKING = '64110',\n COMMERCIAL_BANKS = '64191',\n ISLAMIC_BANKS = '64192',\n OFFSHORE_BANKS = '64193',\n INVESTMENT_BANKS = '64194',\n DEVELOPMENT_FINANCIAL_INSTITUTIONS = '64195',\n OTHER_MONETARY_INTERMEDIATION = '64199',\n HOLDING_COMPANIES = '64200',\n VENTURE_CAPITAL = '64301',\n UNIT_TRUST_FUNDS = '64302',\n PROPERTY_UNIT_TRUST = '64303',\n TRUST_ACCOUNTS = '64304',\n OTHER_TRUSTS = '64309',\n FINANCIAL_LEASING = '64910',\n NON_DEPOSIT_FINANCIAL_INSTITUTIONS = '64921',\n CREDIT_CARD_SERVICES = '64922',\n MONEY_LENDING = '64923',\n PAWNSHOPS = '64924',\n COOPERATIVE_CREDITS = '64925',\n OTHER_CREDIT_GRANTING = '64929',\n FACTORING_COMPANIES = '64991',\n FOREIGN_BANK_OFFICES = '64992',\n NOMINEE_COMPANIES = '64993',\n OTHER_FINANCIAL_SERVICES = '64999',\n LIFE_INSURANCE = '65111',\n FAMILY_TAKAFUL = '65112',\n GENERAL_INSURANCE = '65121',\n GENERAL_TAKAFUL = '65122',\n COMPOSITE_INSURANCE = '65123',\n OFFSHORE_INSURANCE = '65124',\n OFFSHORE_TAKAFUL = '65125',\n LIFE_REINSURANCE = '65201',\n FAMILY_RETAKAFUL = '65202',\n GENERAL_REINSURANCE = '65203',\n GENERAL_RETAKAFUL = '65204',\n COMPOSITE_RETAKAFUL = '65205',\n OFFSHORE_REINSURANCE = '65206',\n OFFSHORE_RETAKAFUL = '65207',\n PENSION_FUNDING = '65301',\n PROVIDENT_FUNDING = '65302',\n STOCK_EXCHANGES = '66111',\n COMMODITY_EXCHANGES = '66112',\n SECURITIES_EXCHANGE = '66113',\n FUTURES_EXCHANGES = '66114',\n OTHER_FINANCIAL_MARKETS = '66119',\n STOCK_BROKERS = '66121',\n COMMODITY_BROKERS = '66122',\n GOLD_BULLION_DEALERS = '66123',\n FOREX_DEALERS = '66124',\n MONEY_CHANGERS = '66125',\n OTHER_FINANCIAL_BROKERS = '66129',\n INVESTMENT_ADVISORY = '66191',\n FINANCIAL_CONSULTANCY = '66192',\n OTHER_FINANCIAL_AUXILIARY = '66199',\n INSURANCE_ADJUSTING = '66211',\n TAKAFUL_ADJUSTING = '66212',\n INSURANCE_AGENTS = '66221',\n TAKAFUL_AGENTS = '66222',\n INSURANCE_BROKERS = '66223',\n TAKAFUL_BROKERS = '66224',\n OTHER_INSURANCE_AUXILIARY = '66290',\n PENSION_MANAGEMENT = '66301',\n PORTFOLIO_MANAGEMENT = '66302',\n UNIT_TRUST_MANAGEMENT = '66303',\n RESIDENTIAL_REAL_ESTATE = '68101',\n COMMERCIAL_REAL_ESTATE = '68102',\n LAND_REAL_ESTATE = '68103',\n BUILDING_PROJECT_OPERATION = '68104',\n OTHER_REAL_ESTATE = '68109',\n REAL_ESTATE_AGENTS = '68201',\n PROPERTY_MANAGEMENT = '68202',\n REAL_ESTATE_APPRAISAL = '68203',\n OTHER_REAL_ESTATE_SERVICES = '68209',\n LEGAL_ACTIVITIES = '69100',\n ACCOUNTING_ACTIVITIES = '69200',\n}\n"],"mappings":";;AAoGA,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACD"}
|
package/dist/index37.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index37.cjs","names":[],"sources":["../src/types/msic/7X.d.ts"],"sourcesContent":["export type MSIC_7X_CODE =\n | '70100'\n | '70201'\n | '70202'\n | '70203'\n | '70209'\n | '71101'\n | '71102'\n | '71103'\n | '71109'\n | '71200'\n | '72101'\n | '72102'\n | '72103'\n | '72104'\n | '72105'\n | '72106'\n | '72109'\n | '72201'\n | '72202'\n | '72209'\n | '73100'\n | '73200'\n | '74101'\n | '74102'\n | '74103'\n | '74109'\n | '74200'\n | '74901'\n | '74902'\n | '74903'\n | '74904'\n | '74905'\n | '74909'\n | '75000'\n | '77101'\n | '77102'\n | '77211'\n | '77212'\n | '77213'\n | '77219'\n | '77220'\n | '77291'\n | '77292'\n | '77293'\n | '77294'\n | '77295'\n | '77296'\n | '77297'\n | '77299'\n | '77301'\n | '77302'\n | '77303'\n | '77304'\n | '77305'\n | '77306'\n | '77307'\n | '77309'\n | '77400'\n | '78100'\n | '78200'\n | '78300'\n | '79110'\n | '79120'\n | '79900'\n\nexport enum MSIC_7X {\n HEAD_OFFICES = '70100',\n BUSINESS_MANAGEMENT_CONSULTANCY = '70201',\n HR_CONSULTANCY = '70202',\n PR_COMMUNICATIONS_CONSULTANCY = '70203',\n OTHER_MANAGEMENT_CONSULTANCY = '70209',\n ARCHITECTURAL_SERVICES = '71101',\n ENGINEERING_SERVICES = '71102',\n LAND_SURVEYING = '71103',\n OTHER_ARCHITECTURAL_ENGINEERING = '71109',\n TECHNICAL_TESTING = '71200',\n NATURAL_SCIENCES_RESEARCH = '72101',\n ENGINEERING_RESEARCH = '72102',\n MEDICAL_SCIENCES_RESEARCH = '72103',\n BIOTECHNOLOGY_RESEARCH = '72104',\n AGRICULTURAL_SCIENCES_RESEARCH = '72105',\n ICT_RESEARCH = '72106',\n OTHER_NATURAL_SCIENCES_RESEARCH = '72109',\n SOCIAL_SCIENCES_RESEARCH = '72201',\n HUMANITIES_RESEARCH = '72202',\n OTHER_SOCIAL_SCIENCES_RESEARCH = '72209',\n ADVERTISING = '73100',\n MARKET_RESEARCH = '73200',\n INTERIOR_DECORATING = '74101',\n GRAPHIC_DESIGN = '74102',\n FASHION_DESIGN = '74103',\n OTHER_SPECIALIZED_DESIGN = '74109',\n PHOTOGRAPHY = '74200',\n TRANSLATION_SERVICES = '74901',\n BUSINESS_BROKERAGE = '74902',\n SECURITY_CONSULTING = '74903',\n QUANTITY_SURVEYING = '74904',\n OTHER_CONSULTANCY = '74905',\n OTHER_PROFESSIONAL_ACTIVITIES = '74909',\n VETERINARY_ACTIVITIES = '75000',\n CAR_RENTAL = '77101',\n TRUCK_RENTAL = '77102',\n BOAT_RENTAL = '77211',\n BICYCLE_RENTAL = '77212',\n BEACH_EQUIPMENT_RENTAL = '77213',\n OTHER_SPORTS_EQUIPMENT_RENTAL = '77219',\n VIDEO_RENTAL = '77220',\n CLOTHING_RENTAL = '77291',\n HOUSEHOLD_ITEMS_RENTAL = '77292',\n JEWELRY_RENTAL = '77293',\n BOOK_RENTAL = '77294',\n HOBBY_EQUIPMENT_RENTAL = '77295',\n PLANT_RENTAL = '77296',\n ELECTRONICS_RENTAL = '77297',\n OTHER_PERSONAL_GOODS_RENTAL = '77299',\n INDUSTRIAL_MACHINERY_RENTAL = '77301',\n LAND_TRANSPORT_RENTAL = '77302',\n WATER_TRANSPORT_RENTAL = '77303',\n AIR_TRANSPORT_RENTAL = '77304',\n AGRICULTURAL_MACHINERY_RENTAL = '77305',\n CONSTRUCTION_MACHINERY_RENTAL = '77306',\n OFFICE_MACHINERY_RENTAL = '77307',\n OTHER_MACHINERY_RENTAL = '77309',\n INTELLECTUAL_PROPERTY_LEASING = '77400',\n EMPLOYMENT_PLACEMENT = '78100',\n TEMPORARY_EMPLOYMENT = '78200',\n HR_PROVISION = '78300',\n TRAVEL_AGENCY = '79110',\n TOUR_OPERATOR = '79120',\n OTHER_RESERVATION_SERVICES = '79900',\n}\n"],"mappings":";;AAkEA,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;;AACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"platformLogin-7RwW1qjT.cjs","names":["client: ClientCredentials","tokenResponse: TokenResponse"],"sources":["../src/api/platformLogin.ts"],"sourcesContent":["import type { ClientCredentials, TokenResponse } from '../types'\n\nexport const platformLogin = async (\n client: ClientCredentials,\n): Promise<{\n token: string\n tokenExpiration: Date\n}> => {\n const { clientId, clientSecret, baseUrl, onBehalfOf, debug } = client\n try {\n const response = await fetch(`${baseUrl}/connect/token`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n ...(onBehalfOf ? { onbehalfof: onBehalfOf } : {}),\n },\n body: new URLSearchParams({\n grant_type: 'client_credentials',\n client_id: clientId,\n client_secret: clientSecret,\n scope: 'InvoicingAPI',\n }),\n })\n\n const tokenResponse: TokenResponse = await response.json()\n return {\n token: tokenResponse.access_token,\n tokenExpiration: new Date(Date.now() + tokenResponse.expires_in * 1000),\n }\n } catch (error) {\n if (debug) console.error(error)\n throw error\n }\n}\n"],"mappings":";;AAEA,MAAa,gBAAgB,OAC3BA,WAII;CACJ,MAAM,EAAE,UAAU,cAAc,SAAS,YAAY,OAAO,GAAG;AAC/D,KAAI;EACF,MAAM,WAAW,MAAM,OAAO,EAAE,QAAQ,iBAAiB;GACvD,QAAQ;GACR,SAAS;IACP,gBAAgB;IAChB,GAAI,aAAa,EAAE,YAAY,WAAY,IAAG,CAAE;GACjD;GACD,MAAM,IAAI,gBAAgB;IACxB,YAAY;IACZ,WAAW;IACX,eAAe;IACf,OAAO;GACR;EACF,EAAC;EAEF,MAAMC,gBAA+B,MAAM,SAAS,MAAM;AAC1D,SAAO;GACL,OAAO,cAAc;GACrB,iBAAiB,IAAI,KAAK,KAAK,KAAK,GAAG,cAAc,aAAa;EACnE;CACF,SAAQ,OAAO;AACd,MAAI,MAAO,SAAQ,MAAM,MAAM;AAC/B,QAAM;CACP;AACF"}
|