const mongoose = require("mongoose");
const timestamp = require("mongoose-timestamp");
const mongoosePaginate = require("mongoose-paginate-v2");

const modelSchema = new mongoose.Schema({
  price: { type: Number, required: true }, // قیمت نهایی شامل مالیات
  discountAmount: { type: Number, default: 0 }, // مبلغ تخفیف
  taxAmount: { type: Number, default: 0 }, // مبلغ مالیات
  taxRate: { type: Number, default: 9 }, // درصد مالیات
  course_name: { type: String, required: true },
  course_id: { type: mongoose.Schema.Types.ObjectId, ref: "Course", required: true },
  academy_id: { type: mongoose.Schema.Types.ObjectId, ref: "Academy", required: true },
  user_id: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true },
  payment_authority: { type: String },
  payment_ref_id: { type: String },
  status: { type: String, enum: ["pending", "success", "failed", "settled"], default: "success" },

  
});

modelSchema.plugin(timestamp);
modelSchema.plugin(mongoosePaginate);
const PostModel = mongoose.model("AcademyPayment", modelSchema);
module.exports = PostModel;
