Skip to main content

Planning Center Giving Data Model

Complete reference for Planning Center Giving tables in Parable: donations, designations, funds, batches, pledges, and the relationships between them.

This document provides complete documentation of the Planning Center Giving data model in Parable, including all tables, fields, and relationships.

Overview

The Giving module contains 19 entity tables and 9 relationship tables supporting donation processing, fund management, pledges, recurring donations, and financial reporting.

Visual Data Model

The diagram below shows the core entities and their relationships in the Giving module. Use it as a visual reference while exploring the detailed table definitions below.

Core Entity Relationships

Giving module data model

Open diagram in new tab →

Key Relationships Explained

Donation Flow:

  1. A DONATION is created with amount and payment details
  2. DESIGNATION(s) split the donation across one or more FUNDs
  3. Donations are grouped into BATCHes for processing
  4. Batches can be organized into BATCH_GROUPs

Generic Relationship Pattern:

  • Donor information stored via giving_donations_relationships (relationship_type: 'Person')
  • Campus association via giving_donations_relationships (relationship_type: 'Campus')
  • Designation links via giving_donations_relationships (relationship_type: 'Designation')
  • Fund links via giving_designations_relationships (relationship_type: 'Fund')
  • Payment details via giving_donations_relationships (relationship_type: 'PaymentSource')

Pledge System:

  • PLEDGE_CAMPAIGN defines fundraising campaigns
  • PLEDGEs are commitments made during campaigns
  • Person relationship tracked via giving_pledges_relationships

Recurring Donations:

  • RECURRING_DONATION defines the schedule and total amount
  • RECURRING_DONATION_DESIGNATIONs split recurring amounts across funds
  • Actual donations created by Planning Center on schedule

Refund Handling:

  • REFUND represents the refund transaction
  • DESIGNATION_REFUNDs track which fund allocations were refunded
  • Maintains audit trail of original donation and refund

Query Requirements

Schema Prefix

IMPORTANT: All tables in the Planning Center Giving module are in the planning_center schema. You MUST prefix all table names with planning_center. in your queries.

✅ CORRECT: SELECT * FROM planning_center.giving_donations ❌ INCORRECT: SELECT * FROM giving_donations

Row Level Security (RLS)

This database uses Row Level Security (RLS) to automatically filter data based on:

  • tenant_organization_id: You only see data for your current organization
  • system_status: You only see 'active' records by default

DO NOT add these filters to your WHERE clause - they are applied automatically:

  • ❌ WHERE tenant_organization_id = 1 (unnecessary)
  • ❌ WHERE system_status = 'active' (unnecessary)

The RLS policies ensure you only access data you're authorized to see, making these filters redundant and potentially causing performance issues.

Core Tables Overview

Primary Entity Tables

  • giving_donations - Individual donation transactions
  • giving_people - Donor profiles
  • giving_funds - Fund definitions for designated giving
  • giving_designations - Donation allocations to funds
  • giving_batches - Groups of donations processed together
  • giving_pledges - Pledge commitments
  • giving_pledge_campaigns - Campaign definitions
  • giving_recurring_donations - Automated recurring giving

Financial Processing Tables

  • giving_batch_groups - Groups of donation batches
  • giving_payment_methods - Payment method details
  • giving_payment_sources - Sources of payments
  • giving_recurring_donation_designations - Fund allocations for recurring
  • giving_refunds - Refund transactions
  • giving_designation_refunds - Refunds for specific designations
  • giving_in_kind_donations - Non-cash (in-kind) donation records

Reference Tables

  • giving_campuses - Physical locations/campuses
  • giving_organizations - Organization settings
  • giving_labels - Categorization tags
  • giving_notes - Text notes

Relationship Tables

  • giving_donations_relationships - Links donations to related entities
  • giving_designations_relationships - Links designations to donations
  • giving_pledges_relationships - Links pledges to people
  • giving_people_relationships - Links people to other entities
  • giving_batches_relationships - Links batches to related entities
  • giving_refunds_relationships - Links refunds to donations
  • giving_in_kind_donations_relationships - Links in-kind donations to related entities
  • giving_recurring_donation_relationships - Links recurring donations to people and funds
  • giving_recurring_donation_designation_relationships - Links recurring donation designations to funds (relationship_type = 'Fund')

