Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for orders custom data on transactions CSV #500

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/server/controllers/account-transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const transactionsFragment = gqlV2/* GraphQL */ `
frequency
memo
processedAt
customData
}
paymentMethod {
service
Expand Down Expand Up @@ -273,6 +274,7 @@ const csvMapping = {
merchantId: (t) => get(t, 'merchantId'),
orderMemo: (t) => get(t, 'order.memo'),
orderProcessedDate: (t) => (t.order?.processedAt ? moment.utc(t.order.processedAt).format('YYYY-MM-DD') : ''),
orderCustomData: (t) => get(t, 'order.customData'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't custom data an object?

Copy link
Member Author

@Betree Betree Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is an object. In my tests json2csv properly stringified the value

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so the CSV value will be a stringified JSON. Is this something that we are already doing elsewhere?

What is the use case, will that help people achieve what they want? Given than they may have to parse the JSON to extract the data?

Not blocking but just to understand.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's from https://opencollective.slack.com/archives/C6JTTA4SK/p1696831552748589?thread_ts=1686331488.222289&cid=C6JTTA4SK, the data they're getting from this is a phone number collected via a custom field in the contribution flow.

The alternative would be to explode the customData object and have one column per field:

  • Input: { phone: '0123456789', age: 43 }
  • Output:
Custom data -> phone customData -> age
0123456789 43

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok let's keep it as stringified JSON.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If needed, we could implement a separate parameter to achieve that behavior of splitting into columns in the future

taxAmount: (t) => get(t, 'taxAmount.value', 0),
taxType: (t) => get(t, 'taxInfo.type'),
taxRate: (t) => get(t, 'taxInfo.rate'),
Expand Down
Loading