@b2y/ecommerce-common 1.4.1 → 1.4.3

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 (99) 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 +16 -16
  6. package/constants/AuditConstants.js +16 -0
  7. package/constants/ReportConstants.js +14 -14
  8. package/constants/StatusMessageConstants.js +61 -61
  9. package/controller/LocationController.js +144 -144
  10. package/controller/SubscriptionAbstractController.js +91 -91
  11. package/controller/TenantAbstractController.js +152 -152
  12. package/controller/TenantSettingsAbstractController.js +259 -259
  13. package/dbconnection/Connect.js +498 -498
  14. package/enum/AccessModeEnum.js +8 -8
  15. package/enum/ActionByTypeEnum.js +4 -4
  16. package/enum/AddressTypeEnum.js +6 -6
  17. package/enum/BillingCycleEnum.js +5 -5
  18. package/enum/BooleanEnum.js +4 -4
  19. package/enum/BulkImportStatusEnum.js +6 -6
  20. package/enum/DimensionUnitEnum.js +5 -5
  21. package/enum/EntityTypeEnum.js +12 -12
  22. package/enum/FeatureTypeEnum.js +6 -6
  23. package/enum/GenderEnum.js +7 -7
  24. package/enum/NotificationStatusEnum.js +5 -5
  25. package/enum/NotificationTypeEnum.js +9 -9
  26. package/enum/OrderActionStatusEnum.js +7 -7
  27. package/enum/OrderStatusEnum.js +8 -8
  28. package/enum/PackageBoxTypeEnum.js +6 -6
  29. package/enum/PaymentMethodEnum.js +6 -6
  30. package/enum/PaymentStatusEnum.js +6 -6
  31. package/enum/PaymentTypeEnum.js +6 -6
  32. package/enum/PlatformEnum.js +4 -4
  33. package/enum/ReasonTypeEnum.js +6 -6
  34. package/enum/RegistrationStatusEnum.js +5 -5
  35. package/enum/SortByEnum.js +7 -7
  36. package/enum/SubscriptionStatusEnum.js +7 -7
  37. package/enum/WeightUnitEnum.js +6 -6
  38. package/index.js +29 -28
  39. package/model/Address.js +95 -95
  40. package/model/AttributeType.js +50 -50
  41. package/model/AttributeValue.js +64 -64
  42. package/model/Banner.js +78 -78
  43. package/model/Brand.js +76 -76
  44. package/model/Cart.js +76 -76
  45. package/model/Category.js +72 -72
  46. package/model/CategoryAttributeType.js +62 -62
  47. package/model/Colour.js +52 -52
  48. package/model/Customer.js +98 -94
  49. package/model/DeviceToken.js +51 -51
  50. package/model/Document.js +73 -73
  51. package/model/DynamicUIComponent.js +52 -52
  52. package/model/Feedback.js +79 -79
  53. package/model/Inventory.js +87 -87
  54. package/model/NotificationHistory.js +67 -67
  55. package/model/Order.js +84 -84
  56. package/model/OrderActionReason.js +99 -99
  57. package/model/OrderItem.js +98 -98
  58. package/model/OrderItemHistory.js +69 -69
  59. package/model/OrderStatus.js +48 -48
  60. package/model/PackagingBox.js +78 -78
  61. package/model/Payment.js +101 -101
  62. package/model/PaymentMethod.js +36 -36
  63. package/model/PaymentStatus.js +36 -36
  64. package/model/PaymentType.js +36 -36
  65. package/model/Permission.js +45 -55
  66. package/model/Product.js +97 -97
  67. package/model/ProductGroup.js +48 -48
  68. package/model/ProductImport.js +55 -55
  69. package/model/ProductImportFailureAudits.js +57 -57
  70. package/model/ProductSpecification.js +65 -65
  71. package/model/ProductVariant.js +111 -111
  72. package/model/ProductVariantAttribute.js +58 -58
  73. package/model/ReasonContextMapping.js +70 -70
  74. package/model/ReasonMaster.js +74 -74
  75. package/model/Role.js +61 -61
  76. package/model/RolePermissionMapping.js +63 -63
  77. package/model/SpecificationType.js +41 -41
  78. package/model/Store.js +99 -99
  79. package/model/StoreUserMapping.js +44 -44
  80. package/model/SubscriptionFeature.js +53 -53
  81. package/model/SubscriptionPlan.js +70 -70
  82. package/model/SubscriptionPlanFeature.js +48 -48
  83. package/model/Tenant.js +91 -91
  84. package/model/TenantSettings.js +47 -47
  85. package/model/TenantSubscription.js +73 -73
  86. package/model/User.js +132 -132
  87. package/model/WishList.js +62 -62
  88. package/package.json +30 -30
  89. package/scripts/QueryBuilder.js +162 -162
  90. package/utility/AppUtil.js +69 -69
  91. package/utility/DateUtil.js +55 -55
  92. package/utility/ExcelUtil.js +125 -125
  93. package/utility/LocationUtility.js +130 -130
  94. package/utility/OrderTimeFilterUtil.js +88 -88
  95. package/utility/PdfUtil.js +67 -67
  96. package/utility/QueryUtil.js +261 -261
  97. package/utility/Razorpay.js +65 -65
  98. package/utility/ResolveAccessMode.js +61 -61
  99. package/utility/VariantPriceUtil.js +54 -54
