-
Notifications
You must be signed in to change notification settings - Fork 0
feat(PS-466): get member payments report #33
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
Open
hentrymartin
wants to merge
3
commits into
develop
Choose a base branch
from
ps-466
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| WITH base AS ( | ||
| SELECT | ||
| DATE(p.created_at) AS payment_created_date, | ||
|
|
||
| -- Payment info | ||
| p.payment_id, | ||
| w.description AS payment_desc, | ||
|
|
||
| -- Challenge system id | ||
| COALESCE( | ||
| NULLIF(TRIM(w.external_id), ''), | ||
| NULLIF(TRIM(c."id"::text), '') | ||
| ) AS challenge_system_id, | ||
|
|
||
| p.payment_status, | ||
| w.category::text AS payment_type_desc, | ||
|
|
||
| -- Member info | ||
| mem.handle AS member_handle, | ||
| NULL::text AS payment_method_desc, | ||
| mem."userId" AS member_user_id, | ||
|
|
||
| -- Billing / client info | ||
| ba."name" AS billing_account_name, | ||
| cl."name" AS customer_name, | ||
| cl."codeName" AS sfdc_account_name, | ||
| NULL::text AS parent_name, | ||
|
|
||
| -- Challenge dates | ||
| DATE(c."createdAt") AS challenge_created_date, | ||
|
|
||
| -- Amount | ||
| COALESCE(p.gross_amount, p.total_amount) AS gross_amount | ||
| FROM finance.payment p | ||
| JOIN finance.winnings w | ||
| ON w.winning_id = p.winnings_id | ||
| JOIN members.member mem | ||
| ON mem."userId"::text = w.winner_id | ||
|
|
||
| LEFT JOIN challenges."Challenge" c | ||
| ON c."id" = w.external_id | ||
|
|
||
| LEFT JOIN challenges."ChallengeBilling" cb | ||
| ON cb."challengeId" = c."id" | ||
|
|
||
| LEFT JOIN "billing-accounts"."BillingAccount" ba | ||
| ON ba."id" = COALESCE( | ||
| NULLIF(p.billing_account, '')::int, | ||
| NULLIF(cb."billingAccountId", '')::int | ||
| ) | ||
|
|
||
| LEFT JOIN "billing-accounts"."Client" cl | ||
| ON cl."id" = ba."clientId" | ||
|
|
||
| LEFT JOIN projects.projects proj | ||
| ON proj.id = c."projectId"::bigint | ||
|
|
||
| WHERE DATE(p.created_at) >= $1::date | ||
| AND DATE(p.created_at) < $2::date | ||
| ) | ||
| SELECT | ||
| payment_created_date AS "payment_create_date.date_date", | ||
| payment_id AS "payment.payment_id", | ||
| payment_desc AS "payment.payment_desc", | ||
| COALESCE(challenge_system_id, '-') AS "challenge.challenge_system_id", | ||
| payment_status AS "payment.payment_status_desc", | ||
| payment_type_desc AS "payment.payment_type_desc", | ||
| member_handle AS "payee.handle", | ||
| payment_method_desc AS "payee.payment_method_desc", | ||
| billing_account_name AS "billing_account_budgets.billing_account_name", | ||
| customer_name AS "billing_account_budgets.customer_name", | ||
| sfdc_account_name AS "sfdc_account.name", | ||
| member_user_id AS "member_profile_basic.user_id", | ||
| parent_name AS "sfdc_account.parent_name", | ||
| challenge_created_date AS "challenge.create_date", | ||
| COALESCE(SUM(gross_amount), 0) AS "user_payment.gross_amount" | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| FROM base | ||
| GROUP BY | ||
| payment_created_date, | ||
| payment_id, | ||
| payment_desc, | ||
| challenge_system_id, | ||
| payment_status, | ||
| payment_type_desc, | ||
| member_handle, | ||
| payment_method_desc, | ||
| billing_account_name, | ||
| customer_name, | ||
| sfdc_account_name, | ||
| member_user_id, | ||
| parent_name, | ||
| challenge_created_date | ||
| ORDER BY | ||
| payment_created_date DESC | ||
| LIMIT 5000; | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.