33213/backend/src/db/models/financial_reports.js
2025-08-04 07:08:08 +00:00

74 lines
1.5 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 financial_reports = sequelize.define(
'financial_reports',
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
report_date: {
type: DataTypes.DATE,
},
profit: {
type: DataTypes.DECIMAL,
},
loss: {
type: DataTypes.DECIMAL,
},
importHash: {
type: DataTypes.STRING(255),
allowNull: true,
unique: true,
},
},
{
timestamps: true,
paranoid: true,
freezeTableName: true,
},
);
financial_reports.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.financial_reports.belongsTo(db.games, {
as: 'game',
foreignKey: {
name: 'gameId',
},
constraints: false,
});
db.financial_reports.belongsTo(db.organizations, {
as: 'organizations',
foreignKey: {
name: 'organizationsId',
},
constraints: false,
});
db.financial_reports.belongsTo(db.users, {
as: 'createdBy',
});
db.financial_reports.belongsTo(db.users, {
as: 'updatedBy',
});
};
return financial_reports;
};