@b2y/ecommerce-common 1.3.6 → 1.3.8

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 (98) hide show
  1. package/.idea/ecommerce-common.iml +11 -11
  2. package/.idea/modules.xml +7 -7
  3. package/.idea/vcs.xml +5 -5
  4. package/README.md +4 -4
  5. package/constants/AppConstants.js +15 -15
  6. package/constants/ReportConstants.js +14 -14
  7. package/constants/StatusMessageConstants.js +61 -61
  8. package/controller/LocationController.js +144 -144
  9. package/controller/SubscriptionAbstractController.js +91 -91
  10. package/controller/TenantAbstractController.js +152 -152
  11. package/controller/TenantSettingsAbstractController.js +243 -243
  12. package/dbconnection/Connect.js +498 -498
  13. package/enum/AccessModeEnum.js +8 -8
  14. package/enum/ActionByTypeEnum.js +4 -4
  15. package/enum/AddressTypeEnum.js +6 -6
  16. package/enum/BillingCycleEnum.js +5 -5
  17. package/enum/BooleanEnum.js +4 -4
  18. package/enum/BulkImportStatusEnum.js +6 -6
  19. package/enum/DimensionUnitEnum.js +6 -0
  20. package/enum/EntityTypeEnum.js +12 -12
  21. package/enum/FeatureTypeEnum.js +6 -6
  22. package/enum/GenderEnum.js +7 -7
  23. package/enum/NotificationStatusEnum.js +5 -5
  24. package/enum/NotificationTypeEnum.js +9 -9
  25. package/enum/OrderActionStatusEnum.js +7 -7
  26. package/enum/OrderStatusEnum.js +8 -7
  27. package/enum/PackageBoxTypeEnum.js +6 -6
  28. package/enum/PaymentMethodEnum.js +6 -6
  29. package/enum/PaymentStatusEnum.js +6 -6
  30. package/enum/PaymentTypeEnum.js +6 -6
  31. package/enum/PlatformEnum.js +4 -4
  32. package/enum/ReasonTypeEnum.js +6 -6
  33. package/enum/RegistrationStatusEnum.js +5 -5
  34. package/enum/SortByEnum.js +7 -7
  35. package/enum/SubscriptionStatusEnum.js +7 -7
  36. package/enum/WeightUnitEnum.js +7 -0
  37. package/index.js +28 -28
  38. package/model/Address.js +95 -95
  39. package/model/AttributeType.js +50 -50
  40. package/model/AttributeValue.js +64 -64
  41. package/model/Banner.js +78 -78
  42. package/model/Brand.js +76 -76
  43. package/model/Cart.js +76 -76
  44. package/model/Category.js +72 -72
  45. package/model/CategoryAttributeType.js +62 -62
  46. package/model/Colour.js +52 -52
  47. package/model/Customer.js +94 -94
  48. package/model/DeviceToken.js +51 -51
  49. package/model/Document.js +73 -73
  50. package/model/DynamicUIComponent.js +52 -52
  51. package/model/Feedback.js +79 -79
  52. package/model/Inventory.js +87 -87
  53. package/model/NotificationHistory.js +67 -67
  54. package/model/Order.js +84 -84
  55. package/model/OrderActionReason.js +99 -99
  56. package/model/OrderItem.js +98 -98
  57. package/model/OrderItemHistory.js +69 -69
  58. package/model/OrderStatus.js +48 -48
  59. package/model/PackagingBox.js +78 -78
  60. package/model/Payment.js +101 -101
  61. package/model/PaymentMethod.js +36 -36
  62. package/model/PaymentStatus.js +36 -36
  63. package/model/PaymentType.js +36 -36
  64. package/model/Permission.js +55 -55
  65. package/model/Product.js +97 -97
  66. package/model/ProductGroup.js +48 -48
  67. package/model/ProductImport.js +55 -55
  68. package/model/ProductImportFailureAudits.js +57 -57
  69. package/model/ProductSpecification.js +65 -65
  70. package/model/ProductVariant.js +111 -111
  71. package/model/ProductVariantAttribute.js +58 -58
  72. package/model/ReasonContextMapping.js +70 -70
  73. package/model/ReasonMaster.js +74 -74
  74. package/model/Role.js +61 -61
  75. package/model/RolePermissionMapping.js +63 -63
  76. package/model/SpecificationType.js +41 -41
  77. package/model/Store.js +99 -99
  78. package/model/StoreUserMapping.js +44 -44
  79. package/model/SubscriptionFeature.js +53 -53
  80. package/model/SubscriptionPlan.js +70 -70
  81. package/model/SubscriptionPlanFeature.js +48 -48
  82. package/model/Tenant.js +91 -91
  83. package/model/TenantSettings.js +47 -47
  84. package/model/TenantSubscription.js +73 -73
  85. package/model/User.js +132 -132
  86. package/model/WishList.js +62 -62
  87. package/package.json +30 -30
  88. package/scripts/QueryBuilder.js +162 -162
  89. package/utility/AppUtil.js +65 -65
  90. package/utility/DateUtil.js +55 -55
  91. package/utility/ExcelUtil.js +125 -125
  92. package/utility/LocationUtility.js +130 -130
  93. package/utility/OrderTimeFilterUtil.js +88 -88
  94. package/utility/PdfUtil.js +64 -64
  95. package/utility/QueryUtil.js +261 -261
  96. package/utility/Razorpay.js +65 -65
  97. package/utility/ResolveAccessMode.js +61 -61
  98. package/utility/VariantPriceUtil.js +54 -54