Table Definitions

giving_donations

Individual donation transactions from donors.

ColumnTypeDescription
idUUIDInternal unique identifier
donation_idVARCHAR(64)Planning Center donation ID
amount_centsINTEGERDonation amount in cents
amount_currencyVARCHAR(10)Currency code (USD, CAD, etc.)
completed_atTIMESTAMPWhen transaction completed
created_atTIMESTAMPWhen donation was created
fee_centsINTEGERProcessing fee in cents
fee_coveredBOOLEANWhether donor covered the fee
fee_currencyVARCHAR(10)Fee currency code
payment_brandVARCHAR(255)Card brand (Visa, Mastercard, etc.)
payment_check_dated_atDATEDate on check
payment_check_numberINTEGERCheck number
payment_last4VARCHAR(4)Last 4 digits of card
payment_methodVARCHAR(255)Payment type (cash, check, card, ach)
payment_method_subVARCHAR(255)Payment subtype details
payment_statusVARCHAR(255)Transaction status
received_atTIMESTAMPWhen donation was received
refundableBOOLEANWhether donation can be refunded
refundedBOOLEANWhether donation has been refunded
updated_atTIMESTAMPLast update time
memoTEXTDonation memo/note
payment_channelVARCHAR(50)Channel used for payment
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status: 'active', 'transferring', 'stale'
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

Note: Related entities (person, batch, campus, fund, recurring donation, refund) are linked via giving_donations_relationships using relationship_type values such as 'Person', 'Batch', 'Campus', 'Designation', 'RecurringDonation', 'Refund', etc.

giving_people

Donor profiles and information.

ColumnTypeDescription
idUUIDInternal unique identifier
person_idVARCHAR(64)Planning Center person ID
donor_numberINTEGERUnique donor identifier
first_nameVARCHAR(255)Donor's first name
last_nameVARCHAR(255)Donor's last name
permissionsVARCHAR(255)Giving permissions
first_donated_atTIMESTAMPDate of first donation
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_funds

Fund definitions for designated giving.

ColumnTypeDescription
idUUIDInternal unique identifier
fund_idVARCHAR(64)Planning Center fund ID
colorVARCHAR(64)Display color for fund
color_identifierINTEGERNumeric color identifier
created_atTIMESTAMPWhen fund was created
is_defaultBOOLEANWhether this is the default/general fund
deletableBOOLEANWhether fund can be deleted
descriptionTEXTFund description
ledger_codeVARCHAR(64)Accounting ledger code
nameVARCHAR(255)Fund name
slugTEXTURL-friendly identifier for the fund
updated_atTIMESTAMPLast update time
visibilityVARCHAR(64)Who can see this fund (everywhere, admin_only, etc.)
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_designations

How donations are allocated to specific funds.

ColumnTypeDescription
idUUIDInternal unique identifier
designation_idVARCHAR(64)Planning Center designation ID
amount_centsINTEGERAmount designated in cents
amount_currencyVARCHAR(10)Currency code
fee_centsINTEGERProcessing fee in cents
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_batches

Groups of donations processed together.

ColumnTypeDescription
idUUIDInternal unique identifier
batch_idVARCHAR(64)Planning Center batch ID
committed_atTIMESTAMPWhen batch was committed
created_atTIMESTAMPWhen batch was created
descriptionTEXTBatch description
donations_countINTEGERNumber of donations in this batch
statusVARCHAR(50)Batch status (in_progress, committed)
total_centsINTEGERTotal amount in cents
total_currencyVARCHAR(50)Currency code
updated_atTIMESTAMPLast update time
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_pledges

Pledge commitments for campaigns.

