-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReport.js
More file actions
86 lines (83 loc) · 1.84 KB
/
Copy pathReport.js
File metadata and controls
86 lines (83 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
* Report model for storing generated financial reports
*/
const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const Report = sequelize.define('Report', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
userId: {
type: DataTypes.UUID,
allowNull: false,
references: {
model: 'Users',
key: 'id'
}
},
tenantId: {
type: DataTypes.UUID,
allowNull: false,
references: {
model: 'XeroTenants',
key: 'id'
}
},
name: {
type: DataTypes.STRING,
allowNull: false
},
description: {
type: DataTypes.TEXT,
allowNull: true
},
type: {
type: DataTypes.ENUM('PROFIT_LOSS', 'BALANCE_SHEET', 'CASH_FLOW', 'AGED_RECEIVABLES', 'AGED_PAYABLES', 'BUDGET_VARIANCE', 'CUSTOM'),
allowNull: false
},
parameters: {
type: DataTypes.JSON,
allowNull: true,
comment: 'JSON object with report parameters like date range, filters, etc.'
},
data: {
type: DataTypes.JSON,
allowNull: true,
comment: 'JSON object with the actual report data'
},
format: {
type: DataTypes.ENUM('JSON', 'PDF', 'CSV', 'XLSX'),
defaultValue: 'JSON',
allowNull: false
},
filePath: {
type: DataTypes.STRING,
allowNull: true,
comment: 'Path to the report file if stored as a file'
},
isScheduled: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
scheduleConfig: {
type: DataTypes.JSON,
allowNull: true,
comment: 'JSON object with schedule configuration'
},
lastGeneratedAt: {
type: DataTypes.DATE,
allowNull: true
},
status: {
type: DataTypes.ENUM('PENDING', 'GENERATING', 'COMPLETED', 'FAILED'),
defaultValue: 'PENDING',
allowNull: false
},
error: {
type: DataTypes.TEXT,
allowNull: true
}
});
module.exports = Report;