import { Invoice, InvoiceItem, MemberPlan, PaymentMethod, PaymentPeriodicity, PaymentProviderCustomer, PrismaClient, Subscription, SubscriptionDeactivation, SubscriptionDeactivationReason, SubscriptionPeriod, User } from '@prisma/client';
import { PaymentsService } from "../../../../payment-api/src";
import { Action } from '../subscription-event-dictionary/subscription-event-dictionary.type';
export type SubscriptionControllerConfig = {
    subscription: Subscription;
};
interface ChargeStatus {
    action: Action | undefined;
    errorCode: string;
}
export declare class SubscriptionService {
    private readonly prismaService;
    private readonly payments;
    constructor(prismaService: PrismaClient, payments: PaymentsService);
    getSubscriptionsForInvoiceCreation(runDate: Date, closestRenewalDate: Date): Promise<(Subscription & {
        periods: SubscriptionPeriod[];
        deactivation: SubscriptionDeactivation | null;
        user: User;
        paymentMethod: PaymentMethod;
        memberPlan: MemberPlan;
    })[]>;
    /**
     * Get all invoices that are due at the current date or earlier.
     * @param runDate The current date.
     * @returns All invoices that are due.
     */
    getInvoicesToCharge(runDate: Date): Promise<({
        subscription: {
            paymentMethod: import("@prisma/client/runtime/library").GetResult<{
                id: string;
                createdAt: Date;
                modifiedAt: Date;
                name: string;
                slug: string;
                description: string;
                paymentProviderID: string;
                active: boolean;
            }, unknown> & {};
            memberPlan: import("@prisma/client/runtime/library").GetResult<{
                id: string;
                createdAt: Date;
                modifiedAt: Date;
                name: string;
                slug: string;
                tags: string[];
                description: import(".prisma/client").Prisma.JsonValue;
                active: boolean;
                amountPerMonthMin: number;
                imageID: string;
            }, unknown> & {};
            user: {
                paymentProviderCustomers: (import("@prisma/client/runtime/library").GetResult<{
                    id: string;
                    createdAt: Date;
                    modifiedAt: Date;
                    paymentProviderID: string;
                    customerID: string;
                    userId: string;
                }, unknown> & {})[];
            } & import("@prisma/client/runtime/library").GetResult<{
                id: string;
                createdAt: Date;
                modifiedAt: Date;
                email: string;
                emailVerifiedAt: Date;
                name: string;
                firstName: string;
                preferredName: string;
                flair: string;
                password: string;
                active: boolean;
                lastLogin: Date;
                roleIDs: string[];
                userImageID: string;
            }, unknown> & {};
        } & import("@prisma/client/runtime/library").GetResult<{
            id: string;
            createdAt: Date;
            modifiedAt: Date;
            paymentPeriodicity: PaymentPeriodicity;
            monthlyAmount: number;
            autoRenew: boolean;
            startsAt: Date;
            paidUntil: Date;
            paymentMethodID: string;
            memberPlanID: string;
            userID: string;
        }, unknown> & {};
        subscriptionPeriods: (import("@prisma/client/runtime/library").GetResult<{
            id: string;
            createdAt: Date;
            modifiedAt: Date;
            startsAt: Date;
            endsAt: Date;
            paymentPeriodicity: PaymentPeriodicity;
            amount: number;
            invoiceID: string;
            subscriptionId: string;
        }, unknown> & {})[];
        items: (import("@prisma/client/runtime/library").GetResult<{
            id: string;
            createdAt: Date;
            modifiedAt: Date;
            name: string;
            description: string;
            quantity: number;
            amount: number;
            invoiceId: string;
        }, unknown> & {})[];
    } & import("@prisma/client/runtime/library").GetResult<{
        id: string;
        createdAt: Date;
        modifiedAt: Date;
        mail: string;
        dueAt: Date;
        description: string;
        paidAt: Date;
        canceledAt: Date;
        scheduledDeactivationAt: Date;
        manuallySetAsPaidByUserId: string;
        subscriptionID: string;
    }, unknown> & {})[]>;
    /**
     * Find all invoices that should be deactivated at the given date and are unpaid.
     * @param runDate the date to check for.
     * @returns a list of invoices.
     */
    getSubscriptionsToDeactivate(runDate: Date): Promise<({
        subscription: {
            user: import("@prisma/client/runtime/library").GetResult<{
                id: string;
                createdAt: Date;
                modifiedAt: Date;
                email: string;
                emailVerifiedAt: Date;
                name: string;
                firstName: string;
                preferredName: string;
                flair: string;
                password: string;
                active: boolean;
                lastLogin: Date;
                roleIDs: string[];
                userImageID: string;
            }, unknown> & {};
        } & import("@prisma/client/runtime/library").GetResult<{
            id: string;
            createdAt: Date;
            modifiedAt: Date;
            paymentPeriodicity: PaymentPeriodicity;
            monthlyAmount: number;
            autoRenew: boolean;
            startsAt: Date;
            paidUntil: Date;
            paymentMethodID: string;
            memberPlanID: string;
            userID: string;
        }, unknown> & {};
    } & import("@prisma/client/runtime/library").GetResult<{
        id: string;
        createdAt: Date;
        modifiedAt: Date;
        mail: string;
        dueAt: Date;
        description: string;
        paidAt: Date;
        canceledAt: Date;
        scheduledDeactivationAt: Date;
        manuallySetAsPaidByUserId: string;
        subscriptionID: string;
    }, unknown> & {})[]>;
    /**
     * Find all subscriptions that have autorenew false and have a missing deactivation object
     * @param runDate the date to check for
     * @returns a list of subscriptions.
     */
    getExpiredNotAutoRenewSubscriptionsToDeactivate(runDate: Date): Promise<({
        deactivation: import("@prisma/client/runtime/library").GetResult<{
            id: string;
            createdAt: Date;
            modifiedAt: Date;
            date: Date;
            reason: SubscriptionDeactivationReason;
            subscriptionID: string;
        }, unknown> & {};
    } & import("@prisma/client/runtime/library").GetResult<{
        id: string;
        createdAt: Date;
        modifiedAt: Date;
        paymentPeriodicity: PaymentPeriodicity;
        monthlyAmount: number;
        autoRenew: boolean;
        startsAt: Date;
        paidUntil: Date;
        paymentMethodID: string;
        memberPlanID: string;
        userID: string;
    }, unknown> & {})[]>;
    /**
     * Calculates the start and end of the next subscription period. if no active
     * periods are passed, the bounds starting from now are returned.
     * @param periods The currently active periods
     * @param periodicity The duration of the next period
     * @returns Start and end date of the next period
     */
    private getNextPeriod;
    /**
     * Create an invoice for the new runtime of a subscription.
     * @param subscription The subscription to create an invoice for.
     * @param scheduledDeactivation The object containing the deactivation date at the end of the new period.
     * @returns The invoice.
     */
    createInvoice(subscription: Subscription & {
        periods: SubscriptionPeriod[];
        user: User;
        memberPlan: MemberPlan;
    }, scheduledDeactivation: Action): Promise<{
        items: (import("@prisma/client/runtime/library").GetResult<{
            id: string;
            createdAt: Date;
            modifiedAt: Date;
            name: string;
            description: string;
            quantity: number;
            amount: number;
            invoiceId: string;
        }, unknown> & {})[];
    } & import("@prisma/client/runtime/library").GetResult<{
        id: string;
        createdAt: Date;
        modifiedAt: Date;
        mail: string;
        dueAt: Date;
        description: string;
        paidAt: Date;
        canceledAt: Date;
        scheduledDeactivationAt: Date;
        manuallySetAsPaidByUserId: string;
        subscriptionID: string;
    }, unknown> & {}>;
    /**
     * Mark a specific invoice and the corresponding subscription as paid.
     * @param invoice The invoice to mark.
     */
    markInvoiceAsPaid(invoice: Invoice & {
        subscription: Subscription | null;
    }): Promise<void>;
    /**
     * Deactivates the subscription belonging to an invoice.
     * @param invoice the invoice belonging to subscription.
     */
    deactivateSubscription(invoice: Invoice): Promise<void>;
    /**
     * Try to charge the payment provider for a specific invoice. If the provider
     * supports off-session payments, it is charged automatically. If it doesn't
     * support them, the method returns.
     * @param invoice The invoice to charge.
     * @param mailActions The possible mailtemplates to use in case of success/failure.
     * @returns The transaction status.
     */
    chargeInvoice(invoice: Invoice & {
        subscription: (Subscription & {
            paymentMethod: PaymentMethod;
            memberPlan: MemberPlan;
            user: (User & {
                paymentProviderCustomers: PaymentProviderCustomer[];
            }) | null;
        }) | null;
        items: InvoiceItem[];
        subscriptionPeriods: SubscriptionPeriod[];
    }, mailActions: Action[]): Promise<ChargeStatus>;
    /**
     * Try to charge an off session payment. This creates a payment record and marks the
     * invoice as paid if the charge was successful.
     * @param invoice The invoice to charge.
     * @param paymentProvider The payment provider.
     * @param mailActions The possible mails to deliver on successful or failed charge.
     * @returns The transaction status.
     */
    private offSessionPayment;
}
export {};
