kcommons 13.11.5 → 13.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/build/helpers/padNumber.helper.spec.d.ts +1 -0
  2. package/build/helpers/padNumber.helper.spec.js +8 -0
  3. package/build/index.d.ts +2 -0
  4. package/build/index.js +2 -0
  5. package/build/typings/vendor/vendorFormRollbackRemark.typings.d.ts +1 -1
  6. package/build/typings/vendor/vendorFormRollbackRemark.typings.js +6 -6
  7. package/build/typings/verification_apis/cinVerification.typings.d.ts +67 -0
  8. package/build/typings/verification_apis/cinVerification.typings.js +2 -0
  9. package/build/utils/convertDurationToreadableFormat.util.spec.d.ts +1 -0
  10. package/build/utils/convertDurationToreadableFormat.util.spec.js +26 -0
  11. package/build/utils/convertToINS.util.spec.d.ts +1 -0
  12. package/build/utils/convertToINS.util.spec.js +38 -0
  13. package/build/utils/getContactPerson.util.spec.d.ts +1 -0
  14. package/build/utils/getContactPerson.util.spec.js +202 -0
  15. package/build/utils/getMediaName.util.spec.d.ts +1 -0
  16. package/build/utils/getMediaName.util.spec.js +17 -0
  17. package/build/utils/parseQueryParams.util.spec.d.ts +1 -0
  18. package/build/utils/parseQueryParams.util.spec.js +11 -0
  19. package/build/utils/parseReqString.spec.d.ts +1 -0
  20. package/build/utils/parseReqString.spec.js +29 -0
  21. package/build/utils/permission.util.spec.d.ts +1 -0
  22. package/build/utils/permission.util.spec.js +30 -0
  23. package/build/utils/quote.util.spec.d.ts +1 -0
  24. package/build/utils/quote.util.spec.js +48 -0
  25. package/build/utils/removeQueryParamsFormReqStr.util.spec.d.ts +1 -0
  26. package/build/utils/removeQueryParamsFormReqStr.util.spec.js +10 -0
  27. package/build/utils/taxes.util.spec.d.ts +1 -0
  28. package/build/utils/taxes.util.spec.js +84 -0
  29. package/build/utils/toFixedDecimal.util.spec.d.ts +1 -0
  30. package/build/utils/toFixedDecimal.util.spec.js +29 -0
  31. package/build/utils/validators/cin.validator.d.ts +2 -0
  32. package/build/utils/validators/cin.validator.js +10 -0
  33. package/package.json +14 -2
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const padNumber_helper_1 = require("./padNumber.helper");
4
+ describe("Get two digit number", () => {
5
+ it("must add one zero before the original number", () => {
6
+ expect((0, padNumber_helper_1.padNumber)(9)).toBe("0" + 9);
7
+ });
8
+ });
package/build/index.d.ts CHANGED
@@ -101,6 +101,7 @@ export * from "./typings/verification_apis/gstReturns.typings";
101
101
  export * from "./typings/verification_apis/fssaiVerification.typings";
102
102
  export * from "./typings/verification_apis/panVerification.typings";
103
103
  export * from "./typings/verification_apis/bankAccountVerification.typings";
104
+ export * from "./typings/verification_apis/cinVerification.typings";
104
105
  export * from "./typings/kpis/basKPIS.typings";
105
106
  export * from "./typings/kpis/company/main/purchase/totalSavings.typings";
106
107
  export * from "./typings/kpis/company/main/purchase/purchaseTrend.typings";
@@ -131,6 +132,7 @@ export * from "./helpers/padNumber.helper";
131
132
  export * from "./typings/plugins/plugin.typings";
132
133
  export * from "./utils/validators/gst.validator";
133
134
  export * from "./utils/validators/pan.validator";