ColumnTypeDescription
idUUIDInternal unique identifier
pledge_idVARCHAR(64)Planning Center pledge ID
amount_centsINTEGERPledged amount in cents
amount_currencyVARCHAR(10)Currency code
created_atTIMESTAMPWhen pledge was made
donated_total_centsINTEGERTotal amount donated toward this pledge
joint_giver_amount_centsINTEGERAmount pledged by joint giver
joint_giver_donated_total_centsINTEGERTotal amount donated by joint giver
updated_atTIMESTAMPLast update time
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

Note: Pledges connect to pledge campaigns and people via giving_pledges_relationships using relationship_type values 'PledgeCampaign' and 'Person'. There is no direct pledge_campaign_id or received_cents column.

giving_pledge_campaigns

Campaign definitions for pledge drives.

ColumnTypeDescription
idUUIDInternal unique identifier
pledge_campaign_idVARCHAR(64)Planning Center campaign ID
created_atTIMESTAMPWhen campaign was created
descriptionTEXTCampaign description
ends_atTIMESTAMPCampaign end date
goal_centsINTEGERCampaign goal in cents
goal_currencyVARCHAR(255)Goal currency
nameTEXTCampaign name
received_total_from_pledges_centsINTEGERTotal received from pledged donations (use this, not received_total_cents)
received_total_outside_of_pledges_centsINTEGERTotal received from non-pledged donations
show_goal_in_church_centerBOOLEANPublic visibility of goal
starts_atTIMESTAMPCampaign start date
updated_atTIMESTAMPLast update
fund_idVARCHAR(64)Associated fund
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_recurring_donations

Automated recurring giving setups.

ColumnTypeDescription
idUUIDInternal unique identifier
recurring_donation_idVARCHAR(64)Planning Center recurring ID
created_atTIMESTAMPWhen setup was created
updated_atTIMESTAMPLast update
release_hold_atTIMESTAMPWhen hold releases
amount_centsINTEGERRecurring amount in cents
amount_currencyVARCHAR(50)Currency code
statusVARCHAR(50)Status (active, indefinite_hold, temporary_hold)
last_donation_received_atTIMESTAMPMost recent successful donation
next_occurrenceTIMESTAMPNext scheduled donation
scheduleJSONBSchedule configuration
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_batch_groups

Groups of donation batches for organizational purposes.

ColumnTypeDescription
idUUIDInternal unique identifier
batch_group_idVARCHAR(64)Planning Center batch group ID
committedBOOLEANWhether batch group is committed
created_atTIMESTAMPWhen created
descriptionTEXTHuman-readable description
statusVARCHAR(50)Batch group status
total_centsINTEGERTotal amount in cents
total_currencyVARCHAR(50)Currency code
updated_atTIMESTAMPLast update
owner_idVARCHAR(64)Person who owns this batch group
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_payment_methods

Payment method details for recurring donations.

ColumnTypeDescription
idUUIDInternal unique identifier
payment_method_idVARCHAR(64)Planning Center payment method ID
recurring_donation_idVARCHAR(64)Associated recurring donation ID
brandVARCHAR(255)Card brand
created_atTIMESTAMPWhen created
expirationVARCHAR(10)Expiration date
last4VARCHAR(4)Last 4 digits
method_subtypeVARCHAR(255)Payment method subtype
method_typeVARCHAR(255)Payment method type
updated_atTIMESTAMPLast update
verifiedBOOLEANWhether verified
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_payment_sources

Sources of payments (broader category than payment methods).

ColumnTypeDescription
idUUIDInternal unique identifier
payment_source_idVARCHAR(64)Planning Center payment source ID
created_atTIMESTAMPWhen created
nameVARCHAR(255)Display name
payment_source_typeVARCHAR(255)Type of payment source
statusVARCHAR(50)Payment source status
updated_atTIMESTAMPLast update
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_refunds

Refund transactions for donations.

ColumnTypeDescription
idUUIDInternal unique identifier
refund_idVARCHAR(64)Planning Center refund ID
amount_centsINTEGERRefund amount in cents
amount_currencyVARCHAR(10)Currency code
created_atTIMESTAMPWhen created
fee_centsINTEGERRefund processing fee in cents
fee_currencyVARCHAR(10)Fee currency code
refunded_atTIMESTAMPWhen refund was processed
updated_atTIMESTAMPLast update
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_campuses

