| Aggregate (cost=31.66..31.67 rows=1 width=8) |
| -> Nested Loop Left Join (cost=9.82..31.66 rows=1 width=0) |
| Join Filter: ((v.object_type = b.object_type) AND (v.object_id = b.object_id) AND ((COALESCE((v.event_type)::integer, 0)) = b.event_type) AND ((COALESCE(v.event_id, 0)) = b.event_id)) |
| Filter: (((count(*) FILTER (WHERE (v.status = 1))) IS NULL) OR ((count(*) FILTER (WHERE (v.status = 1))) = 0)) |
| -> Subquery Scan on b (cost=6.20..26.87 rows=1 width=16) |
| Filter: ((b.object_type <> ALL ('{20,20018}'::integer[])) OR b.have_invoice OR (SubPlan 1)) |
| -> GroupAggregate (cost=6.20..6.22 rows=1 width=125) |
| Group Key: t.id, e.id |
| -> Sort (cost=6.20..6.21 rows=1 width=71) |
| Sort Key: t.id, e.id |
| -> Hash Join (cost=4.60..6.19 rows=1 width=71) |
| Hash Cond: (e.erp_other_income_ticket_id = t.id) |
| -> Seq Scan on tbl_erp_other_income_ticket_bank_ins e (cost=0.00..1.46 rows=31 width=26) |
| Filter: ((settle_at IS NOT NULL) AND (amount > '0'::numeric) AND (amount > '0'::numeric)) |
| -> Hash (cost=4.59..4.59 rows=1 width=49) |
| -> Hash Right Join (cost=3.41..4.59 rows=1 width=49) |
| Hash Cond: (h.erp_other_income_ticket_id = t.id) |
| -> Seq Scan on tbl_erp_other_income_ticket_handlers h (cost=0.00..1.14 rows=14 width=8) |
| -> Hash (cost=3.40..3.40 rows=1 width=49) |
| -> Seq Scan on tbl_erp_other_income_tickets t (cost=0.00..3.40 rows=1 width=49) |
| Filter: ((verify_at IS NOT NULL) AND (verify_at >= '2026-07-01 00:00:00+08'::timestamp with time zone) AND (verify_at <= '2026-07-31 23:59:59+08'::timestamp with time zone) AND (status = 2)) |
| SubPlan 1 |
| -> Nested Loop (cost=0.29..20.63 rows=1 width=0) |
| Join Filter: (r.taxonomy_id = tt.id) |
| -> Index Scan using tbl_term_taxonomy_relationships_object_id_term_id_idx on tbl_term_taxonomy_relationships r (cost=0.29..11.58 rows=1 width=4) |
| Index Cond: ((object_id = b.object_id) AND (term_id = 18)) |
| Filter: (((b.object_type = 20) AND (object_type = 7)) OR ((b.object_type = 20018) AND (object_type = 11))) |
| -> Seq Scan on tbl_term_taxonomies tt (cost=0.00..8.99 rows=5 width=4) |
| Filter: ((serial_no)::text = ANY ('{221106,640301,640302,640303,600704}'::text[])) |
| -> HashAggregate (cost=3.62..3.94 rows=26 width=36) |
| Group Key: v.object_type, v.object_id, COALESCE((v.event_type)::integer, 0), COALESCE(v.event_id, 0) |
| -> Seq Scan on tbl_voucher_gen_items v (cost=0.00..2.81 rows=54 width=18) |
| Filter: (ledger_id = 1) |