@@ -1,62 +1,62 @@
1
- const SubscriptionStatusEnum = require('../enum/SubscriptionStatusEnum');
2
- const AccessModeEnum = require('../enum/AccessModeEnum');
3
- function ResolveAccessMode(subscription) {
4
- const now = new Date();
5
-
6
- if (!subscription) return AccessModeEnum.BLOCKED;
7
- const status = subscription.Status;
8
- // paid endDate
9
- const endDate = subscription.EndDate
10
- ? new Date(subscription.EndDate)
11
- : null;
12
- // paid graceEndDate
13
- const graceEndDate = subscription.GraceEndDate
14
- ? new Date(subscription.GraceEndDate)
15
- : null;
16
- //trialEndDate
17
- const trialEndDate = subscription.TrialEndDate
18
- ? new Date(subscription.TrialEndDate)
19
- : null;
20
-
21
-
22
- if (status === SubscriptionStatusEnum.SUSPENDED) {
23
- return AccessModeEnum.BLOCKED;
24
- }
25
- if(status === SubscriptionStatusEnum.EXPIRED) {
26
- return AccessModeEnum.RENEW_SUBSCRIPTION;
27
- }
28
- // CANCELLED -> still allow till expiry
29
- if(status === SubscriptionStatusEnum.CANCELLED) {
30
- if (endDate && now < endDate) {
31
- return AccessModeEnum.FULL;
32
- }
33
-
34
- if (graceEndDate && now <= graceEndDate) {
35
- return AccessModeEnum.READ_ONLY;
36
- }
37
-
38
- return AccessModeEnum.RENEW_SUBSCRIPTION;
39
- }
40
- if (subscription.Status === SubscriptionStatusEnum.ACTIVE) {
41
- // trial plan
42
- if (subscription.IsTrial === true) {
43
- if (trialEndDate && now < trialEndDate) {
44
- return AccessModeEnum.FULL;
45
- }
46
- return AccessModeEnum.PAYMENT_REQUIRED;
47
- }
48
- // paid plan
49
- // Still in the paid period
50
- if (now < endDate) {
51
- return AccessModeEnum.FULL;
52
- }
53
- // Past EndDate, but within Grace Period
54
- if (graceEndDate && now <= graceEndDate) {
55
- return AccessModeEnum.READ_ONLY;
56
- }
57
- // Past both EndDate and Grace Period
58
- return AccessModeEnum.RENEW_SUBSCRIPTION;
59
- }
60
- return AccessModeEnum.BLOCKED;
61
- };
1
+ const SubscriptionStatusEnum = require('../enum/SubscriptionStatusEnum');
2
+ const AccessModeEnum = require('../enum/AccessModeEnum');
3
+ function ResolveAccessMode(subscription) {
4
+ const now = new Date();
5
+
6
+ if (!subscription) return AccessModeEnum.BLOCKED;
7
+ const status = subscription.Status;
8
+ // paid endDate
9
+ const endDate = subscription.EndDate
10
+ ? new Date(subscription.EndDate)
11
+ : null;
12
+ // paid graceEndDate
13
+ const graceEndDate = subscription.GraceEndDate
14
+ ? new Date(subscription.GraceEndDate)
15
+ : null;
16
+ //trialEndDate
17
+ const trialEndDate = subscription.TrialEndDate
18
+ ? new Date(subscription.TrialEndDate)
19
+ : null;
20
+
21
+
22
+ if (status === SubscriptionStatusEnum.SUSPENDED) {
23
+ return AccessModeEnum.BLOCKED;
24
+ }
25
+ if(status === SubscriptionStatusEnum.EXPIRED) {
26
+ return AccessModeEnum.RENEW_SUBSCRIPTION;
27
+ }
28
+ // CANCELLED -> still allow till expiry
29
+ if(status === SubscriptionStatusEnum.CANCELLED) {
30
+ if (endDate && now < endDate) {
31
+ return AccessModeEnum.FULL;
32
+ }
33
+
34
+ if (graceEndDate && now <= graceEndDate) {
35
+ return AccessModeEnum.READ_ONLY;
36
+ }
37
+
38
+ return AccessModeEnum.RENEW_SUBSCRIPTION;
39
+ }
40
+ if (subscription.Status === SubscriptionStatusEnum.ACTIVE) {
41
+ // trial plan
42
+ if (subscription.IsTrial === true) {
43
+ if (trialEndDate && now < trialEndDate) {
44
+ return AccessModeEnum.FULL;
45
+ }
46
+ return AccessModeEnum.PAYMENT_REQUIRED;
47
+ }
48
+ // paid plan
49
+ // Still in the paid period
50
+ if (now < endDate) {
51
+ return AccessModeEnum.FULL;
52
+ }
53
+ // Past EndDate, but within Grace Period
54
+ if (graceEndDate && now <= graceEndDate) {
55
+ return AccessModeEnum.READ_ONLY;
56
+ }
57
+ // Past both EndDate and Grace Period
58
+ return AccessModeEnum.RENEW_SUBSCRIPTION;
59
+ }
60
+ return AccessModeEnum.BLOCKED;
61
+ };
62
62
  module.exports = ResolveAccessMode;
