import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
import RegionType from '../type/region.js';

class RegionData extends Model { }

RegionData.init({
    name: {
        type: DataTypes.STRING,
        allowNull: false},
    regionTypeId: {
        type: DataTypes.INTEGER,
        allowNull: false
    },
    parentId: {
        type: DataTypes.INTEGER,
        allowNull: true
    },
    map: {
        type: DataTypes.JSONB,
        allowNull: true,
        defaultValue: {}
    }
    ,
    taxPercent: {
        type: DataTypes.DECIMAL,
        allowNull: false,
        defaultValue: 7,
        field: 'tax_percent'
    }
}, {
    sequelize,
    modelName: 'RegionData',
    tableName: 'region',
    schema: 'falukant_data',
    timestamps: false,
    underscored: true});

export default RegionData;