Physical locations/campuses for the organization.

ColumnTypeDescription
idUUIDInternal unique identifier
campus_idVARCHAR(64)Planning Center campus ID
nameTEXTCampus name
street_line_1VARCHAR(255)Street address line 1
street_line_2VARCHAR(255)Street address line 2
cityVARCHAR(255)City
stateVARCHAR(255)State
zipVARCHAR(255)ZIP code
locationVARCHAR(255)Location description
streetVARCHAR(255)Street name
line_1VARCHAR(255)Address line 1
line_2VARCHAR(255)Address line 2
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_organizations

Organization-level settings and information for giving.

ColumnTypeDescription
idUUIDInternal unique identifier
organization_idVARCHAR(64)Planning Center organization ID
nameVARCHAR(255)Organization name
time_zoneVARCHAR(50)Organization time zone
text2give_enabledBOOLEANWhether Text-to-Give is enabled for the organization
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_labels

Categorization tags for giving-related entities.

ColumnTypeDescription
idUUIDInternal unique identifier
label_idVARCHAR(64)Planning Center label ID
slugTEXTURL-friendly identifier
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_notes

Text notes attached to giving-related entities.

ColumnTypeDescription
idUUIDInternal unique identifier
note_idVARCHAR(64)Planning Center note ID
bodyTEXTNote content
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_recurring_donation_designations

Fund allocations for recurring donations.

ColumnTypeDescription
idUUIDInternal unique identifier
recurring_donation_designation_idVARCHAR(64)Planning Center recurring donation designation ID
amount_centsINTEGERAmount designated in cents
amount_currencyVARCHAR(10)Currency code
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_designation_refunds

Refunds for specific designations within donations.

ColumnTypeDescription
idUUIDInternal unique identifier
designation_refund_idVARCHAR(64)Planning Center designation refund ID
donation_idVARCHAR(64)Associated donation ID
amount_centsINTEGERRefund amount in cents
amount_currencyVARCHAR(10)Currency code
designation_idVARCHAR(64)Associated designation ID
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_in_kind_donations

Non-cash (in-kind) donation records such as property, goods, or services.

ColumnTypeDescription
idUUIDInternal unique identifier
in_kind_donation_idVARCHAR(64)Planning Center in-kind donation ID
acknowledgment_last_sent_atTIMESTAMPWhen the last acknowledgment was sent to the donor
created_atTIMESTAMPWhen the in-kind donation was created
descriptionTEXTDescription of the donated item or service
exchange_detailsTEXTDetails about any exchange arrangement
fair_market_value_centsINTEGERFair market value of the donation in cents
fair_market_value_currencyVARCHAR(10)Currency code for fair market value
internal_notesTEXTInternal staff notes about the donation
received_onDATEDate the in-kind donation was received
updated_atTIMESTAMPLast update time
valuation_detailsTEXTDetails about how the value was determined
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

Note: Related entities (person, fund, campus) are linked via giving_in_kind_donations_relationships using the appropriate relationship_type values.

Relationship Tables

giving_donations_relationships

Links donations to related entities beyond the direct ID columns.

ColumnTypeDescription
idUUIDInternal unique identifier
donation_idVARCHAR(64)Parent donation ID
relationship_typeVARCHAR(50)Type of relationship
relationship_idVARCHAR(64)ID of related entity
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_designations_relationships

Links designations to donations and other entities.

ColumnTypeDescription
idUUIDInternal unique identifier
designation_idVARCHAR(64)Parent designation ID
relationship_typeVARCHAR(50)Type of relationship
relationship_idVARCHAR(64)ID of related entity
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_pledges_relationships

Links pledges to people and campaigns.

ColumnTypeDescription
idUUIDInternal unique identifier
pledge_idVARCHAR(64)Parent pledge ID
relationship_typeVARCHAR(50)Type of relationship
relationship_idVARCHAR(64)ID of related entity
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_people_relationships

