"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FeeStructureSchema = exports.FeeStructure = exports.SubFeeSchema = exports.SubFee = void 0;
const mongoose_1 = require("@nestjs/mongoose");
const base_entity_1 = require("../../common/entities/base.entity");
let SubFee = class SubFee {
    name;
    amount;
};
exports.SubFee = SubFee;
__decorate([
    (0, mongoose_1.Prop)({ required: true, trim: true }),
    __metadata("design:type", String)
], SubFee.prototype, "name", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: true, min: 0 }),
    __metadata("design:type", Number)
], SubFee.prototype, "amount", void 0);
exports.SubFee = SubFee = __decorate([
    (0, mongoose_1.Schema)({ _id: false })
], SubFee);
exports.SubFeeSchema = mongoose_1.SchemaFactory.createForClass(SubFee);
let LateFineSlab = class LateFineSlab {
    startDay;
    endDay;
    amount;
};
__decorate([
    (0, mongoose_1.Prop)({ required: true, min: 1 }),
    __metadata("design:type", Number)
], LateFineSlab.prototype, "startDay", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: true, min: 1 }),
    __metadata("design:type", Number)
], LateFineSlab.prototype, "endDay", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: true, min: 0 }),
    __metadata("design:type", Number)
], LateFineSlab.prototype, "amount", void 0);
LateFineSlab = __decorate([
    (0, mongoose_1.Schema)({ _id: false })
], LateFineSlab);
const LateFineSlabSchema = mongoose_1.SchemaFactory.createForClass(LateFineSlab);
let LateFineRule = class LateFineRule {
    enabled;
    type;
    amountPerDay;
    percentage;
    slabs;
};
__decorate([
    (0, mongoose_1.Prop)({ default: false }),
    __metadata("design:type", Boolean)
], LateFineRule.prototype, "enabled", void 0);
__decorate([
    (0, mongoose_1.Prop)({ enum: ['percentage', 'per_day', 'day_wise_slab'], default: 'per_day' }),
    __metadata("design:type", String)
], LateFineRule.prototype, "type", void 0);
__decorate([
    (0, mongoose_1.Prop)({ default: 0, min: 0 }),
    __metadata("design:type", Number)
], LateFineRule.prototype, "amountPerDay", void 0);
__decorate([
    (0, mongoose_1.Prop)({ default: 0, min: 0 }),
    __metadata("design:type", Number)
], LateFineRule.prototype, "percentage", void 0);
__decorate([
    (0, mongoose_1.Prop)({ type: [LateFineSlabSchema], default: [] }),
    __metadata("design:type", Array)
], LateFineRule.prototype, "slabs", void 0);
LateFineRule = __decorate([
    (0, mongoose_1.Schema)({ _id: false })
], LateFineRule);
const LateFineRuleSchema = mongoose_1.SchemaFactory.createForClass(LateFineRule);
let FeeStructure = class FeeStructure extends base_entity_1.BaseEntity {
    name;
    feeType;
    academicYearId;
    amount;
    classIds;
    dueMonth;
    dueDay;
    startDate;
    endDate;
    enableSubFees;
    subFees;
    lateFine;
    isActive;
};
exports.FeeStructure = FeeStructure;
__decorate([
    (0, mongoose_1.Prop)({ required: true, trim: true }),
    __metadata("design:type", String)
], FeeStructure.prototype, "name", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: true, enum: ['one-time', 'monthly', 'quarterly', 'yearly'], default: 'one-time' }),
    __metadata("design:type", String)
], FeeStructure.prototype, "feeType", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: true }),
    __metadata("design:type", String)
], FeeStructure.prototype, "academicYearId", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: true, min: 1 }),
    __metadata("design:type", Number)
], FeeStructure.prototype, "amount", void 0);
__decorate([
    (0, mongoose_1.Prop)({ type: [String], required: true }),
    __metadata("design:type", Array)
], FeeStructure.prototype, "classIds", void 0);
__decorate([
    (0, mongoose_1.Prop)({ min: 1, max: 12, default: 1 }),
    __metadata("design:type", Number)
], FeeStructure.prototype, "dueMonth", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: true, min: 1, max: 31 }),
    __metadata("design:type", Number)
], FeeStructure.prototype, "dueDay", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: false }),
    __metadata("design:type", Date)
], FeeStructure.prototype, "startDate", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: false }),
    __metadata("design:type", Date)
], FeeStructure.prototype, "endDate", void 0);
__decorate([
    (0, mongoose_1.Prop)({ default: false }),
    __metadata("design:type", Boolean)
], FeeStructure.prototype, "enableSubFees", void 0);
__decorate([
    (0, mongoose_1.Prop)({ type: [exports.SubFeeSchema], default: [] }),
    __metadata("design:type", Array)
], FeeStructure.prototype, "subFees", void 0);
__decorate([
    (0, mongoose_1.Prop)({ type: LateFineRuleSchema, default: () => ({ enabled: false, type: 'per_day', amountPerDay: 0, percentage: 0, slabs: [] }) }),
    __metadata("design:type", LateFineRule)
], FeeStructure.prototype, "lateFine", void 0);
__decorate([
    (0, mongoose_1.Prop)({ default: true }),
    __metadata("design:type", Boolean)
], FeeStructure.prototype, "isActive", void 0);
exports.FeeStructure = FeeStructure = __decorate([
    (0, mongoose_1.Schema)({ timestamps: true })
], FeeStructure);
exports.FeeStructureSchema = mongoose_1.SchemaFactory.createForClass(FeeStructure);
exports.FeeStructureSchema.index({ academicYearId: 1, classIds: 1 });
exports.FeeStructureSchema.index({ isActive: 1 });
exports.FeeStructureSchema.set('toJSON', { versionKey: false });
exports.FeeStructureSchema.set('toObject', { versionKey: false });
//# sourceMappingURL=fee-structure.schema.js.map