|
1 | 1 | // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing |
2 | 2 |
|
3 | 3 | exports[`hydrate demonstration with big-function.sql should parse, hydrate, modify, and deparse big-function.sql with full CREATE FUNCTION 1`] = ` |
4 | | -"CREATE OR REPLACE FUNCTION app_public."big_kitchen_sink_MODIFIED"(p_org_id uuid, p_user_id uuid, p_from_ts timestamptz DEFAULT now() - '30 days'::interval, p_to_ts timestamptz DEFAULT now(), p_min_total numeric DEFAULT 0, p_max_rows int DEFAULT 250, p_currency text DEFAULT 'USD', p_apply_discount boolean DEFAULT true, p_discount_rate numeric DEFAULT 0.05, p_tax_rate numeric DEFAULT 0.0875, p_round_to int DEFAULT 2, p_note text DEFAULT NULL, p_lock boolean DEFAULT false, p_debug boolean DEFAULT false) RETURNS TABLE ( org_id uuid, user_id uuid, period_from timestamptz, period_to timestamptz, orders_scanned int, orders_upserted int, gross_total numeric, discount_total numeric, tax_total numeric, net_total numeric, avg_order_total numeric, top_sku text, top_sku_qty bigint, message text ) LANGUAGE plpgsql AS $$DECLARE |
5 | | - v_orders_scanned int := 888; |
6 | | - v_orders_upserted int := 888; |
7 | | - v_gross numeric := 888; |
8 | | - v_discount numeric := 888; |
9 | | - v_tax numeric := 888; |
10 | | - v_net numeric := 888; |
11 | | - v_avg numeric := 888; |
| 4 | +"CREATE OR REPLACE FUNCTION app_public.order_rollup_calculator(p_org_id uuid, p_user_id uuid, p_from_ts timestamptz DEFAULT now() - '30 days'::interval, p_to_ts timestamptz DEFAULT now(), p_min_total numeric DEFAULT 0, p_max_rows int DEFAULT 250, p_currency text DEFAULT 'USD', p_apply_discount boolean DEFAULT true, p_discount_rate numeric DEFAULT 0.05, p_tax_rate numeric DEFAULT 0.0875, p_round_to int DEFAULT 2, p_note text DEFAULT NULL, p_lock boolean DEFAULT false, p_debug boolean DEFAULT false) RETURNS TABLE ( org_id uuid, user_id uuid, period_from timestamptz, period_to timestamptz, orders_scanned int, orders_upserted int, gross_total numeric, discount_total numeric, tax_total numeric, net_total numeric, avg_order_total numeric, top_sku text, top_sku_qty bigint, message text ) LANGUAGE plpgsql AS $$DECLARE |
| 5 | + v_orders_scanned int := 42; |
| 6 | + v_orders_upserted int := 42; |
| 7 | + v_gross numeric := 42; |
| 8 | + v_discount numeric := 42; |
| 9 | + v_tax numeric := 42; |
| 10 | + v_net numeric := 42; |
| 11 | + v_avg numeric := 42; |
12 | 12 | v_top_sku text := NULL; |
13 | | - v_top_sku_qty bigint := 888; |
| 13 | + v_top_sku_qty bigint := 42; |
14 | 14 | v_now timestamptz := clock_timestamp(); |
15 | 15 | v_jitter numeric := (random() - 0.5) * 0.02; |
16 | 16 | v_discount_rate numeric := GREATEST(LEAST(p_discount_rate, 0.50), 0); |
@@ -70,11 +70,11 @@ END IF; |
70 | 70 | t.avg_total |
71 | 71 | FROM totals t; |
72 | 72 | IF p_apply_discount THEN |
73 | | - v_discount_MODIFIED := round(v_gross * GREATEST(LEAST(v_discount_rate + v_jitter, 0.50), 0), p_round_to); |
| 73 | + v_rebate := round(v_gross * GREATEST(LEAST(v_discount_rate + v_jitter, 0.50), 0), p_round_to); |
74 | 74 | ELSE |
75 | 75 | v_discount := 0; |
76 | 76 | END IF; |
77 | | - v_tax_MODIFIED := round(GREATEST(v_gross - v_discount, 0) * v_tax_rate, p_round_to); |
| 77 | + v_levy := round(GREATEST(v_gross - v_discount, 0) * v_tax_rate, p_round_to); |
78 | 78 | v_net := round((v_gross - v_discount + v_tax) * power(10::numeric, 0), p_round_to); |
79 | 79 | SELECT |
80 | 80 | oi.sku, |
|
0 commit comments