Links people to other entities beyond the direct ID columns.

ColumnTypeDescription
idUUIDInternal unique identifier
person_idVARCHAR(64)Parent person ID
relationship_typeVARCHAR(50)Type of relationship
relationship_idVARCHAR(64)ID of related entity
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_batches_relationships

Links batches to related entities.

ColumnTypeDescription
idUUIDInternal unique identifier
batch_idVARCHAR(64)Parent batch ID
relationship_typeVARCHAR(50)Type of relationship
relationship_idVARCHAR(64)ID of related entity
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_refunds_relationships

Links refunds to related entities.

ColumnTypeDescription
idUUIDInternal unique identifier
refund_idVARCHAR(64)Parent refund ID
relationship_typeVARCHAR(50)Type of relationship
relationship_idVARCHAR(64)ID of related entity
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

giving_in_kind_donations_relationships

Links in-kind donations to related entities.

ColumnTypeDescription
idUUIDInternal unique identifier
in_kind_donation_idVARCHAR(64)Parent in-kind donation ID
relationship_typeVARCHAR(50)Type of relationship
relationship_idVARCHAR(64)ID of related entity
tenant_organization_idINTEGEROrganization identifier
system_statusVARCHAR(50)Data status
system_created_atTIMESTAMPWhen record was created in Parable
system_updated_atTIMESTAMPWhen record was last updated in Parable

System Fields

All tables include these system fields for data management:

  • tenant_organization_id - Multi-tenant organization identifier
  • system_status - Data lifecycle status:
    • transferring - Being imported from Planning Center
    • active - Current active data
    • stale - Marked for removal
  • system_created_at - When record was created in Parable
  • system_updated_at - When record was last updated in Parable

Common Query Patterns

Getting Donations with Donor Information

-- CORRECT: Schema prefix included, no manual RLS filters
-- giving_donations has no direct person_id column; join via giving_donations_relationships
SELECT 
    d.donation_id,
    d.amount_cents / 100.0 as amount,
    d.amount_currency,
    p.first_name,
    p.last_name,
    p.donor_number
FROM planning_center.giving_donations d
LEFT JOIN planning_center.giving_donations_relationships dr
    ON d.donation_id = dr.donation_id
    AND dr.relationship_type = 'Person'
LEFT JOIN planning_center.giving_people p 
    ON dr.relationship_id = p.person_id
WHERE d.received_at >= CURRENT_DATE - INTERVAL '30 days'
ORDER BY d.received_at DESC;

Donation Designations by Fund

-- giving_designations has no direct fund_id or donation_id columns;
-- use the relationship tables to join funds → designations → donations
SELECT 
    f.name as fund_name,
    COUNT(DISTINCT des.designation_id) as designation_count,
    SUM(des.amount_cents) / 100.0 as total_amount
FROM planning_center.giving_funds f
-- Join funds to designations via designation_relationships (type='Fund')
JOIN planning_center.giving_designations_relationships desr
    ON desr.relationship_id = f.fund_id
    AND desr.relationship_type = 'Fund'
JOIN planning_center.giving_designations des
    ON des.designation_id = desr.designation_id
-- Join designations to donations via donation_relationships (type='Designation')
JOIN planning_center.giving_donations_relationships dr_des
    ON dr_des.relationship_id = des.designation_id
    AND dr_des.relationship_type = 'Designation'
JOIN planning_center.giving_donations d
    ON d.donation_id = dr_des.donation_id
WHERE d.received_at >= DATE_TRUNC('month', CURRENT_DATE)
    AND d.refunded = false
GROUP BY f.fund_id, f.name
ORDER BY total_amount DESC;

Batch Summary Report

-- giving_donations has no direct batch_id column;
-- join via giving_donations_relationships (relationship_type='Batch')
SELECT 
    b.batch_id,
    b.description,
    b.committed_at,
    b.total_cents / 100.0 as batch_total,
    b.donations_count,
    COUNT(d.donation_id) as calculated_donation_count,
    SUM(d.amount_cents) / 100.0 as calculated_total
