73 lines
1.8 KiB
JavaScript
73 lines
1.8 KiB
JavaScript
const { FNF_STATUS } = require('../config/constants');
|
|
|
|
module.exports = (sequelize, DataTypes) => {
|
|
const FnF = sequelize.define('FnF', {
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true
|
|
},
|
|
resignationId: {
|
|
type: DataTypes.UUID,
|
|
allowNull: true,
|
|
references: {
|
|
model: 'resignations',
|
|
key: 'id'
|
|
}
|
|
},
|
|
outletId: {
|
|
type: DataTypes.UUID,
|
|
allowNull: false,
|
|
references: {
|
|
model: 'outlets',
|
|
key: 'id'
|
|
}
|
|
},
|
|
status: {
|
|
type: DataTypes.ENUM(Object.values(FNF_STATUS)),
|
|
defaultValue: FNF_STATUS.INITIATED
|
|
},
|
|
totalReceivables: {
|
|
type: DataTypes.DECIMAL(15, 2),
|
|
defaultValue: 0
|
|
},
|
|
totalPayables: {
|
|
type: DataTypes.DECIMAL(15, 2),
|
|
defaultValue: 0
|
|
},
|
|
netAmount: {
|
|
type: DataTypes.DECIMAL(15, 2),
|
|
defaultValue: 0
|
|
},
|
|
settlementDate: {
|
|
type: DataTypes.DATE,
|
|
allowNull: true
|
|
},
|
|
clearanceDocuments: {
|
|
type: DataTypes.JSON,
|
|
defaultValue: []
|
|
}
|
|
}, {
|
|
tableName: 'fnf_settlements',
|
|
timestamps: true,
|
|
indexes: [
|
|
{ fields: ['resignationId'] },
|
|
{ fields: ['outletId'] },
|
|
{ fields: ['status'] }
|
|
]
|
|
});
|
|
|
|
FnF.associate = (models) => {
|
|
FnF.belongsTo(models.Resignation, {
|
|
foreignKey: 'resignationId',
|
|
as: 'resignation'
|
|
});
|
|
FnF.belongsTo(models.Outlet, {
|
|
foreignKey: 'outletId',
|
|
as: 'outlet'
|
|
});
|
|
};
|
|
|
|
return FnF;
|
|
};
|