211 lines
2.6 KiB
JavaScript
211 lines
2.6 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 pto_journal_entries = sequelize.define(
|
|
'pto_journal_entries',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
entry_type: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"debit_time_off",
|
|
|
|
|
|
"credit_accrual",
|
|
|
|
|
|
"credit_time_in_lieu",
|
|
|
|
|
|
"credit_manual_adjustment",
|
|
|
|
|
|
"debit_manual_adjustment"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
leave_bucket: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"regular_pto",
|
|
|
|
|
|
"medical_leave",
|
|
|
|
|
|
"bereavement",
|
|
|
|
|
|
"vacation_pay"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
effective_at: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
calendar_year: {
|
|
type: DataTypes.INTEGER,
|
|
|
|
|
|
|
|
},
|
|
|
|
amount_hours: {
|
|
type: DataTypes.DECIMAL,
|
|
|
|
|
|
|
|
},
|
|
|
|
amount_days: {
|
|
type: DataTypes.DECIMAL,
|
|
|
|
|
|
|
|
},
|
|
|
|
counts_against_balance: {
|
|
type: DataTypes.BOOLEAN,
|
|
|
|
allowNull: false,
|
|
defaultValue: false,
|
|
|
|
|
|
|
|
},
|
|
|
|
posting_status: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"pending",
|
|
|
|
|
|
"posted",
|
|
|
|
|
|
"reversed"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
memo: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
entered_at: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
pto_journal_entries.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.pto_journal_entries.belongsTo(db.users, {
|
|
as: 'user',
|
|
foreignKey: {
|
|
name: 'userId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.pto_journal_entries.belongsTo(db.time_off_requests, {
|
|
as: 'source_request',
|
|
foreignKey: {
|
|
name: 'source_requestId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.pto_journal_entries.belongsTo(db.users, {
|
|
as: 'entered_by',
|
|
foreignKey: {
|
|
name: 'entered_byId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
|
|
db.pto_journal_entries.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.pto_journal_entries.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
|
|
|
|
return pto_journal_entries;
|
|
};
|
|
|
|
|