FROM planning_center.giving_batches b
LEFT JOIN planning_center.giving_donations_relationships dr
    ON dr.relationship_id = b.batch_id
    AND dr.relationship_type = 'Batch'
LEFT JOIN planning_center.giving_donations d
    ON d.donation_id = dr.donation_id
WHERE b.status = 'committed'
GROUP BY b.batch_id, b.description, b.committed_at, b.total_cents, b.donations_count
ORDER BY b.committed_at DESC;

Recurring Donation Status

-- giving_donations has no direct recurring_donation_id or person_id columns;
-- find person via donation_relationships using RecurringDonation→Person chain
SELECT DISTINCT ON (rd.recurring_donation_id)
    rd.recurring_donation_id,
    rd.amount_cents / 100.0 as amount,
    rd.status,
    rd.last_donation_received_at,
    rd.next_occurrence,
    p.first_name,
    p.last_name
FROM planning_center.giving_recurring_donations rd
-- Find donations linked to this recurring donation
LEFT JOIN planning_center.giving_donations_relationships dr_rd
    ON dr_rd.relationship_id = rd.recurring_donation_id
    AND dr_rd.relationship_type = 'RecurringDonation'
-- Get the person from that same donation
LEFT JOIN planning_center.giving_donations_relationships dr_p
    ON dr_p.donation_id = dr_rd.donation_id
    AND dr_p.relationship_type = 'Person'
LEFT JOIN planning_center.giving_people p
    ON p.person_id = dr_p.relationship_id
WHERE rd.status = 'active'
ORDER BY rd.recurring_donation_id, rd.next_occurrence;

Data Integrity Rules

  1. Schema Qualification: Always use planning_center. prefix for all table references
  2. Row Level Security: RLS automatically handles multi-tenancy and status filtering - do not add manual filters
  3. Monetary Values: All amounts are stored in cents - divide by 100.0 for display
  4. Refunded Donations: Filter refunded = true when needed for financial reports
  5. Relationship Tables: All entity-to-entity links (donations→person, donations→batch, designations→fund, pledges→campaign, etc.) go through relationship tables — there are no direct FK columns on these tables

Common Mistakes to Avoid

  1. Missing Schema Prefix

    • ❌ FROM giving_donations
    • ✅ FROM planning_center.giving_donations
  2. Adding Redundant RLS Filters

    • ❌ WHERE tenant_organization_id = 1 AND system_status = 'active'
    • ✅ Trust RLS to handle this automatically
  3. Joining Without Schema

    • ❌ JOIN giving_people p ON ...
    • ✅ JOIN planning_center.giving_people p ON ...
  4. Forgetting Currency Conversion

    • ❌ SELECT amount_cents as amount (displays cents)
    • ✅ SELECT amount_cents / 100.0 as amount (displays dollars)

Performance Considerations

  1. Indexes: All tables have optimized indexes on:

    • Primary keys and entity IDs
    • Join columns and foreign keys
    • Date columns for time-based queries
  2. Query Optimization:

    • Always use the planning_center. schema prefix
    • RLS handles tenant and status filtering automatically
    • Filter refunded donations when needed
    • Consider CTEs for complex aggregations
    • Join through the *_relationships tables — entity tables carry no foreign-key columns

Data Types and Conventions

Monetary Values

  • All amounts stored in cents (INTEGER)
  • Divide by 100.0 for dollar amounts
  • Currency codes follow ISO 4217 (USD, CAD, EUR, etc.)

Dates and Times

  • TIMESTAMP fields represent UTC time
  • DATE fields for date-only values (no time component)
  • All times stored without timezone info (implicit UTC)

Payment Methods

  • payment_method - Type (cash, check, card, ach)
  • payment_method_sub - Subtype details
  • payment_status - Transaction status

Boolean Values

  • TRUE/FALSE for PostgreSQL boolean type
  • No NULL booleans - default to FALSE where appropriate

Next Steps

On this page