@@ -2484,6 +2484,72 @@ CREATE VIEW giveffektivt.renew_donations_to_email AS
24842484 WHERE (d .emailed = ' renew-no' ::giveffektivt .emailed_status );
24852485
24862486
2487+ --
2488+ -- Name: transfer_overview; Type: VIEW; Schema: giveffektivt; Owner: -
2489+ --
2490+
2491+ CREATE VIEW giveffektivt .transfer_overview AS
2492+ SELECT t .id ,
2493+ t .earmark ,
2494+ (
2495+ CASE
2496+ WHEN (t .created_at > now()) THEN ' Forventet: ' ::text
2497+ ELSE ' ' ::text
2498+ END || t .recipient ) AS recipient,
2499+ CASE
2500+ WHEN (t .recipient = ' Against Malaria Foundation' ::giveffektivt .transfer_recipient ) THEN ' Antimalaria myggenet' ::text
2501+ WHEN (t .recipient = ' Malaria Consortium' ::giveffektivt .transfer_recipient ) THEN ' Malariabehandlinger' ::text
2502+ WHEN (t .recipient = ' Helen Keller International' ::giveffektivt .transfer_recipient ) THEN ' A-vitamintilskud' ::text
2503+ WHEN (t .recipient = ' New Incentives' ::giveffektivt .transfer_recipient ) THEN ' Vaccinationsprogrammer' ::text
2504+ WHEN (t .recipient = ' Give Directly' ::giveffektivt .transfer_recipient ) THEN ' Dollars' ::text
2505+ WHEN (t .recipient = ' SCI Foundation' ::giveffektivt .transfer_recipient ) THEN ' Ormekure' ::text
2506+ ELSE NULL ::text
2507+ END AS unit,
2508+ round(sum (cdt .amount )) AS total_dkk,
2509+ round((sum (cdt .amount ) / max (t .exchange_rate ))) AS total_usd,
2510+ round(max (t .unit_cost_external ), 2 ) AS unit_cost_external,
2511+ round(max (t .unit_cost_conversion ), 2 ) AS unit_cost_conversion,
2512+ round(((max (t .unit_cost_external ) / max (t .unit_cost_conversion )) * max (t .exchange_rate )), 2 ) AS unit_cost_dkk,
2513+ round(((sum (cdt .amount ) / max (t .exchange_rate )) / (max (t .unit_cost_external ) / max (t .unit_cost_conversion ))), 1 ) AS unit_impact,
2514+ round(max (t .life_cost_external ), 2 ) AS life_cost_external,
2515+ round((max (t .life_cost_external ) * max (t .exchange_rate )), 2 ) AS life_cost_dkk,
2516+ round(((sum (cdt .amount ) / max (t .exchange_rate )) / max (t .life_cost_external )), 1 ) AS life_impact,
2517+ max (cdt .charged_at ) AS computed_at,
2518+ CASE
2519+ WHEN (t .created_at > now()) THEN ' Næste overførsel' ::text
2520+ ELSE to_char(t .created_at , ' yyyy-mm-dd' ::text )
2521+ END AS transferred_at
2522+ FROM (giveffektivt .charged_donations_by_transfer_internal cdt
2523+ JOIN giveffektivt .transfer t ON (((cdt .transfer_id = t .id ) OR ((cdt .transfer_id IS NULL ) AND (cdt .earmark = t .earmark ) AND (t .created_at > now())))))
2524+ GROUP BY t .id , t .earmark , t .recipient , t .created_at
2525+ ORDER BY t .created_at , (sum (cdt .amount )) DESC ;
2526+
2527+
2528+ --
2529+ -- Name: results_monthly_outputs; Type: VIEW; Schema: giveffektivt; Owner: -
2530+ --
2531+
2532+ CREATE VIEW giveffektivt .results_monthly_outputs AS
2533+ SELECT transfer_overview .total_dkk ,
2534+ transfer_overview .earmark ,
2535+ transfer_overview .transferred_at ,
2536+ transfer_overview .unit ,
2537+ transfer_overview .unit_impact ,
2538+ transfer_overview .recipient
2539+ FROM giveffektivt .transfer_overview
2540+ UNION ALL
2541+ SELECT round(sum (charged_donations_by_transfer_internal .amount )) AS total_dkk,
2542+ charged_donations_by_transfer_internal .earmark ,
2543+ ((date_trunc(' month' ::text , charged_donations_by_transfer_internal .charged_at ))::date )::text AS transferred_at,
2544+ ' kr.' ::text AS unit,
2545+ round(sum (charged_donations_by_transfer_internal .amount )) AS unit_impact,
2546+ ' Giv Effektivt' ::text AS recipient
2547+ FROM giveffektivt .charged_donations_by_transfer_internal
2548+ WHERE (charged_donations_by_transfer_internal .earmark = ' Giv Effektivts arbejde og vækst' ::giveffektivt .donation_recipient )
2549+ GROUP BY charged_donations_by_transfer_internal .earmark , ((date_trunc(' month' ::text , charged_donations_by_transfer_internal .charged_at ))::date )::text
2550+ ORDER BY 3 , 1 DESC ;
2551+
2552+
24872553--
24882554-- Name: scanpay_seq; Type: TABLE; Schema: giveffektivt; Owner: -
24892555--
@@ -3220,47 +3286,6 @@ CREATE VIEW giveffektivt.time_distribution_monthly AS
32203286 ORDER BY COALESCE(a .period , b .period ) DESC ;
32213287
32223288
3223- --
3224- -- Name: transfer_overview; Type: VIEW; Schema: giveffektivt; Owner: -
3225- --
3226-
3227- CREATE VIEW giveffektivt .transfer_overview AS
3228- SELECT t .id ,
3229- t .earmark ,
3230- (
3231- CASE
3232- WHEN (t .created_at > now()) THEN ' Forventet: ' ::text
3233- ELSE ' ' ::text
3234- END || t .recipient ) AS recipient,
3235- CASE
3236- WHEN (t .recipient = ' Against Malaria Foundation' ::giveffektivt .transfer_recipient ) THEN ' Antimalaria myggenet' ::text
3237- WHEN (t .recipient = ' Malaria Consortium' ::giveffektivt .transfer_recipient ) THEN ' Malariabehandlinger' ::text
3238- WHEN (t .recipient = ' Helen Keller International' ::giveffektivt .transfer_recipient ) THEN ' A-vitamintilskud' ::text
3239- WHEN (t .recipient = ' New Incentives' ::giveffektivt .transfer_recipient ) THEN ' Vaccinationsprogrammer' ::text
3240- WHEN (t .recipient = ' Give Directly' ::giveffektivt .transfer_recipient ) THEN ' Dollars' ::text
3241- WHEN (t .recipient = ' SCI Foundation' ::giveffektivt .transfer_recipient ) THEN ' Ormekure' ::text
3242- ELSE NULL ::text
3243- END AS unit,
3244- round(sum (cdt .amount )) AS total_dkk,
3245- round((sum (cdt .amount ) / max (t .exchange_rate ))) AS total_usd,
3246- round(max (t .unit_cost_external ), 2 ) AS unit_cost_external,
3247- round(max (t .unit_cost_conversion ), 2 ) AS unit_cost_conversion,
3248- round(((max (t .unit_cost_external ) / max (t .unit_cost_conversion )) * max (t .exchange_rate )), 2 ) AS unit_cost_dkk,
3249- round(((sum (cdt .amount ) / max (t .exchange_rate )) / (max (t .unit_cost_external ) / max (t .unit_cost_conversion ))), 1 ) AS unit_impact,
3250- round(max (t .life_cost_external ), 2 ) AS life_cost_external,
3251- round((max (t .life_cost_external ) * max (t .exchange_rate )), 2 ) AS life_cost_dkk,
3252- round(((sum (cdt .amount ) / max (t .exchange_rate )) / max (t .life_cost_external )), 1 ) AS life_impact,
3253- max (cdt .charged_at ) AS computed_at,
3254- CASE
3255- WHEN (t .created_at > now()) THEN ' Næste overførsel' ::text
3256- ELSE to_char(t .created_at , ' yyyy-mm-dd' ::text )
3257- END AS transferred_at
3258- FROM (giveffektivt .charged_donations_by_transfer_internal cdt
3259- JOIN giveffektivt .transfer t ON (((cdt .transfer_id = t .id ) OR ((cdt .transfer_id IS NULL ) AND (cdt .earmark = t .earmark ) AND (t .created_at > now())))))
3260- GROUP BY t .id , t .earmark , t .recipient , t .created_at
3261- ORDER BY t .created_at , (sum (cdt .amount )) DESC ;
3262-
3263-
32643289--
32653290-- Name: transferred_distribution; Type: VIEW; Schema: giveffektivt; Owner: -
32663291--
0 commit comments