/* jshint indent: 2 */

module.exports = function (sequelize, DataTypes) {
    return sequelize.define('saasinvoice', {
        id: {
            type: DataTypes.STRING(32),
            allowNull: false,
            primaryKey: true
        },
        saas_id: {
            type: DataTypes.STRING(32),
            allowNull: true
        },
        saas_merchant_id: {
            type: DataTypes.STRING(32),
            allowNull: true,
            defaultValue: ''
        },
        batch_no: {
            type: DataTypes.STRING(32),
            allowNull: true
        },
        owner_type: {
            type: DataTypes.STRING(4),
            allowNull: true,
            defaultValue: '00'
        },
        fee_type: {
            type: DataTypes.STRING(2),
            allowNull: true,
            defaultValue: ''
        },
        invoice_type: {
            type: DataTypes.STRING(4),
            allowNull: true
        },
        province: {
            type: DataTypes.STRING(10),
            allowNull: true
        },
        invoice_join: {
            type: DataTypes.STRING(4),
            allowNull: true
        },
        invoice_no: {
            type: DataTypes.STRING(20),
            allowNull: true
        },
        invoice_number: {
            type: DataTypes.STRING(20),
            allowNull: true
        },
        invoice_time: {
            type: DataTypes.DATE,
            allowNull: true
        },
        invoice_amount: {
            type: DataTypes.BIGINT,
            allowNull: true
        },
        sve_invoice_id: {
            type: DataTypes.STRING(32),
            allowNull: true,
            defaultValue: ''
        },
        apply_no: {
            type: DataTypes.STRING(32),
            allowNull: true
        },
        from_name: {
            type: DataTypes.STRING(45),
            allowNull: false
        },
        from_credit_code: {
            type: DataTypes.STRING(45),
            allowNull: false
        },
        from_addr: {
            type: DataTypes.STRING(45),
            allowNull: false
        },
        from_mobile: {
            type: DataTypes.STRING(45),
            allowNull: false
        },
        from_bank: {
            type: DataTypes.STRING(45),
            allowNull: false
        },
        from_account: {
            type: DataTypes.STRING(45),
            allowNull: false
        },
        to_name: {
            type: DataTypes.STRING(45),
            allowNull: false
        },
        to_credit_code: {
            type: DataTypes.STRING(45),
            allowNull: false
        },
        to_addr: {
            type: DataTypes.STRING(45),
            allowNull: false
        },
        to_mobile: {
            type: DataTypes.STRING(45),
            allowNull: false
        },
        to_bank: {
            type: DataTypes.STRING(45),
            allowNull: false
        },
        to_account: {
            type: DataTypes.STRING(45),
            allowNull: false
        },
        mail_to: {
            type: DataTypes.STRING(45),
            allowNull: true
        },
        mail_mobile: {
            type: DataTypes.STRING(20),
            allowNull: true
        },
        mail_addr: {
            type: DataTypes.STRING(200),
            allowNull: true
        },
        personal_invoice_tax: {
            type: DataTypes.INTEGER(11),
            allowNull: true
        },
        additional_tax: {
            type: DataTypes.BIGINT,
            allowNull: true
        },
        value_added_tax: {
            type: DataTypes.BIGINT,
            allowNull: true
        },
        service_tax: {
            type: DataTypes.BIGINT,
            allowNull: true
        },
        summary: {
            type: DataTypes.TEXT,
            allowNull: true
        },
        created_at: {
            type: DataTypes.DATE,
            allowNull: false,
            defaultValue: DataTypes.NOW
        },
        updated_at: {
            type: DataTypes.DATE,
            allowNull: false,
            defaultValue: DataTypes.NOW
        },
        deleted_at: {
            type: DataTypes.DATE,
            allowNull: true
        }
    }, {
        timestamps: false,
        paranoid: true,
        version: true,
        tableName: 'saas_invoice',
        comment: '发票列表（商户）',
    });
};
