%PDF- %PDF-
Direktori : /home/opti/workflow/src/models/ |
Current File : /home/opti/workflow/src/models/payment.js |
'use strict'; module.exports = (sequelize, DataTypes) => { const Payment = sequelize.define('Payment', { uuid: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4 }, paymentTypeId: DataTypes.INTEGER, invoiceId: DataTypes.INTEGER, orgId: DataTypes.INTEGER, partyFromId: DataTypes.INTEGER, partyToId: DataTypes.INTEGER, referenceNumber: DataTypes.STRING, paymentMethodId: DataTypes.INTEGER, number: DataTypes.INTEGER, // PaymentMethodTypeId: DataTypes.INTEGER, paymentDate: DataTypes.DATE, // paymentRefNum: DataTypes.STRING, amount: DataTypes.DECIMAL, currencyId: DataTypes.INTEGER, comment: DataTypes.TEXT }, {}); Payment.associate = function(models) { // associations can be defined here Payment.belongsTo(models.PaymentType, {foreignKey: 'paymentTypeId', targetKey: 'id', as: 'paymentType'}); Payment.belongsTo(models.Organization, {foreignKey: 'orgId', targetKey: 'id', as: 'organisation'}); Payment.hasMany(models.PaymentHistory, {foreignKey: 'id', sourceKey: 'id', as: 'paymentHistories'}); // Payment.belongsTo(models.PaymentStatus, {foreignKey: 'statusId', targetKey: 'id', as: 'paymentStatus'}); Payment.belongsTo(models.Contact, {foreignKey: 'partyFromId', targetKey: 'id', as: 'contactFrom'}); Payment.belongsTo(models.Contact, {foreignKey: 'partyToId', targetKey: 'id', as: 'contactTo'}); Payment.belongsTo(models.PaymentMethod, {foreignKey: 'paymentMethodId', targetKey: 'id', as: 'paymentMethod'}); Payment.belongsTo(models.Invoice, {foreignKey: 'invoiceId', targetKey: 'id', as: 'invoice'}); }; return Payment; };