import * as Sequelize from 'sequelize';
import { DataTypes, Model, Optional } from 'sequelize';
import type { DebtReminderPolicyTarget, DebtReminderPolicyTargetId } from './DebtReminderPolicyTarget';
export interface DebtReminderPolicyAttributes {
	id: string;
	name: string;
	reminder_type: string;
	days_offset: number;
	send_time: string;
	channels: object;
	status: string;
	created_by?: string | null;
	updated_by?: string | null;
	created_at: Date;
	updated_at: Date;
}
export type DebtReminderPolicyPk = 'id';
export type DebtReminderPolicyId = DebtReminderPolicy[DebtReminderPolicyPk];
export type DebtReminderPolicyOptionalAttributes =
	| 'id'
	| 'status'
	| 'created_by'
	| 'updated_by'
	| 'created_at'
	| 'updated_at';
export type DebtReminderPolicyCreationAttributes = Optional<
	DebtReminderPolicyAttributes,
	DebtReminderPolicyOptionalAttributes
>;
export class DebtReminderPolicy extends Model<DebtReminderPolicyAttributes> implements DebtReminderPolicyAttributes {
	declare id: string;
	declare name: string;
	declare reminder_type: string;
	declare days_offset: number;
	declare send_time: string;
	declare channels: object;
	declare status: string;
	declare created_by?: string | null;
	declare updated_by?: string | null;
	declare created_at: Date;
	declare updated_at: Date;
	// DebtReminderPolicy hasMany DebtReminderPolicyTarget via policy_id
	declare debt_reminder_policy_targets: DebtReminderPolicyTarget[];
	declare getDebt_reminder_policy_targets: Sequelize.HasManyGetAssociationsMixin<DebtReminderPolicyTarget>;
	declare setDebt_reminder_policy_targets: Sequelize.HasManySetAssociationsMixin<
		DebtReminderPolicyTarget,
		DebtReminderPolicyTargetId
	>;
	declare addDebt_reminder_policy_target: Sequelize.HasManyAddAssociationMixin<
		DebtReminderPolicyTarget,
		DebtReminderPolicyTargetId
	>;
	declare addDebt_reminder_policy_targets: Sequelize.HasManyAddAssociationsMixin<
		DebtReminderPolicyTarget,
		DebtReminderPolicyTargetId
	>;
	declare createDebt_reminder_policy_target: Sequelize.HasManyCreateAssociationMixin<DebtReminderPolicyTarget>;
	declare removeDebt_reminder_policy_target: Sequelize.HasManyRemoveAssociationMixin<
		DebtReminderPolicyTarget,
		DebtReminderPolicyTargetId
	>;
	declare removeDebt_reminder_policy_targets: Sequelize.HasManyRemoveAssociationsMixin<
		DebtReminderPolicyTarget,
		DebtReminderPolicyTargetId
	>;
	declare hasDebt_reminder_policy_target: Sequelize.HasManyHasAssociationMixin<
		DebtReminderPolicyTarget,
		DebtReminderPolicyTargetId
	>;
	declare hasDebt_reminder_policy_targets: Sequelize.HasManyHasAssociationsMixin<
		DebtReminderPolicyTarget,
		DebtReminderPolicyTargetId
	>;
	declare countDebt_reminder_policy_targets: Sequelize.HasManyCountAssociationsMixin;
	static initModel(sequelize: Sequelize.Sequelize): typeof DebtReminderPolicy {
		return DebtReminderPolicy.init(
			{
				id: {
					type: DataTypes.UUID,
					allowNull: false,
					defaultValue: DataTypes.UUIDV4,
					primaryKey: true,
				},
				name: {
					type: DataTypes.STRING(255),
					allowNull: false,
				},
				reminder_type: {
					type: DataTypes.STRING(255),
					allowNull: false,
				},
				days_offset: {
					type: DataTypes.INTEGER,
					allowNull: false,
				},
				send_time: {
					type: DataTypes.TIME,
					allowNull: false,
				},
				channels: {
					type: DataTypes.JSONB,
					allowNull: false,
				},
				status: {
					type: DataTypes.STRING(20),
					allowNull: false,
					defaultValue: 'ACTIVE',
				},
				created_by: {
					type: DataTypes.UUID,
					allowNull: true,
				},
				updated_by: {
					type: DataTypes.UUID,
					allowNull: true,
				},
				created_at: {
					type: DataTypes.DATE,
					allowNull: false,
					defaultValue: Sequelize.Sequelize.fn('now'),
				},
				updated_at: {
					type: DataTypes.DATE,
					allowNull: false,
					defaultValue: Sequelize.Sequelize.fn('now'),
				},
			},
			{
				sequelize,
				tableName: 'debt_reminder_policies',
				schema: 'public',
				timestamps: false,
				indexes: [
					{
						name: 'debt_reminder_policies_pkey',
						unique: true,
						fields: [{ name: 'id' }],
					},
					{
						name: 'idx_debt_reminder_policies_created_at',
						fields: [{ name: 'created_at', order: 'DESC' }],
					},
					{
						name: 'idx_debt_reminder_policies_reminder_type',
						fields: [{ name: 'reminder_type' }, { name: 'status' }],
					},
					{
						name: 'idx_debt_reminder_policies_status',
						fields: [{ name: 'status' }],
					},
				],
			},
		);
	}
}