135
+ export * from "./utils/validators/cin.validator";
134
136
  export interface ITesting {
135
137
  message: string;
136
138
  age: number;
package/build/index.js CHANGED
@@ -126,6 +126,7 @@ __exportStar(require("./typings/verification_apis/gstReturns.typings"), exports)
126
126
  __exportStar(require("./typings/verification_apis/fssaiVerification.typings"), exports);
127
127
  __exportStar(require("./typings/verification_apis/panVerification.typings"), exports);
128
128
  __exportStar(require("./typings/verification_apis/bankAccountVerification.typings"), exports);
129
+ __exportStar(require("./typings/verification_apis/cinVerification.typings"), exports);
129
130
  // KPIs
130
131
  __exportStar(require("./typings/kpis/basKPIS.typings"), exports);
131
132
  // Main Dashboard KPIS
@@ -167,3 +168,4 @@ __exportStar(require("./typings/plugins/plugin.typings"), exports);
167
168
  // Validators
168
169
  __exportStar(require("./utils/validators/gst.validator"), exports);
169
170
  __exportStar(require("./utils/validators/pan.validator"), exports);
171
+ __exportStar(require("./utils/validators/cin.validator"), exports);
@@ -13,7 +13,7 @@ export declare enum VENDOR_FORM_ROLLBACK_REMARK_INCLUDE {
13
13
  sent_by_company = "sent_by_company",
14
14
  sent_to_vendor = "sent_to_vendor"
15
15
  }
16
- export declare enum FORM_TYPE {
16
+ export declare enum ROLLBACK_FORM_TYPE {
17
17
  VENDOR_PAT = "VENDOR_PRE_ASSESSMENT",
18
18
  VENDOR_SVF = "VENDOR_SELF_VERIFICATION"
19
19
  }
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FORM_TYPE = exports.VENDOR_FORM_ROLLBACK_REMARK_INCLUDE = void 0;
3
+ exports.ROLLBACK_FORM_TYPE = exports.VENDOR_FORM_ROLLBACK_REMARK_INCLUDE = void 0;
4
4
  var VENDOR_FORM_ROLLBACK_REMARK_INCLUDE;
5
5
  (function (VENDOR_FORM_ROLLBACK_REMARK_INCLUDE) {
6
6
  VENDOR_FORM_ROLLBACK_REMARK_INCLUDE["rollback_by_user"] = "rollback_by_user";
7
7
  VENDOR_FORM_ROLLBACK_REMARK_INCLUDE["sent_by_company"] = "sent_by_company";
8
8
  VENDOR_FORM_ROLLBACK_REMARK_INCLUDE["sent_to_vendor"] = "sent_to_vendor";
9
9
  })(VENDOR_FORM_ROLLBACK_REMARK_INCLUDE || (exports.VENDOR_FORM_ROLLBACK_REMARK_INCLUDE = VENDOR_FORM_ROLLBACK_REMARK_INCLUDE = {}));
10
- var FORM_TYPE;
11
- (function (FORM_TYPE) {
12
- FORM_TYPE["VENDOR_PAT"] = "VENDOR_PRE_ASSESSMENT";
13
- FORM_TYPE["VENDOR_SVF"] = "VENDOR_SELF_VERIFICATION";
14
- })(FORM_TYPE || (exports.FORM_TYPE = FORM_TYPE = {}));
10
+ var ROLLBACK_FORM_TYPE;
11
+ (function (ROLLBACK_FORM_TYPE) {
12
+ ROLLBACK_FORM_TYPE["VENDOR_PAT"] = "VENDOR_PRE_ASSESSMENT";
13
+ ROLLBACK_FORM_TYPE["VENDOR_SVF"] = "VENDOR_SELF_VERIFICATION";
14
+ })(ROLLBACK_FORM_TYPE || (exports.ROLLBACK_FORM_TYPE = ROLLBACK_FORM_TYPE = {}));
@@ -0,0 +1,67 @@
1
+ export interface IVerifyCINReq {
2
+ cin_no: string;
3
+ }
4
+ export interface ICINError {
5
+ message: string;
6
+ }
7
+ export interface ICINErrorResponse {
8
+ data: {
9
+ errors: ICINError[];
10
+ };
11
+ }
12
+ export interface ICINVerificationResponse {
13
+ cin: string | null;
14
+ company: string | null;
15
+ company_type: string | null;
16
+ company_origin: string | null;
17
+ registration_number: string | null;
18
+ date_of_incorporation: string | null;
19
+ email_address: string | null;
20
+ whether_listed_or_not: string | null;
21
+ company_category: string | null;
22
+ company_subcategory: string | null;
23
+ class_of_company: string | null;
24
+ authorised_capital: string | null;
25
+ paid_up_capital: string | null;
26
+ date_of_last_agm: string | null;
27
+ llp_status: string | null;
28
+ roc_name: string | null;
29
+ share_capital_flag: string | null;
30
+ subscribed_capital: string | null;
31
+ rd_name: string | null;
32
+ rd_region: string | null;
33
+ balance_sheet_date: string | null;
34
+ inc22aflag: string | null;
35
+ establishment_date: string | null;
36
+ error: string | null;
37
+ message: string | null;
38
+ status: string | null;
39
+ company_address: ICINCompanyAddress | null;
40
+ director_data: ICINDirectorData | null;
41
+ }
42
+ export interface ICINCompanyAddress {
43
+ street_address: string | null;
44
+ street_address2: string | null;
45
+ street_address3: string | null;
46
+ street_address4: string | null;
47
+ address_type: string | null;
48
+ locality: string | null;
49
+ district: string | null;
50
+ city: string | null;
51
+ state: string | null;
52
+ country: string | null;
53
+ postal_code: string | null;
54
+ office_type: string | null;
55
+ active_status: string | null;
56
+ establishment_date: string | null;
57
+ migration_flag: string | null;
58
+ }
59
+ export interface ICINDirectorData {
60
+ din: string | null;
61
+ pan: string | null;
62
+ date_of_appointment: string | null;
63
+ director_disqualified: string | null;
64
+ first_name: string | null;
65
+ middle_name: string | null;
66
+ last_name: string | null;
67
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const convertDurationToreadableFormat_util_1 = require("./convertDurationToreadableFormat.util");
4
+ describe("Convert Duration to Redable Format", () => {
5
+ it("Converting MS to 1Sec", () => {
6
+ expect((0, convertDurationToreadableFormat_util_1.convertDurationToReadableFormat)(1000)).toBe("1 sec");
7
+ });
8
+ it("Converting MS to 1Min", () => {
9
+ expect((0, convertDurationToreadableFormat_util_1.convertDurationToReadableFormat)(60000)).toBe("1 min");
10
+ });
11
+ it("Converting MS to 1Hr", () => {
12
+ expect((0, convertDurationToreadableFormat_util_1.convertDurationToReadableFormat)(3600000)).toBe("1 hr");
13
+ });
14
+ it("Converting MS to 1Day", () => {
15
+ expect((0, convertDurationToreadableFormat_util_1.convertDurationToReadableFormat)(3600000 * 24)).toBe("1 day");
16
+ });
17
+ it("Converting MS to 1Week", () => {
18
+ expect((0, convertDurationToreadableFormat_util_1.convertDurationToReadableFormat)(3600000 * 24 * 7)).toBe("1 week");
19
+ });
20
+ it("Converting MS to 1Month", () => {
21
+ expect((0, convertDurationToreadableFormat_util_1.convertDurationToReadableFormat)(3600000 * 24 * 30)).toBe("1 month");
22
+ });
23
+ it("Converting MS to 1year 1month ", () => {
24
+ expect((0, convertDurationToreadableFormat_util_1.convertDurationToReadableFormat)(3600000 * 24 * 30 * 13)).toBe("13 months");
25
+ });
26
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const convertToINS_util_1 = require("./convertToINS.util");
4
+ describe("Convert number to INS", () => {
5
+ it("Convert null ", () => {
6
+ expect((0, convertToINS_util_1.convertToINS)(null)).toBe("-");
7
+ });
8
+ it("Convert undefined ", () => {
9
+ expect((0, convertToINS_util_1.convertToINS)(undefined)).toBe("-");
10
+ });
11
+ it("Convert NAN to 10k", () => {
12
+ expect((0, convertToINS_util_1.convertToINS)(NaN)).toBe("-");
13
+ });
14
+ it("Convert empty string to 0", () => {
15
+ expect((0, convertToINS_util_1.convertToINS)(" ")).toBe("0");
16
+ });
17
+ it("Convert 1,000 to 1K", () => {
18
+ expect((0, convertToINS_util_1.convertToINS)(1000)).toBe("1 K");
19
+ });
20
+ it("Convert 10,000 to 10k", () => {
21
+ expect((0, convertToINS_util_1.convertToINS)(10000)).toBe("10 K");
22
+ });
23
+ it("Convert 1,00,000 to 1L", () => {
24
+ expect((0, convertToINS_util_1.convertToINS)(100000)).toBe("1 L");
25
+ });
26
+ it("Convert 10,00,000 to 10L", () => {
27
+ expect((0, convertToINS_util_1.convertToINS)(1000000)).toBe("10 L");
28
+ });
29
+ it("Convert 1,00,00,000 to 1 Cr", () => {
30
+ expect((0, convertToINS_util_1.convertToINS)(10000000)).toBe("1 Cr");
31
+ });
32
+ it("Convert 10,00,00,000 to 10 Cr", () => {
33
+ expect((0, convertToINS_util_1.convertToINS)(100000000)).toBe("10 Cr");
34
+ });
35
+ it("Convert 100,00,00,000 to 100 Cr", () => {
36
+ expect((0, convertToINS_util_1.convertToINS)(1000000000)).toBe("100 Cr");
37
+ });
38
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,202 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const contactPeople_typings_1 = require("../typings/contactPeople.typings");
4
+ const getContactPerson_util_1 = require("./getContactPerson.util");
5
+ describe("Get Contact Person", () => {
6
+ it("if contact_person_type = company_user ", () => {
7
+ const contact_person_type = contactPeople_typings_1.CONTACT_PERSON_TYPE.COMPANY_USER;
8
+ const company_user = {
9
+ id: "TEST-01",
10
+ contact: "942256XXXX",
11
+ email: "test@kraya.com",
12
+ firstname: "virat",
13
+ kraya_id: "",
14
+ password: "",
15
+ company_id: "",
16
+ employee_code: "999",
17
+ created_by_id: "",
18
+ lastname: "kholi",
19
+ jwtVersion: "",
20
+ has_read_release_note: false,
21
+ created_item_subcategories: null,
22
+ last_updated_item_subcategories: null,
23
+ created_items: null,
24
+ items_sent_for_approval: null,
25
+ created_grns: null,
26
+ last_updated_grns: null,
27
+ created_contact_people: null,
28
+ updated_contact_people: null,
29
+ last_updated_company_item_vendor_version: null,
30
+ items_last_updated_by_user: null,
31
+ created_istds: null,
32
+ last_updated_istds: null,
33
+ source_contact_person_for_istd: null,
34
+ dest_contact_person_for_istd: null,
35
+ istds_sent_for_source_approval: null,
36
+ istds_sent_for_dest_approval: null,
37
+ istds_sent_for_dest_store: null,
38
+ istds_marked_as_processed: null,
39
+ istds_terminated: null,
40
+ created_iads: null,
41
+ user_last_updated_iads: null,
42
+ as_approver_for_iads: null,
43
+ finalised_iads: null,
44
+ iads_terminated_by_user: null,
45
+ initiated_inventory_logs: null,
46
+ logs: null,
47
+ vendor_onboarding_requests_created_by_user: null,
48
+ vendor_onboarding_requests_last_updated: null,
49
+ vendor_onboarding_requests_sent_for_approval: null,
50
+ invitation_sent_for_vendor_onboarding_requests: null,
51
+ created_vendor_management_bodies: null,
52
+ last_updated_vendor_management_bodies: null,
53
+ head_of_vendor_management_bodies: null,
54
+ cancelled_vendor_onboarding_requests: null,
55
+ company_vendor_created_by_user: null,
56
+ company_vendors_last_updated_by_user: null,
57
+ sent_for_approval_company_vendors: null,
58
+ sent_questions_to_company_vendors: null,
59
+ cancelled_company_vendors: null,
60
+ created_vendor_onboarding_request_categories: null,
61
+ last_updated_vendor_onboarding_request_categories: null,
62
+ created_item_management_bodies: null,
63
+ last_updated_item_management_bodies: null,
64
+ as_head_of_item_management_bodies: null,
65
+ cancelled_items: null,
66
+ as_contact_person_for_rfqs: null,
67
+ as_contact_person_for_quotes: null,
68
+ cancelled_asns: null,
69
+ created_payment_terms: null,
70
+ invoices_marked_as_paid_or_rejected: null,
71
+ onboarded_company_vendors: null,
72
+ created_indents: null,
73
+ rollback_forms_by_user: null,
74
+ };
75
+ const contact_person = {
76
+ id: "",
77
+ name: "",
78
+ email: null,
79
+ contact: "",
80
+ description: null,
81
+ company_id: "",
82
+ created_by_user_id: "",
83
+ updated_by_user_id: "",
84
+ is_enabled: false,
85
+ is_deleted: false,
86
+ deleted_at: null,
87
+ created_at: "",
88
+ updated_at: "",
89
+ mis_issued_for_person: null,
90
+ indent_created_for_person: null,
91
+ created_by_user: null,
92
+ updated_by_user: null,
93
+ company: null,
94
+ referred_pos: null,
95
+ };
96
+ expect((0, getContactPerson_util_1.getContactPerson)({ contact_person_type, company_user, contact_person })).toStrictEqual({
97
+ contact: "942256XXXX",
98
+ email: "test@kraya.com",
99
+ emp_code: "999",
100
+ id: "TEST-01",
101
+ name: "virat kholi",
102
+ });
103
+ });
104
+ it("if contact_person_type = external_user ", () => {
105
+ const contact_person_type = contactPeople_typings_1.CONTACT_PERSON_TYPE.EXTERNAL_USER;
106
+ const company_user = {
107
+ id: "TEST-01",
108
+ contact: "942256XXXX",
109
+ email: "test@kraya.com",
110
+ firstname: "virat",
111
+ kraya_id: "",
112
+ password: "",
113
+ company_id: "",
114
+ employee_code: "999",
115
+ created_by_id: "",
116
+ lastname: "kholi",
117
+ jwtVersion: "",
118
+ has_read_release_note: false,
119
+ created_item_subcategories: null,
120
+ last_updated_item_subcategories: null,
121
+ created_items: null,
122
+ items_sent_for_approval: null,
123
+ created_grns: null,
124
+ last_updated_grns: null,
125
+ created_contact_people: null,
126
+ updated_contact_people: null,
127
+ last_updated_company_item_vendor_version: null,
128
+ items_last_updated_by_user: null,
129
+ created_istds: null,
130
+ last_updated_istds: null,
131
+ source_contact_person_for_istd: null,
132
+ dest_contact_person_for_istd: null,
133
+ istds_sent_for_source_approval: null,
134
+ istds_sent_for_dest_approval: null,
135
+ istds_sent_for_dest_store: null,
136
+ istds_marked_as_processed: null,
137
+ istds_terminated: null,
138
+ created_iads: null,
139
+ user_last_updated_iads: null,
140
+ as_approver_for_iads: null,
141
+ finalised_iads: null,
142
+ iads_terminated_by_user: null,
143
+ initiated_inventory_logs: null,
144
+ logs: null,
145
+ vendor_onboarding_requests_created_by_user: null,
146
+ vendor_onboarding_requests_last_updated: null,
147
+ vendor_onboarding_requests_sent_for_approval: null,
148
+ invitation_sent_for_vendor_onboarding_requests: null,
149
+ created_vendor_management_bodies: null,
150
+ last_updated_vendor_management_bodies: null,
151
+ head_of_vendor_management_bodies: null,
152
+ cancelled_vendor_onboarding_requests: null,
153
+ company_vendor_created_by_user: null,
154
+ company_vendors_last_updated_by_user: null,
155
+ sent_for_approval_company_vendors: null,
156
+ sent_questions_to_company_vendors: null,
157
+ cancelled_company_vendors: null,
158
+ created_vendor_onboarding_request_categories: null,
159
+ last_updated_vendor_onboarding_request_categories: null,
160
+ created_item_management_bodies: null,
161
+ last_updated_item_management_bodies: null,
162
+ as_head_of_item_management_bodies: null,
163
+ cancelled_items: null,
164
+ as_contact_person_for_rfqs: null,
165
+ as_contact_person_for_quotes: null,
166
+ cancelled_asns: null,
167
+ created_payment_terms: null,
168
+ invoices_marked_as_paid_or_rejected: null,
169
+ onboarded_company_vendors: null,
170
+ created_indents: null,
171
+ rollback_forms_by_user: null,
172
+ };
173
+ const contact_person = {
174
+ id: "CP-001",
175
+ name: "contact_person01",
176
+ email: "contact_person@kraya",
177
+ contact: "954508XXXX",
178
+ description: null,
179
+ company_id: "",
180
+ created_by_user_id: "",
181
+ updated_by_user_id: "",
182
+ is_enabled: false,
183
+ is_deleted: false,
184
+ deleted_at: null,
185
+ created_at: "",
186
+ updated_at: "",
187
+ mis_issued_for_person: null,
188
+ indent_created_for_person: null,
189
+ created_by_user: null,
190
+ updated_by_user: null,
191
+ company: null,
192
+ referred_pos: null,
193
+ };
194
+ expect((0, getContactPerson_util_1.getContactPerson)({ contact_person_type, company_user, contact_person })).toStrictEqual({
195
+ contact: "954508XXXX",
196
+ email: "contact_person@kraya",
197
+ emp_code: null,
198
+ id: "CP-001",
199
+ name: "contact_person01",
200
+ });
201
+ });
202
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const getMediaName_util_1 = require("./getMediaName.util");
4
+ describe("Get Media Name From Link", () => {
5
+ it("If link is Null it gives null", () => {
6
+ expect((0, getMediaName_util_1.getMediaNameFromLink)()).toBe(null);
7
+ });
8
+ it("if gives Image URL is present it gives Media Name", () => {
9
+ expect((0, getMediaName_util_1.getMediaNameFromLink)("https://example.com/images/my-awesome-photo.jpg?size=large")).toBe("my-awesome-photo");
10
+ });
11
+ it("if gives Video URL is present it gives Media Name", () => {
12
+ expect((0, getMediaName_util_1.getMediaNameFromLink)("https://cdn.videos.net/clips/holiday-vacation-clip.mp4")).toBe("holiday-vacation-clip");
13
+ });
14
+ it("if gives Video URL is present it gives Media Name", () => {
15
+ expect((0, getMediaName_util_1.getMediaNameFromLink)("https://docs.storage.org/reports/quarterly_report_2025.pdf")).toBe("quarterly_report_2025");
16
+ });
17
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const parseQueryParams_util_1 = require("./parseQueryParams.util");
4
+ describe("To Parse Query Parameter", () => {
5
+ it("if URL not conatin the query parameters it gives {} ", () => {
6
+ expect((0, parseQueryParams_util_1.parseQueryParams)("https://example.com/products")).toStrictEqual({});
7
+ });
8
+ it("if URL conatin the query parameters it gives {key: value} pair", () => {
9
+ expect((0, parseQueryParams_util_1.parseQueryParams)("https://example.com/products?category=electronics&sort=price_desc&page=2")).toStrictEqual({ category: "electronics", sort: "price_desc", page: "2" });
10
+ });
11
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const parseReqString_1 = require("./parseReqString");
4
+ describe("Parse Request String", () => {
5
+ it("For url with no filter", () => {
6
+ const url = "https://localhost:8000/api/v1/c/users";
7
+ expect((0, parseReqString_1.parseReqString)(url)).toBe("https://localhost:8000/api/v1/c/users");
8
+ });
9
+ it("For url with filter conatin null", () => {
10
+ const url = "https://localhost:8000/api/v1/c/users";
11
+ const filter = { limit: null };
12
+ expect((0, parseReqString_1.parseReqString)(url, filter)).toBe("https://localhost:8000/api/v1/c/users");
13
+ });
14
+ it("For url with filter conatin undefined", () => {
15
+ const url = "https://localhost:8000/api/v1/c/users";
16
+ const filter = { limit: undefined };
17
+ expect((0, parseReqString_1.parseReqString)(url, filter)).toBe("https://localhost:8000/api/v1/c/users");
18
+ });
19
+ it("For url with filter conatin string and null", () => {
20
+ const url = "https://localhost:8000/api/v1/c/users";
21
+ const filter = { page: "1", limit: null };
22
+ expect((0, parseReqString_1.parseReqString)(url, filter)).toBe("https://localhost:8000/api/v1/c/users?page=1&");
23
+ });
24
+ it("For url with multiple filter", () => {
25
+ const url = "https://localhost:8000/api/v1/c/users";
26
+ const filter = { limit: "10", page: "1", name: "firstname" };
27
+ expect((0, parseReqString_1.parseReqString)(url, filter)).toBe("https://localhost:8000/api/v1/c/users?limit=10&page=1&name=firstname&");
28
+ });
29
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const permission_constants_1 = require("../constants/permission.constants");
4
+ const permission_utils_1 = require("./permission.utils");
5
+ describe("Name of permission action", () => {
6
+ it("For PERMISSION_ACTIONS.CRUDSAC it gives Crudsac ", () => {
7
+ expect((0, permission_utils_1.getPermissionName)(permission_constants_1.PERMISSION_ACTIONS.CRUDSAC)).toBe("Crudsac");
8
+ });
9
+ it("For PERMISSION_ACTIONS.READ_ONLY it gives Read Only ", () => {
10
+ expect((0, permission_utils_1.getPermissionName)(permission_constants_1.PERMISSION_ACTIONS.READ_ONLY)).toBe("Read Only");
11
+ });
12
+ it("For PERMISSION_ACTIONS.STV it gives Send To Vendor ", () => {
13
+ expect((0, permission_utils_1.getPermissionName)(permission_constants_1.PERMISSION_ACTIONS.STV)).toBe("Send To Vendor");
14
+ });
15
+ it("For PERMISSION_ACTIONS.APPROVALS it gives Approvals ", () => {
16
+ expect((0, permission_utils_1.getPermissionName)(permission_constants_1.PERMISSION_ACTIONS.APPROVALS)).toBe("Approvals");
17
+ });
18
+ it("For PERMISSION_ACTIONS.STS it gives Send To Store ", () => {
19
+ expect((0, permission_utils_1.getPermissionName)(permission_constants_1.PERMISSION_ACTIONS.STS)).toBe("Send To Store");
20
+ });
21
+ it("For PERMISSION_ACTIONS.SEND_QUESTIONS it gives Send Ques ", () => {
22
+ expect((0, permission_utils_1.getPermissionName)(permission_constants_1.PERMISSION_ACTIONS.SEND_QUESTIONS)).toBe("Send Ques");
23
+ });
24
+ it("For PERMISSION_ACTIONS.INVITE it gives Invite ", () => {
25
+ expect((0, permission_utils_1.getPermissionName)(permission_constants_1.PERMISSION_ACTIONS.INVITE)).toBe("Invite");
26
+ });
27
+ it("For PERMISSION_ACTIONS.ONBOARDING it gives Onboarding ", () => {
28
+ expect((0, permission_utils_1.getPermissionName)(permission_constants_1.PERMISSION_ACTIONS.ONBOARDING)).toBe("Onboarding");
29
+ });
30
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const quote_util_1 = require("./quote.util");
4
+ const taxes_util_1 = require("./taxes.util");
5
+ describe("Get Initial Discount per unit rate", () => {
6
+ it(`get Discount per unit rate when per_unit_rate !== initial_per_unit_rate &&
7
+ initial_discount_type !== discount_type &&
8
+ initial_discount_value !== discount_value`, () => {
9
+ const quoteItem = {
10
+ quote_id: "id",
11
+ initial_per_unit_rate: 1000,
12
+ initial_discount_value: 10,
13
+ initial_discount_type: "trade",
14
+ company_attachment_link: "xyz",
15
+ discount_type: "qty",
16
+ discount_value: 20,
17
+ per_unit_rate: 500,
18
+ id: "123",
19
+ item_id: "000",
20
+ item_name: "pqr",
21
+ code_sku: "a-123",
22
+ uom: "box",
23
+ tolerence: 10,
24
+ };
25
+ expect((0, quote_util_1.getInitialDiscountedPerUnitRate)(quoteItem)).toBe((0, taxes_util_1.getDiscountedPerUnitRate)(Object.assign(Object.assign({}, quoteItem), { per_unit_rate: quoteItem.initial_per_unit_rate, discount_type: quoteItem.initial_discount_type, discount_value: quoteItem.initial_discount_value })));
26
+ });
27
+ it(`get Discount per unit rate when per_unit_rate === initial_per_unit_rate &&
28
+ initial_discount_type === discount_type &&
29
+ initial_discount_value === discount_value`, () => {
30
+ const quoteItem = {
31
+ quote_id: "id",
32
+ initial_per_unit_rate: 1000,
33
+ initial_discount_value: 10,
34
+ initial_discount_type: "trade",
35
+ company_attachment_link: "xyz",
36
+ discount_type: "trade",
37
+ discount_value: 10,
38
+ per_unit_rate: 1000,
39
+ id: "123",
40
+ item_id: "000",
41
+ item_name: "pqr",
42
+ code_sku: "a-123",
43
+ uom: "box",
44
+ tolerence: 10,
45
+ };
46
+ expect((0, quote_util_1.getInitialDiscountedPerUnitRate)(quoteItem)).toBe(null);
47
+ });
48
+ });
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const removeQueryParamsFromReqStr_util_1 = require("./removeQueryParamsFromReqStr.util");
4
+ describe("", () => {
5
+ it("", () => {
6
+ const str = "https://example.com/products?category=electronics&sort=price_desc&page=2";
7
+ const remove = [""];
8
+ expect((0, removeQueryParamsFromReqStr_util_1.removeQueryParamsFromReqStr)(str, remove)).toBe("");
9
+ });
10
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const documentTaxes_typings_1 = require("../typings/documentTaxes.typings");
4
+ const taxes_util_1 = require("./taxes.util");
5
+ describe("Get Discount per unit rate", () => {
6
+ it("if per_unit_rate is NaN", () => {
7
+ const item = {
8
+ id: "123",
9
+ item_id: "laptop-15",
10
+ item_name: "laptop",
11
+ code_sku: "l-123",
12
+ uom: "box",
13
+ tolerence: null,
14
+ per_unit_rate: NaN,
15
+ };
16
+ expect((0, taxes_util_1.getDiscountedPerUnitRate)(item)).toBe(null);
17
+ });
18
+ it("if per_unit_rate is null", () => {
19
+ const item = {
20
+ id: "123",
21
+ item_id: "laptop-15",
22
+ item_name: "laptop",
23
+ code_sku: "l-123",
24
+ uom: "box",
25
+ tolerence: null,
26
+ per_unit_rate: null,
27
+ };
28
+ expect((0, taxes_util_1.getDiscountedPerUnitRate)(item)).toBe(null);
29
+ });
30
+ it("if per_unit_rate is undefined", () => {
31
+ const item = {
32
+ id: "123",
33
+ item_id: "laptop-15",
34
+ item_name: "laptop",
35
+ code_sku: "l-123",
36
+ uom: "box",
37
+ tolerence: null,
38
+ per_unit_rate: undefined,
39
+ };
40
+ expect((0, taxes_util_1.getDiscountedPerUnitRate)(item)).toBe(null);
41
+ });
42
+ it("if discount_type is FIXED", () => {
43
+ const item = {
44
+ id: "123",
45
+ item_id: "laptop-15",
46
+ item_name: "laptop",
47
+ code_sku: "l-123",
48
+ uom: "box",
49
+ tolerence: null,
50
+ per_unit_rate: 1000,
51
+ discount_type: documentTaxes_typings_1.TAX_TYPE.FIXED,
52
+ discount_value: 10,
53
+ };
54
+ expect((0, taxes_util_1.getDiscountedPerUnitRate)(item)).toBe(990);
55
+ });
56
+ it("if discount_type is PERCENTAGE ", () => {
57
+ const item = {
58
+ id: "123",
59
+ item_id: "laptop-15",
60
+ item_name: "laptop",
61
+ code_sku: "l-123",
62
+ uom: "box",
63
+ tolerence: null,
64
+ per_unit_rate: 1000,
65
+ discount_type: documentTaxes_typings_1.TAX_TYPE.PERCENTAGE,
66
+ discount_value: 10,
67
+ };
68
+ expect((0, taxes_util_1.getDiscountedPerUnitRate)(item)).toBe(900);
69
+ });
70
+ it("if discount_type is PERCENTAGE ", () => {
71
+ const item = {
72
+ id: "123",
73
+ item_id: "laptop-15",
74
+ item_name: "laptop",
75
+ code_sku: "l-123",
76
+ uom: "box",
77
+ tolerence: null,
78
+ per_unit_rate: 1000,
79
+ discount_type: null,
80
+ discount_value: 10,
81
+ };
82
+ expect((0, taxes_util_1.getDiscountedPerUnitRate)(item)).toBe(1000);
83
+ });
84
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const toFixedDecimal_util_1 = require("./toFixedDecimal.util");
4
+ describe("Fixed Decimal in en-IN", () => {
5
+ it("if input is null", () => {
6
+ expect((0, toFixedDecimal_util_1.toFixedDecimal)(null)).toBe("-");
7
+ });
8
+ it("if input is undefined", () => {
9
+ expect((0, toFixedDecimal_util_1.toFixedDecimal)(undefined)).toBe("-");
10
+ });
11
+ it("if input is not typeOf number", () => {
12
+ expect((0, toFixedDecimal_util_1.toFixedDecimal)("undefined")).toBe("-");
13
+ });
14
+ it("if input is NaN", () => {
15
+ expect((0, toFixedDecimal_util_1.toFixedDecimal)(NaN)).toBe("-");
16
+ });
17
+ it("if input is valid", () => {
18
+ expect((0, toFixedDecimal_util_1.toFixedDecimal)(1234567890)).toBe("1,23,45,67,890");
19
+ });
20
+ it("if input is in decimal", () => {
21
+ expect((0, toFixedDecimal_util_1.toFixedDecimal)(1234567.89)).toBe("12,34,568");
22
+ });
23
+ it("if input is in decimal", () => {
24
+ expect((0, toFixedDecimal_util_1.toFixedDecimal)(1200.89)).toBe("1,201");
25
+ });
26
+ it("if input is in decimal", () => {
27
+ expect((0, toFixedDecimal_util_1.toFixedDecimal)(1200.4)).toBe("1,200");
28
+ });
29
+ });
@@ -0,0 +1,2 @@
1
+ export declare const CIN_REGEX: RegExp;
2
+ export declare function isValidCIN(cin_no: string): boolean;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CIN_REGEX = void 0;
4
+ exports.isValidCIN = isValidCIN;
5
+ exports.CIN_REGEX = /^[LU][A-Z]{5}\d{5}[A-Z]{2}[A-Z]\d{6}$/;
6
+ function isValidCIN(cin_no) {
7
+ // TODO: Fix the CIN_REGEX value and use it to verify if the provided cin_no is valid or invalid
8
+ return true;
9
+ // return CIN_REGEX.test(cin_no);
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kcommons",
3
- "version": "13.11.5",
3
+ "version": "13.12.0",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -8,7 +8,11 @@
8
8
  "./build/**/*"
9
9
  ],
10
10
  "scripts": {
11
- "prepare": "rm -rf ./dist && tsc"
11
+ "prepare": "rm -rf ./dist && tsc",
12
+ "test": "jest",
13
+ "test:watch": "jest --watch",
14
+ "test:cov": "jest --coverage",
15
+ "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand"
12
16
  },
13
17
  "author": "",
14
18
  "license": "ISC",
@@ -16,5 +20,13 @@
16
20
  "date-fns": "^4.1.0",
17
21
  "uuid": "^11.1.0",
18
22
  "zod": "^3.23.8"
23
+ },
24
+ "devDependencies": {
25
+ "@nestjs/testing": "^10.4.20",
26
+ "@types/jest": "^29.5.14",
27
+ "jest": "^29.7.0",
28
+ "ts-jest": "^29.4.5",
29
+ "ts-node": "^10.9.1",
30
+ "typescript": "^5.2.0"
19
31
  }
20
32
  }