@b2y/ecommerce-common 1.1.1 → 1.1.4

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 (80) hide show
  1. package/README.md +4 -4
  2. package/constants/AppConstants.js +6 -6
  3. package/constants/ReportConstants.js +14 -14
  4. package/constants/StatusMessageConstants.js +17 -17
  5. package/dbconnection/Connect.js +432 -420
  6. package/enum/AccessModeEnum.js +7 -7
  7. package/enum/AddressTypeEnum.js +6 -6
  8. package/enum/BillingCycleEnum.js +5 -5
  9. package/enum/BooleanEnum.js +4 -4
  10. package/enum/BulkImportStatusEnum.js +7 -0
  11. package/enum/EntityTypeEnum.js +11 -11
  12. package/enum/FeatureTypeEnum.js +6 -6
  13. package/enum/GenderEnum.js +7 -7
  14. package/enum/NotificationStatusEnum.js +5 -5
  15. package/enum/NotificationTypeEnum.js +9 -9
  16. package/enum/OrderStatusEnum.js +7 -7
  17. package/enum/PaymentMethodEnum.js +6 -6
  18. package/enum/PaymentStatusEnum.js +6 -6
  19. package/enum/PaymentTypeEnum.js +6 -6
  20. package/enum/PlatformEnum.js +4 -4
  21. package/enum/RegistrationStatusEnum.js +5 -5
  22. package/enum/SortByEnum.js +7 -7
  23. package/enum/SubscriptionStatusEnum.js +7 -7
  24. package/index.js +22 -22
  25. package/model/Address.js +95 -95
  26. package/model/AttributeType.js +50 -50
  27. package/model/AttributeValue.js +64 -64
  28. package/model/Banner.js +78 -78
  29. package/model/Brand.js +76 -76
  30. package/model/Cart.js +76 -76
  31. package/model/Category.js +72 -72
  32. package/model/CategoryAttributeType.js +62 -62
  33. package/model/Colour.js +52 -52
  34. package/model/Customer.js +94 -94
  35. package/model/DeviceToken.js +51 -51
  36. package/model/Document.js +73 -70
  37. package/model/DynamicUIComponent.js +52 -52
  38. package/model/Feedback.js +79 -79
  39. package/model/Inventory.js +83 -83
  40. package/model/NotificationHistory.js +67 -67
  41. package/model/Order.js +94 -94
  42. package/model/OrderItem.js +98 -98
  43. package/model/OrderItemHistory.js +69 -69
  44. package/model/OrderStatus.js +48 -48
  45. package/model/Payment.js +101 -101
  46. package/model/PaymentMethod.js +36 -36
  47. package/model/PaymentStatus.js +36 -36
  48. package/model/PaymentType.js +36 -36
  49. package/model/Permission.js +55 -55
  50. package/model/Product.js +82 -82
  51. package/model/ProductGroup.js +48 -48
  52. package/model/ProductImport.js +55 -0
  53. package/model/ProductImportFailureAudits.js +58 -0
  54. package/model/ProductSpecification.js +65 -65
  55. package/model/ProductVariant.js +75 -75
  56. package/model/ProductVariantAttribute.js +58 -58
  57. package/model/Role.js +61 -61
  58. package/model/RolePermissionMapping.js +63 -63
  59. package/model/SpecificationType.js +41 -41
  60. package/model/Store.js +99 -99
  61. package/model/StoreUserMapping.js +44 -44
  62. package/model/SubscriptionFeature.js +49 -49
  63. package/model/SubscriptionPlan.js +66 -66
  64. package/model/SubscriptionPlanFeature.js +48 -48
  65. package/model/Tenant.js +91 -91
  66. package/model/TenantSettings.js +47 -47
  67. package/model/TenantSubscription.js +73 -73
  68. package/model/User.js +132 -132
  69. package/model/WishList.js +62 -62
  70. package/package.json +29 -29
  71. package/utility/AppUtil.js +65 -65
  72. package/utility/DateUtil.js +55 -55
  73. package/utility/ExcelUtil.js +125 -125
  74. package/utility/LocationUtility.js +130 -130
  75. package/utility/OrderTimeFilterUtil.js +88 -88
  76. package/utility/PdfUtil.js +64 -64
  77. package/utility/QueryUtil.js +261 -261
  78. package/utility/Razorpay.js +65 -65
  79. package/utility/ResolveAccessMode.js +38 -38
  80. package/utility/VariantPriceUtil.js +54 -54
@@ -1,39 +1,39 @@
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
-
8
- if ([SubscriptionStatusEnum.CANCELLED, SubscriptionStatusEnum.EXPIRED, SubscriptionStatusEnum.SUSPENDED].includes(subscription.Status)) {
9
- return AccessModeEnum.BLOCKED;
10
- }
11
-
12
- if (subscription.Status === SubscriptionStatusEnum.ACTIVE) {
13
- if (subscription.IsTrial === true) {
14
- const trialEndDate = subscription.TrialEndDate
15
- ? new Date(subscription.TrialEndDate)
16
- : null;
17
- if (trialEndDate && now < trialEndDate) {
18
- return AccessModeEnum.FULL;
19
- }
20
- return AccessModeEnum.PAYMENT_REQUIRED;
21
- }
22
- const endDate = new Date(subscription.EndDate);
23
- const graceEndDate = subscription.GraceEndDate
24
- ? new Date(subscription.GraceEndDate)
25
- : null;
26
- // Still in the paid period
27
- if (now < endDate) {
28
- return AccessModeEnum.FULL;
29
- }
30
- // Past EndDate, but within Grace Period
31
- if (graceEndDate && now <= graceEndDate) {
32
- return AccessModeEnum.READ_ONLY;
33
- }
34
- // Past both EndDate and Grace Period
35
- return AccessModeEnum.BLOCKED;
36
- }
37
- return AccessModeEnum.BLOCKED;
38
- };
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
+
8
+ if ([SubscriptionStatusEnum.CANCELLED, SubscriptionStatusEnum.EXPIRED, SubscriptionStatusEnum.SUSPENDED].includes(subscription.Status)) {
9
+ return AccessModeEnum.BLOCKED;
10
+ }
11
+
12
+ if (subscription.Status === SubscriptionStatusEnum.ACTIVE) {
13
+ if (subscription.IsTrial === true) {
14
+ const trialEndDate = subscription.TrialEndDate
15
+ ? new Date(subscription.TrialEndDate)
16
+ : null;
17
+ if (trialEndDate && now < trialEndDate) {
18
+ return AccessModeEnum.FULL;
19
+ }
20
+ return AccessModeEnum.PAYMENT_REQUIRED;
21
+ }
22
+ const endDate = new Date(subscription.EndDate);
23
+ const graceEndDate = subscription.GraceEndDate
24
+ ? new Date(subscription.GraceEndDate)
25
+ : null;
26
+ // Still in the paid period
27
+ if (now < endDate) {
28
+ return AccessModeEnum.FULL;
29
+ }
30
+ // Past EndDate, but within Grace Period
31
+ if (graceEndDate && now <= graceEndDate) {
32
+ return AccessModeEnum.READ_ONLY;
33
+ }
34
+ // Past both EndDate and Grace Period
35
+ return AccessModeEnum.BLOCKED;
36
+ }
37
+ return AccessModeEnum.BLOCKED;
38
+ };
39
39
  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;