@b2y/ecommerce-common 1.3.0 → 1.3.2

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.
@@ -51,7 +51,8 @@ const initializeModels = (sequelize) => {
51
51
  SubscriptionPlanFeature,
52
52
  TenantSubscription,
53
53
  ProductImport,
54
- ProductImportFailureAudits
54
+ ProductImportFailureAudits,
55
+ PackagingBox
55
56
  } = models;
56
57
  Category.hasMany(Category, {
57
58
  foreignKey: "ParentCategoryID",
@@ -176,6 +177,11 @@ const initializeModels = (sequelize) => {
176
177
  as: "AttributeValue",
177
178
  });
178
179
 
180
+ ProductVariant.hasOne(PackagingBox, {
181
+ foreignKey: "PackagingBoxID",
182
+ as: "PackagingBox"
183
+ })
184
+
179
185
  // Product and ProductGroup Association
180
186
  // Many-to-One
181
187
  Product.belongsTo(ProductGroup, {
@@ -0,0 +1,7 @@
1
+ const PackageBoxTypeEnum = Object.freeze({
2
+ BOX: "Box",
3
+ ENVELOPE: "Envelope",
4
+ SOFT_PACKAGE: "Soft Package"
5
+ });
6
+
7
+ module.exports = PackageBoxTypeEnum;
@@ -0,0 +1,78 @@
1
+ const { DataTypes } = require('sequelize');
2
+ module.exports = (sequelize) => {
3
+ return sequelize.define('PackagingBox', {
4
+ PackagingBoxID: {
5
+ type: DataTypes.UUID,
6
+ primaryKey: true,
7
+ allowNull: false,
8
+ defaultValue: DataTypes.UUIDV4
9
+ },
10
+ TenantID: {
11
+ type: DataTypes.UUID,
12
+ allowNull: false,
13
+ references: {
14
+ model: 'Tenant',
15
+ key: 'TenantID'
16
+ },
17
+ onDelete: 'CASCADE',
18
+ onUpdate: 'CASCADE'
19
+ },
20
+ PackageType: {
21
+ type: DataTypes.STRING(255),
22
+ allowNull: false,
23
+ },
24
+ PackageName: {
25
+ type: DataTypes.STRING(100),
26
+ allowNull: false
27
+ },
28
+ Length: {
29
+ type: DataTypes.DECIMAL(10, 2),
30
+ allowNull: false
31
+ },
32
+ Width: {
33
+ type: DataTypes.DECIMAL(10, 2),
34
+ allowNull: false
35
+ },
36
+ Height: {
37
+ type: DataTypes.DECIMAL(10, 2),
38
+ allowNull: true
39
+ },
40
+ Unit: {
41
+ type: DataTypes.STRING(5),
42
+ allowNull: false
43
+ },
44
+ EmptyWeight: {
45
+ type: DataTypes.DECIMAL(10, 2),
46
+ allowNull: false
47
+ },
48
+ WeightUnit: {
49
+ type: DataTypes.STRING(5),
50
+ allowNull: false,
51
+ },
52
+ IsDefaultPackage: {
53
+ type: DataTypes.BOOLEAN,
54
+ defaultValue: false
55
+ },
56
+ CreatedBy: {
57
+ type: DataTypes.UUID,
58
+ allowNull: false
59
+ },
60
+ CreatedAt: {
61
+ type: DataTypes.DATE,
62
+ allowNull: false,
63
+ defaultValue: DataTypes.NOW
64
+ },
65
+ UpdatedBy: {
66
+ type: DataTypes.UUID,
67
+ allowNull: false
68
+ },
69
+ UpdatedAt: {
70
+ type: DataTypes.DATE,
71
+ allowNull: false,
72
+ defaultValue: DataTypes.NOW
73
+ }
74
+ }, {
75
+ tableName: 'PackagingBox',
76
+ timestamps: false
77
+ });
78
+ };
@@ -51,6 +51,32 @@ module.exports = (sequelize) => {
51
51
  type: DataTypes.BOOLEAN,
52
52
  defaultValue: true
53
53
  },
54
+ Weight: {
55
+ type: DataTypes.DECIMAL(10, 2),
56
+ allowNull: false
57
+ },
58
+ Unit: {
59
+ type: DataTypes.STRING(5),
60
+ allowNull: false
61
+ },
62
+ CountryCode: {
63
+ type: DataTypes.STRING(2),
64
+ allowNull: true
65
+ },
66
+ HSCode: {
67
+ type: DataTypes.STRING(10),
68
+ allowNull: true
69
+ },
70
+ PackagingBoxID: {
71
+ type: DataTypes.UUID,
72
+ allowNull: false,
73
+ references: {
74
+ model: 'PackagingBox',
75
+ key: 'PackagingBoxID'
76
+ },
77
+ onDelete: 'RESTRICT',
78
+ onUpdate: 'CASCADE'
79
+ },
54
80
  GroupByAttributeValue: {
55
81
  type: DataTypes.UUID,
56
82
  allowNull: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b2y/ecommerce-common",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "E-commerce common library",
5
5
  "main": "index.js",
6
6
  "scripts": {