feat: Implement getInvoices graphQL query

This commit is contained in:
Faruk AYDIN
2023-03-26 02:02:36 +03:00
parent bd55b37d5f
commit 1cbf96dff1
6 changed files with 52 additions and 2 deletions

View File

@@ -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();

View 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;