@b2y/ecommerce-common 1.0.3 → 1.0.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.
@@ -11,9 +11,6 @@ const StatusMessageConstants = {
11
11
  INVALID_END_DATE: "Invalid endDate",
12
12
  INVALID_START_DATE: "Invalid startDate",
13
13
  INVALID_ISACTIVE_STATUS: "IsActive must be either true or false",
14
- PAYMENT_STATUS_INVALID: "PaymentStatus is invalid",
15
- PAYMENT_TYPE_INVALID: "PaymentType is invalid",
16
- PAYMENT_METHOD_INVALID: "PaymentMethod is invalid",
17
14
  ORDER_CREATION_FAILED:"Order creation failed",
18
15
  PAYMENT_SIGNATURE_VERIFICATION_FAILED:"Payment signature verification failed",
19
16
  PAYMENT_VERIFICATION_FAILED:"Payment verification failed"
package/model/Address.js CHANGED
@@ -40,7 +40,7 @@ module.exports = (sequelize) => {
40
40
  allowNull: false,
41
41
  },
42
42
  StateCode: {
43
- type:DataTypes.CHAR(3),
43
+ type:DataTypes.STRING(3),
44
44
  allowNull:false
45
45
  },
46
46
  CountryCode:{
package/model/Store.js CHANGED
@@ -45,7 +45,7 @@ module.exports = (sequelize) => {
45
45
  allowNull:false
46
46
  },
47
47
  StateCode: {
48
- type:DataTypes.CHAR(3),
48
+ type:DataTypes.STRING(3),
49
49
  allowNull:false
50
50
  },
51
51
  CityName: {
package/model/Tenant.js CHANGED
@@ -55,7 +55,7 @@ module.exports = (sequelize) => {
55
55
  allowNull: false
56
56
  },
57
57
  StateCode: {
58
- type: DataTypes.CHAR(3),
58
+ type: DataTypes.STRING(3),
59
59
  allowNull: false
60
60
  },
61
61
  CountryCode: {
package/model/User.js CHANGED
@@ -70,7 +70,7 @@ module.exports = (sequelize) => {
70
70
  allowNull: false,
71
71
  },
72
72
  StateCode: {
73
- type:DataTypes.CHAR(3),
73
+ type:DataTypes.STRING(3),
74
74
  allowNull:false
75
75
  },
76
76
  CountryCode:{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b2y/ecommerce-common",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "E-commerce common library",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -2,9 +2,6 @@
2
2
  const AppUtil = require('../utility/AppUtil');
3
3
  const StatusMessage = require('../constants/StatusMessageConstants');
4
4
  const DateUtil = require('../utility/DateUtil');
5
- const PaymentStatusEnum = require('../enum/PaymentStatusEnum');
6
- const PaymentTypeEnum = require('../enum/PaymentTypeEnum');
7
- const PaymentMethodEnum = require('../enum/PaymentMethodEnum');
8
5
  const {Sequelize} = require('sequelize');
9
6
  class QueryUtil {
10
7
  static parseId(idParam) {
@@ -61,7 +58,7 @@ class QueryUtil {
61
58
  return storeWhereClause;
62
59
  }
63
60
  static orderWhereClause(filters, tenantID, logger) {
64
- const { startDate, endDate, searchText, paymentStatus, storeId } = filters;
61
+ const { startDate, endDate, searchText, paymentStatusId, storeId } = filters;
65
62
  let orderWhereClause = {};
66
63
  let paymentStatusWhere = {};
67
64
  let storeWhereClause = {};
@@ -80,13 +77,9 @@ class QueryUtil {
80
77
  { "$Customer.FirstName$": { [Sequelize.Op.iLike]: `%${searchText}%` } },
81
78
  ];
82
79
  }
83
- if (paymentStatus) {
84
- const validPaymentStatus = new Set(Object.values(PaymentStatusEnum));
85
- if (!validPaymentStatus.has(paymentStatus)) {
86
- logger.warn("invalid payment status")
87
- throw new Error(StatusMessage.INVALID_PAYMENT_STATUS);
88
- }
89
- paymentStatusWhere.PaymentStatusName = paymentStatus;
80
+ if (paymentStatusId) {
81
+ const paymentStatusIDs = this.parseId(paymentStatusId);
82
+ paymentStatusWhere.PaymentStatusID = {[Sequelize.Op.in] : paymentStatusIDs};
90
83
  }
91
84
  if(storeId) {
92
85
  const storeIDs = this.parseId(storeId);
@@ -105,10 +98,10 @@ class QueryUtil {
105
98
  }
106
99
  static paymentWhereClause(filters, tenantID, logger) {
107
100
  const {
108
- paymentStatus,
101
+ paymentStatusId,
109
102
  searchText,
110
- paymentType,
111
- paymentMethod,
103
+ paymentTypeId,
104
+ paymentMethodId,
112
105
  storeId,
113
106
  startDate,
114
107
  endDate,
@@ -133,29 +126,17 @@ class QueryUtil {
133
126
  { PaymentRefID: { [Sequelize.Op.iLike]: `%${searchText}%` } },
134
127
  ];
135
128
  }
136
- if (paymentStatus) {
137
- const validPaymentStatus = new Set(Object.values(PaymentStatusEnum));
138
- if (!validPaymentStatus.has(paymentStatus)) {
139
- logger.warn("invalid payment status");
140
- throw new Error(StatusMessage.PAYMENT_STATUS_INVALID);
141
- }
142
- paymentStatusWhere.PaymentStatusName = paymentStatus;
129
+ if (paymentStatusId) {
130
+ const paymentStatusIDs = this.parseId(paymentStatusId)
131
+ paymentStatusWhere.PaymentStatusID = {[Sequelize.Op.in] : paymentStatusIDs};
143
132
  }
144
- if (paymentType) {
145
- const validPaymentType = new Set(Object.values(PaymentTypeEnum));
146
- if (!validPaymentType.has(paymentType)) {
147
- logger.warn("invalid payment type");
148
- throw new Error(StatusMessage.PAYMENT_TYPE_INVALID);
149
- }
150
- paymentTypeWhere.PaymentTypeName = paymentType;
133
+ if (paymentTypeId) {
134
+ const paymentTypeIDs = this.parseId(paymentTypeId)
135
+ paymentTypeWhere.PaymentTypeID = {[Sequelize.Op.in] : paymentTypeIDs};
151
136
  }
152
- if (paymentMethod) {
153
- const validPaymentMethod = new Set(Object.values(PaymentMethodEnum));
154
- if (!validPaymentMethod.has(paymentMethod)) {
155
- logger.warn("invalid payment method")
156
- throw new Error(StatusMessage.PAYMENT_METHOD_INVALID);
157
- }
158
- paymentMethodWhere.PaymentMethodName = paymentMethod;
137
+ if (paymentMethodId) {
138
+ const paymentMethodIDs = this.parseId(paymentMethodId);
139
+ paymentMethodWhere.PaymentMethodID = {[Sequelize.Op.in] : paymentMethodIDs};
159
140
  }
160
141
  if(storeId) {
161
142
  const storeIDs = this.parseId(storeId);
@@ -1,12 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="WEB_MODULE" version="4">
3
- <component name="NewModuleRootManager">
4
- <content url="file://$MODULE_DIR$">
5
- <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6
- <excludeFolder url="file://$MODULE_DIR$/temp" />
7
- <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
- </content>
9
- <orderEntry type="inheritedJdk" />
10
- <orderEntry type="sourceFolder" forTests="false" />
11
- </component>
12
- </module>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/ecommerce-common.iml" filepath="$PROJECT_DIR$/.idea/ecommerce-common.iml" />
6
- </modules>
7
- </component>
8
- </project>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="" vcs="Git" />
5
- </component>
6
- </project>