Skip to main content

CieTrade Account Hierarchy for CRM

A quick reference for understanding how CieTrade data is organized in the Wasteology portal.

Account Hierarchy Overview

The Problem

CieTrade has no native parent account concept - each facility is a separate CPID. Enterprise customers like UPS (1,500+ facilities) need consolidated reporting and management under a single parent entity.

The Business Problem: Flat Data vs Enterprise Needs

The Solution

A 3-tier portal hierarchy that groups CieTrade data under parent accounts for enterprise-level visibility and control.

The Solution: A Three-Tier Hierarchy

The Three Tiers

TierTablePurposeExample
1wg_parent_accountsTop-level customer"UPS"
2wg_accountsLinks to CieTrade CPID"UPS - Bedford Park"
3wg_account_locationsService addressesPhysical pickup locations

Each tier connects to the one above it, creating a hierarchy that rolls up data from individual service locations to enterprise parent accounts.

Two Relationship Patterns

Hierarchy Patterns: Standard vs Complex

Standard (1:1:N)

1 Parent → 1 Account → Many Locations

  • Used by most customers
  • Single CieTrade CPID per parent
  • Simple setup for single-location or franchise customers

Complex (1:N:N)

1 Parent → Many Accounts → Many Locations

  • Used by UPS, McKesson, large enterprises
  • Multiple CieTrade CPIDs under one parent
  • Needed when billing requires separate accounts per facility or region

Key Enterprise Parent IDs

CustomerParent IDPatternAccount Count
UPS11971:N:N1,500+
McKesson12091:N:N200+
Goodwill KY10021:1:N1

How to Join CieTrade Data

Data Model & The Golden Rule of Joining

Use the unified view portal.vw_wg_accounts - it joins all three tiers automatically:

SELECT
v.parent_account_name,
v.account_name,
v.location_name,
t.order_date,
t.revenue
FROM cietrade.orders t
JOIN portal.vw_wg_accounts v
ON v.cietrade_account_id = t.account_id
AND v.location_name = t.location_name
WHERE v.parent_account_id = 1197 -- UPS example

Critical: Always join on BOTH cietrade_account_id AND location_name to ensure correct location matching.

Why Both Fields?

  • cietrade_account_id links to the CieTrade CPID
  • location_name disambiguates when one CPID has multiple service addresses
  • Without both, you may get duplicate or incorrect location assignments

Edge Cases

Edge Cases & The Exclusion List

UPS

(Parent Account ID: 1197)

AttributeValue
Hierarchy Type1:N:N (1 parent → 20+ accounts → N locations each)
ReasonBilling restrictions require separate account for each location
Templateadd_new_account_ups_hierarchy.sql
Special FeaturesDedicated export procedures: usp_export_spend_rebate_ups, usp_export_weight_ups
ExclusionUPS Conveyor Recycling (account_id 7611) excluded from container profiles
SeasonalUPS PEAK 2023 (7098), UPS PEAK 2024 (7885) excluded from standard sync

Example Facilities:

  • ILBED - Bedford Park
  • ILFRA - Franklin Park Hub
  • ILGAN - Morgan Street Center
  • ILJOL - Joliet
  • IL53A - Rockford Air Cargo Facility

McKesson

(Parent Account ID: 1209)

AttributeValue
Hierarchy Type1:N:N (same as UPS)
ReasonBilling restrictions require separate account for each location
Templateadd_new_account_ups_hierarchy.sql
Special AccountMcKesson Direct (CPID 8544) - excluded from sync
McKesson Direct

This account is for "Billing Purposes" only, not a physical location. It should never appear in location sync.

Goodwill Industries of Kentucky

(Parent Account ID: 1002)

AttributeValue
Hierarchy Type1:1:N (standard)
Special FeaturesDedicated ETL module in goodwill schema
Custom Tablesgoodwill.sales_history, goodwill.weight_history, goodwill.haul_rate

Business Rules (stakeholder-approved):

  • Shively ADC should never have weight
  • Exclude Open Top weight from KY West – The Outlet
  • Exclude Open Top sales from KY West – The Outlet
  • Do not count scheduled monthly services as hauls
  • Exclude all Front Loads from haul and weight metrics
  • Exclude all "Hand Pick Up" equipment types from haul and weight metrics

Standard Hierarchy Examples

CustomerParent IDStructureNotes
BGISvaries1:1:NStandard template reference
Regions Bankvaries1:1:NStandard template reference
CBRE - VDOTvaries1:1:NStandard template reference
Sonepar11951:1:N-
Ball Corp13561:1:N-

Exclusion List

The following CPIDs are excluded from standard sync operations in get_missing_locations.sql:

Vendor Accounts

(Dual-labeled as CUSTOMER in CieTrade)

CPIDAccount NameReason
188ABC SALVAGEVendor
2020ALL METALS RECYCLINGVendor
4086GRANGER WASTEVendor
1985RUMPKEVendor
...(30+ additional vendors)Vendor

Special Cases

CPIDAccount NameReason
8544McKesson DirectBilling account only
709335 LandsdowneDuplicate location
8244SPRINGHILL SUITES FISHERSDuplicate location
3573WESTROCKDuplicate account
7640DAWN HENDRENNot a real account
3095STACEY HARRALSONNot a real account
4105TEST CUSTOMERTest data
7098UPS PEAK 2023Seasonal
7885UPS PEAK 2024Seasonal

Quick Reference

Common Parent Account IDs

ParentIDHierarchy
UPS11971:N:N
McKesson12091:N:N
Goodwill Industries of Kentucky10021:1:N
Sonepar11951:1:N
Ball Corp13561:1:N

Summary

Key Takeaways
  1. The hierarchy bridges CieTrade and portal - Parent Account → Account (CPID) → Location
  2. Two patterns exist - Standard (1:1:N) for most customers, Complex (1:N:N) for enterprises like UPS/McKesson
  3. Always join on TWO fields - cietrade_account_id AND location_name (The Golden Rule)
  4. Use the unified view - portal.vw_wg_accounts joins all three tiers for you
  5. Know your exclusions - Vendors, test accounts, and seasonal accounts are filtered from sync

Need More Detail?

See the full Account Hierarchy Documentation for:

  • Detailed table schemas
  • Synchronization process
  • Complex relationship patterns
  • Data quality considerations