@b2y/ecommerce-common 1.3.4 → 1.3.5
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.
- package/dbconnection/Connect.js +55 -1
- package/enum/ActionByTypeEnum.js +5 -0
- package/enum/OrderActionStatusEnum.js +7 -0
- package/enum/ReasonTypeEnum.js +7 -0
- package/model/OrderActionReason.js +100 -0
- package/model/ReasonContextMapping.js +71 -0
- package/model/ReasonMaster.js +74 -0
- package/package.json +1 -1
package/dbconnection/Connect.js
CHANGED
|
@@ -52,7 +52,10 @@ const initializeModels = (sequelize) => {
|
|
|
52
52
|
TenantSubscription,
|
|
53
53
|
ProductImport,
|
|
54
54
|
ProductImportFailureAudits,
|
|
55
|
-
PackagingBox
|
|
55
|
+
PackagingBox,
|
|
56
|
+
ReasonContextMapping,
|
|
57
|
+
ReasonMaster,
|
|
58
|
+
OrderActionReason
|
|
56
59
|
} = models;
|
|
57
60
|
Category.hasMany(Category, {
|
|
58
61
|
foreignKey: "ParentCategoryID",
|
|
@@ -429,6 +432,57 @@ const initializeModels = (sequelize) => {
|
|
|
429
432
|
foreignKey: 'ProductImportID',
|
|
430
433
|
as: 'ProductImport'
|
|
431
434
|
})
|
|
435
|
+
|
|
436
|
+
// order reasons
|
|
437
|
+
ReasonMaster.hasMany(ReasonContextMapping, {
|
|
438
|
+
foreignKey: "ReasonID",
|
|
439
|
+
as: "ReasonContextMappings",
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
ReasonContextMapping.belongsTo(ReasonMaster, {
|
|
443
|
+
foreignKey: "ReasonID",
|
|
444
|
+
as: "Reason",
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
ReasonMaster.hasMany(OrderActionReason, {
|
|
448
|
+
foreignKey: "ReasonID",
|
|
449
|
+
as: "OrderActionReasons",
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
OrderActionReason.belongsTo(ReasonMaster, {
|
|
453
|
+
foreignKey: "ReasonID",
|
|
454
|
+
as: "Reason",
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
ReasonContextMapping.belongsTo(Category, {
|
|
458
|
+
foreignKey: "CategoryID",
|
|
459
|
+
as: "Category",
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
Category.hasMany(ReasonContextMapping, {
|
|
463
|
+
foreignKey: "CategoryID",
|
|
464
|
+
as: "ReasonContextMappings",
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
OrderActionReason.belongsTo(Order, {
|
|
468
|
+
foreignKey: "OrderID",
|
|
469
|
+
as: "Order",
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
Order.hasMany(OrderActionReason, {
|
|
473
|
+
foreignKey: "OrderID",
|
|
474
|
+
as: "OrderActionReasons",
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
OrderActionReason.belongsTo(OrderItem, {
|
|
478
|
+
foreignKey: "OrderItemID",
|
|
479
|
+
as: "OrderItem",
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
OrderItem.hasMany(OrderActionReason, {
|
|
483
|
+
foreignKey: "OrderItemID",
|
|
484
|
+
as: "OrderActionReasons",
|
|
485
|
+
});
|
|
432
486
|
|
|
433
487
|
//Tenant Settings
|
|
434
488
|
Tenant.hasOne(TenantSettings, {
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
const { DataTypes, UUID } = require('sequelize');
|
|
2
|
+
const ActionByTypeEnum = require('../enum/ActionByTypeEnum');
|
|
3
|
+
const OrderActionStatusEnum = require('../enum/OrderActionStatusEnum');
|
|
4
|
+
module.exports = (sequelize) => {
|
|
5
|
+
return sequelize.define('OrderActionReason', {
|
|
6
|
+
OrderActionReasonID: {
|
|
7
|
+
type: DataTypes.UUID,
|
|
8
|
+
primaryKey: true,
|
|
9
|
+
allowNull: false,
|
|
10
|
+
defaultValue: DataTypes.UUIDV4
|
|
11
|
+
},
|
|
12
|
+
TenantID: {
|
|
13
|
+
type: DataTypes.UUID,
|
|
14
|
+
allowNull: false,
|
|
15
|
+
references: {
|
|
16
|
+
model: 'Tenant',
|
|
17
|
+
key: 'TenantID'
|
|
18
|
+
},
|
|
19
|
+
onDelete: 'CASCADE',
|
|
20
|
+
onUpdate: 'CASCADE'
|
|
21
|
+
},
|
|
22
|
+
OrderID: {
|
|
23
|
+
type: DataTypes.UUID,
|
|
24
|
+
allowNull: false,
|
|
25
|
+
references: {
|
|
26
|
+
model: 'Order',
|
|
27
|
+
key: 'OrderID'
|
|
28
|
+
},
|
|
29
|
+
onDelete: 'CASCADE',
|
|
30
|
+
onUpdate: 'CASCADE'
|
|
31
|
+
},
|
|
32
|
+
OrderItemID: {
|
|
33
|
+
type: DataTypes.UUID,
|
|
34
|
+
allowNull: false,
|
|
35
|
+
references: {
|
|
36
|
+
model: 'OrderItem',
|
|
37
|
+
key: 'OrderItemID'
|
|
38
|
+
},
|
|
39
|
+
onDelete: 'CASCADE',
|
|
40
|
+
onUpdate: 'CASCADE'
|
|
41
|
+
},
|
|
42
|
+
ReasonID: {
|
|
43
|
+
type: DataTypes.UUID,
|
|
44
|
+
allowNull: false,
|
|
45
|
+
references: {
|
|
46
|
+
model: 'ReasonMaster',
|
|
47
|
+
key: 'ReasonID'
|
|
48
|
+
},
|
|
49
|
+
onDelete: 'RESTRICT',
|
|
50
|
+
onUpdate: 'CASCADE'
|
|
51
|
+
},
|
|
52
|
+
ActionType: {
|
|
53
|
+
type: DataTypes.STRING(30),
|
|
54
|
+
allowNull: false
|
|
55
|
+
},
|
|
56
|
+
ActionByType: {
|
|
57
|
+
type: DataTypes.STRING(30),
|
|
58
|
+
allowNull: true,
|
|
59
|
+
defaultValue: ActionByTypeEnum.CUSTOMER
|
|
60
|
+
},
|
|
61
|
+
OrderActionStatus: {
|
|
62
|
+
type: DataTypes.STRING(20),
|
|
63
|
+
allowNull: true,
|
|
64
|
+
defaultValue: OrderActionStatusEnum.PENDING
|
|
65
|
+
},
|
|
66
|
+
UserComment: {
|
|
67
|
+
type: DataTypes.TEXT,
|
|
68
|
+
allowNull: true
|
|
69
|
+
},
|
|
70
|
+
AdminComment: {
|
|
71
|
+
type: DataTypes.TEXT,
|
|
72
|
+
allowNull: true
|
|
73
|
+
},
|
|
74
|
+
IsActive: {
|
|
75
|
+
type: DataTypes.BOOLEAN,
|
|
76
|
+
defaultValue: true
|
|
77
|
+
},
|
|
78
|
+
CreatedBy: {
|
|
79
|
+
type: DataTypes.UUID,
|
|
80
|
+
allowNull: false
|
|
81
|
+
},
|
|
82
|
+
CreatedAt: {
|
|
83
|
+
type: DataTypes.DATE,
|
|
84
|
+
allowNull: false,
|
|
85
|
+
defaultValue: DataTypes.NOW
|
|
86
|
+
},
|
|
87
|
+
UpdatedBy: {
|
|
88
|
+
type: DataTypes.UUID,
|
|
89
|
+
allowNull: false
|
|
90
|
+
},
|
|
91
|
+
UpdatedAt: {
|
|
92
|
+
type: DataTypes.DATE,
|
|
93
|
+
allowNull: false,
|
|
94
|
+
defaultValue: DataTypes.NOW
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
tableName: 'ReasonMaster',
|
|
98
|
+
timestamps: false
|
|
99
|
+
})
|
|
100
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const { DataTypes } = require('sequelize');
|
|
2
|
+
|
|
3
|
+
module.exports = (sequelize) => {
|
|
4
|
+
return sequelize.define('ReasonContextMapping', {
|
|
5
|
+
ReasonContextMappingID: {
|
|
6
|
+
type: DataTypes.UUID,
|
|
7
|
+
primaryKey: true,
|
|
8
|
+
allowNull: false,
|
|
9
|
+
defaultValue: DataTypes.UUIDV4
|
|
10
|
+
},
|
|
11
|
+
TenantID: {
|
|
12
|
+
type: DataTypes.UUID,
|
|
13
|
+
allowNull: false,
|
|
14
|
+
references: {
|
|
15
|
+
model: 'Tenant',
|
|
16
|
+
key: 'TenantID'
|
|
17
|
+
},
|
|
18
|
+
onDelete: 'CASCADE',
|
|
19
|
+
onUpdate: 'CASCADE'
|
|
20
|
+
},
|
|
21
|
+
ReasonID: {
|
|
22
|
+
type: DataTypes.UUID,
|
|
23
|
+
allowNull: false,
|
|
24
|
+
references: {
|
|
25
|
+
model: 'ReasonMaster',
|
|
26
|
+
key: 'ReasonID'
|
|
27
|
+
},
|
|
28
|
+
onDelete: 'CASCADE',
|
|
29
|
+
onUpdate: 'CASCADE'
|
|
30
|
+
},
|
|
31
|
+
CategoryID: {
|
|
32
|
+
type: DataTypes.UUID,
|
|
33
|
+
allowNull: false,
|
|
34
|
+
references: {
|
|
35
|
+
model: 'Category',
|
|
36
|
+
key: 'CategoryID'
|
|
37
|
+
},
|
|
38
|
+
onDelete: 'CASCADE',
|
|
39
|
+
onUpdate: 'CASCADE'
|
|
40
|
+
},
|
|
41
|
+
SortOrder: {
|
|
42
|
+
type: DataTypes.INTEGER,
|
|
43
|
+
defaultValue: 0
|
|
44
|
+
},
|
|
45
|
+
IsActive: {
|
|
46
|
+
type: DataTypes.BOOLEAN,
|
|
47
|
+
defaultValue: true
|
|
48
|
+
},
|
|
49
|
+
CreatedBy: {
|
|
50
|
+
type: DataTypes.UUID,
|
|
51
|
+
allowNull: false
|
|
52
|
+
},
|
|
53
|
+
CreatedAt: {
|
|
54
|
+
type: DataTypes.DATE,
|
|
55
|
+
allowNull: false,
|
|
56
|
+
defaultValue: DataTypes.NOW
|
|
57
|
+
},
|
|
58
|
+
UpdatedBy: {
|
|
59
|
+
type: DataTypes.UUID,
|
|
60
|
+
allowNull: false
|
|
61
|
+
},
|
|
62
|
+
UpdatedAt: {
|
|
63
|
+
type: DataTypes.DATE,
|
|
64
|
+
allowNull: false,
|
|
65
|
+
defaultValue: DataTypes.NOW
|
|
66
|
+
}
|
|
67
|
+
}, {
|
|
68
|
+
tableName: 'ReasonContextMapping',
|
|
69
|
+
timestamps: false
|
|
70
|
+
})
|
|
71
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const { DataTypes } = require('sequelize');
|
|
2
|
+
|
|
3
|
+
module.exports = (sequelize) => {
|
|
4
|
+
return sequelize.define('ReasonMaster', {
|
|
5
|
+
ReasonID: {
|
|
6
|
+
type: DataTypes.UUID,
|
|
7
|
+
primaryKey: true,
|
|
8
|
+
allowNull: false,
|
|
9
|
+
defaultValue: DataTypes.UUIDV4
|
|
10
|
+
},
|
|
11
|
+
TenantID: {
|
|
12
|
+
type: DataTypes.UUID,
|
|
13
|
+
allowNull: false,
|
|
14
|
+
references: {
|
|
15
|
+
model: 'Tenant',
|
|
16
|
+
key: 'TenantID'
|
|
17
|
+
},
|
|
18
|
+
onDelete: 'CASCADE',
|
|
19
|
+
onUpdate: 'CASCADE'
|
|
20
|
+
},
|
|
21
|
+
ReasonType: {
|
|
22
|
+
type: DataTypes.STRING(30),
|
|
23
|
+
allowNull: false
|
|
24
|
+
},
|
|
25
|
+
ReasonCode: {
|
|
26
|
+
type: DataTypes.STRING(50),
|
|
27
|
+
allowNull: false
|
|
28
|
+
},
|
|
29
|
+
ReasonLabel: {
|
|
30
|
+
type: DataTypes.STRING(255),
|
|
31
|
+
allowNull: false
|
|
32
|
+
},
|
|
33
|
+
RequiresComment: {
|
|
34
|
+
type: DataTypes.BOOLEAN,
|
|
35
|
+
defaultValue: false
|
|
36
|
+
},
|
|
37
|
+
RequiresAttachment: {
|
|
38
|
+
type: DataTypes.BOOLEAN,
|
|
39
|
+
defaultValue: false
|
|
40
|
+
},
|
|
41
|
+
IsActive: {
|
|
42
|
+
type: DataTypes.BOOLEAN,
|
|
43
|
+
defaultValue: true
|
|
44
|
+
},
|
|
45
|
+
CreatedBy: {
|
|
46
|
+
type: DataTypes.UUID,
|
|
47
|
+
allowNull: false
|
|
48
|
+
},
|
|
49
|
+
CreatedAt: {
|
|
50
|
+
type: DataTypes.DATE,
|
|
51
|
+
allowNull: false,
|
|
52
|
+
defaultValue: DataTypes.NOW
|
|
53
|
+
},
|
|
54
|
+
UpdatedBy: {
|
|
55
|
+
type: DataTypes.UUID,
|
|
56
|
+
allowNull: false
|
|
57
|
+
},
|
|
58
|
+
UpdatedAt: {
|
|
59
|
+
type: DataTypes.DATE,
|
|
60
|
+
allowNull: false,
|
|
61
|
+
defaultValue: DataTypes.NOW
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
tableName: 'ReasonMaster',
|
|
65
|
+
timestamps: false,
|
|
66
|
+
indexes: [
|
|
67
|
+
{
|
|
68
|
+
unique: true,
|
|
69
|
+
fields: ['ReasonType', 'ReasonCode'],
|
|
70
|
+
name: 'uq_reason_type_code'
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
})
|
|
74
|
+
};
|