kcommons 18.12.16 → 18.13.1

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/build/index.d.ts CHANGED
@@ -91,6 +91,7 @@ export * from "./typings/company/masters/imr.typings";
91
91
  export * from "./typings/approvalComments.typings";
92
92
  export * from "./typings/integrations/erp/vendorDuplicityCheck.typings";
93
93
  export * from "./typings/entityApprovalChainEntryLog.typings";
94
+ export * from "./typings/vendorLogs.typings";
94
95
  export * from "./typings/system/queueJob.typings";
95
96
  export * from "./typings/system/erpPluginConfigCompany.typings";
96
97
  export * from "./typings/system/erpPluginsMetadata.typings";
@@ -135,6 +136,7 @@ export * from "./utils/removeQueryParamsFromReqStr.util";
135
136
  export * from "./utils/toFixedDecimal.util";
136
137
  export * from "./utils/convertToINS.util";
137
138
  export * from "./utils/convertDurationToreadableFormat.util";
139
+ export * from "./utils/businessTime.util";
138
140
  export * from "./utils/extra-form/formatValidationSchema.util";
139
141
  export * from "./utils/extra-form/getFormProps.util";
140
142
  export * from "./utils/extra-form/parseExtraFormAnswers.util";
package/build/index.js CHANGED
@@ -111,6 +111,7 @@ __exportStar(require("./typings/company/masters/imr.typings"), exports);
111
111
  __exportStar(require("./typings/approvalComments.typings"), exports);
112
112
  __exportStar(require("./typings/integrations/erp/vendorDuplicityCheck.typings"), exports);
113
113
  __exportStar(require("./typings/entityApprovalChainEntryLog.typings"), exports);
114
+ __exportStar(require("./typings/vendorLogs.typings"), exports);
114
115
  // System
115
116
  __exportStar(require("./typings/system/queueJob.typings"), exports);
116
117
  __exportStar(require("./typings/system/erpPluginConfigCompany.typings"), exports);
@@ -161,6 +162,7 @@ __exportStar(require("./utils/removeQueryParamsFromReqStr.util"), exports);
161
162
  __exportStar(require("./utils/toFixedDecimal.util"), exports);
162
163
  __exportStar(require("./utils/convertToINS.util"), exports);
163
164
  __exportStar(require("./utils/convertDurationToreadableFormat.util"), exports);
165
+ __exportStar(require("./utils/businessTime.util"), exports);
164
166
  __exportStar(require("./utils/extra-form/formatValidationSchema.util"), exports);
165
167
  __exportStar(require("./utils/extra-form/getFormProps.util"), exports);
166
168
  __exportStar(require("./utils/extra-form/parseExtraFormAnswers.util"), exports);
@@ -14,6 +14,7 @@ import { INestedVendor, IVendorInputs } from "../../vendor.typings";
14
14
  import { INestedVendorManagementBody } from "../masters/vendorManagementBody.typings";
15
15
  import { INestedVendorOnboardingRequestCategory } from "./vendorOnboardingRequestCategory.typings";
16
16
  import { INestedVendorOnboardingRequestScore } from "./vendorOnboardingRequestScore.typings";
