38712-vm/backend/src/db/models/checklist_items.js
2026-02-23 13:46:29 +00:00

155 lines
1.8 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 checklist_items = sequelize.define(
'checklist_items',
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
step: {
type: DataTypes.ENUM,
values: [
"start_steuerjahr",
"haushalt_personen",
"einkommen",
"werbungskosten",
"sonderausgaben",
"aussergewoehnliche_belastungen",
"haushaltsnahe_dienstleistungen_handwerker",
"belege_zuordnung",
"pruefen_optimieren",
"export_zusammenfassung"
],
},
title: {
type: DataTypes.TEXT,
},
is_done: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
},
priority: {
type: DataTypes.ENUM,
values: [
"low",
"medium",
"high"
],
},
importHash: {
type: DataTypes.STRING(255),
allowNull: true,
unique: true,
},
},
{
timestamps: true,
paranoid: true,
freezeTableName: true,
},
);
checklist_items.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.checklist_items.belongsTo(db.tax_profiles, {
as: 'tax_profile',
foreignKey: {
name: 'tax_profileId',
},
constraints: false,
});
db.checklist_items.belongsTo(db.users, {
as: 'createdBy',
});
db.checklist_items.belongsTo(db.users, {
as: 'updatedBy',
});
};
return checklist_items;
};