Update planning docs to reflect current implementation state
- Doc 02: Add member_identifier table, member_number, primary_member_id, account_number auto-generation, isMinor override, tax_exemption as separate table, member move, updated business rules - Doc 03: Document lookup table pattern replacing pgEnums for status and condition, add system/custom value distinction - Doc 22: Mark all Phase 2 items as complete, add new tables to additions section, update audit findings, note admin frontend exists
This commit is contained in:
@@ -68,7 +68,7 @@ account_number
|
||||
|
||||
varchar
|
||||
|
||||
Human-readable account ID
|
||||
Auto-generated 6-digit random number, unique per company. Human-readable account ID.
|
||||
|
||||
name
|
||||
|
||||
@@ -101,6 +101,12 @@ enum
|
||||
|
||||
consolidated | split
|
||||
|
||||
primary_member_id
|
||||
|
||||
uuid FK
|
||||
|
||||
Nullable — references the primary contact member on this account. Auto-set when first member is added.
|
||||
|
||||
is_active
|
||||
|
||||
boolean
|
||||
@@ -201,6 +207,12 @@ uuid FK
|
||||
|
||||
Tenant scoping — identifies which company owns this record
|
||||
|
||||
member_number
|
||||
|
||||
varchar
|
||||
|
||||
Auto-generated 6-digit random number, unique per company. Human-readable member ID.
|
||||
|
||||
first_name
|
||||
|
||||
varchar
|
||||
@@ -217,13 +229,13 @@ date_of_birth
|
||||
|
||||
date
|
||||
|
||||
Used to derive is_minor status
|
||||
Optional — used to derive is_minor if set
|
||||
|
||||
is_minor
|
||||
|
||||
boolean
|
||||
|
||||
True if under 18 — derived from date_of_birth, controls consent and portal access rules
|
||||
Default false. Auto-derived from date_of_birth if provided, but can be set manually (e.g. parent declines to give DOB). Manual flag takes precedence over DOB calculation.
|
||||
|
||||
email
|
||||
|
||||
@@ -261,7 +273,30 @@ timestamptz
|
||||
|
||||
|
||||
|
||||
## 3.3 account_processor_link
|
||||
## 3.3 member_identifier
|
||||
|
||||
Identity documents associated with a member. Supports multiple IDs per member (driver's license, passport, school ID). Images stored as base64 in Postgres for simplified backup/restore.
|
||||
|
||||
Column | Type | Notes
|
||||
id | uuid PK |
|
||||
member_id | uuid FK | References member
|
||||
company_id | uuid FK | Tenant scoping
|
||||
type | varchar | Constrained: drivers_license, passport, school_id
|
||||
label | varchar | Optional display label
|
||||
value | varchar | The ID number
|
||||
issuing_authority | varchar | e.g. "State of Texas", "US Dept of State"
|
||||
issued_date | date |
|
||||
expires_at | date |
|
||||
image_front | text | Base64-encoded front image
|
||||
image_back | text | Base64-encoded back image
|
||||
notes | text |
|
||||
is_primary | boolean | Default false — which ID to display by default
|
||||
created_at | timestamptz |
|
||||
updated_at | timestamptz |
|
||||
|
||||
|
||||
|
||||
## 3.4 account_processor_link
|
||||
|
||||
Links an account to a payment processor's customer record. This is processor-agnostic — supports Stripe, Global Payments, or any future processor. Replaces the previous `stripe_customer_id` column that was directly on the account table.
|
||||
|
||||
@@ -315,7 +350,7 @@ timestamptz
|
||||
|
||||
An account may have links to multiple processors simultaneously — this is expected during migration from one processor to another (e.g. AIM legacy → Stripe transition).
|
||||
|
||||
## 3.4 account_payment_method
|
||||
## 3.5 account_payment_method
|
||||
|
||||
Tracks payment methods on file. Card data lives in the processor — this table only stores references for display and selection.
|
||||
|
||||
@@ -399,6 +434,32 @@ timestamptz
|
||||
|
||||
|
||||
|
||||
## 3.6 tax_exemption
|
||||
|
||||
Tax exemptions are tracked in a separate table (not on account) for audit history. An account can have multiple exemption records over time (expired, revoked, renewed).
|
||||
|
||||
Column | Type | Notes
|
||||
id | uuid PK |
|
||||
account_id | uuid FK |
|
||||
company_id | uuid FK | Tenant scoping
|
||||
status | enum | none, pending, approved
|
||||
certificate_number | varchar | Required
|
||||
certificate_type | varchar | e.g. "resale", "nonprofit"
|
||||
issuing_state | varchar(2) | State abbreviation
|
||||
expires_at | date |
|
||||
approved_by | uuid | Employee who verified
|
||||
approved_at | timestamptz |
|
||||
revoked_by | uuid |
|
||||
revoked_at | timestamptz |
|
||||
revoked_reason | text |
|
||||
notes | text |
|
||||
created_at | timestamptz |
|
||||
updated_at | timestamptz |
|
||||
|
||||
Action endpoints: POST /tax-exemptions/:id/approve, POST /tax-exemptions/:id/revoke (requires reason).
|
||||
|
||||
|
||||
|
||||
# 4. Business Rules
|
||||
|
||||
- Every member must belong to exactly one account
|
||||
@@ -417,11 +478,23 @@ timestamptz
|
||||
|
||||
- Duplicate account detection on email and phone during creation
|
||||
|
||||
- Account numbers auto-generated as 6-digit random numbers, unique per company
|
||||
|
||||
- Member numbers auto-generated as 6-digit random numbers, unique per company
|
||||
|
||||
- First member added to an account is auto-set as primary_member_id
|
||||
|
||||
- Members can be moved between accounts via POST /members/:id/move (optional accountId — creates new account if omitted)
|
||||
|
||||
- isMinor on member: explicit flag takes precedence, else derived from date_of_birth, else defaults to false
|
||||
|
||||
- Tax exemptions tracked in separate tax_exemption table for audit history — not on account directly
|
||||
|
||||
- Tax-exempt accounts must have a valid certificate number and expiry date before status can be set to "approved"
|
||||
|
||||
- Expired tax exemption certificates revert account to "pending" — staff prompted to collect updated certificate
|
||||
- Expired tax exemption certificates revert to "pending" — staff prompted to collect updated certificate
|
||||
|
||||
- Tax exemption status changes logged in audit trail (who approved, when, certificate details)
|
||||
- Tax exemption status changes logged with who approved/revoked, when, and reason
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user