feat: Implement getInvoices graphQL query
This commit is contained in:
@@ -59,7 +59,7 @@ const getBillingAndUsage = async (
|
||||
.andWhere(
|
||||
'created_at',
|
||||
'>=',
|
||||
DateTime.now().minus({ days: 30 }).toFormat('D')
|
||||
DateTime.now().minus({ days: 30 }).toISODate()
|
||||
)
|
||||
.count()
|
||||
.first();
|
||||
|
17
packages/backend/src/graphql/queries/get-invoices.ee.ts
Normal file
17
packages/backend/src/graphql/queries/get-invoices.ee.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import Context from '../../types/express/context';
|
||||
import Billing from '../../helpers/billing/index.ee';
|
||||
|
||||
const getInvoices = async (
|
||||
_parent: unknown,
|
||||
_params: unknown,
|
||||
context: Context
|
||||
) => {
|
||||
const subscription = await context.currentUser.$relatedQuery('subscription');
|
||||
const invoices = await Billing.paddleClient.getInvoices(
|
||||
Number(subscription.paddleSubscriptionId)
|
||||
);
|
||||
|
||||
return invoices;
|
||||
};
|
||||
|
||||
export default getInvoices;
|
@@ -15,6 +15,7 @@ import getUsageData from './queries/get-usage-data.ee';
|
||||
import getPaymentPlans from './queries/get-payment-plans.ee';
|
||||
import getPaddleInfo from './queries/get-paddle-info.ee';
|
||||
import getBillingAndUsage from './queries/get-billing-and-usage.ee';
|
||||
import getInvoices from './queries/get-invoices.ee';
|
||||
import getAutomatischInfo from './queries/get-automatisch-info';
|
||||
import healthcheck from './queries/healthcheck';
|
||||
|
||||
@@ -36,6 +37,7 @@ const queryResolvers = {
|
||||
getPaymentPlans,
|
||||
getPaddleInfo,
|
||||
getBillingAndUsage,
|
||||
getInvoices,
|
||||
getAutomatischInfo,
|
||||
healthcheck,
|
||||
};
|
||||
|
@@ -38,6 +38,7 @@ type Query {
|
||||
getPaymentPlans: [PaymentPlan]
|
||||
getPaddleInfo: GetPaddleInfo
|
||||
getBillingAndUsage: GetBillingAndUsage
|
||||
getInvoices: [Invoice]
|
||||
getAutomatischInfo: GetAutomatischInfo
|
||||
healthcheck: AppHealth
|
||||
}
|
||||
@@ -504,6 +505,14 @@ type GetPaddleInfo {
|
||||
vendorId: Int
|
||||
}
|
||||
|
||||
type Invoice {
|
||||
id: Int
|
||||
amount: Float
|
||||
currency: String
|
||||
payout_date: String
|
||||
receipt_url: String
|
||||
}
|
||||
|
||||
type PaymentPlan {
|
||||
name: String
|
||||
limit: String
|
||||
|
Reference in New Issue
Block a user