"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.FeeAssignmentSchema = exports.FeeAssignment = void 0;
const mongoose_1 = require("@nestjs/mongoose");
const base_entity_1 = require("../../common/entities/base.entity");
const fee_structure_schema_1 = require("./fee-structure.schema");
let FeeAssignment = class FeeAssignment extends base_entity_1.BaseEntity {
    studentId;
    feeStructureId;
    academicYearId;
    classId;
    feeName;
    installment;
    amount;
    baseAmount;
    subFees;
    fineAmount;
    paidAmount;
    dueDate;
    status;
    discountType;
    discountValue;
    discountAmount;
    discountReason;
    discountValidUntil;
    discountAppliedBy;
    paidAt;
    paymentMethod;
    receiptNumber;
    razorpayOrderId;
    razorpayPaymentId;
    razorpaySignature;
    razorpayOrderAmount;
    collectedBy;
    notes;
    transactionId;
};
exports.FeeAssignment = FeeAssignment;
__decorate([
    (0, mongoose_1.Prop)({ required: true }),
    __metadata("design:type", String)
], FeeAssignment.prototype, "studentId", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: true }),
    __metadata("design:type", String)
], FeeAssignment.prototype, "feeStructureId", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: true }),
    __metadata("design:type", String)
], FeeAssignment.prototype, "academicYearId", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: true }),
    __metadata("design:type", String)
], FeeAssignment.prototype, "classId", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: true, trim: true }),
    __metadata("design:type", String)
], FeeAssignment.prototype, "feeName", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: true, trim: true }),
    __metadata("design:type", String)
], FeeAssignment.prototype, "installment", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: true, min: 0 }),
    __metadata("design:type", Number)
], FeeAssignment.prototype, "amount", void 0);
__decorate([
    (0, mongoose_1.Prop)({ default: 0, min: 0 }),
    __metadata("design:type", Number)
], FeeAssignment.prototype, "baseAmount", void 0);
__decorate([
    (0, mongoose_1.Prop)({ type: [fee_structure_schema_1.SubFeeSchema], default: [] }),
    __metadata("design:type", Array)
], FeeAssignment.prototype, "subFees", void 0);
__decorate([
    (0, mongoose_1.Prop)({ default: 0, min: 0 }),
    __metadata("design:type", Number)
], FeeAssignment.prototype, "fineAmount", void 0);
__decorate([
    (0, mongoose_1.Prop)({ default: 0, min: 0 }),
    __metadata("design:type", Number)
], FeeAssignment.prototype, "paidAmount", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: true }),
    __metadata("design:type", Date)
], FeeAssignment.prototype, "dueDate", void 0);
__decorate([
    (0, mongoose_1.Prop)({ required: true, enum: ['pending', 'partial', 'paid'], default: 'pending' }),
    __metadata("design:type", String)
], FeeAssignment.prototype, "status", void 0);
__decorate([
    (0, mongoose_1.Prop)({ enum: ['amount', 'percentage'] }),
    __metadata("design:type", String)
], FeeAssignment.prototype, "discountType", void 0);
__decorate([
    (0, mongoose_1.Prop)({ min: 0 }),
    __metadata("design:type", Number)
], FeeAssignment.prototype, "discountValue", void 0);
__decorate([
    (0, mongoose_1.Prop)({ default: 0, min: 0 }),
    __metadata("design:type", Number)
], FeeAssignment.prototype, "discountAmount", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true, maxlength: 500 }),
    __metadata("design:type", String)
], FeeAssignment.prototype, "discountReason", void 0);
__decorate([
    (0, mongoose_1.Prop)(),
    __metadata("design:type", Date)
], FeeAssignment.prototype, "discountValidUntil", void 0);
__decorate([
    (0, mongoose_1.Prop)(),
    __metadata("design:type", String)
], FeeAssignment.prototype, "discountAppliedBy", void 0);
__decorate([
    (0, mongoose_1.Prop)(),
    __metadata("design:type", Date)
], FeeAssignment.prototype, "paidAt", void 0);
__decorate([
    (0, mongoose_1.Prop)({ enum: ['razorpay', 'cash', 'cheque', 'bank_transfer', 'upi', 'online'] }),
    __metadata("design:type", String)
], FeeAssignment.prototype, "paymentMethod", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], FeeAssignment.prototype, "receiptNumber", void 0);
__decorate([
    (0, mongoose_1.Prop)(),
    __metadata("design:type", String)
], FeeAssignment.prototype, "razorpayOrderId", void 0);
__decorate([
    (0, mongoose_1.Prop)(),
    __metadata("design:type", String)
], FeeAssignment.prototype, "razorpayPaymentId", void 0);
__decorate([
    (0, mongoose_1.Prop)(),
    __metadata("design:type", String)
], FeeAssignment.prototype, "razorpaySignature", void 0);
__decorate([
    (0, mongoose_1.Prop)({ min: 0 }),
    __metadata("design:type", Number)
], FeeAssignment.prototype, "razorpayOrderAmount", void 0);
__decorate([
    (0, mongoose_1.Prop)(),
    __metadata("design:type", String)
], FeeAssignment.prototype, "collectedBy", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true }),
    __metadata("design:type", String)
], FeeAssignment.prototype, "notes", void 0);
__decorate([
    (0, mongoose_1.Prop)({ trim: true, maxlength: 200 }),
    __metadata("design:type", String)
], FeeAssignment.prototype, "transactionId", void 0);
exports.FeeAssignment = FeeAssignment = __decorate([
    (0, mongoose_1.Schema)({ timestamps: true })
], FeeAssignment);
exports.FeeAssignmentSchema = mongoose_1.SchemaFactory.createForClass(FeeAssignment);
exports.FeeAssignmentSchema.index({ studentId: 1, academicYearId: 1 });
exports.FeeAssignmentSchema.index({ feeStructureId: 1 });
exports.FeeAssignmentSchema.index({ academicYearId: 1, classId: 1, status: 1 });
exports.FeeAssignmentSchema.index({ status: 1, dueDate: 1 });
exports.FeeAssignmentSchema.index({ razorpayOrderId: 1 }, { unique: true, sparse: true });
exports.FeeAssignmentSchema.index({ receiptNumber: 1 }, { unique: true, sparse: true });
exports.FeeAssignmentSchema.index({ studentId: 1, feeStructureId: 1, installment: 1 }, { unique: true });
exports.FeeAssignmentSchema.set('toJSON', { versionKey: false });
exports.FeeAssignmentSchema.set('toObject', { versionKey: false });
//# sourceMappingURL=fee-assignment.schema.js.map