File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed
Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -108,4 +108,7 @@ export default {
108108
109109 // mails
110110 minMailingAddressLength : 10 ,
111+
112+ // payment plan
113+ internalPaymentPlanName : "Internal Payment Plan" ,
111114} as const ;
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import constants from "@config/constants";
1313import { checkPermission } from "@courselit/utils" ;
1414import PaymentPlanModel from "@models/PaymentPlan" ;
1515import { getPaymentMethodFromSettings } from "@/payments-new" ;
16+ import { Domain } from "@models/Domain" ;
1617const { MembershipEntityType : membershipEntityType } = Constants ;
1718const { permissions } = constants ;
1819
@@ -65,6 +66,7 @@ export async function getPlans({
6566 domain : ctx . subdomain . _id ,
6667 planId : { $in : planIds } ,
6768 archived : false ,
69+ internal : false ,
6870 } ) . lean ( ) ;
6971}
7072
@@ -258,3 +260,16 @@ export async function getInternalPaymentPlan(ctx: any) {
258260 internal : true ,
259261 } ) ;
260262}
263+
264+ export async function createInternalPaymentPlan (
265+ domain : Domain ,
266+ userId : string ,
267+ ) {
268+ return await PaymentPlanModel . create ( {
269+ domain : domain . _id ,
270+ name : constants . internalPaymentPlanName ,
271+ type : Constants . PaymentPlanType . FREE ,
272+ internal : true ,
273+ userId : userId ,
274+ } ) ;
275+ }
Original file line number Diff line number Diff line change @@ -34,7 +34,10 @@ import { addMailJob } from "@/services/queue";
3434import { getPaymentMethodFromSettings } from "@/payments-new" ;
3535import { checkForInvalidPermissions } from "@/lib/check-invalid-permissions" ;
3636import { activateMembership } from "@/app/api/payment/helpers" ;
37- import { getInternalPaymentPlan } from "../paymentplans/logic" ;
37+ import {
38+ createInternalPaymentPlan ,
39+ getInternalPaymentPlan ,
40+ } from "../paymentplans/logic" ;
3841import {
3942 convertFiltersToDBConditions ,
4043 InternalMembership ,
@@ -374,6 +377,7 @@ export async function createUser({
374377 if ( isNewUser ) {
375378 if ( superAdmin ) {
376379 await initMandatoryPages ( domain , createdUser ) ;
380+ await createInternalPaymentPlan ( domain , createdUser . userId ) ;
377381 }
378382
379383 await recordActivity ( {
You can’t perform that action at this time.
0 commit comments