@@ -1,92 +1,92 @@
1
- const StatusMessage = require('../constants/StatusMessageConstants');
2
- const AppUtil = require('../utility/AppUtil');
3
-
4
- // getAllSubscriptionPlans
5
- const getAllSubscriptionPlans = (
6
- SubscriptionPlan,
7
- SubscriptionFeature,
8
- TenantSubscription,
9
- logger,
10
- ) => {
11
- return async (req, res) => {
12
- const { pageNumber, pageSize } = req.query;
13
- const { limit, offset } = AppUtil.getPagination(pageNumber, pageSize);
14
- const tenantId = req.user?.TenantID;
15
- try {
16
- let tenantPlan = null;
17
- if (tenantId !== null || tenantId !== undefined) {
18
- tenantPlan = await TenantSubscription.findOne({
19
- where: tenantId ? { TenantID: tenantId } : undefined,
20
- attributes: ["SubscriptionPlanID", "Status"],
21
- });
22
- }
23
- const { rows, count } = await SubscriptionPlan.findAndCountAll({
24
- attributes: [
25
- "SubscriptionPlanID",
26
- "PlanName",
27
- "PlanCode",
28
- "Price",
29
- "BillingCycle",
30
- "Currency",
31
- "TrialPeriodDays",
32
- "IsActive",
33
- "SortOrder"
34
- ],
35
- include: [
36
- {
37
- model: SubscriptionFeature,
38
- as: "Features",
39
- attributes: ["SubscriptionFeatureID", "FeatureName", "FeatureCode"],
40
- through: { attributes: ["FeatureValue"] },
41
- },
42
- ],
43
- limit,
44
- offset,
45
- distinct: true,
46
- });
47
- const formattedPlanFeatures = rows.map((plan) => {
48
- let isCurrentPlan = null;
49
- let currentPlanStatus = null;
50
- if (tenantId) {
51
- isCurrentPlan =
52
- tenantPlan.SubscriptionPlanID === plan.SubscriptionPlanID;
53
- currentPlanStatus = isCurrentPlan ? tenantPlan.Status : null;
54
- }
55
- return {
56
- SubscriptionPlanID: plan.SubscriptionPlanID,
57
- PlanName: plan.PlanName,
58
- PlanCode: plan.PlanCode,
59
- Price: AppUtil.trimDecimal(plan.Price),
60
- BillingCycle: plan.BillingCycle,
61
- Currency: plan.Currency,
62
- TrialPeriodDays: plan.TrialPeriodDays,
63
- IsActive: plan.IsActive,
64
- SortOrder: plan.SortOrder,
65
- isCurrentPlan,
66
- currentPlanStatus,
67
- Features: plan.Features,
68
- };
69
- });
70
- logger.debug("subscription plans fetched successfully");
71
- return AppUtil.generateResponse(
72
- 200,
73
- StatusMessage.SUCCESS,
74
- null,
75
- { rows: formattedPlanFeatures, count, pageNumber, limit },
76
- res,
77
- );
78
- } catch (error) {
79
- logger.error("error occurred while fetching subscription plans", error);
80
- return AppUtil.generateResponse(
81
- 500,
82
- StatusMessage.FAILURE,
83
- StatusMessage.SERVER_ERROR,
84
- null,
85
- res,
86
- );
87
- }
88
- };
89
- };
90
-
91
-
1
+ const StatusMessage = require('../constants/StatusMessageConstants');
2
+ const AppUtil = require('../utility/AppUtil');
3
+
4
+ // getAllSubscriptionPlans
5
+ const getAllSubscriptionPlans = (
6
+ SubscriptionPlan,
7
+ SubscriptionFeature,
8
+ TenantSubscription,
9
+ logger,
10
+ ) => {
11
+ return async (req, res) => {
12
+ const { pageNumber, pageSize } = req.query;
13
+ const { limit, offset } = AppUtil.getPagination(pageNumber, pageSize);
14
+ const tenantId = req.user?.TenantID;
15
+ try {
16
+ let tenantPlan = null;
17
+ if (tenantId !== null || tenantId !== undefined) {
18
+ tenantPlan = await TenantSubscription.findOne({
19
+ where: tenantId ? { TenantID: tenantId } : undefined,
20
+ attributes: ["SubscriptionPlanID", "Status"],
21
+ });
22
+ }
23
+ const { rows, count } = await SubscriptionPlan.findAndCountAll({
24
+ attributes: [
25
+ "SubscriptionPlanID",
26
+ "PlanName",
27
+ "PlanCode",
28
+ "Price",
29
+ "BillingCycle",
30
+ "Currency",
31
+ "TrialPeriodDays",
32
+ "IsActive",
33
+ "SortOrder"
34
+ ],
35
+ include: [
36
+ {
37
+ model: SubscriptionFeature,
38
+ as: "Features",
39
+ attributes: ["SubscriptionFeatureID", "FeatureName", "FeatureCode"],
40
+ through: { attributes: ["FeatureValue"] },
41
+ },
42
+ ],
43
+ limit,
44
+ offset,
45
+ distinct: true,
46
+ });
47
+ const formattedPlanFeatures = rows.map((plan) => {
48
+ let isCurrentPlan = null;
49
+ let currentPlanStatus = null;
50
+ if (tenantId) {
51
+ isCurrentPlan =
52
+ tenantPlan.SubscriptionPlanID === plan.SubscriptionPlanID;
53
+ currentPlanStatus = isCurrentPlan ? tenantPlan.Status : null;
54
+ }
55
+ return {
56
+ SubscriptionPlanID: plan.SubscriptionPlanID,
57
+ PlanName: plan.PlanName,
58
+ PlanCode: plan.PlanCode,
59
+ Price: AppUtil.trimDecimal(plan.Price),
60
+ BillingCycle: plan.BillingCycle,
61
+ Currency: plan.Currency,
62
+ TrialPeriodDays: plan.TrialPeriodDays,
63
+ IsActive: plan.IsActive,
64
+ SortOrder: plan.SortOrder,
65
+ isCurrentPlan,
66
+ currentPlanStatus,
67
+ Features: plan.Features,
68
+ };
69
+ });
70
+ logger.debug("subscription plans fetched successfully");
71
+ return AppUtil.generateResponse(
72
+ 200,
73
+ StatusMessage.SUCCESS,
74
+ null,
75
+ { rows: formattedPlanFeatures, count, pageNumber, limit },
76
+ res,
77
+ );
78
+ } catch (error) {
79
+ logger.error("error occurred while fetching subscription plans", error);
80
+ return AppUtil.generateResponse(
81
+ 500,
82
+ StatusMessage.FAILURE,
83
+ StatusMessage.SERVER_ERROR,
84
+ null,
85
+ res,
86
+ );
87
+ }
88
+ };
89
+ };
90
+
91
+
92
92
  module.exports = {getAllSubscriptionPlans}
