mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat: auto subscribe to free plan once signup on community version.
This commit is contained in:
@@ -15,13 +15,17 @@ export class Subscription {
|
||||
public async newSubscribtion(
|
||||
tenantId: number,
|
||||
planSlug: string,
|
||||
invoiceInterval: string,
|
||||
invoicePeriod: number,
|
||||
subscriptionSlug: string = 'main'
|
||||
) {
|
||||
const tenant = await Tenant.query().findById(tenantId).throwIfNotFound();
|
||||
const plan = await Plan.query().findOne('slug', planSlug).throwIfNotFound();
|
||||
|
||||
const isFree = plan.price === 0;
|
||||
|
||||
// Take the invoice interval and period from the given plan.
|
||||
const invoiceInterval = plan.invoiceInternal;
|
||||
const invoicePeriod = isFree ? Infinity : plan.invoicePeriod;
|
||||
|
||||
const subscription = await tenant
|
||||
.$relatedQuery('subscriptions')
|
||||
.modify('subscriptionBySlug', subscriptionSlug)
|
||||
|
||||
Reference in New Issue
Block a user