234 lines
2.7 KiB
JavaScript
234 lines
2.7 KiB
JavaScript
const config = require('../../config');
|
|
const providers = config.providers;
|
|
const crypto = require('crypto');
|
|
const bcrypt = require('bcrypt');
|
|
const moment = require('moment');
|
|
|
|
module.exports = function(sequelize, DataTypes) {
|
|
const identity_verifications = sequelize.define(
|
|
'identity_verifications',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
verification_type: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"ktp",
|
|
|
|
|
|
"npwp",
|
|
|
|
|
|
"business_legal",
|
|
|
|
|
|
"face_biometric",
|
|
|
|
|
|
"education_credential",
|
|
|
|
|
|
"employment_credential",
|
|
|
|
|
|
"address_proof"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
status: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"submitted",
|
|
|
|
|
|
"in_review",
|
|
|
|
|
|
"approved",
|
|
|
|
|
|
"rejected",
|
|
|
|
|
|
"expired"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
submitted_at: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
reviewed_at: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
expires_at: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
document_number: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
match_confidence: {
|
|
type: DataTypes.DECIMAL,
|
|
|
|
|
|
|
|
},
|
|
|
|
review_notes: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
identity_verifications.associate = (db) => {
|
|
|
|
|
|
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//end loop
|
|
|
|
|
|
|
|
db.identity_verifications.belongsTo(db.users, {
|
|
as: 'user',
|
|
foreignKey: {
|
|
name: 'userId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.identity_verifications.belongsTo(db.organizations, {
|
|
as: 'organizations',
|
|
foreignKey: {
|
|
name: 'organizationsId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
db.identity_verifications.hasMany(db.file, {
|
|
as: 'document_files',
|
|
foreignKey: 'belongsToId',
|
|
constraints: false,
|
|
scope: {
|
|
belongsTo: db.identity_verifications.getTableName(),
|
|
belongsToColumn: 'document_files',
|
|
},
|
|
});
|
|
|
|
db.identity_verifications.hasMany(db.file, {
|
|
as: 'selfie_images',
|
|
foreignKey: 'belongsToId',
|
|
constraints: false,
|
|
scope: {
|
|
belongsTo: db.identity_verifications.getTableName(),
|
|
belongsToColumn: 'selfie_images',
|
|
},
|
|
});
|
|
|
|
|
|
db.identity_verifications.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.identity_verifications.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
|
|
|
|
return identity_verifications;
|
|
};
|
|
|
|
|