enhancv/mongoose-subscriptions

View on GitHub
src/Schema/Coupon/Amount.js

Summary

Maintainability
A
0 mins
Test Coverage
const mongoose = require("mongoose");

const Schema = mongoose.Schema;

const CouponAmount = new Schema({
    amount: {
        type: Number,
        required: true,
    },
});

CouponAmount.methods.currentAmount = function currentAmount(subscription) {
    return Math.min(subscription.plan.price, this.amount);
};

module.exports = CouponAmount;