mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-02-21 22:11:37 +01:00
chore: changes
This commit is contained in:
parent
c7008111ba
commit
396b61c4a0
2 changed files with 15 additions and 7 deletions
|
@ -1,15 +1,13 @@
|
|||
import { GraphQLObjectType, GraphQLString } from 'graphql';
|
||||
import { GraphQLObjectType, GraphQLString, GraphQLInt } from 'graphql';
|
||||
|
||||
export const InOutType = new GraphQLObjectType({
|
||||
name: 'InOutType',
|
||||
fields: () => {
|
||||
return {
|
||||
invoices: {
|
||||
type: GraphQLString,
|
||||
},
|
||||
payments: {
|
||||
type: GraphQLString,
|
||||
},
|
||||
invoices: { type: GraphQLString },
|
||||
payments: { type: GraphQLString },
|
||||
confirmedInvoices: { type: GraphQLInt },
|
||||
unConfirmedInvoices: { type: GraphQLInt },
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
|
@ -90,6 +90,14 @@ export const getInOut = {
|
|||
return payment.isConfirmed && dif < periods;
|
||||
});
|
||||
|
||||
const allInvoices = invoices.filter(invoice => {
|
||||
const dif = differenceFn(endDate, new Date(invoice.createdAt));
|
||||
return dif < periods;
|
||||
});
|
||||
|
||||
const totalConfirmed = confirmedInvoices.length;
|
||||
const totalUnConfirmed = allInvoices.length - totalConfirmed;
|
||||
|
||||
const orderedInvoices = groupBy(confirmedInvoices, invoice => {
|
||||
return periods - differenceFn(endDate, new Date(invoice.createdAt));
|
||||
});
|
||||
|
@ -103,6 +111,8 @@ export const getInOut = {
|
|||
return {
|
||||
invoices: JSON.stringify(reducedInvoices),
|
||||
payments: JSON.stringify(reducedPayments),
|
||||
confirmedInvoices: totalConfirmed,
|
||||
unConfirmedInvoices: totalUnConfirmed,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue