Skip to content

CODE_MASTER Design & Convention

Overview

CODE_MASTER is the centralized reference-data management system for Client Processing. It stores all classification codes, status values, and enumeration codes used throughout the system. Instead of hard-coding business rules, CODE_MASTER enables flexible, audit-ready code management with optional attribute-driven behavior.

Architecture

Data Residency

  • Location: Database resident (PostgreSQL code_master, code_detail, code_attribute tables)
  • Rationale: Enables real-time changes, audit trail, and queries across all code domains without service restart
  • Not a server-side cache: Codes are queried from the database; caching is handled at application layer if needed

Design Pattern

CODE_MASTER is attribute-driven, supporting both:

  1. Simple codes: Static classification (e.g., document types: INVOICE, CREDIT_MEMO, STATEMENT)
  2. Attribute-based codes: Codes with business-logic attributes (e.g., WORKSHEET_STATUS.APPROVED with attribute FINAL=true to trigger cash application)

Core Tables

1. code_master (Header)

Stores the master code definitions.

FieldTypeNotes
code_master_typevarchar(50)Code domain (e.g., INVOICE_STATUS_CD, DOCUMENT_TYPE_CD) — part of PK
code_master_cdvarchar(50)Code value (e.g., DRAFT, ISSUED, PAID) — part of PK
code_master_descvarchar(255)Human-readable description (e.g., "Invoice sent to recipient")
created_by, created_dtvarchar(255), timestampAudit trail
updated_by, updated_dtvarchar(255), timestampAudit trail

Primary Key: (code_master_type, code_master_cd) — guarantees one definition per code

2. code_detail (Hierarchies & Relationships)

Tracks parent-child relationships, mappings, and equivalencies between codes across different domains.

FieldTypeNotes
code_master_typevarchar(50)Parent code domain — part of PK
code_master_cdvarchar(50)Parent code value — part of PK
detail_code_master_typevarchar(50)Child code domain — part of PK
detail_code_master_cdvarchar(50)Child code value — part of PK
relationship_typevarchar(50)CHILD, MAPS_TO, EQUIVALENT
sequence_nointegerOrder for multi-child relationships
active_indbooleanEnable/disable relationship without deletion
created_by, created_dtvarchar(255), timestampAudit trail
updated_by, updated_dtvarchar(255), timestampAudit trail

Primary Key: (code_master_type, code_master_cd, detail_code_master_type, detail_code_master_cd) — guarantees one relationship per pair

Use Cases:

  • Family → SubFamily hierarchy: (ISO20022_FAMILY, RCDT) → (ISO20022_SUBFAMILY, DMCT, CHILD)
  • Standard mappings: (BAI_CODE, 165) → (ISO20022_SUBFAMILY, APAC, MAPS_TO)
  • Code equivalencies: Mark codes as equivalent across systems for reporting

3. code_attribute (Attribute-Driven Business Logic)

Stores key-value pairs attached to codes, enabling attribute-driven behavior without modifying application code.

FieldTypeNotes
code_master_typevarchar(50)Code domain (e.g., WORKSHEET_STATUS_CD) — part of PK
codevarchar(50)Code value (e.g., APPROVED) — part of PK
attributevarchar(100)Attribute name (e.g., FINAL, ALLOW_EDIT, TRIGGER_GL_POST) — part of PK
valuevarchar(255)Attribute value (e.g., true, false, N, Y, 180)
descriptionvarchar(255)Explanation of the attribute (e.g., "When true, cash is considered applied")
created_by, created_dtvarchar(255), timestampAudit trail
updated_by, updated_dtvarchar(255), timestampAudit trail

Primary Key: (code_master_type, code, attribute) — guarantees one value per attribute

Example: Cash Receipt Worksheet status behavior

code_master_type: WORKSHEET_STATUS_CD
code: APPROVED
attribute: FINAL
value: "true"
description: "When true, cash in this worksheet is considered applied"

code_master_type: WORKSHEET_STATUS_CD
code: APPROVED
attribute: TRIGGER_GL_POST
value: "true"
description: "When true, GL entries are generated upon reaching this status"

CODE Master Types (Domains)

Status Codes

INVOICE_STATUS_CD — Invoice lifecycle

CodeDescriptionAttributes
DRAFTInvoice created, not yet sent
ISSUEDInvoice sent to recipientMarks when 14-day clock starts for WGA
IN_REVISIONInvoice being corrected before reissue
REISSUEDInvoice reissued from prior versionLinked via reissued_from_invoice_id
PAIDPayment received and applied
VOIDInvoice cancelled and replacedImmutable; original record preserved
CANCELLEDInvoice retracted before issuance

CREDIT_MEMO_STATUS_CD — Credit memo (adjustment) lifecycle

CodeDescription
DRAFTAdjustment created, not yet issued
ISSUEDAdjustment issued; terminal state

CLIENT_LETTER_STATUS_CD — Client letter (summarized statement) lifecycle

CodeDescription
DRAFTLetter created, not yet issued
ISSUEDLetter issued to recipient
VOIDLetter retracted

BILLING_ITEM_STATUS_CD — Billing item processing state

CodeDescription
UUnprocessed; waiting for billed or cancelled
BBilled; invoiced to client
XCancelled; no longer valid
CCollected; payment applied

CASH_RECEIPT_WORKSHEET_STATUS_CD — Worksheet classification

CodeDescriptionAttributes
DRAFTWorksheet open for edits
APPLIEDCash identified and applied to invoices
SETTLEDCash settled and final
APPROVEDApproved for GL posting and paymentFINAL=true, TRIGGER_GL_POST=true
RETURNEDRejected; cash returned to receipt

PARTICIPANT_SETTLEMENT_STATUS_CD — Participant settlement state (6-letter codes)

CodeDescription
DDraft; settlement under preparation
TSettled; final calculation ready
AApproved; authorized for payment
RReturned; rejected and reopened
PPaid; payment executed

SETTLEMENT_PACKET_STATUS_CD — Batch settlement processing

Multiple codes tracking the settlement pipeline (values to be documented per settlement service)

POSTING_STATUS_CD — GL posting state (universal across transactions)

CodeDescription
UUnposted; waiting for GL batch
PPosted; GL entry created
X or VVoided; GL entry reversed (immutable)
FFailed; posting error

REVENUE_ITEM_STATUS_CD — Revenue line-item classification

CodeDescription
UUnearned; waiting for revenue trigger
CCollected; revenue recognized
MModified; updated after recognition

REVENUE_ITEM_DATE_STATUS_CD — Revenue date validation

CodeDescription
UUnvalidated; date pending milestone confirmation
CConfirmed; revenue date locked

Document & Scope Codes

DOCUMENT_TYPE_CD — Document classification

CodeDescriptionNotes
CIClient InvoiceStandard invoice to client
BIBooking InternalInternal booking statement
DMDeal MemoContract summary
CMCredit MemoAdjustment/correction document
FCFinancial CertificateAccounting certification
CLClient LetterSummarized client statement (new)

SCOPE_CD — Client letter filtering scope

CodeDescription
INVOICED_ONLYShow only invoiced items
UNINVOICED_ONLYShow only uninvoiced items (accruals, adjustments)
ALLShow all items

SUMMARIZE_BY_CD — Client letter summarization method

CodeDescription
NONEShow all line items; no rollup
DEALSummarize by deal, with detail breakdown
SALES_ITEMSummarize by sales item within deal

Adjustment & Reason Codes

ADJUSTMENT_TYPE_CD — Credit memo adjustment type

CodeDescriptionSign Convention
FULL_CREDITCancel/reverse invoice entirelyNegative (reduces amount due)
DEBITSupplemental billingPositive (increases amount due)
CREDITPartial credit/discountNegative (reduces amount due)

CREDIT_MEMO_REASON_CD — Why adjustment was issued

CodeDescription
FULL_CANCELLATIONOriginal invoice is void; credit memo replaces it
PRICE_CORRECTIONPrice error in original invoice
INCORRECT_VATTax/withholding error
OTHERMiscellaneous (see memo notes)

Task & Workflow Codes

TASK_STATUS_CD — Workflow task state

CodeDescription
OPENTask created, not started
WORKINGTask in progress
WAITINGTask blocked awaiting external input
COMPLETETask finished
CANCELLEDTask abandoned

DOC_EXECUTION_STATUS_CD — Document generation state

CodeDescription
PENDINGQueued for generation
PENDING_REVIEWGenerated; awaiting approval
APPROVEDApproved for delivery
REJECTEDGeneration failed or denied
SUCCESSDocument delivered
PARTIALSome recipients failed
FAILUREGeneration error

GENERATION_STATUS_CD — Statement/report generation progress

CodeDescription
PENDINGGeneration queued
GENERATINGIn progress
COMPLETEDReady for download
FAILEDGeneration error

Entity State Codes

ACCOUNT_STATUS_CD — General ledger account state

CodeDescription
AActive
IInactive

STATUS_CD (generic) — Default active/inactive indicator

CodeDescription
ACTIVEEntity is active
INACTIVEEntity is inactive

Naming Convention

Code Master Type Naming

  • Format: {DOMAIN}_{CONCEPT}_CD or {DOMAIN}_STATUS_CD
  • Rationale: Clear, searchable, and explicitly marks that it's a CODE_MASTER type
  • Examples:
    • INVOICE_STATUS_CD (status codes within invoicing domain)
    • DOCUMENT_TYPE_CD (document classification; cross-domain)
    • POSTING_STATUS_CD (GL posting state; universal)

Code Value Naming

  • Short codes (preferred): 1–5 characters for database compactness and UI display
    • Examples: DRAFT, PAID, U, P, X
    • Use for high-volume fields (millions of rows) or frequent filtering
  • Descriptive codes: Full words for clarity when code readability matters
    • Examples: FULL_CANCELLATION, PRICE_CORRECTION
    • Use for infrequently changed or audit-critical fields

Mixed Naming Across Domains

Some legacy domains use mixed approaches:

  • Invoicing: Descriptive (DRAFT, ISSUED, PAID)
  • GL: Short codes (U, P, X)
  • Settlement: Short codes (D, T, A, R, P)

Future: Standardize on descriptive names for new code types; legacy codes remain as-is for backwards compatibility.

Audit & Change Tracking

All CODE_MASTER tables include audit columns:

  • created_by, created_dt — record creator and timestamp
  • updated_by, updated_dt — last modifier and timestamp

Change Control

  • Adds: New codes are inserted with creator and timestamp; backward compatible
  • Updates: Description or non-structural changes update updated_by and updated_dt
  • Deletes: Not recommended — instead, use active_ind = false in code_detail to disable relationships without deleting
  • Immutable codes: Code values themselves are immutable (PK); never rename or delete

Design Decisions Pending (CP-DM-001, CP-DM-002)

1. CODE_MASTER Location & Caching Strategy (CP-DM-001)

Status: DATABASE RESIDENT (confirmed in cp-poc)

Currently implemented as database tables. Options for future consideration:

  • Caching Layer: Implement application-level caching (Redis, in-memory) for read-heavy workloads
  • Change Notifications: Event-driven cache invalidation when codes are updated
  • Read Replicas: Replicate CODE_MASTER to read-only instances for reporting

2. Attribute-Driven Business Logic (CP-DM-002)

Status: ARCHITECTURE DESIGNED; IMPLEMENTATION PENDING

The code_attribute table is built to support rules-driven behavior. Decision pending:

  • Rules Engine: Centralize business logic in a rules engine that queries code_attribute at runtime
  • Application Integration: Each service that depends on attributes reads them from code_attribute and acts accordingly
  • Scope: Decide which behaviors should be attribute-driven (e.g., WORKSHEET_STATUS triggers) vs. hard-coded

3. Seeding & Naming Convention (CP-DM-003)

Status: PARTIAL — Some codes defined in schema; naming convention refinement pending

Current State:

  • Code types are scattered across service initialization and seed data
  • No unified seed file; each domain manages its own codes

Action Item:

  • Consolidate all CODE_MASTER seed values into a single seed script
  • Standardize naming convention (short vs. descriptive) per domain
  • Document required codes for each service startup

Migration & Rollout

Adding New Codes

  1. Insert row in code_master with new code_master_cd and description
  2. If code has behavior attributes, insert corresponding rows in code_attribute
  3. If code relates to other codes, insert rows in code_detail
  4. No application restart required; services query the database

Adding New Code Attributes

  1. Insert row in code_attribute with the attribute name and value
  2. Update application code to check the attribute at runtime (if not yet implemented)
  3. Audit trail preserved; attribute change history queryable

Removing or Deprecating Codes

  • Unused codes: Safe to delete (full table delete with audit backup)
  • In-use codes: Mark as inactive in code_detail relationships; keep the code_master row for historical traceability

References

Confidential. For internal use only.

Loading...