@@ -1,152 +1,152 @@
1
- const LocationUtility = require('../utility/LocationUtility');
2
- const StatusMessage = require('../constants/StatusMessageConstants');
3
- const AppUtil = require('../utility/AppUtil');
4
- const EntityTypeEnum = require('../enum/EntityTypeEnum');
5
-
6
-
7
- const getTenantById = (
8
- Tenant,
9
- TenantSubscription,
10
- SubscriptionPlan,
11
- TenantSettings,
12
- Document,
13
- getPublicUrl,
14
- logger,
15
- ) => {
16
- return async (req, res) => {
17
- try {
18
- const { id } = req.params;
19
-
20
- const tenant = await Tenant.findOne({
21
- where: { TenantID: id },
22
- attributes: [
23
- 'TenantID',
24
- 'CompanyName',
25
- 'CompanyCode',
26
- 'Email',
27
- 'CountryCallingCode',
28
- 'PhoneNumber',
29
- 'GSTNo',
30
- 'CustomerPortalDomain',
31
- 'AdminPortalDomain',
32
- 'AddressLine',
33
- 'CityName',
34
- 'StateCode',
35
- 'CountryCode',
36
- 'Zipcode',
37
- ],
38
- include: [
39
- {
40
- model: TenantSettings,
41
- as: 'TenantSettings',
42
- attributes: ['TenantSettingID']
43
- },
44
- {
45
- model: TenantSubscription,
46
- as: "CurrentSubscription",
47
- attributes: [
48
- "TenantSubscriptionID",
49
- "Status",
50
- "StartDate",
51
- "EndDate",
52
- "GraceEndDate",
53
- "TrialEndDate",
54
- "IsTrial",
55
- "AutoRenew",
56
- ],
57
- include: [
58
- {
59
- model: SubscriptionPlan,
60
- as: "SubscriptionPlan",
61
- attributes: ["SubscriptionPlanID", "PlanName", "PlanCode", "BillingCycle"],
62
- },
63
- ],
64
- },
65
- ],
66
- });
67
-
68
- if (!tenant) {
69
- return AppUtil.generateResponse(
70
- 404,
71
- StatusMessage.FAILURE,
72
- StatusMessage.TENANT_NOT_FOUND,
73
- null,
74
- res,
75
- );
76
- }
77
- let logo = null;;
78
- if(tenant.TenantSettings) {
79
- const document = await Document.findOne({
80
- where: {
81
- EntityType: EntityTypeEnum.TENANT_SETTINGS,
82
- EntityID: tenant.TenantSettings.TenantSettingID,
83
- },
84
- order: [["SortOrder", "ASC"]],
85
- });
86
- if (document) {
87
- logo = {
88
- documentId: document.DocumentID,
89
- sortOrder: document.SortOrder,
90
- documentUrl: await getPublicUrl(document, logger),
91
- };
92
- }
93
- }
94
- const { countryName, stateName } =
95
- await LocationUtility.resolveCountryAndState(
96
- tenant.CountryCode,
97
- tenant.StateCode,
98
- logger,
99
- );
100
-
101
- const formattedTenant = {
102
- TenantID: tenant.TenantID,
103
- CompanyName: tenant.CompanyName,
104
- CompanyCode: tenant.CompanyCode,
105
- Email: tenant.Email,
106
- CountryCallingCode: tenant.CountryCallingCode,
107
- PhoneNumber: tenant.PhoneNumber,
108
- GSTNo: tenant.GSTNo,
109
- CustomerPortalDomain: tenant.CustomerPortalDomain,
110
- AdminPortalDomain: tenant.AdminPortalDomain,
111
- AddressLine: tenant.AddressLine,
112
- CityName: tenant.CityName,
113
- StateCode: tenant.StateCode,
114
- StateName: stateName,
115
- CountryCode: tenant.CountryCode,
116
- CountryName: countryName,
117
- Zipcode: tenant.Zipcode,
118
- TenantLogo: logo,
119
- SubscriptionPlanID: tenant.CurrentSubscription?.SubscriptionPlan?.SubscriptionPlanID,
120
- PlanName: tenant.CurrentSubscription?.SubscriptionPlan?.PlanName,
121
- BillingCycle: tenant.CurrentSubscription?.SubscriptionPlan?.BillingCycle,
122
- TenantSubscriptionStatus: tenant.CurrentSubscription?.Status,
123
- StartDate: tenant.CurrentSubscription?.StartDate,
124
- EndDate: tenant.CurrentSubscription?.EndDate,
125
- GraceEndDate: tenant.CurrentSubscription?.GraceEndDate,
126
- TrialEndDate: tenant.CurrentSubscription?.TrialEndDate,
127
- IsTrial: tenant.CurrentSubscription?.IsTrial,
128
- AutoRenew: tenant.CurrentSubscription?.AutoRenew,
129
- };
130
-
131
- return AppUtil.generateResponse(
132
- 200,
133
- StatusMessage.SUCCESS,
134
- null,
135
- formattedTenant,
136
- res,
137
- );
138
- } catch (error) {
139
- logger.error("Error fetching tenant:", error);
140
- return AppUtil.generateResponse(
141
- 500,
142
- StatusMessage.FAILURE,
143
- StatusMessage.SERVER_ERROR,
144
- null,
145
- res,
146
- );
147
- }
148
- };
149
- };
150
-
151
- module.exports = { getTenantById };
152
-
1
+ const LocationUtility = require('../utility/LocationUtility');
2
+ const StatusMessage = require('../constants/StatusMessageConstants');
3
+ const AppUtil = require('../utility/AppUtil');
4
+ const EntityTypeEnum = require('../enum/EntityTypeEnum');
5
+
6
+
7
+ const getTenantById = (
8
+ Tenant,
9
+ TenantSubscription,
10
+ SubscriptionPlan,
11
+ TenantSettings,
12
+ Document,
13
+ getPublicUrl,
14
+ logger,
15
+ ) => {
16
+ return async (req, res) => {
17
+ try {
18
+ const { id } = req.params;
19
+
20
+ const tenant = await Tenant.findOne({
21
+ where: { TenantID: id },
22
+ attributes: [
23
+ 'TenantID',
24
+ 'CompanyName',
25
+ 'CompanyCode',
26
+ 'Email',
27
+ 'CountryCallingCode',
28
+ 'PhoneNumber',
29
+ 'GSTNo',
30
+ 'CustomerPortalDomain',
31
+ 'AdminPortalDomain',
32
+ 'AddressLine',
33
+ 'CityName',
34
+ 'StateCode',
35
+ 'CountryCode',
36
+ 'Zipcode',
37
+ ],
38
+ include: [
39
+ {
40
+ model: TenantSettings,
41
+ as: 'TenantSettings',
42
+ attributes: ['TenantSettingID']
43
+ },
44
+ {
45
+ model: TenantSubscription,
46
+ as: "CurrentSubscription",
47
+ attributes: [
48
+ "TenantSubscriptionID",
49
+ "Status",
50
+ "StartDate",
51
+ "EndDate",
52
+ "GraceEndDate",
53
+ "TrialEndDate",
54
+ "IsTrial",
55
+ "AutoRenew",
56
+ ],
57
+ include: [
58
+ {
59
+ model: SubscriptionPlan,
60
+ as: "SubscriptionPlan",
61
+ attributes: ["SubscriptionPlanID", "PlanName", "PlanCode", "BillingCycle"],
62
+ },
63
+ ],
64
+ },
65
+ ],
66
+ });
67
+
68
+ if (!tenant) {
69
+ return AppUtil.generateResponse(
70
+ 404,
71
+ StatusMessage.FAILURE,
72
+ StatusMessage.TENANT_NOT_FOUND,
73
+ null,
74
+ res,
75
+ );
76
+ }
77
+ let logo = null;;
78
+ if(tenant.TenantSettings) {
79
+ const document = await Document.findOne({
80
+ where: {
81
+ EntityType: EntityTypeEnum.TENANT_SETTINGS,
82
+ EntityID: tenant.TenantSettings.TenantSettingID,
83
+ },
84
+ order: [["SortOrder", "ASC"]],
85
+ });
86
+ if (document) {
87
+ logo = {
88
+ documentId: document.DocumentID,
89
+ sortOrder: document.SortOrder,
90
+ documentUrl: await getPublicUrl(document, logger),
91
+ };
92
+ }
93
+ }
94
+ const { countryName, stateName } =
95
+ await LocationUtility.resolveCountryAndState(
96
+ tenant.CountryCode,
97
+ tenant.StateCode,
98
+ logger,
99
+ );
100
+
101
+ const formattedTenant = {
102
+ TenantID: tenant.TenantID,
103
+ CompanyName: tenant.CompanyName,
104
+ CompanyCode: tenant.CompanyCode,
105
+ Email: tenant.Email,
106
+ CountryCallingCode: tenant.CountryCallingCode,
107
+ PhoneNumber: tenant.PhoneNumber,
108
+ GSTNo: tenant.GSTNo,
109
+ CustomerPortalDomain: tenant.CustomerPortalDomain,
110
+ AdminPortalDomain: tenant.AdminPortalDomain,
111
+ AddressLine: tenant.AddressLine,
112
+ CityName: tenant.CityName,
113
+ StateCode: tenant.StateCode,
114
+ StateName: stateName,
115
+ CountryCode: tenant.CountryCode,
116
+ CountryName: countryName,
117
+ Zipcode: tenant.Zipcode,
118
+ TenantLogo: logo,
119
+ SubscriptionPlanID: tenant.CurrentSubscription?.SubscriptionPlan?.SubscriptionPlanID,
120
+ PlanName: tenant.CurrentSubscription?.SubscriptionPlan?.PlanName,
121
+ BillingCycle: tenant.CurrentSubscription?.SubscriptionPlan?.BillingCycle,
122
+ TenantSubscriptionStatus: tenant.CurrentSubscription?.Status,
123
+ StartDate: tenant.CurrentSubscription?.StartDate,
124
+ EndDate: tenant.CurrentSubscription?.EndDate,
125
+ GraceEndDate: tenant.CurrentSubscription?.GraceEndDate,
126
+ TrialEndDate: tenant.CurrentSubscription?.TrialEndDate,
127
+ IsTrial: tenant.CurrentSubscription?.IsTrial,
128
+ AutoRenew: tenant.CurrentSubscription?.AutoRenew,
129
+ };
130
+
131
+ return AppUtil.generateResponse(
132
+ 200,
133
+ StatusMessage.SUCCESS,
134
+ null,
135
+ formattedTenant,
136
+ res,
137
+ );
138
+ } catch (error) {
139
+ logger.error("Error fetching tenant:", error);
140
+ return AppUtil.generateResponse(
141
+ 500,
142
+ StatusMessage.FAILURE,
143
+ StatusMessage.SERVER_ERROR,
144
+ null,
145
+ res,
146
+ );
147
+ }
148
+ };
149
+ };
150
+
151
+ module.exports = { getTenantById };
152
+