'use strict';
const {
  Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
  class invoicedetails extends Model {
    /**
     * Helper method for defining associations.
     * This method is not a part of Sequelize lifecycle.
     * The `models/index` file will call this method automatically.
     */
    static associate(models) {
      // define association here
      invoicedetails.belongsTo(models.invoice, { foreignKey: 'inv_id', as: 'invoice' });
    }
  }
  invoicedetails.init({
    inv_id: {
      primaryKey: true,
      type: DataTypes.STRING,
      onUpdate: 'CASCADE',
      onDelete: 'CASCADE',
      references: {
        model: 'invoices',
        key: 'inv_id'
      }
    },
    inv_date: DataTypes.DATE,
    inv_duedate: DataTypes.DATE,
    client_name: DataTypes.STRING,
    client_address: DataTypes.STRING,
    sub_total: DataTypes.STRING,
    ppn: DataTypes.STRING,
    credit: DataTypes.STRING,
    total: DataTypes.STRING
  }, {
    sequelize,
    modelName: 'invoicedetails',
  });
  return invoicedetails;
};