narinder1231 commited on
Commit
6eeb165
·
1 Parent(s): 68a1f99

add model for invoice detail model

Browse files
src/models/invoicedetail.ts ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {
2
+ DataTypes,
3
+ Model,
4
+ InferAttributes,
5
+ InferCreationAttributes,
6
+ CreationOptional,
7
+ } from 'sequelize';
8
+ import { sequelize } from './index';
9
+ import { InvoiceDetailInterface } from '../shared/interfaces/invoiceDetail.interface';
10
+ import Invoice from './invoice';
11
+
12
+ class InvoiceDetail extends Model<InferAttributes<InvoiceDetail>, InferCreationAttributes<InvoiceDetail>> implements InvoiceDetailInterface {
13
+ declare id?: CreationOptional<number>;
14
+ declare invoice_id: number;
15
+ declare pw_portfolio_id?: number;
16
+ declare pw_building_id?: number;
17
+ declare pw_unit_id?: number;
18
+ declare pw_gl_account_id?: number;
19
+ declare amount: number;
20
+ declare description?: string;
21
+
22
+ }
23
+
24
+ InvoiceDetail.init(
25
+ {
26
+ id: {
27
+ type: DataTypes.INTEGER,
28
+ autoIncrement: true,
29
+ primaryKey: true,
30
+ },
31
+ invoice_id: {
32
+ type: DataTypes.INTEGER,
33
+ allowNull: false,
34
+ references: {
35
+ model: Invoice,
36
+ key: 'id',
37
+ },
38
+ onDelete: 'CASCADE',
39
+ },
40
+ pw_portfolio_id: {
41
+ type: DataTypes.INTEGER,
42
+ allowNull: true,
43
+ },
44
+ pw_building_id: {
45
+ type: DataTypes.INTEGER,
46
+ allowNull: true,
47
+ },
48
+ pw_unit_id: {
49
+ type: DataTypes.INTEGER,
50
+ allowNull: true,
51
+ },
52
+ pw_gl_account_id: {
53
+ type: DataTypes.INTEGER,
54
+ allowNull: true,
55
+ defaultValue: null,
56
+ },
57
+ amount: {
58
+ type: DataTypes.DECIMAL(10, 2),
59
+ allowNull: false,
60
+ },
61
+ description: {
62
+ type: DataTypes.TEXT,
63
+ allowNull: true,
64
+ },
65
+ },
66
+ {
67
+ sequelize,
68
+ tableName: 'invoice_details',
69
+ underscored: true,
70
+ freezeTableName: true,
71
+ timestamps: true,
72
+ createdAt: 'created_at',
73
+ updatedAt: 'updated_at',
74
+ }
75
+ );
76
+
77
+ InvoiceDetail.belongsTo(Invoice, { foreignKey: 'invoice_id' });
78
+
79
+ export default InvoiceDetail;
src/shared/interfaces/invoiceDetail.interface.ts ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ export interface InvoiceDetailInterface {
2
+ id?: number;
3
+ invoice_id: number;
4
+ pw_portfolio_id?: number;
5
+ pw_building_id?: number;
6
+ pw_unit_id?: number;
7
+ pw_gl_account_id?: number;
8
+ amount: number;
9
+ description?: string;
10
+ }