@ripwords/myinvois-client 0.2.24 → 0.2.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/api/documentSubmission.js +1 -1
  2. package/dist/{documentSubmission-Dz1RhbtK.cjs → documentSubmission-DQy30z4E.cjs} +3 -3
  3. package/dist/documentSubmission-DQy30z4E.cjs.map +1 -0
  4. package/dist/{documentSubmission-CJQJAa4z.js → documentSubmission-DRbswZAD.js} +2 -2
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/index10.cjs +24 -4
  8. package/dist/index10.cjs.map +1 -0
  9. package/dist/index11.cjs +0 -22
  10. package/dist/index12.cjs +33 -2
  11. package/dist/{index26.cjs.map → index12.cjs.map} +1 -1
  12. package/dist/index13.cjs +23 -2
  13. package/dist/{index27.cjs.map → index13.cjs.map} +1 -1
  14. package/dist/index14.cjs +0 -330
  15. package/dist/index15.cjs +0 -193
  16. package/dist/index16.cjs +0 -62
  17. package/dist/index17.cjs +4 -531
  18. package/dist/index18.cjs +6 -195
  19. package/dist/index19.cjs +5 -0
  20. package/dist/index2.cjs +61 -4
  21. package/dist/index2.cjs.map +1 -0
  22. package/dist/index20.cjs +2 -24
  23. package/dist/index21.cjs +3 -0
  24. package/dist/index22.cjs +6 -0
  25. package/dist/index23.cjs +3 -28
  26. package/dist/index24.cjs +9 -21
  27. package/dist/index24.cjs.map +1 -1
  28. package/dist/index25.cjs +5 -0
  29. package/dist/index26.cjs +21 -33
  30. package/dist/index27.cjs +2 -23
  31. package/dist/index28.cjs +3 -0
  32. package/dist/index29.cjs +330 -0
  33. package/dist/{index14.cjs.map → index29.cjs.map} +1 -1
  34. package/dist/index3.cjs +531 -6
  35. package/dist/index3.cjs.map +1 -0
  36. package/dist/index30.cjs +193 -0
  37. package/dist/{index15.cjs.map → index30.cjs.map} +1 -1
  38. package/dist/index4.cjs +195 -4
  39. package/dist/index4.cjs.map +1 -0
  40. package/dist/index5.cjs +0 -3
  41. package/dist/index6.cjs +24 -2
  42. package/dist/index6.cjs.map +1 -0
  43. package/dist/index7.cjs +0 -6
  44. package/dist/index8.cjs +0 -4
  45. package/dist/index9.cjs +25 -9
  46. package/dist/index9.cjs.map +1 -1
  47. package/package.json +1 -1
  48. package/dist/documentSubmission-Dz1RhbtK.cjs.map +0 -1
  49. package/dist/index16.cjs.map +0 -1
  50. package/dist/index17.cjs.map +0 -1
  51. package/dist/index18.cjs.map +0 -1
  52. package/dist/index20.cjs.map +0 -1
  53. package/dist/index23.cjs.map +0 -1
