Spaces:
Runtime error
Runtime error
import { | |
DataTypes, | |
Model, | |
InferAttributes, | |
InferCreationAttributes, | |
CreationOptional, | |
} from 'sequelize'; | |
import { sequelize } from './index'; | |
import { InvoiceDetailInterface } from '../shared/interfaces/invoiceDetail.interface'; | |
import Invoice from './invoice'; | |
import { fetchGLAccounts } from '../shared/services/propertyware.service'; | |
class InvoiceDetail extends Model<InvoiceDetailInterface> implements InvoiceDetailInterface { | |
declare id?: CreationOptional<number>; | |
declare invoice_id: number; | |
declare pw_portfolio_id?: number; | |
declare pw_building_id?: number; | |
declare pw_unit_id: number; | |
declare pw_gl_account_id: number | null; | |
declare amount: number; | |
declare description?: string; | |
} | |
// Define and initialize the model | |
InvoiceDetail.init( | |
{ | |
id: { | |
type: DataTypes.INTEGER, | |
autoIncrement: true, | |
primaryKey: true, | |
}, | |
invoice_id: { | |
type: DataTypes.INTEGER, | |
allowNull: false, | |
references: { | |
model: Invoice, | |
key: 'id', | |
}, | |
onDelete: 'CASCADE', | |
}, | |
pw_portfolio_id: { | |
type: DataTypes.INTEGER, | |
allowNull: true, | |
}, | |
pw_building_id: { | |
type: DataTypes.INTEGER, | |
allowNull: true, | |
}, | |
pw_unit_id: { | |
type: DataTypes.INTEGER, | |
allowNull: true, | |
}, | |
pw_gl_account_id: { | |
type: DataTypes.INTEGER, | |
allowNull: true, | |
defaultValue: null | |
}, | |
amount: { | |
type: DataTypes.DECIMAL(10, 2), | |
allowNull: false, | |
}, | |
description: { | |
type: DataTypes.TEXT, | |
allowNull: true, | |
}, | |
}, | |
{ | |
sequelize, | |
tableName: 'invoice_details', | |
underscored: true, | |
freezeTableName: true, | |
timestamps: true, | |
createdAt: 'created_at', | |
updatedAt: 'updated_at', | |
} | |
); | |
export default InvoiceDetail; | |