Skip to content

Commit

Permalink
Fix(account-transactions): Include new GraphQL args in query
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavlrsn committed Apr 8, 2024
1 parent aeb06a2 commit 8f6386b
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions src/server/controllers/account-transactions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Parser } from '@json2csv/plainjs';
import gqlV2 from 'graphql-tag';
import { difference, get, head, intersection, isNil, pick, toUpper, trim } from 'lodash';
import { difference, get, head, intersection, pick, toUpper, trim } from 'lodash';
import moment from 'moment';

import { graphqlRequest } from '../lib/graphql';
Expand Down Expand Up @@ -206,6 +206,10 @@ const transactionsQuery = gqlV2/* GraphQL */ `
includeGiftCardTransactions: $includeGiftCardTransactions
includeRegularTransactions: $includeRegularTransactions
paymentMethodType: $paymentMethodType
expenseType: $expenseType
expense: $expense
order: $order
isRefund: $isRefund
) {
...TransactionsFragment
}
Expand Down Expand Up @@ -259,6 +263,10 @@ const hostTransactionsQuery = gqlV2/* GraphQL */ `
includeChildrenTransactions: $includeChildrenTransactions
includeHost: $includeHost
paymentMethodType: $paymentMethodType
expenseType: $expenseType
expense: $expense
order: $order
isRefund: $isRefund
) {
...TransactionsFragment
}
Expand Down Expand Up @@ -557,22 +565,22 @@ const accountTransactions = async (req, res) => {
variables.kind = difference(variables.kind || allKinds, ['TAX']);
}

if (variables.expenseType) {
variables.expenseType = variables.expenseType.split(',').map(toUpper).map(trim);
}
// if (variables.expenseType) {
// variables.expenseType = variables.expenseType.split(',').map(toUpper).map(trim);
// }

if (variables.orderId) {
variables.order = { legacyId: parseInt(variables.orderId) };
}
// if (variables.orderId) {
// variables.order = { legacyId: parseInt(variables.orderId) };
// }

if (variables.expenseId) {
variables.expense = { legacyId: parseInt(variables.expenseId) };
}
// if (variables.expenseId) {
// variables.expense = { legacyId: parseInt(variables.expenseId) };
// }

// isRefund can be false but default should be undefined
if (!isNil(variables.isRefund)) {
variables.isRefund = parseToBooleanDefaultFalse(variables.isRefund);
}
// // isRefund can be false but default should be undefined
// if (!isNil(variables.isRefund)) {
// variables.isRefund = parseToBooleanDefaultFalse(variables.isRefund);
// }

if (req.query.fullDescription) {
variables.fullDescription = parseToBooleanDefaultFalse(req.query.fullDescription);
Expand Down

0 comments on commit 8f6386b

Please sign in to comment.