package/dist/index15.cjs CHANGED
@@ -1,193 +0,0 @@
1
-
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
- };
185
-
186
- //#endregion
187
- exports.validateContactNumber = validateContactNumber;
188
- exports.validateInvoice = validateInvoice;
189
- exports.validateLineItemTax = validateLineItemTax;
190
- exports.validateMonetaryAmount = validateMonetaryAmount;
191
- exports.validateTIN = validateTIN;
192
- exports.validateTaxCalculations = validateTaxCalculations;
193
- //# sourceMappingURL=index15.cjs.map
package/dist/index16.cjs CHANGED
@@ -1,62 +0,0 @@
1
-
2
- //#region src/types/classification-codes.d.ts
3
- /**
4
- * Enum representing the allowed classification codes with descriptive names.
5
- * Provides a more readable way to reference classification codes.
6
- *
7
- * @example
8
- * const code = ClassificationCodeEnum.ComputerSmartphoneOrTablet;
9
- * console.log(code); // Output: "003"
10
- */
11
- let ClassificationCodeEnum = /* @__PURE__ */ function(ClassificationCodeEnum$1) {
12
- ClassificationCodeEnum$1["BreastfeedingEquipment"] = "001";
13
- ClassificationCodeEnum$1["ChildCareCentresAndKindergartensFees"] = "002";
14
- ClassificationCodeEnum$1["ComputerSmartphoneOrTablet"] = "003";
15
- ClassificationCodeEnum$1["ConsolidatedEInvoice"] = "004";
16
- ClassificationCodeEnum$1["ConstructionMaterials"] = "005";
17
- ClassificationCodeEnum$1["Disbursement"] = "006";
18
- ClassificationCodeEnum$1["Donation"] = "007";
19
- ClassificationCodeEnum$1["ECommerceEInvoiceToBuyer"] = "008";
20
- ClassificationCodeEnum$1["ECommerceSelfBilledToSellerLogistics"] = "009";
21
- ClassificationCodeEnum$1["EducationFees"] = "010";
22
- ClassificationCodeEnum$1["GoodsOnConsignmentConsignor"] = "011";
23
- ClassificationCodeEnum$1["GoodsOnConsignmentConsignee"] = "012";
24
- ClassificationCodeEnum$1["GymMembership"] = "013";
25
- ClassificationCodeEnum$1["InsuranceEducationMedicalBenefits"] = "014";
26
- ClassificationCodeEnum$1["InsuranceTakafulLife"] = "015";
27
- ClassificationCodeEnum$1["InterestFinancingExpenses"] = "016";
28
- ClassificationCodeEnum$1["InternetSubscription"] = "017";
29
- ClassificationCodeEnum$1["LandAndBuilding"] = "018";
30
- ClassificationCodeEnum$1["MedicalExamLearningDisabilities"] = "019";
31
- ClassificationCodeEnum$1["MedicalExamVaccination"] = "020";
32
- ClassificationCodeEnum$1["MedicalExpensesSeriousDiseases"] = "021";
33
- ClassificationCodeEnum$1["Others"] = "022";
34
- ClassificationCodeEnum$1["PetroleumOperations"] = "023";
35
- ClassificationCodeEnum$1["PrivateRetirementSchemeDeferredAnnuity"] = "024";
36
- ClassificationCodeEnum$1["MotorVehicle"] = "025";
37
- ClassificationCodeEnum$1["SubscriptionBooksJournalsEtc"] = "026";
38
- ClassificationCodeEnum$1["Reimbursement"] = "027";
39
- ClassificationCodeEnum$1["RentalOfMotorVehicle"] = "028";
40
- ClassificationCodeEnum$1["EVChargingFacilities"] = "029";
41
- ClassificationCodeEnum$1["RepairAndMaintenance"] = "030";
42
- ClassificationCodeEnum$1["ResearchAndDevelopment"] = "031";
43
- ClassificationCodeEnum$1["ForeignIncome"] = "032";
44
- ClassificationCodeEnum$1["SelfBilledBettingGaming"] = "033";
45
- ClassificationCodeEnum$1["SelfBilledImportationGoods"] = "034";
46
- ClassificationCodeEnum$1["SelfBilledImportationServices"] = "035";
47
- ClassificationCodeEnum$1["SelfBilledOthers"] = "036";
48
- ClassificationCodeEnum$1["SelfBilledMonetaryPaymentToAgents"] = "037";
49
- ClassificationCodeEnum$1["SportsEquipmentRentalFeesEtc"] = "038";
50
- ClassificationCodeEnum$1["SupportingEquipmentDisabledPerson"] = "039";
51
- ClassificationCodeEnum$1["VoluntaryContributionProvidentFund"] = "040";
52
- ClassificationCodeEnum$1["DentalExamTreatment"] = "041";
53
- ClassificationCodeEnum$1["FertilityTreatment"] = "042";
54
- ClassificationCodeEnum$1["TreatmentHomeCareNursingEtc"] = "043";
55
- ClassificationCodeEnum$1["VouchersGiftCardsLoyaltyPoints"] = "044";
56
- ClassificationCodeEnum$1["SelfBilledNonMonetaryPaymentToAgents"] = "045";
57
- return ClassificationCodeEnum$1;
58
- }({});
59
-
60
- //#endregion
61
- exports.ClassificationCodeEnum = ClassificationCodeEnum;
62
- //# sourceMappingURL=index16.cjs.map