17
+ import { INestedVendorLogs, IPendingWithUserData, VENDOR_LOGS_ACTION } from "../../vendorLogs.typings";
17
18
  export declare enum VENDOR_ONBOARDING_REQUEST_VIEW_TYPE {
18
19
  OPEN = "OPEN",
19
20
  DETAILED = "DETAILED"
@@ -43,13 +44,15 @@ export declare enum VENDOR_ONBOARDING_REQUEST_INCLUDES {
43
44
  extra_form_answers = "extra_form_answers",
44
45
  child_company_vendors = "child_company_vendors",
45
46
  scores = "scores",
46
- vendor_onboarding_request_category = "vendor_onboarding_request_category"
47
+ vendor_onboarding_request_category = "vendor_onboarding_request_category",
48
+ vendor_logs = "vendor_logs"
47
49
  }
48
50
  export declare enum VENDOR_ONBOARDING_REQUEST_METAFIELDS_INCLUDE {
49
51
  manual_verification_records = "manual_verification_records",
50
52
  vendor_onboarded_by_user = "vendor_onboarded_by_user",
51
53
  vendor_send_for_approval_by_user = "vendor_send_for_approval_by_user",
52
- approval_logs = "approval_logs"
54
+ approval_logs = "approval_logs",
55
+ pending_with_data = "pending_with_data"
53
56
  }
54
57
  export interface IVendorOnboardingRequestFilters {
55
58
  name?: string | null;
@@ -73,6 +76,7 @@ export interface IVendorOnboardingRequestMetafields {
73
76
  vendor_onboarded_by_user: INestedUser | null;
74
77
  vendor_send_for_approval_by_user: INestedUser | null;
75
78
  approval_logs: INestedEntityApprovalChainEntryLog[] | null;
79
+ pending_with_data: IPendingWithData | null;
76
80
  }
77
81
  export interface IVendorOnboardingRequest {
78
82
  id: string;
@@ -122,8 +126,9 @@ export interface IVendorOnboardingRequest {
122
126
  child_company_vendors: INestedCompanyVendors[] | null;
123
127
  scores: INestedVendorOnboardingRequestScore[] | null;
124
128
  metafields?: IVendorOnboardingRequestMetafields | null;
129
+ vendor_logs: INestedVendorLogs[] | null;
125
130
  }
126
- export interface INestedVendorOnboardingRequest extends Omit<IVendorOnboardingRequest, "company" | "created_by_user" | "last_updated_by_user" | "sent_for_approval_by_user" | "invitation_sent_by_user" | "approval_chain" | "parent_department" | "parent_vendor_management_body" | "extra_form_answers" | "cancelled_by_user" | "child_company_vendors" | "scores" | "vendor_onboarding_request_category" | "metafields"> {
131
+ export interface INestedVendorOnboardingRequest extends Omit<IVendorOnboardingRequest, "company" | "created_by_user" | "last_updated_by_user" | "sent_for_approval_by_user" | "invitation_sent_by_user" | "approval_chain" | "parent_department" | "parent_vendor_management_body" | "extra_form_answers" | "cancelled_by_user" | "child_company_vendors" | "scores" | "vendor_onboarding_request_category" | "metafields" | "vendor_logs"> {
127
132
  }
128
133
  export interface IOpenVendorOnboardingRequestApprovalPayload extends IOpenApprovalsBase {
129
134
  vendor_onboarding_request_id: string;
@@ -162,3 +167,19 @@ export declare enum VENDOR_ONBOARDING_REQUEST_LIST_TYPE {
162
167
  MY_APPROVALS = "MY_APPROVALS",
163
168
  APPROVED_BY_ME = "APPROVED_BY_ME"
164
169
  }
170
+ export interface IPendingWithData {
171
+ pending_with: IPendingWithUserData[];
172
+ pending_since: number | null;
173
+ }
174
+ export interface IVendorReport {
175
+ vendorName: string;
176
+ category: string;
177
+ vendorCode: string | null;
178
+ initiatedBy: string;
179
+ initiatorEmail: string;
180
+ status: VENDOR_LOGS_ACTION;
181
+ pendingWith: IPendingWithUserData[];
182
+ pendingSince: number;
183
+ remarks: string;
184
+ pendingFrom: Date | null;
185
+ }
@@ -35,6 +35,7 @@ var VENDOR_ONBOARDING_REQUEST_INCLUDES;
35
35
  VENDOR_ONBOARDING_REQUEST_INCLUDES["child_company_vendors"] = "child_company_vendors";
36
36
  VENDOR_ONBOARDING_REQUEST_INCLUDES["scores"] = "scores";
37
37
  VENDOR_ONBOARDING_REQUEST_INCLUDES["vendor_onboarding_request_category"] = "vendor_onboarding_request_category";
38
+ VENDOR_ONBOARDING_REQUEST_INCLUDES["vendor_logs"] = "vendor_logs";
38
39
  })(VENDOR_ONBOARDING_REQUEST_INCLUDES || (exports.VENDOR_ONBOARDING_REQUEST_INCLUDES = VENDOR_ONBOARDING_REQUEST_INCLUDES = {}));
39
40
  var VENDOR_ONBOARDING_REQUEST_METAFIELDS_INCLUDE;
40
41
  (function (VENDOR_ONBOARDING_REQUEST_METAFIELDS_INCLUDE) {
@@ -42,6 +43,7 @@ var VENDOR_ONBOARDING_REQUEST_METAFIELDS_INCLUDE;
42
43
  VENDOR_ONBOARDING_REQUEST_METAFIELDS_INCLUDE["vendor_onboarded_by_user"] = "vendor_onboarded_by_user";
43
44
  VENDOR_ONBOARDING_REQUEST_METAFIELDS_INCLUDE["vendor_send_for_approval_by_user"] = "vendor_send_for_approval_by_user";
44
45
  VENDOR_ONBOARDING_REQUEST_METAFIELDS_INCLUDE["approval_logs"] = "approval_logs";
46
+ VENDOR_ONBOARDING_REQUEST_METAFIELDS_INCLUDE["pending_with_data"] = "pending_with_data";
45
47
  })(VENDOR_ONBOARDING_REQUEST_METAFIELDS_INCLUDE || (exports.VENDOR_ONBOARDING_REQUEST_METAFIELDS_INCLUDE = VENDOR_ONBOARDING_REQUEST_METAFIELDS_INCLUDE = {}));
46
48
  var VENDOR_ONBOARDING_REQUEST_LIST_TYPE;
47
49
  (function (VENDOR_ONBOARDING_REQUEST_LIST_TYPE) {
@@ -68,6 +68,7 @@ import { ISupplierInvoice } from "./supplierInvoice.typings";
68
68
  import { INestedQualityClearanceDocument } from "./qcd.typings";
69
69
  import { INestedAudits } from "./audits.typings";
70
70
  import { INestedApprovalComment } from "./approvalComments.typings";
71
+ import { INestedVendorLogs } from "./vendorLogs.typings";
71
72
  export declare enum PRICING_PLANS {
72
73
  BASIC = "BASIC",
73
74
  GROWTH = "GROWTH",
@@ -152,7 +153,8 @@ export declare enum COMPANY_INCLUDE {
152
153
  invoice = "invoice",
153
154
  quality_clearance_documents = "quality_clearance_documents",
154
155
  audits = "audits",
155
- approval_comments = "approval_comments"
156
+ approval_comments = "approval_comments",
157
+ vendor_logs = "vendor_logs"
156
158
  }
157
159
  export interface ICompany extends IAddress {
158
160
  id: string;
@@ -256,8 +258,9 @@ export interface ICompany extends IAddress {
256
258
  quality_clearance_documents: INestedQualityClearanceDocument[] | null;
257
259
  audits: INestedAudits[] | null;
258
260
  approval_comments: INestedApprovalComment[] | null;
261
+ vendor_logs: INestedVendorLogs[] | null;
259
262
  }
260
- export interface INestedCompany extends Omit<ICompany, "associated_purchase_locations" | "associated_vendors" | "associated_permissions" | "associated_roles" | "approval_configs" | "subdepartments" | "subcategories" | "categories" | "items" | "offices" | "stores" | "employees" | "departments" | "vendor_groups" | "company_indents" | "indent_items" | "company_mis" | "mi_items" | "company_prs" | "pr_items" | "company_rfqs" | "company_quotes" | "entity_approval_chain_entries" | "company_negotiations" | "company_pos" | "company_grns" | "company_grns_items" | "company_mrns" | "company_mrns_items" | "company_boms" | "company_bom_items" | "company_comparatives" | "company_comparative_items" | "company_notifications" | "extra_question_ans" | "extra_core_related_questions" | "company_specific_vendor_items" | "po_asn_items_junction" | "company_contact_people" | "company_item_vendor_versions" | "istds" | "istd_items" | "inventory_logs" | "invoices" | "logs" | "vendor_onboarding_requests" | "vendor_management_bodies" | "item_management_bodies" | "rollback_forms_sent_by_company" | "company_checkpoints" | "company_ves" | "queue_jobs" | "company_terms_and_conditions" | "company_config" | "erp_plugins" | "company_temporary_worker_form" | "extra_questions" | "is_deleted" | "payment_terms" | "po_grn_items_junction" | "vendor_onboarding_request_categories" | "company_amended_po_items" | "sub_pos" | "sub_po_items" | "item_questionnaire" | "rfq_questionnaire" | "rfq_questionnaire_answers" | "company_customer_categories" | "associated_customer" | "customer_management_bodies" | "qa_locations" | "accounts_locations" | "vendor_documents_manual_verification_by_company" | "erp_plugings_metadata" | "invoice" | "quality_clearance_documents" | "audits" | "approval_comments"> {
263
+ export interface INestedCompany extends Omit<ICompany, "associated_purchase_locations" | "associated_vendors" | "associated_permissions" | "associated_roles" | "approval_configs" | "subdepartments" | "subcategories" | "categories" | "items" | "offices" | "stores" | "employees" | "departments" | "vendor_groups" | "company_indents" | "indent_items" | "company_mis" | "mi_items" | "company_prs" | "pr_items" | "company_rfqs" | "company_quotes" | "entity_approval_chain_entries" | "company_negotiations" | "company_pos" | "company_grns" | "company_grns_items" | "company_mrns" | "company_mrns_items" | "company_boms" | "company_bom_items" | "company_comparatives" | "company_comparative_items" | "company_notifications" | "extra_question_ans" | "extra_core_related_questions" | "company_specific_vendor_items" | "po_asn_items_junction" | "company_contact_people" | "company_item_vendor_versions" | "istds" | "istd_items" | "inventory_logs" | "invoices" | "logs" | "vendor_onboarding_requests" | "vendor_management_bodies" | "item_management_bodies" | "rollback_forms_sent_by_company" | "company_checkpoints" | "company_ves" | "queue_jobs" | "company_terms_and_conditions" | "company_config" | "erp_plugins" | "company_temporary_worker_form" | "extra_questions" | "is_deleted" | "payment_terms" | "po_grn_items_junction" | "vendor_onboarding_request_categories" | "company_amended_po_items" | "sub_pos" | "sub_po_items" | "item_questionnaire" | "rfq_questionnaire" | "rfq_questionnaire_answers" | "company_customer_categories" | "associated_customer" | "customer_management_bodies" | "qa_locations" | "accounts_locations" | "vendor_documents_manual_verification_by_company" | "erp_plugings_metadata" | "invoice" | "quality_clearance_documents" | "audits" | "approval_comments" | "vendor_logs"> {
261
264
  }
262
265
  export interface ICompanyVendorAdditionalInfoMappingConfig {
263
266
  additional_info_form_que_id: string;
@@ -86,6 +86,7 @@ var COMPANY_INCLUDE;
86
86
  COMPANY_INCLUDE["quality_clearance_documents"] = "quality_clearance_documents";
87
87
  COMPANY_INCLUDE["audits"] = "audits";
88
88
  COMPANY_INCLUDE["approval_comments"] = "approval_comments";
89
+ COMPANY_INCLUDE["vendor_logs"] = "vendor_logs";
89
90
  })(COMPANY_INCLUDE || (exports.COMPANY_INCLUDE = COMPANY_INCLUDE = {}));
90
91
  // export interface IUpdateVendorOnboardingRequestCategoriesInputs
91
92
  // extends Pick<ICompany, "vendor_onboarding_request_categories"> {}
@@ -5,6 +5,12 @@ export declare enum COMPANY_PLUGINS {
5
5
  ACCOUNT_PAYABLES_AUTOMATION_MODULE = "ACCOUNT_PAYABLES_AUTOMATION_MODULE",
6
6
  COMPANY_CUSTOMER_MODULE = "COMPANY_CUSTOMER_MODULE"
7
7
  }
8
+ export interface IWeekOff {
9
+ /** Day of week, using JS Date#getDay() values (0=Sunday ... 6=Saturday) */
10
+ day: number;
11
+ /** Which occurrence(s) of that weekday in the month are a week-off (1=1st, 2=2nd, ...). */
12
+ occurrences: number[];
13
+ }
8
14
  export interface ICompanyConfig {
9
15
  id: string;
10
16
  selected_price_plan: PRICING_PLANS;
@@ -22,6 +28,10 @@ export interface ICompanyConfig {
22
28
  allow_custom_whatsapp: boolean;
23
29
  allow_custom_mailer: boolean;
24
30
  requires_qcd_for_imr: boolean;
31
+ shift_start_time: string | null;
32
+ shift_end_time: string | null;
33
+ week_off: IWeekOff[];
34
+ public_holidays: string[];
25
35
  created_at: string;
26
36
  updated_at: string;
27
37
  company: INestedCompany | null;
@@ -1,7 +1,7 @@
1
1
  import { IAddress } from "./common/address.typings";
2
2
  import { IOpenApprovalsBase } from "./common/openApprovals.typings";
3
3
  import { INestedCompany } from "./company.typings";
4
- import { INestedVendorOnboardingRequest } from "./company/vendorOnboardingRequest/vendorOnboardingRequest.typing";
4
+ import { INestedVendorOnboardingRequest, IPendingWithData } from "./company/vendorOnboardingRequest/vendorOnboardingRequest.typing";
5
5
  import { INestedVendorOnboardingRequestCategory } from "./company/vendorOnboardingRequest/vendorOnboardingRequestCategory.typings";
6
6
  import { INestedCompanyItemVendorVersion } from "./companyItemVendorVersion.typings";
7
7
  import { IEntityApprovalChainEntry, INestedEntityApprovalChainEntry } from "./entityApprovalChainEntry.typings";
@@ -20,6 +20,7 @@ import { IPaginationFilters } from "./common/paginationFilters.typings";
20
20
  import { IVendorDocumentManualVerificationByCompanyForMetafields } from "./common/vendorDocumentsManualVerificationByCompany.typings";
21
21
  import { ISupplierInvoice } from "./supplierInvoice.typings";
22
22
  import { INestedEntityApprovalChainEntryLog } from "./entityApprovalChainEntryLog.typings";
23
+ import { INestedVendorLogs } from "./vendorLogs.typings";
23
24
  export declare enum COMPANY_FORM_STATUS_FOR_VENDOR {
24
25
  INVITED = "INVITED",
25
26
  ANSWERED = "ANSWERED",
@@ -56,7 +57,8 @@ export declare enum CompanyVendorsInclude {
56
57
  onboarded_by_user = "onboarded_by_user",
57
58
  extra_form_ans = "extra_form_ans",
58
59
  parent_vendor_onboarding_request_category = "parent_vendor_onboarding_request_category",
59
- invoice = "invoice"
60
+ invoice = "invoice",
61
+ vendor_logs = "vendor_logs"
60
62
  }
61
63
  export declare enum COMPANY_VENDOR_METAFIELDS_INCLUDE {
62
64
  contact_details_for_po = "contact_details_for_po",
@@ -65,7 +67,8 @@ export declare enum COMPANY_VENDOR_METAFIELDS_INCLUDE {
65
67
  contact_details_for_general = "contact_details_for_general",
66
68
  parent_vor_created_by_user = "parent_vor_created_by_user",
67
69
  manual_verification_records = "manual_verification_records",
68
- approval_logs = "approval_logs"
70
+ approval_logs = "approval_logs",
71
+ pending_with_data = "pending_with_data"
69
72
  }
70
73
  export interface ICompanyVendorMetafields {
71
74
  contact_details_for_po: INestedVendorUser | null;
@@ -75,6 +78,7 @@ export interface ICompanyVendorMetafields {
75
78
  parent_vor_created_by_user: INestedUser | null;
76
79
  manual_verification_records: IVendorDocumentManualVerificationByCompanyForMetafields[] | null;
77
80
  approval_logs: INestedEntityApprovalChainEntryLog[] | null;
81
+ pending_with_data: IPendingWithData | null;
78
82
  }
79
83
  export interface ICompanyVendorFilters {
80
84
  name?: string;
@@ -144,8 +148,9 @@ export interface ICompanyVendor {
144
148
  parent_vendor_onboarding_request_category: INestedVendorOnboardingRequestCategory | null;
145
149
  metafields: ICompanyVendorMetafields | null;
146
150
  invoice: ISupplierInvoice[] | null;
151
+ vendor_logs: INestedVendorLogs[] | null;
147
152
  }
148
- export interface INestedCompanyVendors extends Omit<ICompanyVendor, "company" | "vendor" | "rfqs_sent" | "vendor_groups" | "negotiations" | "pos" | "selected_item_categories" | "selected_items" | "company_allowed_item_categories" | "company_item_verndor_versions" | "approval_chain" | "invoices" | "parent_vendor_onboarding_request" | "created_by_user" | "last_updated_by" | "sent_for_approval_by_user" | "questions_sent_by_user" | "extra_form_ans" | "parent_vendor_onboarding_request_category" | "metafields"> {
153
+ export interface INestedCompanyVendors extends Omit<ICompanyVendor, "company" | "vendor" | "rfqs_sent" | "vendor_groups" | "negotiations" | "pos" | "selected_item_categories" | "selected_items" | "company_allowed_item_categories" | "company_item_verndor_versions" | "approval_chain" | "invoices" | "parent_vendor_onboarding_request" | "created_by_user" | "last_updated_by" | "sent_for_approval_by_user" | "questions_sent_by_user" | "extra_form_ans" | "parent_vendor_onboarding_request_category" | "metafields" | "vendor_logs"> {
149
154
  }
150
155
  export interface IICheckCompanyVendorStatusRes {
151
156
  vendor: IVendor;
@@ -41,6 +41,7 @@ var CompanyVendorsInclude;
41
41
  CompanyVendorsInclude["extra_form_ans"] = "extra_form_ans";
42
42
  CompanyVendorsInclude["parent_vendor_onboarding_request_category"] = "parent_vendor_onboarding_request_category";
43
43
  CompanyVendorsInclude["invoice"] = "invoice";
44
+ CompanyVendorsInclude["vendor_logs"] = "vendor_logs";
44
45
  })(CompanyVendorsInclude || (exports.CompanyVendorsInclude = CompanyVendorsInclude = {}));
45
46
  var COMPANY_VENDOR_METAFIELDS_INCLUDE;
46
47
  (function (COMPANY_VENDOR_METAFIELDS_INCLUDE) {
@@ -51,6 +52,7 @@ var COMPANY_VENDOR_METAFIELDS_INCLUDE;
51
52
  COMPANY_VENDOR_METAFIELDS_INCLUDE["parent_vor_created_by_user"] = "parent_vor_created_by_user";
52
53
  COMPANY_VENDOR_METAFIELDS_INCLUDE["manual_verification_records"] = "manual_verification_records";
53
54
  COMPANY_VENDOR_METAFIELDS_INCLUDE["approval_logs"] = "approval_logs";
55
+ COMPANY_VENDOR_METAFIELDS_INCLUDE["pending_with_data"] = "pending_with_data";
54
56
  })(COMPANY_VENDOR_METAFIELDS_INCLUDE || (exports.COMPANY_VENDOR_METAFIELDS_INCLUDE = COMPANY_VENDOR_METAFIELDS_INCLUDE = {}));
55
57
  var COMPANY_VENDOR_LIST_TYPE;
56
58
  (function (COMPANY_VENDOR_LIST_TYPE) {
@@ -26,3 +26,21 @@ export interface IVORTrendKPIResponse {
26
26
  parsedVor: IVORCategory[];
27
27
  vorTrend: IVORTrendKPIDataUnit[];
28
28
  }
29
+ export interface IVORTurnaroundTime {
30
+ id: string;
31
+ company_id: string;
32
+ vendor_id: string;
33
+ vendor_onboarding_request_id: string | null;
34
+ company_vendor_id: string | null;
35
+ vendor_user_id: string | null;
36
+ user_id: string | null;
37
+ action: string;
38
+ remark: string | null;
39
+ turnaround_time: string;
40
+ initiator_name: string;
41
+ created_at: string;
42
+ updated_at: string;
43
+ }
44
+ export interface IVORTurnaroundTimeKPIResponse {
45
+ data: IVORTurnaroundTime[];
46
+ }
@@ -64,6 +64,7 @@ import { INestedVendorDocumentManualVerificationByCompany } from "./common/vendo
64
64
  import { INestedQualityClearanceDocument } from "./qcd.typings";
65
65
  import { INestedAudits } from "./audits.typings";
66
66
  import { INestedApprovalComment } from "./approvalComments.typings";
67
+ import { INestedVendorLogs } from "./vendorLogs.typings";
67
68
  export interface IUser {
68
69
  id: string;
69
70
  is_enabled?: boolean | null;
@@ -247,8 +248,9 @@ export interface IUser {
247
248
  supplier_invoices_marked_as_verified: INestedSupplierInvoice[] | null;
248
249
  approval_comments: INestedApprovalComment[] | null;
249
250
  last_updated_supplier_invoice: INestedSupplierInvoice[] | null;
251
+ vendor_logs: INestedVendorLogs[] | null;
250
252
  }
251
- export interface INestedUser extends Omit<IUser, "updated_at" | "created_at" | "deleted_at" | "reporting_to" | "active_company" | "active_role" | "subordinates" | "otps" | "as_incharge_in_purchase_locations" | "as_incharge_in_store_locations" | "as_incharge_in_offices" | "as_incharge_in_gates" | "as_contact_person_companies" | "as_contact_person_offices" | "as_contact_person_gates" | "owned_companies" | "head_for_departments" | "created_item_subcategories" | "last_updated_item_subcategories" | "head_for_departments" | "approval_chains" | "indents_created_for_user" | "created_mis" | "mis_issued_for_user" | "mis_sent_for_approval" | "mis_issued" | "mis_last_updated" | "created_prs" | "pr_sent_for_approval" | "pr_sent_to_purchase_location" | "last_updated_prs" | "created_rfqs" | "entity_approval_chains" | "as_contact_person_for_rfqs" | "as_contact_person_for_quotes" | "rfqs_sent_for_approval" | "rfqs_sent_to_vendors" | "created_rfq_items" | "negotiations" | "created_pos" | "last_updated_pos" | "as_contact_person_for_pos" | "pos_sent_for_approval" | "pos_sent_to_vendors" | "created_grns" | "last_updated_grns" | "as_contact_person_for_grns" | "grns_sent_for_approval" | "grns_sent_to_store" | "mrns_sent_for_approval" | "as_contact_person_for_mrns" | "created_boms" | "last_updated_boms" | "created_vendor_groups" | "last_updated_vendor_groups" | "comparatives_sent_for_approval" | "user_notifications" | "created_extra_quesstions" | "updated_extra_quesstions" | "answered_questions" | "created_extra_core_question_for_companies" | "updated_extra_core_question_for_companies" | "cancelled_asns" | "created_contact_people" | "updated_contact_people" | "last_updated_company_item_vendor_version" | "items_last_updated_by_user" | "company_vendors_last_updated_by_user" | "created_istds" | "last_updated_istds" | "source_contact_person_for_istd" | "dest_contact_person_for_istd" | "istds_sent_for_source_approval" | "istds_sent_for_dest_approval" | "istds_sent_for_dest_store" | "istds_marked_as_processed" | "istds_terminated" | "created_payment_terms" | "created_iads" | "user_last_updated_iads" | "as_approver_for_iads" | "iads_terminated_by_user" | "finalised_iads" | "assigned_roles" | "initiated_inventory_logs" | "logs" | "vendor_onboarding_requests_created_by_user" | "vendor_onboarding_requests_last_updated" | "vendor_onboarding_requests_sent_for_approval" | "invitation_sent_for_vendor_onboarding_requests" | "created_vendor_management_bodies" | "last_updated_vendor_management_bodies" | "head_of_vendor_management_bodies" | "cancelled_vendor_onboarding_requests" | "company_vendor_created_by_user" | "company_vendors_last_updated_by_user" | "sent_for_approval_company_vendors" | "sent_questions_to_company_vendors" | "cancelled_company_vendors" | "created_vendor_onboarding_request_categories" | "last_updated_vendor_onboarding_request_categories" | "created_item_management_bodies" | "last_updated_item_management_bodies" | "as_head_of_item_management_bodies" | "created_items" | "items_sent_for_approval" | "cancelled_items" | "invoices_marked_as_paid_or_rejected" | "onboarded_company_vendors" | "created_indents" | "rollback_forms_by_user" | "asns_sent_to_vendor_by_user" | "created_terms_and_conditions" | "last_updated_terms_and_conditions" | "checkpoints_created_by_user" | "checkpoints_last_updated_by_user" | "pos_closed_early" | "ves_created_by_user" | "ves_last_updated_by_user" | "ves_cancelled_by_user" | "take_on_approval_for_ves" | "time_records_at_checkpoint" | "created_queue_jobs" | "last_updated_payment_terms" | "created_temporary_worker_form" | "last_updated_temporary_worker_form" | "resolved_mrns" | "created_amended_po_items" | "last_updated_amended_po_items" | "created_sub_pos" | "last_updated_sub_pos" | "sent_for_approval_sub_pos" | "sent_to_vendor_sub_pos" | "created_sub_po_items" | "last_updated_sub_po_items" | "marked_as_deleted_sub_po_items" | "created_item_questions" | "last_updated_item_questions" | "created_rfq_questions" | "last_updated_rfq_questions" | "created_company_customer_categories" | "last_updated_company_customer_categories" | "company_customer_created_by_user" | "company_customer_last_updated_by_user" | "sent_for_approval_company_customer" | "onboarded_company_customer" | "created_customer_management_bodies" | "last_updated_customer_management_bodies" | "head_of_customer_management_bodies" | "last_updated_comparative_items_quantity_splits" | "comparative_early_access_requests" | "otp_security" | "qa_location_incharge" | "accounts_location_incharge" | "vendor_documents_verified_by_user" | "created_supplier_invoice" | "qcd_cancelled" | "qcd_created" | "qcd_last_updated" | "audits_incharge" | "supplier_invoices_marked_as_cancelled" | "supplier_invoices_marked_as_verified" | "approval_comments" | "last_updated_supplier_invoice"> {
253
+ export interface INestedUser extends Omit<IUser, "updated_at" | "created_at" | "deleted_at" | "reporting_to" | "active_company" | "active_role" | "subordinates" | "otps" | "as_incharge_in_purchase_locations" | "as_incharge_in_store_locations" | "as_incharge_in_offices" | "as_incharge_in_gates" | "as_contact_person_companies" | "as_contact_person_offices" | "as_contact_person_gates" | "owned_companies" | "head_for_departments" | "created_item_subcategories" | "last_updated_item_subcategories" | "head_for_departments" | "approval_chains" | "indents_created_for_user" | "created_mis" | "mis_issued_for_user" | "mis_sent_for_approval" | "mis_issued" | "mis_last_updated" | "created_prs" | "pr_sent_for_approval" | "pr_sent_to_purchase_location" | "last_updated_prs" | "created_rfqs" | "entity_approval_chains" | "as_contact_person_for_rfqs" | "as_contact_person_for_quotes" | "rfqs_sent_for_approval" | "rfqs_sent_to_vendors" | "created_rfq_items" | "negotiations" | "created_pos" | "last_updated_pos" | "as_contact_person_for_pos" | "pos_sent_for_approval" | "pos_sent_to_vendors" | "created_grns" | "last_updated_grns" | "as_contact_person_for_grns" | "grns_sent_for_approval" | "grns_sent_to_store" | "mrns_sent_for_approval" | "as_contact_person_for_mrns" | "created_boms" | "last_updated_boms" | "created_vendor_groups" | "last_updated_vendor_groups" | "comparatives_sent_for_approval" | "user_notifications" | "created_extra_quesstions" | "updated_extra_quesstions" | "answered_questions" | "created_extra_core_question_for_companies" | "updated_extra_core_question_for_companies" | "cancelled_asns" | "created_contact_people" | "updated_contact_people" | "last_updated_company_item_vendor_version" | "items_last_updated_by_user" | "company_vendors_last_updated_by_user" | "created_istds" | "last_updated_istds" | "source_contact_person_for_istd" | "dest_contact_person_for_istd" | "istds_sent_for_source_approval" | "istds_sent_for_dest_approval" | "istds_sent_for_dest_store" | "istds_marked_as_processed" | "istds_terminated" | "created_payment_terms" | "created_iads" | "user_last_updated_iads" | "as_approver_for_iads" | "iads_terminated_by_user" | "finalised_iads" | "assigned_roles" | "initiated_inventory_logs" | "logs" | "vendor_onboarding_requests_created_by_user" | "vendor_onboarding_requests_last_updated" | "vendor_onboarding_requests_sent_for_approval" | "invitation_sent_for_vendor_onboarding_requests" | "created_vendor_management_bodies" | "last_updated_vendor_management_bodies" | "head_of_vendor_management_bodies" | "cancelled_vendor_onboarding_requests" | "company_vendor_created_by_user" | "company_vendors_last_updated_by_user" | "sent_for_approval_company_vendors" | "sent_questions_to_company_vendors" | "cancelled_company_vendors" | "created_vendor_onboarding_request_categories" | "last_updated_vendor_onboarding_request_categories" | "created_item_management_bodies" | "last_updated_item_management_bodies" | "as_head_of_item_management_bodies" | "created_items" | "items_sent_for_approval" | "cancelled_items" | "invoices_marked_as_paid_or_rejected" | "onboarded_company_vendors" | "created_indents" | "rollback_forms_by_user" | "asns_sent_to_vendor_by_user" | "created_terms_and_conditions" | "last_updated_terms_and_conditions" | "checkpoints_created_by_user" | "checkpoints_last_updated_by_user" | "pos_closed_early" | "ves_created_by_user" | "ves_last_updated_by_user" | "ves_cancelled_by_user" | "take_on_approval_for_ves" | "time_records_at_checkpoint" | "created_queue_jobs" | "last_updated_payment_terms" | "created_temporary_worker_form" | "last_updated_temporary_worker_form" | "resolved_mrns" | "created_amended_po_items" | "last_updated_amended_po_items" | "created_sub_pos" | "last_updated_sub_pos" | "sent_for_approval_sub_pos" | "sent_to_vendor_sub_pos" | "created_sub_po_items" | "last_updated_sub_po_items" | "marked_as_deleted_sub_po_items" | "created_item_questions" | "last_updated_item_questions" | "created_rfq_questions" | "last_updated_rfq_questions" | "created_company_customer_categories" | "last_updated_company_customer_categories" | "company_customer_created_by_user" | "company_customer_last_updated_by_user" | "sent_for_approval_company_customer" | "onboarded_company_customer" | "created_customer_management_bodies" | "last_updated_customer_management_bodies" | "head_of_customer_management_bodies" | "last_updated_comparative_items_quantity_splits" | "comparative_early_access_requests" | "otp_security" | "qa_location_incharge" | "accounts_location_incharge" | "vendor_documents_verified_by_user" | "created_supplier_invoice" | "qcd_cancelled" | "qcd_created" | "qcd_last_updated" | "audits_incharge" | "supplier_invoices_marked_as_cancelled" | "supplier_invoices_marked_as_verified" | "approval_comments" | "last_updated_supplier_invoice" | "vendor_logs"> {
252
254
  }
253
255
  export declare enum UserInclude {
254
256
  subordinates = "subordinates",
@@ -409,7 +411,8 @@ export declare enum UserInclude {
409
411
  supplier_invoices_marked_as_cancelled = "supplier_invoices_marked_as_cancelled",
410
412
  supplier_invoices_marked_as_verified = "supplier_invoices_marked_as_verified",
411
413
  approval_comments = "approval_comments",
412
- last_updated_supplier_invoice = "last_updated_supplier_invoice"
414
+ last_updated_supplier_invoice = "last_updated_supplier_invoice",
415
+ vendor_logs = "vendor_logs"
413
416
  }
414
417
  export interface IUserFilters {
415
418
  name?: string | null;
@@ -162,4 +162,5 @@ var UserInclude;
162
162
  UserInclude["supplier_invoices_marked_as_verified"] = "supplier_invoices_marked_as_verified";
163
163
  UserInclude["approval_comments"] = "approval_comments";
164
164
  UserInclude["last_updated_supplier_invoice"] = "last_updated_supplier_invoice";
165
+ UserInclude["vendor_logs"] = "vendor_logs";
165
166
  })(UserInclude || (exports.UserInclude = UserInclude = {}));
@@ -12,6 +12,7 @@ import { INestedVendorItem } from "../vendorItem.typings";
12
12
  import { INestedVendorQuoteItem } from "../vendorQuoteItems.typings";
13
13
  import { INestedVendorPermission } from "./vendorPermission.typings";
14
14
  import { INestedVendorRole } from "./vendorRole.typings";
15
+ import { INestedVendorLogs } from "../vendorLogs.typings";
15
16
  export interface IVendorUser {
16
17
  id: string;
17
18
  contact: string;
@@ -65,8 +66,9 @@ export interface IVendorUser {
65
66
  last_updated_vendor_quote_items: INestedVendorQuoteItem[] | null;
66
67
  otp_security: INestedOtpSecurity | null;
67
68
  created_invoice: ISupplierInvoice[] | null;
69
+ vendor_logs: INestedVendorLogs[] | null;
68
70
  }
69
- export interface INestedVendorUser extends Omit<IVendorUser, "parent_vendor" | "otps" | "created_vendor_items" | "last_updated_vendor_items" | "deleted_vendor_items" | "created_company_specific_vendor_item_versions" | "last_udpated_company_specific_vendor_item_versions" | "deleted_company_specific_vendor_item_versions" | "accepted_rejected_po" | "vendor_user_notifications" | "quotes_last_updated" | "created_asns" | "last_updated_asns" | "cancelled_asn" | "owned_vendor_organizations" | "contact_person_for_po_at" | "contact_person_for_quote_at" | "contact_person_for_asn_at" | "contact_person_for_general_at" | "created_vendor_roles" | "last_updated_vendor_roles" | "assigned_vendor_roles" | "created_vendor_permissions" | "last_updated_vendor_permission" | "created_invoices" | "last_updated_invoices" | "created_vendor_quote_items" | "last_updated_vendor_quote_items" | "otp_security" | "created_invoice"> {
71
+ export interface INestedVendorUser extends Omit<IVendorUser, "parent_vendor" | "otps" | "created_vendor_items" | "last_updated_vendor_items" | "deleted_vendor_items" | "created_company_specific_vendor_item_versions" | "last_udpated_company_specific_vendor_item_versions" | "deleted_company_specific_vendor_item_versions" | "accepted_rejected_po" | "vendor_user_notifications" | "quotes_last_updated" | "created_asns" | "last_updated_asns" | "cancelled_asn" | "owned_vendor_organizations" | "contact_person_for_po_at" | "contact_person_for_quote_at" | "contact_person_for_asn_at" | "contact_person_for_general_at" | "created_vendor_roles" | "last_updated_vendor_roles" | "assigned_vendor_roles" | "created_vendor_permissions" | "last_updated_vendor_permission" | "created_invoices" | "last_updated_invoices" | "created_vendor_quote_items" | "last_updated_vendor_quote_items" | "otp_security" | "created_invoice" | "vendor_logs"> {
70
72
  }
71
73
  export declare enum VENDOR_USER_INCLUDE {
72
74
  parent_vendor = "parent_vendor",
@@ -98,7 +100,8 @@ export declare enum VENDOR_USER_INCLUDE {
98
100
  created_vendor_quote_items = "created_vendor_quote_items",
99
101
  last_updated_vendor_quote_items = "last_updated_vendor_quote_items",
100
102
  otp_security = "otp_security",
101
- created_invoice = "created_invoice"
103
+ created_invoice = "created_invoice",
104
+ vendor_logs = "vendor_logs"
102
105
  }
103
106
  export interface IVendorUserFilters {
104
107
  name?: string;
@@ -33,4 +33,5 @@ var VENDOR_USER_INCLUDE;
33
33
  VENDOR_USER_INCLUDE["last_updated_vendor_quote_items"] = "last_updated_vendor_quote_items";
34
34
  VENDOR_USER_INCLUDE["otp_security"] = "otp_security";
35
35
  VENDOR_USER_INCLUDE["created_invoice"] = "created_invoice";
36
+ VENDOR_USER_INCLUDE["vendor_logs"] = "vendor_logs";
36
37
  })(VENDOR_USER_INCLUDE || (exports.VENDOR_USER_INCLUDE = VENDOR_USER_INCLUDE = {}));
@@ -21,6 +21,7 @@ import { INestedLifecycleLogs } from "./common/lifecycleLogger.typings";
21
21
  import { INestedVendorQuoteItem } from "./vendorQuoteItems.typings";
22
22
  import { INestedVendorDocumentManualVerificationByCompany } from "./common/vendorDocumentsManualVerificationByCompany.typings";
23
23
  import { ISupplierInvoice } from "./supplierInvoice.typings";
24
+ import { INestedVendorLogs } from "./vendorLogs.typings";
24
25
  export interface IVendor extends IAddress {
25
26
  id: string;
26
27
  owner_vendor_user_id: string | null;
@@ -111,13 +112,14 @@ export interface IVendor extends IAddress {
111
112
  vendor_quote_items: INestedVendorQuoteItem[] | null;
112
113
  vendor_documents_manual_verification_by_company: INestedVendorDocumentManualVerificationByCompany[] | null;
113
114
  invoice: ISupplierInvoice[] | null;
115
+ vendor_logs: INestedVendorLogs[] | null;
114
116
  }
115
117
  export declare enum VENDOR_SVF_FORM_STATUS {
116
118
  SENT = "SENT",
117
119
  ANSWERED = "ANSWERED",
118
120
  ROLLED_BACK = "ROLLED_BACK"
119
121
  }
120
- export interface INestedVendor extends Omit<IVendor, "quotes" | "associated_companies" | "negotiations" | "as_additional_in_rfqs" | "vendor_notifications" | "extra_que_answers" | "pos" | "company_item_versions" | "invoices" | "contact_people" | "rollback_form_sent_to_vendor" | "created_queue_jobs" | "vendor_users" | "owner_vendor_user" | "po_contact_vendor_user" | "quote_contact_vendor_user" | "asn_contact_vendor_user" | "general_contact_vendor_user" | "associated_vendor_roles" | "associated_vendor_permissions" | "asns" | "asn_items" | "vendor_items" | "vendor_item_categories" | "logs" | "vendor_quote_items" | "vendor_documents_manual_verification_by_company" | "invoice"> {
122
+ export interface INestedVendor extends Omit<IVendor, "quotes" | "associated_companies" | "negotiations" | "as_additional_in_rfqs" | "vendor_notifications" | "extra_que_answers" | "pos" | "company_item_versions" | "invoices" | "contact_people" | "rollback_form_sent_to_vendor" | "created_queue_jobs" | "vendor_users" | "owner_vendor_user" | "po_contact_vendor_user" | "quote_contact_vendor_user" | "asn_contact_vendor_user" | "general_contact_vendor_user" | "associated_vendor_roles" | "associated_vendor_permissions" | "asns" | "asn_items" | "vendor_items" | "vendor_item_categories" | "logs" | "vendor_quote_items" | "vendor_documents_manual_verification_by_company" | "invoice" | "vendor_logs"> {
121
123
  }
122
124
  export interface IVendorOrganizationInputs extends Omit<INestedVendor, "id" | "created_at" | "updated_at" | "is_profile_complete" | "is_profile_verified" | "is_self_verified" | "deleted_at" | "is_deleted" | "vendor" | "vkraya_id" | "is_invitation_sent" | "is_enabled" | "svf_form_status" | "svf_rollback_remark" | "vendor_mob_notification_token" | "password" | "owner_vendor_user_id" | "po_contact_vendor_user_id" | "quote_contact_vendor_user_id" | "asn_contact_vendor_user_id" | "general_contact_vendor_user_id"> {
123
125
  }
@@ -161,7 +163,8 @@ export declare enum VENDOR_INCLUDE {
161
163
  logs = "logs",
162
164
  vendor_quote_items = "vendor_quote_items",
163
165
  vendor_documents_manual_verification_by_company = "vendor_documents_manual_verification_by_company",
164
- invoice = "invoice"
166
+ invoice = "invoice",
167
+ vendor_logs = "vendor_logs"
165
168
  }
166
169
  export declare enum VENDOR_TYPE {
167
170
  MFG = "Manufacturing",
@@ -37,6 +37,7 @@ var VENDOR_INCLUDE;
37
37
  VENDOR_INCLUDE["vendor_quote_items"] = "vendor_quote_items";
38
38
  VENDOR_INCLUDE["vendor_documents_manual_verification_by_company"] = "vendor_documents_manual_verification_by_company";
39
39
  VENDOR_INCLUDE["invoice"] = "invoice";
40
+ VENDOR_INCLUDE["vendor_logs"] = "vendor_logs";
40
41
  })(VENDOR_INCLUDE || (exports.VENDOR_INCLUDE = VENDOR_INCLUDE = {}));
41
42
  // for GST-Core activities Types
42
43
  var VENDOR_TYPE;
@@ -0,0 +1,99 @@
1
+ import { INestedCompany } from "./company.typings";
2
+ import { INestedCompanyVendors } from "./companyVendors.typings";
3
+ import { IPaginationFilters } from "./common/paginationFilters.typings";
4
+ import { INestedUser } from "./user.typings";
5
+ import { INestedVendor } from "./vendor.typings";
6
+ import { INestedVendorOnboardingRequest } from "./company/vendorOnboardingRequest/vendorOnboardingRequest.typing";
7
+ import { INestedVendorUser } from "./vendor/vendorUser.typings";
8
+ export declare enum VENDOR_LOGS_INCLUDE {
9
+ company = "company",
10
+ vendor = "vendor",
11
+ vendor_onboarding_request = "vendor_onboarding_request",
12
+ company_vendor = "company_vendor",
13
+ vendor_user = "vendor_user",
14
+ user = "user"
15
+ }
16
+ export interface IVendorLogs {
17
+ id: string;
18
+ company_id: string;
19
+ vendor_id: string;
20
+ vendor_onboarding_request_id: string | null;
21
+ company_vendor_id: string | null;
22
+ vendor_user_id: string | null;
23
+ user_id: string | null;
24
+ action: string;
25
+ remark: string | null;
26
+ turnaround_time: number;
27
+ initiator_name: string;
28
+ created_at: string;
29
+ updated_at: string;
30
+ company: INestedCompany | null;
31
+ vendor: INestedVendor | null;
32
+ vendor_onboarding_request: INestedVendorOnboardingRequest | null;
33
+ company_vendor: INestedCompanyVendors | null;
34
+ vendor_user: INestedVendorUser | null;
35
+ user: INestedUser | null;
36
+ }
37
+ export interface INestedVendorLogs extends Omit<IVendorLogs, "company" | "vendor" | "vendor_onboarding_request" | "company_vendor" | "vendor_user" | "user"> {
38
+ }
39
+ export interface IVendorLogsFilters extends Partial<Pick<IVendorLogs, "vendor_id" | "vendor_onboarding_request_id" | "company_vendor_id" | "vendor_user_id" | "user_id">> {
40
+ }
41
+ export interface IVendorLogsFiltersWithPagination extends IVendorLogsFilters, IPaginationFilters {
42
+ include?: VENDOR_LOGS_INCLUDE[];
43
+ }
44
+ export declare enum VENDOR_LOGS_ACTION {
45
+ VOR_CREATED = "VOR_CREATED",
46
+ VOR_UPDATED = "VOR_UPDATED",
47
+ SENT_PAT_TO_VENDOR = "SENT_PAT_TO_VENDOR",
48
+ VENDOR_SUBMITTED_PAT = "VENDOR_SUBMITTED_PAT",
49
+ VOR_SEND_FOR_APPROVAL = "VOR_SEND_FOR_APPROVAL",
50
+ VOR_APPROVAL = "VOR_APPROVAL",
51
+ VOR_APPROVED = "VOR_APPROVED",
52
+ VOR_REJECTED = "VOR_REJECTED",
53
+ VOR_CANCELLED = "VOR_CANCELLED",
54
+ COMPANY_VENDOR_CREATED = "COMPANY_VENDOR_CREATED",
55
+ COMPANY_VENDOR_UPDATED = "COMPANY_VENDOR_UPDATED",
56
+ COMPANY_VENDOR_ONBOARDED = "COMPANY_VENDOR_ONBOARDED",
57
+ COMPANY_VENDOR_SEND_FOR_APPROVAL = "COMPANY_VENDOR_SEND_FOR_APPROVAL",
58
+ COMPANY_VENDOR_APPROVAL = "COMPANY_VENDOR_APPROVAL",
59
+ COMPANY_VENDOR_APPROVED = "COMPANY_VENDOR_APPROVED",
60
+ COMPANY_VENDOR_REJECTED = "COMPANY_VENDOR_REJECTED",
61
+ SEND_SVF = "SEND_SVF",
62
+ SVF_ROLLBACK = "SVF_ROLLBACK",
63
+ PAT_ROLLBACK = "PAT_ROLLBACK",
64
+ COMPANY_VENDOR_CANCELLED = "COMPANY_VENDOR_CANCELLED",
65
+ VENDOR_SYNC_TO_ERP = "VENDOR_SYNC_TO_ERP"
66
+ }
67
+ export interface IVendorTurnaroundTime {
68
+ id: string;
69
+ company_id: string;
70
+ vendor_id: string;
71
+ vendor_onboarding_request_id: string | null;
72
+ company_vendor_id: string | null;
73
+ vendor_user_id: string | null;
74
+ user_id: string | null;
75
+ action: string;
76
+ remark: string | null;
77
+ turnaround_time: number;
78
+ initiator_name: string;
79
+ created_at: string;
80
+ updated_at: string;
81
+ }
82
+ export interface IVendorTurnaroundTimeKPIResponse {
83
+ data: IVendorTurnaroundTime[];
84
+ pending_with: IPendingWithUserData[];
85
+ pending_action: VENDOR_LOGS_ACTION | null;
86
+ pending_since: number | null;
87
+ }
88
+ export interface IPendingWithUserData {
89
+ user_id: string | null;
90
+ vendor_id: string | null;
91
+ firstname: string | null;
92
+ lastname: string | null;
93
+ middlename: string | null;
94
+ email: string | null;
95
+ contact: string | null;
96
+ employee_code: string | null;
97
+ vendor_trade_name: string | null;
98
+ order: number | null;
99
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VENDOR_LOGS_ACTION = exports.VENDOR_LOGS_INCLUDE = void 0;
4
+ var VENDOR_LOGS_INCLUDE;
5
+ (function (VENDOR_LOGS_INCLUDE) {
6
+ VENDOR_LOGS_INCLUDE["company"] = "company";
7
+ VENDOR_LOGS_INCLUDE["vendor"] = "vendor";
8
+ VENDOR_LOGS_INCLUDE["vendor_onboarding_request"] = "vendor_onboarding_request";
9
+ VENDOR_LOGS_INCLUDE["company_vendor"] = "company_vendor";
10
+ VENDOR_LOGS_INCLUDE["vendor_user"] = "vendor_user";
11
+ VENDOR_LOGS_INCLUDE["user"] = "user";
12
+ })(VENDOR_LOGS_INCLUDE || (exports.VENDOR_LOGS_INCLUDE = VENDOR_LOGS_INCLUDE = {}));
13
+ var VENDOR_LOGS_ACTION;
14
+ (function (VENDOR_LOGS_ACTION) {
15
+ VENDOR_LOGS_ACTION["VOR_CREATED"] = "VOR_CREATED";
16
+ VENDOR_LOGS_ACTION["VOR_UPDATED"] = "VOR_UPDATED";
17
+ VENDOR_LOGS_ACTION["SENT_PAT_TO_VENDOR"] = "SENT_PAT_TO_VENDOR";
18
+ VENDOR_LOGS_ACTION["VENDOR_SUBMITTED_PAT"] = "VENDOR_SUBMITTED_PAT";
19
+ VENDOR_LOGS_ACTION["VOR_SEND_FOR_APPROVAL"] = "VOR_SEND_FOR_APPROVAL";
20
+ VENDOR_LOGS_ACTION["VOR_APPROVAL"] = "VOR_APPROVAL";
21
+ VENDOR_LOGS_ACTION["VOR_APPROVED"] = "VOR_APPROVED";
22
+ VENDOR_LOGS_ACTION["VOR_REJECTED"] = "VOR_REJECTED";
23
+ VENDOR_LOGS_ACTION["VOR_CANCELLED"] = "VOR_CANCELLED";
24
+ VENDOR_LOGS_ACTION["COMPANY_VENDOR_CREATED"] = "COMPANY_VENDOR_CREATED";
25
+ VENDOR_LOGS_ACTION["COMPANY_VENDOR_UPDATED"] = "COMPANY_VENDOR_UPDATED";
26
+ VENDOR_LOGS_ACTION["COMPANY_VENDOR_ONBOARDED"] = "COMPANY_VENDOR_ONBOARDED";
27
+ VENDOR_LOGS_ACTION["COMPANY_VENDOR_SEND_FOR_APPROVAL"] = "COMPANY_VENDOR_SEND_FOR_APPROVAL";
28
+ VENDOR_LOGS_ACTION["COMPANY_VENDOR_APPROVAL"] = "COMPANY_VENDOR_APPROVAL";
29
+ VENDOR_LOGS_ACTION["COMPANY_VENDOR_APPROVED"] = "COMPANY_VENDOR_APPROVED";
30
+ VENDOR_LOGS_ACTION["COMPANY_VENDOR_REJECTED"] = "COMPANY_VENDOR_REJECTED";
31
+ VENDOR_LOGS_ACTION["SEND_SVF"] = "SEND_SVF";
32
+ VENDOR_LOGS_ACTION["SVF_ROLLBACK"] = "SVF_ROLLBACK";
33
+ VENDOR_LOGS_ACTION["PAT_ROLLBACK"] = "PAT_ROLLBACK";
34
+ VENDOR_LOGS_ACTION["COMPANY_VENDOR_CANCELLED"] = "COMPANY_VENDOR_CANCELLED";
35
+ VENDOR_LOGS_ACTION["VENDOR_SYNC_TO_ERP"] = "VENDOR_SYNC_TO_ERP";
36
+ })(VENDOR_LOGS_ACTION || (exports.VENDOR_LOGS_ACTION = VENDOR_LOGS_ACTION = {}));
@@ -0,0 +1,57 @@
1
+ export declare const SHIFT_START_HOUR = 0;
2
+ export declare const SHIFT_END_HOUR = 24;
3
+ export declare const WORKING_SECONDS_PER_DAY = 86400;
4
+ export declare const WORKING_DAYS_PER_WEEK = 5;
5
+ export declare const WORKING_WEEKS_PER_MONTH = 4;
6
+ export declare const WORKING_MONTHS_PER_YEAR = 12;
7
+ export declare const WORKING_SECONDS_PER_WEEK: number;
8
+ export declare const WORKING_SECONDS_PER_MONTH: number;
9
+ export declare const WORKING_SECONDS_PER_YEAR: number;
10
+ export declare enum WorkingHourStatus {
11
+ BEFORE_WORKING_HOURS = "before_working_hours",
12
+ WITHIN_WORKING_HOURS = "within_working_hours",
13
+ AFTER_WORKING_HOURS = "after_working_hours"
14
+ }
15
+ export interface BusinessCalendarOptions {
16
+ /** Days of week to treat as week-offs, using JS Date#getDay() values (0=Sunday ... 6=Saturday). */
17
+ weekOffDays?: number[];
18
+ /** Calendar dates (compared in the business timezone) to treat as public holidays. */
19
+ holidays?: Date[];
20
+ /** Shift start, as a fractional hour (e.g. 9.5 for 09:30). Defaults to SHIFT_START_HOUR. */
21
+ shiftStartHour?: number;
22
+ /** Shift end, as a fractional hour (e.g. 18.5 for 18:30). Defaults to SHIFT_END_HOUR. */
23
+ shiftEndHour?: number;
24
+ }
25
+ /** A recurring week-off rule: a weekday plus which occurrence(s) of it in the month are off. */
26
+ export interface WeekOffRule {
27
+ /** Day of week, using JS Date#getDay() values (0=Sunday ... 6=Saturday). */
28
+ day: number;
29
+ /** Which occurrence(s) of that weekday in the month are a week-off (1=1st, 2=2nd, ...). */
30
+ occurrences: number[];
31
+ }
32
+ /** Parses an "HH:mm" string (as stored on CompanyConfig) into a fractional hour, e.g. "09:30" -> 9.5. */
33
+ export declare function parseShiftTimeToHour(time?: string | null): number | undefined;
34
+ /** Derives a company's working seconds per day from its configured shift hours, falling back to WORKING_SECONDS_PER_DAY when either bound is missing. */
35
+ export declare function getWorkingSecondsPerDay(shiftStartHour?: number, shiftEndHour?: number): number;
36
+ /** Derives a company's working days per week from its recurring week-off rules (one off weekday per rule), falling back to WORKING_DAYS_PER_WEEK when none are configured. */
37
+ export declare function getWorkingDaysPerWeek(weekOff: WeekOffRule[] | null | undefined): number;
38
+ /**
39
+ * Expands recurring week-off rules (e.g. "2nd and 4th Saturday") into the concrete
40
+ * calendar dates they land on within [rangeStart, rangeEnd], so they can be merged
41
+ * with `holidays` for a specific calculation instead of being treated as blanket
42
+ * weekly off-days.
43
+ */
44
+ export declare function expandWeekOffRulesToDates(rules: WeekOffRule[] | null | undefined, rangeStart: Date, rangeEnd: Date): Date[];
45
+ export declare function getWorkingHourStatus(date: Date, options?: BusinessCalendarOptions): WorkingHourStatus;
46
+ export declare function normalizeStartTime(start: Date, options?: BusinessCalendarOptions): Date;
47
+ export declare function normalizeEndTime(end: Date, options?: BusinessCalendarOptions): Date;
48
+ export declare function calculateSameDayWorkingSeconds(start: Date, end: Date): number;
49
+ export declare function calculateMultiDayWorkingSeconds(start: Date, end: Date, options?: BusinessCalendarOptions): number;
50
+ export declare function calculateWorkingSeconds(start: Date, end: Date, options?: BusinessCalendarOptions): number;
51
+ export interface FormatBusinessDurationOptions {
52
+ /** Working seconds in a single day. Derive with getWorkingSecondsPerDay() from the company's shift hours; falls back to WORKING_SECONDS_PER_DAY. */
53
+ workingSecondsPerDay?: number;
54
+ /** Working days in a week. Derive with getWorkingDaysPerWeek() from the company's week-off rules; falls back to WORKING_DAYS_PER_WEEK. */
55
+ workingDaysPerWeek?: number;
56
+ }
57
+ export declare function formatBusinessDuration(seconds: number, options?: FormatBusinessDurationOptions): string;
@@ -0,0 +1,265 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkingHourStatus = exports.WORKING_SECONDS_PER_YEAR = exports.WORKING_SECONDS_PER_MONTH = exports.WORKING_SECONDS_PER_WEEK = exports.WORKING_MONTHS_PER_YEAR = exports.WORKING_WEEKS_PER_MONTH = exports.WORKING_DAYS_PER_WEEK = exports.WORKING_SECONDS_PER_DAY = exports.SHIFT_END_HOUR = exports.SHIFT_START_HOUR = void 0;
4
+ exports.parseShiftTimeToHour = parseShiftTimeToHour;
5
+ exports.getWorkingSecondsPerDay = getWorkingSecondsPerDay;
6
+ exports.getWorkingDaysPerWeek = getWorkingDaysPerWeek;
7
+ exports.expandWeekOffRulesToDates = expandWeekOffRulesToDates;
8
+ exports.getWorkingHourStatus = getWorkingHourStatus;
9
+ exports.normalizeStartTime = normalizeStartTime;
10
+ exports.normalizeEndTime = normalizeEndTime;
11
+ exports.calculateSameDayWorkingSeconds = calculateSameDayWorkingSeconds;
12
+ exports.calculateMultiDayWorkingSeconds = calculateMultiDayWorkingSeconds;
13
+ exports.calculateWorkingSeconds = calculateWorkingSeconds;
14
+ exports.formatBusinessDuration = formatBusinessDuration;
15
+ const date_fns_1 = require("date-fns");
16
+ exports.SHIFT_START_HOUR = 0;
17
+ exports.SHIFT_END_HOUR = 24;
18
+ // Fallbacks used only when a company hasn't configured shift hours / week-offs.
19
+ exports.WORKING_SECONDS_PER_DAY = 86400; // 24h
20
+ exports.WORKING_DAYS_PER_WEEK = 5;
21
+ exports.WORKING_WEEKS_PER_MONTH = 4;
22
+ exports.WORKING_MONTHS_PER_YEAR = 12;
23
+ exports.WORKING_SECONDS_PER_WEEK = exports.WORKING_SECONDS_PER_DAY * exports.WORKING_DAYS_PER_WEEK;
24
+ exports.WORKING_SECONDS_PER_MONTH = exports.WORKING_SECONDS_PER_WEEK * exports.WORKING_WEEKS_PER_MONTH;
25
+ exports.WORKING_SECONDS_PER_YEAR = exports.WORKING_SECONDS_PER_MONTH * exports.WORKING_MONTHS_PER_YEAR;
26
+ var WorkingHourStatus;
27
+ (function (WorkingHourStatus) {
28
+ WorkingHourStatus["BEFORE_WORKING_HOURS"] = "before_working_hours";
29
+ WorkingHourStatus["WITHIN_WORKING_HOURS"] = "within_working_hours";
30
+ WorkingHourStatus["AFTER_WORKING_HOURS"] = "after_working_hours";
31
+ })(WorkingHourStatus || (exports.WorkingHourStatus = WorkingHourStatus = {}));
32
+ // Working hours are defined in the business's own timezone (Asia/Kolkata,
33
+ // UTC+5:30, no DST) regardless of the timezone the code happens to run in
34
+ // (dev machine, server, CI), so status is deterministic for a given instant.
35
+ const BUSINESS_TZ_OFFSET_MS = 5.5 * 60 * 60 * 1000;
36
+ const MS_PER_DAY = 24 * 60 * 60 * 1000;
37
+ function toBusinessTz(date) {
38
+ return new Date(date.getTime() + BUSINESS_TZ_OFFSET_MS);
39
+ }
40
+ function fromBusinessTz(date) {
41
+ return new Date(date.getTime() - BUSINESS_TZ_OFFSET_MS);
42
+ }
43
+ function addBusinessDays(date, days) {
44
+ return new Date(date.getTime() + days * MS_PER_DAY);
45
+ }
46
+ /** Parses an "HH:mm" string (as stored on CompanyConfig) into a fractional hour, e.g. "09:30" -> 9.5. */
47
+ function parseShiftTimeToHour(time) {
48
+ if (!time)
49
+ return undefined;
50
+ const [hoursPart, minutesPart] = time.split(":");
51
+ const hours = Number(hoursPart);
52
+ const minutes = Number(minutesPart);
53
+ if (Number.isNaN(hours))
54
+ return undefined;
55
+ return hours + (Number.isNaN(minutes) ? 0 : minutes / 60);
56
+ }
57
+ /** Derives a company's working seconds per day from its configured shift hours, falling back to WORKING_SECONDS_PER_DAY when either bound is missing. */
58
+ function getWorkingSecondsPerDay(shiftStartHour, shiftEndHour) {
59
+ if (shiftStartHour === undefined || shiftEndHour === undefined)
60
+ return exports.WORKING_SECONDS_PER_DAY;
61
+ const seconds = (shiftEndHour - shiftStartHour) * 3600;
62
+ return seconds > 0 ? seconds : exports.WORKING_SECONDS_PER_DAY;
63
+ }
64
+ /** Derives a company's working days per week from its recurring week-off rules (one off weekday per rule), falling back to WORKING_DAYS_PER_WEEK when none are configured. */
65
+ function getWorkingDaysPerWeek(weekOff) {
66
+ if (!(weekOff === null || weekOff === void 0 ? void 0 : weekOff.length))
67
+ return exports.WORKING_DAYS_PER_WEEK;
68
+ const offDays = new Set(weekOff.map((rule) => rule.day));
69
+ const workingDays = 7 - offDays.size;
70
+ return workingDays > 0 ? workingDays : exports.WORKING_DAYS_PER_WEEK;
71
+ }
72
+ /**
73
+ * Expands recurring week-off rules (e.g. "2nd and 4th Saturday") into the concrete
74
+ * calendar dates they land on within [rangeStart, rangeEnd], so they can be merged
75
+ * with `holidays` for a specific calculation instead of being treated as blanket
76
+ * weekly off-days.
77
+ */
78
+ function expandWeekOffRulesToDates(rules, rangeStart, rangeEnd) {
79
+ var _a, _b;
80
+ if (!(rules === null || rules === void 0 ? void 0 : rules.length) || !rangeStart || !rangeEnd)
81
+ return [];
82
+ const shiftedStart = toBusinessTz(rangeStart);
83
+ const shiftedEnd = toBusinessTz(rangeEnd);
84
+ const startDayMs = Date.UTC(shiftedStart.getUTCFullYear(), shiftedStart.getUTCMonth(), shiftedStart.getUTCDate());
85
+ const endDayMs = Date.UTC(shiftedEnd.getUTCFullYear(), shiftedEnd.getUTCMonth(), shiftedEnd.getUTCDate());
86
+ const dates = [];
87
+ const occurrenceCounters = new Map();
88
+ for (let dayMs = startDayMs; dayMs <= endDayMs; dayMs += MS_PER_DAY) {
89
+ const current = new Date(dayMs);
90
+ const weekday = current.getUTCDay();
91
+ const counterKey = `${current.getUTCFullYear()}-${current.getUTCMonth()}-${weekday}`;
92
+ const occurrence = ((_a = occurrenceCounters.get(counterKey)) !== null && _a !== void 0 ? _a : 0) + 1;
93
+ occurrenceCounters.set(counterKey, occurrence);
94
+ const matchingRule = rules.find((rule) => rule.day === weekday);
95
+ if ((_b = matchingRule === null || matchingRule === void 0 ? void 0 : matchingRule.occurrences) === null || _b === void 0 ? void 0 : _b.includes(occurrence)) {
96
+ dates.push(fromBusinessTz(current));
97
+ }
98
+ }
99
+ return dates;
100
+ }
101
+ function differenceInBusinessCalendarDays(end, start) {
102
+ const shiftedEnd = toBusinessTz(end);
103
+ const shiftedStart = toBusinessTz(start);
104
+ const endDay = Date.UTC(shiftedEnd.getUTCFullYear(), shiftedEnd.getUTCMonth(), shiftedEnd.getUTCDate());
105
+ const startDay = Date.UTC(shiftedStart.getUTCFullYear(), shiftedStart.getUTCMonth(), shiftedStart.getUTCDate());
106
+ return Math.round((endDay - startDay) / MS_PER_DAY);
107
+ }
108
+ function atHour(date, hour) {
109
+ const shifted = toBusinessTz(date);
110
+ const wholeHour = Math.floor(hour);
111
+ const minutes = Math.round((hour - wholeHour) * 60);
112
+ shifted.setUTCHours(wholeHour, minutes, 0, 0);
113
+ return fromBusinessTz(shifted);
114
+ }
115
+ function isNonWorkingDay(date, options) {
116
+ var _a, _b;
117
+ if (!options)
118
+ return false;
119
+ if ((_a = options.weekOffDays) === null || _a === void 0 ? void 0 : _a.includes(toBusinessTz(date).getUTCDay()))
120
+ return true;
121
+ return Boolean((_b = options.holidays) === null || _b === void 0 ? void 0 : _b.some((holiday) => differenceInBusinessCalendarDays(date, holiday) === 0));
122
+ }
123
+ function ceilToWorkingInstant(date, options) {
124
+ var _a;
125
+ const startHour = (_a = options === null || options === void 0 ? void 0 : options.shiftStartHour) !== null && _a !== void 0 ? _a : exports.SHIFT_START_HOUR;
126
+ const status = getWorkingHourStatus(date, options);
127
+ let candidate;
128
+ switch (status) {
129
+ case WorkingHourStatus.BEFORE_WORKING_HOURS:
130
+ candidate = atHour(date, startHour);
131
+ break;
132
+ case WorkingHourStatus.AFTER_WORKING_HOURS:
133
+ candidate = atHour(addBusinessDays(date, 1), startHour);
134
+ break;
135
+ case WorkingHourStatus.WITHIN_WORKING_HOURS:
136
+ default:
137
+ candidate = date;
138
+ }
139
+ while (isNonWorkingDay(candidate, options)) {
140
+ candidate = atHour(addBusinessDays(candidate, 1), startHour);
141
+ }
142
+ return candidate;
143
+ }
144
+ function getWorkingHourStatus(date, options) {
145
+ var _a, _b;
146
+ const startHour = (_a = options === null || options === void 0 ? void 0 : options.shiftStartHour) !== null && _a !== void 0 ? _a : exports.SHIFT_START_HOUR;
147
+ const endHour = (_b = options === null || options === void 0 ? void 0 : options.shiftEndHour) !== null && _b !== void 0 ? _b : exports.SHIFT_END_HOUR;
148
+ const shifted = toBusinessTz(date);
149
+ const hours = shifted.getUTCHours() + shifted.getUTCMinutes() / 60;
150
+ if (hours < startHour)
151
+ return WorkingHourStatus.BEFORE_WORKING_HOURS;
152
+ if (hours >= endHour)
153
+ return WorkingHourStatus.AFTER_WORKING_HOURS;
154
+ return WorkingHourStatus.WITHIN_WORKING_HOURS;
155
+ }
156
+ // export function isAfterWorkingHours(
157
+ // date: Date | null | undefined,
158
+ // options?: BusinessCalendarOptions,
159
+ // ): boolean {
160
+ // if (!date) return false;
161
+ // return (
162
+ // getWorkingHourStatus(date, options) ===
163
+ // WorkingHourStatus.AFTER_WORKING_HOURS
164
+ // );
165
+ // }
166
+ // export function isBeforeWorkingHours(
167
+ // date: Date | null | undefined,
168
+ // options?: BusinessCalendarOptions,
169
+ // ): boolean {
170
+ // if (!date) return false;
171
+ // return (
172
+ // getWorkingHourStatus(date, options) ===
173
+ // WorkingHourStatus.BEFORE_WORKING_HOURS
174
+ // );
175
+ // }
176
+ function normalizeStartTime(start, options) {
177
+ return ceilToWorkingInstant(start, options);
178
+ }
179
+ function normalizeEndTime(end, options) {
180
+ return ceilToWorkingInstant(end, options);
181
+ }
182
+ function calculateSameDayWorkingSeconds(start, end) {
183
+ return Math.max(0, (0, date_fns_1.differenceInSeconds)(end, start));
184
+ }
185
+ function countFullWorkingDaysBetween(start, end, options) {
186
+ const totalCalendarDays = Math.max(0, differenceInBusinessCalendarDays(end, start) - 1);
187
+ if (totalCalendarDays === 0 || !options)
188
+ return totalCalendarDays;
189
+ let count = 0;
190
+ for (let day = 1; day <= totalCalendarDays; day++) {
191
+ if (!isNonWorkingDay(addBusinessDays(start, day), options))
192
+ count++;
193
+ }
194
+ return count;
195
+ }
196
+ function calculateMultiDayWorkingSeconds(start, end, options) {
197
+ var _a, _b;
198
+ const startHour = (_a = options === null || options === void 0 ? void 0 : options.shiftStartHour) !== null && _a !== void 0 ? _a : exports.SHIFT_START_HOUR;
199
+ const endHour = (_b = options === null || options === void 0 ? void 0 : options.shiftEndHour) !== null && _b !== void 0 ? _b : exports.SHIFT_END_HOUR;
200
+ const workingSecondsPerDay = (endHour - startHour) * 3600;
201
+ const firstDaySeconds = (0, date_fns_1.differenceInSeconds)(atHour(start, endHour), start);
202
+ const fullDays = countFullWorkingDaysBetween(start, end, options);
203
+ const lastDaySeconds = (0, date_fns_1.differenceInSeconds)(end, atHour(end, startHour));
204
+ return (Math.max(0, firstDaySeconds) +
205
+ fullDays * workingSecondsPerDay +
206
+ Math.max(0, lastDaySeconds));
207
+ }
208
+ function calculateWorkingSeconds(start, end, options) {
209
+ if (!start || !end || end <= start)
210
+ return 0;
211
+ const normalizedStart = normalizeStartTime(start, options);
212
+ const normalizedEnd = normalizeEndTime(end, options);
213
+ const isSameDay = differenceInBusinessCalendarDays(normalizedEnd, normalizedStart) === 0;
214
+ return isSameDay
215
+ ? calculateSameDayWorkingSeconds(normalizedStart, normalizedEnd)
216
+ : calculateMultiDayWorkingSeconds(normalizedStart, normalizedEnd, options);
217
+ }
218
+ function formatBusinessDuration(seconds, options) {
219
+ if (!seconds || seconds <= 0)
220
+ return "0s";
221
+ const workingSecondsPerDay = (options === null || options === void 0 ? void 0 : options.workingSecondsPerDay) || exports.WORKING_SECONDS_PER_DAY;
222
+ const workingDaysPerWeek = (options === null || options === void 0 ? void 0 : options.workingDaysPerWeek) || exports.WORKING_DAYS_PER_WEEK;
223
+ const workingSecondsPerWeek = workingSecondsPerDay * workingDaysPerWeek;
224
+ const workingSecondsPerMonth = workingSecondsPerWeek * exports.WORKING_WEEKS_PER_MONTH;
225
+ const workingSecondsPerYear = workingSecondsPerMonth * exports.WORKING_MONTHS_PER_YEAR;
226
+ const totalSeconds = Math.floor(seconds);
227
+ if (totalSeconds < 60)
228
+ return `${totalSeconds}s`;
229
+ if (totalSeconds < 3600) {
230
+ const minutes = Math.floor(totalSeconds / 60);
231
+ const secs = totalSeconds % 60;
232
+ return [`${minutes}m`, secs > 0 ? `${secs}s` : ""]
233
+ .filter(Boolean)
234
+ .join(" ");
235
+ }
236
+ if (totalSeconds < workingSecondsPerDay) {
237
+ const hours = Math.floor(totalSeconds / 3600);
238
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
239
+ return [`${hours}h`, minutes > 0 ? `${minutes}m` : ""]
240
+ .filter(Boolean)
241
+ .join(" ");
242
+ }
243
+ if (totalSeconds < workingSecondsPerWeek) {
244
+ const days = Math.floor(totalSeconds / workingSecondsPerDay);
245
+ const hours = Math.floor((totalSeconds % workingSecondsPerDay) / 3600);
246
+ return [`${days}d`, hours > 0 ? `${hours}h` : ""].filter(Boolean).join(" ");
247
+ }
248
+ if (totalSeconds < workingSecondsPerMonth) {
249
+ const weeks = Math.floor(totalSeconds / workingSecondsPerWeek);
250
+ const days = Math.floor((totalSeconds % workingSecondsPerWeek) / workingSecondsPerDay);
251
+ return [`${weeks}w`, days > 0 ? `${days}d` : ""].filter(Boolean).join(" ");
252
+ }
253
+ if (totalSeconds < workingSecondsPerYear) {
254
+ const months = Math.floor(totalSeconds / workingSecondsPerMonth);
255
+ const weeks = Math.floor((totalSeconds % workingSecondsPerMonth) / workingSecondsPerWeek);
256
+ return [`${months}mo`, weeks > 0 ? `${weeks}w` : ""]
257
+ .filter(Boolean)
258
+ .join(" ");
259
+ }
260
+ const years = Math.floor(totalSeconds / workingSecondsPerYear);
261
+ const months = Math.floor((totalSeconds % workingSecondsPerYear) / workingSecondsPerMonth);
262
+ return [`${years}y`, months > 0 ? `${months}mo` : ""]
263
+ .filter(Boolean)
264
+ .join(" ");
265
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const businessTime_util_1 = require("./businessTime.util");
4
+ // isAfterWorkingHours / isBeforeWorkingHours are commented out in the source
5
+ // (unused for now), so these tests assert the same classifications directly
6
+ // via getWorkingHourStatus instead.
7
+ // Business hours are pinned to Asia/Kolkata (IST, UTC+5:30). Dates below use
8
+ // explicit "+05:30" offsets so the tests assert real behavior regardless of
9
+ // the timezone the test runner's host machine happens to be in.
10
+ //
11
+ // SHIFT_START_HOUR/SHIFT_END_HOUR default to a full 0-24 calendar day (no
12
+ // clipping) so that calculateWorkingSeconds is a plain elapsed-time
13
+ // calculation when a company hasn't configured shift hours. Tests below that
14
+ // exercise shift-hour clipping pass an explicit 10:00-19:00 shift via
15
+ // options, matching what a company with configured shift hours would supply.
16
+ const SHIFT_OPTIONS = { shiftStartHour: 10, shiftEndHour: 19 };
17
+ describe("calculateWorkingSeconds - same day", () => {
18
+ it("09:00 -> 12:00 is 2h", () => {
19
+ const start = new Date("2025-07-31T09:00:00+05:30");
20
+ const end = new Date("2025-07-31T12:00:00+05:30");
21
+ expect((0, businessTime_util_1.calculateWorkingSeconds)(start, end, SHIFT_OPTIONS)).toBe(2 * 3600);
22
+ });
23
+ it("11:00 -> 18:00 is 7h", () => {
24
+ const start = new Date("2025-07-31T11:00:00+05:30");
25
+ const end = new Date("2025-07-31T18:00:00+05:30");
26
+ expect((0, businessTime_util_1.calculateWorkingSeconds)(start, end, SHIFT_OPTIONS)).toBe(7 * 3600);
27
+ });
28
+ it("18:00 -> 21:00 is 1h (end normalizes to next day 10:00)", () => {
29
+ const start = new Date("2025-07-31T18:00:00+05:30");
30
+ const end = new Date("2025-07-31T21:00:00+05:30");
31
+ expect((0, businessTime_util_1.calculateWorkingSeconds)(start, end, SHIFT_OPTIONS)).toBe(1 * 3600);
32
+ });
33
+ it("20:00 -> 22:00 is 0s (both normalize to same next-day slot)", () => {
34
+ const start = new Date("2025-07-31T20:00:00+05:30");
35
+ const end = new Date("2025-07-31T22:00:00+05:30");
36
+ expect((0, businessTime_util_1.calculateWorkingSeconds)(start, end, SHIFT_OPTIONS)).toBe(0);
37
+ });
38
+ });
39
+ describe("calculateWorkingSeconds - multi day", () => {
40
+ it("31 Jul 6PM -> 1 Aug 11AM is 2h", () => {
41
+ const start = new Date("2025-07-31T18:00:00+05:30");
42
+ const end = new Date("2025-08-01T11:00:00+05:30");
43
+ expect((0, businessTime_util_1.calculateWorkingSeconds)(start, end, SHIFT_OPTIONS)).toBe(2 * 3600);
44
+ });
45
+ it("31 Jul 8PM -> 1 Aug 12PM is 2h (start normalizes into 1 Aug)", () => {
46
+ const start = new Date("2025-07-31T20:00:00+05:30");
47
+ const end = new Date("2025-08-01T12:00:00+05:30");
48
+ expect((0, businessTime_util_1.calculateWorkingSeconds)(start, end, SHIFT_OPTIONS)).toBe(2 * 3600);
49
+ });
50
+ it("31 Jul 9AM -> 3 Aug 4PM is 33h (9h + 9h + 9h + 6h)", () => {
51
+ const start = new Date("2025-07-31T09:00:00+05:30");
52
+ const end = new Date("2025-08-03T16:00:00+05:30");
53
+ expect((0, businessTime_util_1.calculateWorkingSeconds)(start, end, SHIFT_OPTIONS)).toBe(33 * 3600);
54
+ });
55
+ });
56
+ describe("calculateWorkingSeconds - week-offs and public holidays", () => {
57
+ it("without any options, elapsed time is not clipped to any shift (backward compatible)", () => {
58
+ // 2025-08-01 09:00 -> 2025-08-04 16:00 is 3 days 7 hours with no shift-hour
59
+ // or week-off/holiday restriction applied.
60
+ const start = new Date("2025-08-01T09:00:00+05:30");
61
+ const end = new Date("2025-08-04T16:00:00+05:30");
62
+ expect((0, businessTime_util_1.calculateWorkingSeconds)(start, end)).toBe(79 * 3600);
63
+ });
64
+ it("skips a configured week-off day when counting full days in between", () => {
65
+ // Fri 1 Aug 9AM -> Mon 4 Aug 4PM, with Sunday (3 Aug) as a week-off:
66
+ // Fri full day (9h) + Sat full day (9h) + Mon partial (6h); Sun contributes 0.
67
+ const start = new Date("2025-08-01T09:00:00+05:30");
68
+ const end = new Date("2025-08-04T16:00:00+05:30");
69
+ expect((0, businessTime_util_1.calculateWorkingSeconds)(start, end, Object.assign(Object.assign({}, SHIFT_OPTIONS), { weekOffDays: [0] }))).toBe(24 * 3600);
70
+ });
71
+ it("rolls a start/end landing on a week-off forward to the next working day", () => {
72
+ // Sunday 3 Aug entirely, with Sunday configured as a week-off, should be 0.
73
+ const start = new Date("2025-08-03T11:00:00+05:30");
74
+ const end = new Date("2025-08-03T15:00:00+05:30");
75
+ expect((0, businessTime_util_1.calculateWorkingSeconds)(start, end, { weekOffDays: [0] })).toBe(0);
76
+ });
77
+ it("skips a configured public holiday within a multi-day range", () => {
78
+ // Fri 1 Aug 9AM -> Mon 4 Aug 4PM, with Saturday (2 Aug) as a public holiday:
79
+ // Fri full day (9h) + Sun full day (9h) + Mon partial (6h); Sat (holiday) contributes 0.
80
+ const start = new Date("2025-08-01T09:00:00+05:30");
81
+ const end = new Date("2025-08-04T16:00:00+05:30");
82
+ const holidays = [new Date("2025-08-02T00:00:00+05:30")];
83
+ expect((0, businessTime_util_1.calculateWorkingSeconds)(start, end, Object.assign(Object.assign({}, SHIFT_OPTIONS), { holidays }))).toBe(24 * 3600);
84
+ });
85
+ });
86
+ describe("getWorkingHourStatus - timezone independence", () => {
87
+ it("classifies a UTC instant by IST wall-clock time, not host timezone", () => {
88
+ // 2026-08-03T20:36:00Z is 2026-08-04 02:06 IST: before the 10:00 IST shift start.
89
+ const date = new Date("2026-08-03T20:36:00.000Z");
90
+ expect((0, businessTime_util_1.getWorkingHourStatus)(date, SHIFT_OPTIONS)).toBe(businessTime_util_1.WorkingHourStatus.BEFORE_WORKING_HOURS);
91
+ });
92
+ it("classifies an instant that is after 19:00 IST as after working hours", () => {
93
+ // 2026-08-03T14:05:00Z is 2026-08-03 19:35 IST: past the 19:00 IST shift end.
94
+ const date = new Date("2026-08-03T14:05:00.000Z");
95
+ expect((0, businessTime_util_1.getWorkingHourStatus)(date, SHIFT_OPTIONS)).toBe(businessTime_util_1.WorkingHourStatus.AFTER_WORKING_HOURS);
96
+ });
97
+ });
98
+ describe("formatBusinessDuration", () => {
99
+ it("formats seconds under a minute", () => {
100
+ expect((0, businessTime_util_1.formatBusinessDuration)(45)).toBe("45s");
101
+ });
102
+ it("formats minutes and seconds", () => {
103
+ expect((0, businessTime_util_1.formatBusinessDuration)(15 * 60 + 20)).toBe("15m 20s");
104
+ });
105
+ it("formats hours and minutes", () => {
106
+ expect((0, businessTime_util_1.formatBusinessDuration)(4 * 3600 + 30 * 60)).toBe("4h 30m");
107
+ });
108
+ it("formats days and hours once past a full working day (24h)", () => {
109
+ expect((0, businessTime_util_1.formatBusinessDuration)(24 * 3600 + 3 * 3600)).toBe("1d 3h");
110
+ });
111
+ it("formats weeks and days once past a full working week (5d)", () => {
112
+ expect((0, businessTime_util_1.formatBusinessDuration)(2 * 432000 + 86400)).toBe("2w 1d");
113
+ });
114
+ it("formats months and weeks once past a full working month (4w)", () => {
115
+ expect((0, businessTime_util_1.formatBusinessDuration)(3 * 1728000 + 2 * 432000)).toBe("3mo 2w");
116
+ });
117
+ it("formats years and months once past a full working year (12mo)", () => {
118
+ expect((0, businessTime_util_1.formatBusinessDuration)(20736000 + 5 * 1728000)).toBe("1y 5mo");
119
+ });
120
+ it("formats zero/negative durations as 0s", () => {
121
+ expect((0, businessTime_util_1.formatBusinessDuration)(0)).toBe("0s");
122
+ });
123
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kcommons",
3
- "version": "18.12.16",
3
+ "version": "18.13.1",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",