diff --git a/package.json b/package.json index fbddbcd5..aa89d83c 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "dev": "nodemon --exec babel-node -- src/server", "git:clean": "./scripts/git_clean.sh", "graphql:update": "npm-run-all graphql:updateV1 graphql:updateV2", + "graphql:update:local": "cp ../frontend/lib/graphql/*.graphql src/graphql/ && prettier src/graphql/*.graphql --write", "graphql:updateV1": "curl https://raw.githubusercontent.com/opencollective/opencollective-frontend/main/lib/graphql/schema.graphql --output src/graphql/schema.graphql && prettier src/graphql/schema.graphql --write", "graphql:updateV2": "curl https://raw.githubusercontent.com/opencollective/opencollective-frontend/main/lib/graphql/schemaV2.graphql --output src/graphql/schemaV2.graphql && prettier src/graphql/schemaV2.graphql --write", "lint": "eslint \"src/**/*.js\" \"test/**/*.js\"", diff --git a/src/graphql/schemaV2.graphql b/src/graphql/schemaV2.graphql index 0c3cccf7..bc04f6ba 100644 --- a/src/graphql/schemaV2.graphql +++ b/src/graphql/schemaV2.graphql @@ -275,6 +275,16 @@ interface Account { Get pending member invitations for this account """ memberInvitations(role: [MemberRole]): [MemberInvitation] + + """ + The legal documents associated with this account + """ + legalDocuments( + """ + Filter by type + """ + type: [LegalDocumentType] + ): [LegalDocument] memberOf( limit: Int! = 100 offset: Int! = 0 @@ -332,6 +342,16 @@ interface Account { """ paymentMethodType: [PaymentMethodType] + """ + The payment method services. + """ + paymentMethodService: [PaymentMethodService] + + """ + Reference of the account(s) assigned to the main side of the transaction you want to EXCLUDE from the results + """ + excludeAccount: [AccountReferenceInput] + """ Reference of the account assigned to the other side of the transaction (CREDIT -> sender, DEBIT -> recipient). Avoid, favor account instead. """ @@ -450,13 +470,23 @@ interface Account { """ The transactions group to filter by """ - group: String + group: [String] virtualCard: [VirtualCardReferenceInput] """ Only return transactions that are refunds (or not refunds if false) """ isRefund: Boolean + + """ + Only return transactions that are associated with these external merchant IDs + """ + merchantId: [String] + + """ + Only return transactions that are associated with these accounting categories + """ + accountingCategory: [String] ): TransactionCollection! orders( """ @@ -582,6 +612,7 @@ interface Account { Use this field to filter expenses on their type (RECEIPT/INVOICE) """ type: ExpenseType + types: [ExpenseType] """ Only expenses that match these tags @@ -1839,6 +1870,16 @@ type Host implements Account & AccountWithContributions { """ role: [MemberRole] ): [MemberInvitation] + + """ + The legal documents associated with this account + """ + legalDocuments( + """ + Filter by type + """ + type: [LegalDocumentType] + ): [LegalDocument] memberOf( limit: Int! = 150 offset: Int! = 0 @@ -1912,6 +1953,16 @@ type Host implements Account & AccountWithContributions { """ paymentMethodType: [PaymentMethodType] + """ + The payment method services. + """ + paymentMethodService: [PaymentMethodService] + + """ + Reference of the account(s) assigned to the main side of the transaction you want to EXCLUDE from the results + """ + excludeAccount: [AccountReferenceInput] + """ Reference of the account assigned to the other side of the transaction (CREDIT -> sender, DEBIT -> recipient). Avoid, favor account instead. """ @@ -2030,13 +2081,23 @@ type Host implements Account & AccountWithContributions { """ The transactions group to filter by """ - group: String + group: [String] virtualCard: [VirtualCardReferenceInput] """ Only return transactions that are refunds (or not refunds if false) """ isRefund: Boolean + + """ + Only return transactions that are associated with these external merchant IDs + """ + merchantId: [String] + + """ + Only return transactions that are associated with these accounting categories + """ + accountingCategory: [String] ): TransactionCollection! orders( """ @@ -2162,6 +2223,7 @@ type Host implements Account & AccountWithContributions { Use this field to filter expenses on their type (RECEIPT/INVOICE) """ type: ExpenseType + types: [ExpenseType] """ Only expenses that match these tags @@ -2468,6 +2530,16 @@ type Host implements Account & AccountWithContributions { platformContributionAvailable: Boolean! contributionPolicy: String + """ + Returns true if the remote user can start the process to resume contributions for account + """ + canStartResumeContributionsProcess: Boolean! + + """ + Returns true if the account has started the process to resume contributions + """ + hasResumeContributionsProcessStarted: Boolean! + """ List of accounting categories for this host """ @@ -2483,6 +2555,7 @@ type Host implements Account & AccountWithContributions { isOpenToApplications: Boolean termsUrl: URL plan: HostPlan! + hostTransactionsReports(timeUnit: TimeUnit = MONTH, dateFrom: DateTime, dateTo: DateTime): HostTransactionReports transactionsReport(dateFrom: DateTime, dateTo: DateTime): [TransactionSum] hostMetrics( """ @@ -2864,6 +2937,16 @@ interface AccountWithContributions { """ platformContributionAvailable: Boolean! contributionPolicy: String + + """ + Returns true if the remote user can start the process to resume contributions for account + """ + canStartResumeContributionsProcess: Boolean! + + """ + Returns true if the account has started the process to resume contributions + """ + hasResumeContributionsProcessStarted: Boolean! } """ @@ -2976,6 +3059,84 @@ input AccountReferenceInput { slug: String } +""" +A legal document (e.g. W9, W8BEN, W8BEN-E) +""" +type LegalDocument { + """ + Unique identifier for this legal document + """ + id: String! + + """ + The year this legal document is for + """ + year: Int! + + """ + The type of legal document + """ + type: LegalDocumentType! + + """ + The status of the request for this legal document + """ + status: LegalDocumentRequestStatus! + + """ + The service that provided this legal document + """ + service: LegalDocumentService! + + """ + The date and time the request for this legal document was created + """ + requestedAt: DateTime! + + """ + The date and time this legal document was last updated + """ + updatedAt: DateTime! + + """ + The account this legal document is for + """ + account: Account! + + """ + URL to download the file. Must be logged in as an account admin. The returned URL will be protected by authentication + 2FA. + """ + documentLink: URL +} + +""" +Type for a required legal document +""" +enum LegalDocumentType { + """ + US tax form (W9, W8BEN, W8BEN-E) + """ + US_TAX_FORM +} + +""" +Status for a legal document +""" +enum LegalDocumentRequestStatus { + NOT_REQUESTED + REQUESTED + RECEIVED + ERROR +} + +""" +Type for a required legal document +""" +enum LegalDocumentService { + DROPBOX_FORMS + OPENCOLLECTIVE +} + """ A collection of "MemberOf" (ie: Collective backed by an Organization) """ @@ -3104,6 +3265,15 @@ enum PaymentMethodType { VIRTUAL_CARD } +enum PaymentMethodService { + PAYPAL + STRIPE + OPENCOLLECTIVE + PREPAID + THEGIVINGBLOCK + WISE +} + input ExpenseReferenceInput { """ The public id identifying the expense (ie: dgm9bnk8-0437xqry-ejpvzeol-jdayw5re) @@ -4213,15 +4383,6 @@ type PaymentMethod { ): OrderCollection } -enum PaymentMethodService { - PAYPAL - STRIPE - OPENCOLLECTIVE - PREPAID - THEGIVINGBLOCK - WISE -} - enum PaymentMethodLegacyType { ALIPAY CREDIT_CARD @@ -4860,6 +5021,7 @@ enum TimeUnit { DAY WEEK MONTH + QUARTER YEAR } @@ -5352,6 +5514,7 @@ enum ActivityType { COLLECTIVE_EXPENSE_RECURRING_DRAFTED COLLECTIVE_EXPENSE_MISSING_RECEIPT TAXFORM_REQUEST + TAXFORM_RECEIVED COLLECTIVE_VIRTUAL_CARD_ADDED COLLECTIVE_VIRTUAL_CARD_MISSING_RECEIPTS COLLECTIVE_VIRTUAL_CARD_RESUMED @@ -5379,6 +5542,8 @@ enum ActivityType { SUBSCRIPTION_ACTIVATED SUBSCRIPTION_CANCELED SUBSCRIPTION_PAUSED + SUBSCRIPTION_RESUMED + SUBSCRIPTION_READY_TO_BE_RESUMED TICKET_CONFIRMED ORDER_CANCELED_ARCHIVED_COLLECTIVE ORDER_PENDING @@ -5562,6 +5727,60 @@ type HostPlan { platformTips: Boolean } +""" +EXPERIMENTAL (this may change or be deleted): Host transaction report +""" +type HostTransactionReports { + """ + The start date of the time series + """ + dateFrom: DateTime + + """ + The end date of the time series + """ + dateTo: DateTime + + """ + The interval between two data points + """ + timeUnit: TimeUnit! + nodes: [HostTransactionReportNode!] +} + +type HostTransactionReportNode { + date: DateTime! + managedFunds: TransactionsReport! + operationalFunds: TransactionsReport! +} + +""" +Transactions report +""" +type TransactionsReport { + startingBalance: Amount! + endingBalance: Amount! + totalChange: Amount! + groups: [TransactionsAmountGroup]! +} + +""" +EXPERIMENTAL (this may change or be deleted): Transaction amounts grouped by type, kind, isRefund, isHost, expenseType +""" +type TransactionsAmountGroup { + netAmount: Amount + amount: Amount + platformFee: Amount + paymentProcessorFee: Amount + hostFee: Amount + taxAmount: Amount + type: TransactionType + kind: TransactionKind + isRefund: Boolean + isHost: Boolean + expenseType: ExpenseType +} + """ EXPERIMENTAL (this may change or be deleted): Transaction amounts grouped by type, kind, isRefund, isHost, expenseType """ @@ -6222,16 +6441,6 @@ type ExpensePermissions { release: Permission! } -""" -Type for a required legal document -""" -enum LegalDocumentType { - """ - US tax form (W9) - """ - US_TAX_FORM -} - """ Fields for an expense quote """ @@ -6435,6 +6644,11 @@ type OrderPermissions { Whether the current user can update the accounting category of this order """ canUpdateAccountingCategory: Boolean! + + """ + If paused, whether the current user can resume this order + """ + canResume: Boolean! } """ @@ -6635,6 +6849,16 @@ type Bot implements Account { """ role: [MemberRole] ): [MemberInvitation] + + """ + The legal documents associated with this account + """ + legalDocuments( + """ + Filter by type + """ + type: [LegalDocumentType] + ): [LegalDocument] memberOf( limit: Int! = 150 offset: Int! = 0 @@ -6708,6 +6932,16 @@ type Bot implements Account { """ paymentMethodType: [PaymentMethodType] + """ + The payment method services. + """ + paymentMethodService: [PaymentMethodService] + + """ + Reference of the account(s) assigned to the main side of the transaction you want to EXCLUDE from the results + """ + excludeAccount: [AccountReferenceInput] + """ Reference of the account assigned to the other side of the transaction (CREDIT -> sender, DEBIT -> recipient). Avoid, favor account instead. """ @@ -6826,13 +7060,23 @@ type Bot implements Account { """ The transactions group to filter by """ - group: String + group: [String] virtualCard: [VirtualCardReferenceInput] """ Only return transactions that are refunds (or not refunds if false) """ isRefund: Boolean + + """ + Only return transactions that are associated with these external merchant IDs + """ + merchantId: [String] + + """ + Only return transactions that are associated with these accounting categories + """ + accountingCategory: [String] ): TransactionCollection! orders( """ @@ -6958,6 +7202,7 @@ type Bot implements Account { Use this field to filter expenses on their type (RECEIPT/INVOICE) """ type: ExpenseType + types: [ExpenseType] """ Only expenses that match these tags @@ -7334,6 +7579,16 @@ type Collective implements Account & AccountWithHost & AccountWithContributions """ role: [MemberRole] ): [MemberInvitation] + + """ + The legal documents associated with this account + """ + legalDocuments( + """ + Filter by type + """ + type: [LegalDocumentType] + ): [LegalDocument] memberOf( limit: Int! = 150 offset: Int! = 0 @@ -7407,6 +7662,16 @@ type Collective implements Account & AccountWithHost & AccountWithContributions """ paymentMethodType: [PaymentMethodType] + """ + The payment method services. + """ + paymentMethodService: [PaymentMethodService] + + """ + Reference of the account(s) assigned to the main side of the transaction you want to EXCLUDE from the results + """ + excludeAccount: [AccountReferenceInput] + """ Reference of the account assigned to the other side of the transaction (CREDIT -> sender, DEBIT -> recipient). Avoid, favor account instead. """ @@ -7525,13 +7790,23 @@ type Collective implements Account & AccountWithHost & AccountWithContributions """ The transactions group to filter by """ - group: String + group: [String] virtualCard: [VirtualCardReferenceInput] """ Only return transactions that are refunds (or not refunds if false) """ isRefund: Boolean + + """ + Only return transactions that are associated with these external merchant IDs + """ + merchantId: [String] + + """ + Only return transactions that are associated with these accounting categories + """ + accountingCategory: [String] ): TransactionCollection! orders( """ @@ -7657,6 +7932,7 @@ type Collective implements Account & AccountWithHost & AccountWithContributions Use this field to filter expenses on their type (RECEIPT/INVOICE) """ type: ExpenseType + types: [ExpenseType] """ Only expenses that match these tags @@ -8002,6 +8278,16 @@ type Collective implements Account & AccountWithHost & AccountWithContributions """ platformContributionAvailable: Boolean! contributionPolicy: String + + """ + Returns true if the remote user can start the process to resume contributions for account + """ + canStartResumeContributionsProcess: Boolean! + + """ + Returns true if the account has started the process to resume contributions + """ + hasResumeContributionsProcessStarted: Boolean! } """ @@ -8196,7 +8482,7 @@ type Credit implements Transaction { ): [Transaction]! """ - Merchant id related to the Transaction (Stripe, PayPal, Wise, Privacy) + Merchant ID related to the Transaction (Stripe, PayPal, Wise, Privacy) """ merchantId: String balanceInHostCurrency: Amount @@ -8340,7 +8626,7 @@ type Debit implements Transaction { ): [Transaction]! """ - Merchant id related to the Transaction (Stripe, PayPal, Wise, Privacy) + Merchant ID related to the Transaction (Stripe, PayPal, Wise, Privacy) """ merchantId: String balanceInHostCurrency: Amount @@ -8464,6 +8750,16 @@ type Event implements Account & AccountWithHost & AccountWithContributions & Acc """ role: [MemberRole] ): [MemberInvitation] + + """ + The legal documents associated with this account + """ + legalDocuments( + """ + Filter by type + """ + type: [LegalDocumentType] + ): [LegalDocument] memberOf( limit: Int! = 150 offset: Int! = 0 @@ -8537,6 +8833,16 @@ type Event implements Account & AccountWithHost & AccountWithContributions & Acc """ paymentMethodType: [PaymentMethodType] + """ + The payment method services. + """ + paymentMethodService: [PaymentMethodService] + + """ + Reference of the account(s) assigned to the main side of the transaction you want to EXCLUDE from the results + """ + excludeAccount: [AccountReferenceInput] + """ Reference of the account assigned to the other side of the transaction (CREDIT -> sender, DEBIT -> recipient). Avoid, favor account instead. """ @@ -8655,13 +8961,23 @@ type Event implements Account & AccountWithHost & AccountWithContributions & Acc """ The transactions group to filter by """ - group: String + group: [String] virtualCard: [VirtualCardReferenceInput] """ Only return transactions that are refunds (or not refunds if false) """ isRefund: Boolean + + """ + Only return transactions that are associated with these external merchant IDs + """ + merchantId: [String] + + """ + Only return transactions that are associated with these accounting categories + """ + accountingCategory: [String] ): TransactionCollection! orders( """ @@ -8787,6 +9103,7 @@ type Event implements Account & AccountWithHost & AccountWithContributions & Acc Use this field to filter expenses on their type (RECEIPT/INVOICE) """ type: ExpenseType + types: [ExpenseType] """ Only expenses that match these tags @@ -9133,6 +9450,16 @@ type Event implements Account & AccountWithHost & AccountWithContributions & Acc platformContributionAvailable: Boolean! contributionPolicy: String + """ + Returns true if the remote user can start the process to resume contributions for account + """ + canStartResumeContributionsProcess: Boolean! + + """ + Returns true if the account has started the process to resume contributions + """ + hasResumeContributionsProcessStarted: Boolean! + """ The Account parenting this account """ @@ -9383,6 +9710,16 @@ type Individual implements Account { """ role: [MemberRole] ): [MemberInvitation] + + """ + The legal documents associated with this account + """ + legalDocuments( + """ + Filter by type + """ + type: [LegalDocumentType] + ): [LegalDocument] memberOf( limit: Int! = 150 offset: Int! = 0 @@ -9456,6 +9793,16 @@ type Individual implements Account { """ paymentMethodType: [PaymentMethodType] + """ + The payment method services. + """ + paymentMethodService: [PaymentMethodService] + + """ + Reference of the account(s) assigned to the main side of the transaction you want to EXCLUDE from the results + """ + excludeAccount: [AccountReferenceInput] + """ Reference of the account assigned to the other side of the transaction (CREDIT -> sender, DEBIT -> recipient). Avoid, favor account instead. """ @@ -9574,13 +9921,23 @@ type Individual implements Account { """ The transactions group to filter by """ - group: String + group: [String] virtualCard: [VirtualCardReferenceInput] """ Only return transactions that are refunds (or not refunds if false) """ isRefund: Boolean + + """ + Only return transactions that are associated with these external merchant IDs + """ + merchantId: [String] + + """ + Only return transactions that are associated with these accounting categories + """ + accountingCategory: [String] ): TransactionCollection! orders( """ @@ -9706,6 +10063,7 @@ type Individual implements Account { Use this field to filter expenses on their type (RECEIPT/INVOICE) """ type: ExpenseType + types: [ExpenseType] """ Only expenses that match these tags @@ -10288,6 +10646,16 @@ type Organization implements Account & AccountWithContributions { """ role: [MemberRole] ): [MemberInvitation] + + """ + The legal documents associated with this account + """ + legalDocuments( + """ + Filter by type + """ + type: [LegalDocumentType] + ): [LegalDocument] memberOf( limit: Int! = 150 offset: Int! = 0 @@ -10361,6 +10729,16 @@ type Organization implements Account & AccountWithContributions { """ paymentMethodType: [PaymentMethodType] + """ + The payment method services. + """ + paymentMethodService: [PaymentMethodService] + + """ + Reference of the account(s) assigned to the main side of the transaction you want to EXCLUDE from the results + """ + excludeAccount: [AccountReferenceInput] + """ Reference of the account assigned to the other side of the transaction (CREDIT -> sender, DEBIT -> recipient). Avoid, favor account instead. """ @@ -10479,13 +10857,23 @@ type Organization implements Account & AccountWithContributions { """ The transactions group to filter by """ - group: String + group: [String] virtualCard: [VirtualCardReferenceInput] """ Only return transactions that are refunds (or not refunds if false) """ isRefund: Boolean + + """ + Only return transactions that are associated with these external merchant IDs + """ + merchantId: [String] + + """ + Only return transactions that are associated with these accounting categories + """ + accountingCategory: [String] ): TransactionCollection! orders( """ @@ -10611,6 +10999,7 @@ type Organization implements Account & AccountWithContributions { Use this field to filter expenses on their type (RECEIPT/INVOICE) """ type: ExpenseType + types: [ExpenseType] """ Only expenses that match these tags @@ -10914,6 +11303,16 @@ type Organization implements Account & AccountWithContributions { """ platformContributionAvailable: Boolean! contributionPolicy: String + + """ + Returns true if the remote user can start the process to resume contributions for account + """ + canStartResumeContributionsProcess: Boolean! + + """ + Returns true if the account has started the process to resume contributions + """ + hasResumeContributionsProcessStarted: Boolean! email: String @deprecated(reason: "2022-07-18: This field is deprecated and will return null") """ @@ -11077,6 +11476,16 @@ type Vendor implements Account & AccountWithContributions { """ role: [MemberRole] ): [MemberInvitation] + + """ + The legal documents associated with this account + """ + legalDocuments( + """ + Filter by type + """ + type: [LegalDocumentType] + ): [LegalDocument] memberOf( limit: Int! = 150 offset: Int! = 0 @@ -11150,6 +11559,16 @@ type Vendor implements Account & AccountWithContributions { """ paymentMethodType: [PaymentMethodType] + """ + The payment method services. + """ + paymentMethodService: [PaymentMethodService] + + """ + Reference of the account(s) assigned to the main side of the transaction you want to EXCLUDE from the results + """ + excludeAccount: [AccountReferenceInput] + """ Reference of the account assigned to the other side of the transaction (CREDIT -> sender, DEBIT -> recipient). Avoid, favor account instead. """ @@ -11268,13 +11687,23 @@ type Vendor implements Account & AccountWithContributions { """ The transactions group to filter by """ - group: String + group: [String] virtualCard: [VirtualCardReferenceInput] """ Only return transactions that are refunds (or not refunds if false) """ isRefund: Boolean + + """ + Only return transactions that are associated with these external merchant IDs + """ + merchantId: [String] + + """ + Only return transactions that are associated with these accounting categories + """ + accountingCategory: [String] ): TransactionCollection! orders( """ @@ -11400,6 +11829,7 @@ type Vendor implements Account & AccountWithContributions { Use this field to filter expenses on their type (RECEIPT/INVOICE) """ type: ExpenseType + types: [ExpenseType] """ Only expenses that match these tags @@ -11705,6 +12135,16 @@ type Vendor implements Account & AccountWithContributions { """ platformContributionAvailable: Boolean! contributionPolicy: String + + """ + Returns true if the remote user can start the process to resume contributions for account + """ + canStartResumeContributionsProcess: Boolean! + + """ + Returns true if the account has started the process to resume contributions + """ + hasResumeContributionsProcessStarted: Boolean! vendorInfo: VendorInfo """ @@ -11855,6 +12295,11 @@ type Query { """ includeArchived: Boolean + """ + Ignore individual accounts used to make contributions as guests + """ + skipGuests: Boolean = true + """ Only return "active" accounts with Financial Contributions enabled if true. """ @@ -11875,6 +12320,11 @@ type Query { """ host: [AccountReferenceInput] + """ + Parent Collective hosting the account + """ + parent: [AccountReferenceInput] + """ Only return accounts that match these account types (COLLECTIVE, FUND, EVENT, PROJECT, ORGANIZATION or INDIVIDUAL) """ @@ -12081,6 +12531,7 @@ type Query { Use this field to filter expenses on their type (RECEIPT/INVOICE) """ type: ExpenseType + types: [ExpenseType] """ Only expenses that match these tags @@ -12238,6 +12689,11 @@ type Query { """ includeArchived: Boolean + """ + Ignore individual accounts used to make contributions as guests + """ + skipGuests: Boolean = true + """ Only return "active" accounts with Financial Contributions enabled if true. """ @@ -12500,6 +12956,16 @@ type Query { """ paymentMethodType: [PaymentMethodType] + """ + The payment method services. + """ + paymentMethodService: [PaymentMethodService] + + """ + Reference of the account(s) assigned to the main side of the transaction you want to EXCLUDE from the results + """ + excludeAccount: [AccountReferenceInput] + """ Reference of the account assigned to the other side of the transaction (CREDIT -> sender, DEBIT -> recipient). Avoid, favor account instead. """ @@ -12618,13 +13084,23 @@ type Query { """ The transactions group to filter by """ - group: String + group: [String] virtualCard: [VirtualCardReferenceInput] """ Only return transactions that are refunds (or not refunds if false) """ isRefund: Boolean + + """ + Only return transactions that are associated with these external merchant IDs + """ + merchantId: [String] + + """ + Only return transactions that are associated with these accounting categories + """ + accountingCategory: [String] ): TransactionCollection! update( """ @@ -12680,6 +13156,11 @@ type Query { amount: AmountInput! frequency: ContributionFrequency! + """ + The order for which the plan is created, if any + """ + order: OrderReferenceInput + """ The tier you are contributing to """ @@ -14030,6 +14511,7 @@ enum ActivityAndClassesType { COLLECTIVE_EXPENSE_RECURRING_DRAFTED COLLECTIVE_EXPENSE_MISSING_RECEIPT TAXFORM_REQUEST + TAXFORM_RECEIVED COLLECTIVE_VIRTUAL_CARD_ADDED COLLECTIVE_VIRTUAL_CARD_MISSING_RECEIPTS COLLECTIVE_VIRTUAL_CARD_RESUMED @@ -14057,6 +14539,8 @@ enum ActivityAndClassesType { SUBSCRIPTION_ACTIVATED SUBSCRIPTION_CANCELED SUBSCRIPTION_PAUSED + SUBSCRIPTION_RESUMED + SUBSCRIPTION_READY_TO_BE_RESUMED TICKET_CONFIRMED ORDER_CANCELED_ARCHIVED_COLLECTIVE ORDER_PENDING @@ -14263,6 +14747,16 @@ type Fund implements Account & AccountWithHost & AccountWithContributions { """ role: [MemberRole] ): [MemberInvitation] + + """ + The legal documents associated with this account + """ + legalDocuments( + """ + Filter by type + """ + type: [LegalDocumentType] + ): [LegalDocument] memberOf( limit: Int! = 150 offset: Int! = 0 @@ -14336,6 +14830,16 @@ type Fund implements Account & AccountWithHost & AccountWithContributions { """ paymentMethodType: [PaymentMethodType] + """ + The payment method services. + """ + paymentMethodService: [PaymentMethodService] + + """ + Reference of the account(s) assigned to the main side of the transaction you want to EXCLUDE from the results + """ + excludeAccount: [AccountReferenceInput] + """ Reference of the account assigned to the other side of the transaction (CREDIT -> sender, DEBIT -> recipient). Avoid, favor account instead. """ @@ -14454,13 +14958,23 @@ type Fund implements Account & AccountWithHost & AccountWithContributions { """ The transactions group to filter by """ - group: String + group: [String] virtualCard: [VirtualCardReferenceInput] """ Only return transactions that are refunds (or not refunds if false) """ isRefund: Boolean + + """ + Only return transactions that are associated with these external merchant IDs + """ + merchantId: [String] + + """ + Only return transactions that are associated with these accounting categories + """ + accountingCategory: [String] ): TransactionCollection! orders( """ @@ -14586,6 +15100,7 @@ type Fund implements Account & AccountWithHost & AccountWithContributions { Use this field to filter expenses on their type (RECEIPT/INVOICE) """ type: ExpenseType + types: [ExpenseType] """ Only expenses that match these tags @@ -14931,6 +15446,16 @@ type Fund implements Account & AccountWithHost & AccountWithContributions { """ platformContributionAvailable: Boolean! contributionPolicy: String + + """ + Returns true if the remote user can start the process to resume contributions for account + """ + canStartResumeContributionsProcess: Boolean! + + """ + Returns true if the account has started the process to resume contributions + """ + hasResumeContributionsProcessStarted: Boolean! } """ @@ -15060,6 +15585,16 @@ type Project implements Account & AccountWithHost & AccountWithContributions & A """ role: [MemberRole] ): [MemberInvitation] + + """ + The legal documents associated with this account + """ + legalDocuments( + """ + Filter by type + """ + type: [LegalDocumentType] + ): [LegalDocument] memberOf( limit: Int! = 150 offset: Int! = 0 @@ -15133,6 +15668,16 @@ type Project implements Account & AccountWithHost & AccountWithContributions & A """ paymentMethodType: [PaymentMethodType] + """ + The payment method services. + """ + paymentMethodService: [PaymentMethodService] + + """ + Reference of the account(s) assigned to the main side of the transaction you want to EXCLUDE from the results + """ + excludeAccount: [AccountReferenceInput] + """ Reference of the account assigned to the other side of the transaction (CREDIT -> sender, DEBIT -> recipient). Avoid, favor account instead. """ @@ -15251,13 +15796,23 @@ type Project implements Account & AccountWithHost & AccountWithContributions & A """ The transactions group to filter by """ - group: String + group: [String] virtualCard: [VirtualCardReferenceInput] """ Only return transactions that are refunds (or not refunds if false) """ isRefund: Boolean + + """ + Only return transactions that are associated with these external merchant IDs + """ + merchantId: [String] + + """ + Only return transactions that are associated with these accounting categories + """ + accountingCategory: [String] ): TransactionCollection! orders( """ @@ -15383,6 +15938,7 @@ type Project implements Account & AccountWithHost & AccountWithContributions & A Use this field to filter expenses on their type (RECEIPT/INVOICE) """ type: ExpenseType + types: [ExpenseType] """ Only expenses that match these tags @@ -15729,6 +16285,16 @@ type Project implements Account & AccountWithHost & AccountWithContributions & A platformContributionAvailable: Boolean! contributionPolicy: String + """ + Returns true if the remote user can start the process to resume contributions for account + """ + canStartResumeContributionsProcess: Boolean! + + """ + Returns true if the account has started the process to resume contributions + """ + hasResumeContributionsProcessStarted: Boolean! + """ The Account parenting this account """ @@ -16539,6 +17105,26 @@ type Mutation { currentPassword: String ): SetPasswordResponse! + """ + Submit a legal document + """ + submitLegalDocument( + """ + The account the legal document is for + """ + account: AccountReferenceInput! + + """ + The type of legal document + """ + type: LegalDocumentType! + + """ + The form data for the legal document. Will be validated against the schema for the document type and encrypted. + """ + formData: JSON! + ): LegalDocument! + """ Invite a new member to the Collective. Scope: "account". """ @@ -16840,6 +17426,21 @@ type Mutation { """ editPendingOrder(order: PendingOrderEditInput!): Order! + """ + Starts or resumes the process of notifying contributors for their PAUSED contributions + """ + startResumeOrdersProcess( + """ + The account to start/resume the process for + """ + account: AccountReferenceInput! + + """ + An optional message to send to contributors + """ + message: String + ): Account! + """ Add a new payment method to be used with an Order. Scope: "orders". """ @@ -18711,6 +19312,7 @@ Implemented Captcha Providers enum CaptchaProvider { HCAPTCHA RECAPTCHA + TURNSTILE } """ diff --git a/src/server/controllers/account-transactions.js b/src/server/controllers/account-transactions.js index 81d63f1f..ad4faf61 100644 --- a/src/server/controllers/account-transactions.js +++ b/src/server/controllers/account-transactions.js @@ -12,6 +12,9 @@ function json2csv(data, opts) { return parser.parse(data); } +const splitIds = (str) => str?.split(',').map(trim); +const splitEnums = (str) => splitIds(str).map(toUpper); + export const transactionsFragment = gqlV2/* GraphQL */ ` fragment TransactionsFragment on TransactionCollection { __typename @@ -160,56 +163,66 @@ export const transactionsFragment = gqlV2/* GraphQL */ ` const transactionsQuery = gqlV2/* GraphQL */ ` query AccountTransactions( - $slug: String - $limit: Int - $offset: Int - $type: TransactionType - $kind: [TransactionKind] - $dateFrom: DateTime - $dateTo: DateTime + $accountingCategory: [String] $clearedFrom: DateTime $clearedTo: DateTime - $minAmount: Int - $maxAmount: Int - $searchTerm: String - $includeIncognitoTransactions: Boolean - $includeChildrenTransactions: Boolean - $includeGiftCardTransactions: Boolean - $includeRegularTransactions: Boolean + $dateFrom: DateTime + $dateTo: DateTime + $excludeAccount: [AccountReferenceInput!] + $expense: ExpenseReferenceInput + $expenseType: [ExpenseType] $fetchHostFee: Boolean $fetchPaymentProcessorFee: Boolean $fetchTax: Boolean $fullDescription: Boolean + $group: [String] $hasAccountingCategoryField: Boolean! - $paymentMethodType: [PaymentMethodType] - $expenseType: [ExpenseType] - $expense: ExpenseReferenceInput - $order: OrderReferenceInput + $includeChildrenTransactions: Boolean + $includeGiftCardTransactions: Boolean + $includeIncognitoTransactions: Boolean + $includeRegularTransactions: Boolean $isRefund: Boolean + $kind: [TransactionKind] + $limit: Int + $maxAmount: Int + $merchantId: [String] + $minAmount: Int + $offset: Int + $order: OrderReferenceInput + $paymentMethodService: [PaymentMethodService] + $paymentMethodType: [PaymentMethodType] + $searchTerm: String + $slug: String + $type: TransactionType ) { transactions( - includeDebts: true account: { slug: $slug } - limit: $limit - offset: $offset - type: $type - kind: $kind - dateFrom: $dateFrom - dateTo: $dateTo + accountingCategory: $accountingCategory clearedFrom: $clearedFrom clearedTo: $clearedTo - minAmount: $minAmount - maxAmount: $maxAmount - searchTerm: $searchTerm - includeIncognitoTransactions: $includeIncognitoTransactions + dateFrom: $dateFrom + dateTo: $dateTo + excludeAccount: $excludeAccount + expense: $expense + expenseType: $expenseType + group: $group includeChildrenTransactions: $includeChildrenTransactions + includeDebts: true includeGiftCardTransactions: $includeGiftCardTransactions + includeIncognitoTransactions: $includeIncognitoTransactions includeRegularTransactions: $includeRegularTransactions - paymentMethodType: $paymentMethodType - expenseType: $expenseType - expense: $expense - order: $order isRefund: $isRefund + kind: $kind + limit: $limit + maxAmount: $maxAmount + merchantId: $merchantId + minAmount: $minAmount + offset: $offset + order: $order + paymentMethodService: $paymentMethodService + paymentMethodType: $paymentMethodType + searchTerm: $searchTerm + type: $type ) { ...TransactionsFragment } @@ -219,54 +232,64 @@ const transactionsQuery = gqlV2/* GraphQL */ ` const hostTransactionsQuery = gqlV2/* GraphQL */ ` query HostTransactions( - $slug: String - $limit: Int - $offset: Int - $type: TransactionType - $kind: [TransactionKind] - $dateFrom: DateTime - $dateTo: DateTime + $account: [AccountReferenceInput!] + $accountingCategory: [String] $clearedFrom: DateTime $clearedTo: DateTime - $minAmount: Int - $maxAmount: Int - $searchTerm: String - $includeChildrenTransactions: Boolean - $includeHost: Boolean + $dateFrom: DateTime + $dateTo: DateTime + $excludeAccount: [AccountReferenceInput!] + $expense: ExpenseReferenceInput + $expenseType: [ExpenseType] $fetchHostFee: Boolean $fetchPaymentProcessorFee: Boolean $fetchTax: Boolean $fullDescription: Boolean - $account: [AccountReferenceInput!] + $group: [String] $hasAccountingCategoryField: Boolean! - $paymentMethodType: [PaymentMethodType] - $expenseType: [ExpenseType] - $expense: ExpenseReferenceInput - $order: OrderReferenceInput + $includeChildrenTransactions: Boolean + $includeHost: Boolean $isRefund: Boolean + $kind: [TransactionKind] + $limit: Int + $maxAmount: Int + $merchantId: [String] + $minAmount: Int + $offset: Int + $order: OrderReferenceInput + $paymentMethodService: [PaymentMethodService] + $paymentMethodType: [PaymentMethodType] + $searchTerm: String + $slug: String + $type: TransactionType ) { transactions( - includeDebts: true - host: { slug: $slug } account: $account - limit: $limit - offset: $offset - type: $type - kind: $kind - dateFrom: $dateFrom - dateTo: $dateTo + accountingCategory: $accountingCategory clearedFrom: $clearedFrom clearedTo: $clearedTo - minAmount: $minAmount - maxAmount: $maxAmount - searchTerm: $searchTerm + dateFrom: $dateFrom + dateTo: $dateTo + excludeAccount: $excludeAccount + expense: $expense + expenseType: $expenseType + group: $group + host: { slug: $slug } includeChildrenTransactions: $includeChildrenTransactions + includeDebts: true includeHost: $includeHost - paymentMethodType: $paymentMethodType - expenseType: $expenseType - expense: $expense - order: $order isRefund: $isRefund + kind: $kind + limit: $limit + maxAmount: $maxAmount + merchantId: $merchantId + minAmount: $minAmount + offset: $offset + order: $order + paymentMethodService: $paymentMethodService + paymentMethodType: $paymentMethodType + searchTerm: $searchTerm + type: $type ) { ...TransactionsFragment } @@ -446,26 +469,31 @@ const accountTransactions = async (req, res) => { const variables = pick({ ...req.params, ...req.query }, [ 'account', - 'slug', - 'limit', - 'offset', - 'type', - 'kind', + 'accountingCategory', 'dateFrom', 'dateTo', - 'minAmount', - 'maxAmount', - 'paymentMethodType', - 'searchTerm', - 'includeIncognitoTransactions', + 'excludeAccount', + 'expenseId', + 'expenseType', + 'group', 'includeChildrenTransactions', 'includeGiftCardTransactions', - 'includeRegularTransactions', 'includeHost', - 'expenseType', - 'expenseId', - 'orderId', + 'includeIncognitoTransactions', + 'includeRegularTransactions', 'isRefund', + 'kind', + 'limit', + 'maxAmount', + 'merchantId', + 'minAmount', + 'offset', + 'orderId', + 'paymentMethodService', + 'paymentMethodType', + 'searchTerm', + 'slug', + 'type', ]); variables.limit = // If HEAD, we only want count, so we set limit to 0 @@ -480,6 +508,9 @@ const accountTransactions = async (req, res) => { if (variables.account) { variables.account = variables.account.split(',').map((slug) => ({ slug })); } + if (variables.excludeAccount) { + variables.excludeAccount = variables.excludeAccount.split(',').map((slug) => ({ slug })); + } if (variables.dateFrom) { variables.dateFrom = moment.utc(variables.dateFrom).toISOString(); @@ -523,11 +554,23 @@ const accountTransactions = async (req, res) => { } if (variables.kind) { - variables.kind = variables.kind.split(',').map(toUpper).map(trim); + variables.kind = splitEnums(variables.kind); + } + if (variables.paymentMethodService) { + variables.paymentMethodService = splitEnums(variables.paymentMethodService); } - if (variables.paymentMethodType) { - variables.paymentMethodType = variables.paymentMethodType.split(',').map(toUpper).map(trim); + variables.paymentMethodType = splitEnums(variables.paymentMethodType); + } + + if (variables.group) { + variables.group = splitIds(variables.group); + } + if (variables.merchantId) { + variables.merchantId = splitIds(variables.merchantId); + } + if (variables.accountingCategory) { + variables.accountingCategory = splitIds(variables.accountingCategory); } if (variables.includeIncognitoTransactions) { @@ -566,7 +609,7 @@ const accountTransactions = async (req, res) => { } if (variables.expenseType) { - variables.expenseType = variables.expenseType.split(',').map(toUpper).map(trim); + variables.expenseType = splitEnums(variables.expenseType); } if (variables.orderId) {