@@ -1,55 +1,55 @@
1
- const StatusMessage = require('../constants/StatusMessageConstants');
2
- const VariantPriceUtil = async function (
3
- variantData
4
- ) {
5
- const { MRP, SellingPrice, DiscountPercentage } = variantData;
6
-
7
- if (!MRP || MRP <= 0) {
8
- throw new Error(StatusMessage.PRODUCTVARIANT_INVALID_MRP);
9
- }
10
-
11
- if (SellingPrice == null && DiscountPercentage == null) {
12
- throw new Error(StatusMessage.PRODUCTVARIANT_MISSING_PRICE_OR_DISCOUNT);
13
- }
14
-
15
- let calculatedSellingPrice = SellingPrice;
16
- let calculatedDiscountPercentage = DiscountPercentage;
17
-
18
- if (SellingPrice != null && DiscountPercentage != null) {
19
- // Consistency check when both are provided
20
- const expectedDiscount = ((MRP - SellingPrice) / MRP) * 100;
21
- if (Math.abs(expectedDiscount - DiscountPercentage) > 0.01) {
22
- // Tolerance for floating point
23
- throw new Error(StatusMessage.PRODUCTVARIANT_INCONSISTENT_PRICING);
24
- }
25
- // Use provided values since they are consistent
26
- calculatedDiscountPercentage = DiscountPercentage;
27
- calculatedSellingPrice = SellingPrice;
28
- } else if (SellingPrice != null) {
29
- if (SellingPrice > MRP) {
30
- throw new Error(StatusMessage.PRODUCTVARIANT_SELLING_PRICE_EXCEEDS_MRP);
31
- }
32
- if (SellingPrice < 0) {
33
- throw new Error(StatusMessage.PRODUCTVARIANT_INVALID_SELLING_PRICE);
34
- }
35
- calculatedDiscountPercentage = ((MRP - SellingPrice) / MRP) * 100;
36
- calculatedDiscountPercentage = parseFloat(
37
- calculatedDiscountPercentage.toFixed(2)
38
- );
39
- } else if (DiscountPercentage != null) {
40
- if (DiscountPercentage < 0 || DiscountPercentage > 100) {
41
- throw new Error(
42
- StatusMessage.PRODUCTVARIANT_INVALID_DISCOUNT_PERCENTAGE
43
- );
44
- }
45
- calculatedSellingPrice = MRP * (1 - DiscountPercentage / 100);
46
- calculatedSellingPrice = parseFloat(calculatedSellingPrice.toFixed(2));
47
- }
48
-
49
- return {
50
- ...variantData,
51
- SellingPrice: calculatedSellingPrice,
52
- DiscountPercentage: calculatedDiscountPercentage,
53
- };
54
- }
1
+ const StatusMessage = require('../constants/StatusMessageConstants');
2
+ const VariantPriceUtil = async function (
3
+ variantData
4
+ ) {
5
+ const { MRP, SellingPrice, DiscountPercentage } = variantData;
6
+
7
+ if (!MRP || MRP <= 0) {
8
+ throw new Error(StatusMessage.PRODUCTVARIANT_INVALID_MRP);
9
+ }
10
+
11
+ if (SellingPrice == null && DiscountPercentage == null) {
12
+ throw new Error(StatusMessage.PRODUCTVARIANT_MISSING_PRICE_OR_DISCOUNT);
13
+ }
14
+
15
+ let calculatedSellingPrice = SellingPrice;
16
+ let calculatedDiscountPercentage = DiscountPercentage;
17
+
18
+ if (SellingPrice != null && DiscountPercentage != null) {
19
+ // Consistency check when both are provided
20
+ const expectedDiscount = ((MRP - SellingPrice) / MRP) * 100;
21
+ if (Math.abs(expectedDiscount - DiscountPercentage) > 0.01) {
22
+ // Tolerance for floating point
23
+ throw new Error(StatusMessage.PRODUCTVARIANT_INCONSISTENT_PRICING);
24
+ }
25
+ // Use provided values since they are consistent
26
+ calculatedDiscountPercentage = DiscountPercentage;
27
+ calculatedSellingPrice = SellingPrice;
28
+ } else if (SellingPrice != null) {
29
+ if (SellingPrice > MRP) {
30
+ throw new Error(StatusMessage.PRODUCTVARIANT_SELLING_PRICE_EXCEEDS_MRP);
31
+ }
32
+ if (SellingPrice < 0) {
33
+ throw new Error(StatusMessage.PRODUCTVARIANT_INVALID_SELLING_PRICE);
34
+ }
35
+ calculatedDiscountPercentage = ((MRP - SellingPrice) / MRP) * 100;
36
+ calculatedDiscountPercentage = parseFloat(
37
+ calculatedDiscountPercentage.toFixed(2)
38
+ );
39
+ } else if (DiscountPercentage != null) {
40
+ if (DiscountPercentage < 0 || DiscountPercentage > 100) {
41
+ throw new Error(
42
+ StatusMessage.PRODUCTVARIANT_INVALID_DISCOUNT_PERCENTAGE
43
+ );
44
+ }
45
+ calculatedSellingPrice = MRP * (1 - DiscountPercentage / 100);
46
+ calculatedSellingPrice = parseFloat(calculatedSellingPrice.toFixed(2));
47
+ }
48
+
49
+ return {
50
+ ...variantData,
51
+ SellingPrice: calculatedSellingPrice,
52
+ DiscountPercentage: calculatedDiscountPercentage,
53
+ };
54
+ }
55
55
  module.exports = VariantPriceUtil;