Skip to content

Worksheets Data Model

1. Executive Summary

The worksheets domain manages the central working document for cash application -- the cash receipt worksheet. A worksheet is where incoming cash (from a buyer's payment) is allocated against specific receivables (billing item details), on-account client ledger entries, and ultimately transformed into outbound payment items destined for the client and their party.

Every dollar that enters the system through a cash receipt must flow through a worksheet before it can be posted to the general ledger (REV) or sent to a bank as an outbound payment (PAY). The worksheet enforces a multi-step approval lifecycle with distinct roles at each stage, ensuring segregation of duties between cash application, settlement creation, and final approval.

Tables covered in this document:

  • cash_receipt_worksheet -- The worksheet header: status, lifecycle timestamps, return/reversal linkage
  • cash_receipt_application -- Individual cash applications against billing item details (REV and PAY receivables)
  • cash_receipt_application_deduction -- Deductions applied at the application level (tax withholding, bank charges, etc.)
  • cash_receipt_client_ledger -- Cash applied on-account to a client ledger entry rather than a specific receivable
  • cash_receipt_payout -- Outbound payment line items derived from settlements or passthroughs
  • client_ledger -- On-account ledger entries for deal/entity/department/client

Position in the financial flow:

Cash Receipt (money arrives)
  --> Cash Receipt Split (portion of receipt)
    --> WORKSHEET (this document)
          |
          |--> cash_receipt_application (allocate to REV / PAY receivables)
          |      `--> cash_receipt_application_deduction (tax, withholding, etc.)
          |
          |--> cash_receipt_client_ledger (allocate to on-account ledger)
          |      `--> client_ledger (the on-account ledger entry itself)
          |
          `--> cash_receipt_payout (payment line items for outbound bank transmission)
                 `--> payment_item (created at Approval)

A worksheet belongs to exactly one cash receipt split. Each split can have at most one active worksheet (current_item_ind = true). Historical worksheets (returned, reversed) remain linked to the split but with current_item_ind = false.


2. Data Model

2.0 Entity Relationship Diagram

mermaid
erDiagram
    CASH_RECEIPT_SPLIT ||--o{ CASH_RECEIPT_WORKSHEET : "has (at most one active)"
    CASH_RECEIPT_WORKSHEET ||--o{ CASH_RECEIPT_APPLICATION : contains
    CASH_RECEIPT_WORKSHEET ||--o{ CASH_RECEIPT_CLIENT_LEDGER : contains
    CASH_RECEIPT_WORKSHEET ||--o{ CASH_RECEIPT_PAYOUT : contains
    CASH_RECEIPT_APPLICATION ||--o{ CASH_RECEIPT_APPLICATION_DEDUCTION : has
    CASH_RECEIPT_APPLICATION }o--|| BILLING_ITEM_DETAIL : "applies to"
    CASH_RECEIPT_APPLICATION }o--o| PARTICIPANT_SETTLEMENT : "linked via"
    CASH_RECEIPT_CLIENT_LEDGER }o--|| CLIENT_LEDGER : "credits"
    CLIENT_LEDGER }o--|| PARTY : "belongs to"
    CLIENT_LEDGER }o--o| DEAL : "scoped to"
    CLIENT_LEDGER }o--o| UTA_ENTITY : "billed by"
    CLIENT_LEDGER }o--o| DEPARTMENT : "within"
    CASH_RECEIPT_PAYOUT }o--o| PAYMENT_ITEM : "creates"
    CASH_RECEIPT_PAYOUT }o--o| PARTICIPANT_SETTLEMENT_ITEM : "derived from"
    CASH_RECEIPT_PAYOUT }o--o| PARTY : "paid to"
    CASH_RECEIPT_PAYOUT }o--o| BANK_ACCOUNT : "sent via"
    CASH_RECEIPT_WORKSHEET ||--o| CASH_RECEIPT_WORKSHEET : "replaced_by / previous"

    CASH_RECEIPT_WORKSHEET {
        serial cash_receipt_worksheet_id PK
        integer cash_receipt_split_id FK
        integer worksheet_sequence
        boolean current_item_ind
        varchar cash_receipt_worksheet_status_cd
        integer locked_by_user_id FK
        varchar worksheet_type_cd
        varchar posting_status_cd
        date posting_dt
        integer replaced_by_worksheet_id FK
        integer previous_worksheet_id FK
    }

    CASH_RECEIPT_APPLICATION {
        serial cash_receipt_application_id PK
        integer cash_receipt_worksheet_id FK
        integer billing_item_detail_id FK
        integer participant_settlement_id FK
        decimal cash_receipt_amt_applied
        integer reversal_of_application_id
        varchar reversal_reason_cd
    }

    CASH_RECEIPT_APPLICATION_DEDUCTION {
        serial cash_receipt_application_deduction_id PK
        integer cash_receipt_application_id FK
        varchar billing_item_deduction_type_cd
        decimal deduction_amt_applied
    }

    CASH_RECEIPT_CLIENT_LEDGER {
        serial cash_receipt_client_ledger_id PK
        integer cash_receipt_worksheet_id FK
        integer client_ledger_id FK
        integer deal_id FK
        integer uta_entity_id FK
        integer department_id FK
        integer client_id FK
        decimal cash_receipt_amt_applied
        integer reversal_of_ledger_id
        varchar reversal_reason_cd
    }

    CLIENT_LEDGER {
        serial client_ledger_id PK
        integer client_id FK
        integer contracted_party_id FK
        integer buyer_id FK
        integer deal_id FK
        integer uta_entity_id FK
        integer department_id FK
        varchar client_ledger_type_cd
        varchar client_ledger_status_cd
        decimal client_ledger_amt
        varchar client_ledger_currency_cd
        boolean client_ledger_open_item_ind
        varchar posting_status_cd
    }

    CASH_RECEIPT_PAYOUT {
        serial cash_receipt_payout_id PK
        integer cash_receipt_worksheet_id FK
        integer payout_party_id FK
        integer payment_party_bank_id FK
        integer payment_item_id FK
        integer participant_settlement_item_id FK
        varchar payment_item_type_cd
        decimal payment_item_amt
        varchar payment_item_currency_cd
        varchar payout_status_cd
        boolean do_not_send_ind
        integer reversal_of_payout_id
    }

2.1 cash_receipt_worksheet

The worksheet header record. Tracks lifecycle status, workflow timestamps, return/reversal linkage, and posting state.

FieldTypeRequiredDefaultDescription
cash_receipt_worksheet_idserialYesAutoPrimary key.
cash_receipt_split_idintegerNonullFK to cash_receipt_split. Null only for legacy worksheets that predate the split model.
worksheet_sequenceintegerNonullOrdinal within the receipt (1, 2, 3...). Used for display ordering when a receipt has multiple splits.
current_item_indbooleanNotrueWhether this is the active worksheet for its split. Set to false when a worksheet is returned or replaced. Only one worksheet per split should have current_item_ind = true.
cash_receipt_worksheet_status_cdvarchar(50)No'D'Current lifecycle status. Values: D (Draft), P (Applied), T (Settled), A (Approved), R (Returned), S (Submitted -- deprecated). See Status Lifecycle section.
locked_by_user_idintegerNonullFK to users. The user currently holding an edit lock on this worksheet. Null when unlocked. Prevents concurrent editing.
applied_dttimestampNonullTimestamp when worksheet transitioned to Applied status.
applied_byvarchar(100)NonullDisplay name of the user who applied the worksheet.
settled_dttimestampNonullTimestamp when worksheet transitioned to Settled status.
settled_byvarchar(100)NonullDisplay name of the user who settled the worksheet.
approved_dttimestampNonullTimestamp when worksheet transitioned to Approved status.
approved_byvarchar(100)NonullDisplay name of the user who approved the worksheet.
returned_dttimestampNonullTimestamp when the worksheet was returned (sealed).
returned_byvarchar(100)NonullDisplay name of the user who returned the worksheet.
return_reasontextNonullFree-text reason provided when the worksheet is returned.
replaced_by_worksheet_idintegerNonullSelf-FK. Points to the replacement draft worksheet created after this worksheet was returned. Set on the original (returned) worksheet.
previous_worksheet_idintegerNonullSelf-FK. Points to the returned worksheet that this worksheet replaces. Set on the replacement draft worksheet.
worksheet_type_cdvarchar(20)NonullClassifies the worksheet's role in the return chain. Values: ORIGINAL, REVERSAL, REPLACEMENT. Null for worksheets that have never been through a return cycle.
posting_status_cdvarchar(50)NonullGL posting pickup status. Values: U (Unposted -- ready for pickup), P (Posted), X (Skipped). Set to U when the worksheet transitions to Applied.
posting_dtdateNonullThe date the worksheet was posted to the general ledger.

Legacy fields (deprecated):

FieldTypeRequiredDefaultDescription
submitted_dttimestampNonullTimestamp of legacy Submit action.
submitted_byvarchar(100)NonullUser who performed legacy Submit.
rejected_dttimestampNonullTimestamp of legacy Reject action.
rejected_byvarchar(100)NonullUser who performed legacy Reject.
rejection_reasontextNonullReason for legacy rejection.

WARNING

The submitted_dt, submitted_by, rejected_dt, rejected_by, and rejection_reason fields exist for backward compatibility with legacy status S (Submitted). New code must not use these fields. The current lifecycle uses Applied (P) instead of Submitted (S).

Database indexes:

IndexColumnsPurpose
cash_receipt_worksheet_current_item_idxcurrent_item_indFast lookup of active worksheets
cash_receipt_worksheet_split_idxcash_receipt_split_idSplit-to-worksheet navigation
cash_receipt_worksheet_status_idxcash_receipt_worksheet_status_cdStatus-based queue filtering
cash_receipt_worksheet_current_status_idxcurrent_item_ind, cash_receipt_worksheet_status_cdComposite for common "active worksheets by status" queries

2.2 cash_receipt_application

Records the application of cash to a specific billing item detail (REV or PAY receivable). Each row represents one application event. The same billing item detail can appear multiple times on the same worksheet as separate application records (for credits, adjustments, or partial applications).

FieldTypeRequiredDefaultDescription
cash_receipt_application_idserialYesAutoPrimary key.
cash_receipt_worksheet_idintegerNonullFK to cash_receipt_worksheet. Links the application to its parent worksheet.
billing_item_detail_idintegerNonullFK to billing_item_detail. The specific REV or PAY receivable line being applied against. Nullable when the application targets a settlement directly.
participant_settlement_idintegerNonullFK to participant_settlement. Links PAY applications to their settlement. Populated when a settlement is created for this application's PAY receivable.
cash_receipt_amt_applieddecimal(15,2)NonullThe dollar amount applied. Positive for normal applications, negative for reversal entries.
reversal_of_application_idintegerNonullSelf-FK. Points to the original cash_receipt_application_id that this record reverses. Populated on reversal worksheet entries.
reversal_reason_cdvarchar(20)NonullReason code for the reversal. Example: WORKSHEET_RETURN.

IMPORTANT

A single billing_item_detail_id can appear multiple times on the same worksheet as separate application records. This supports incremental application events, adjustments, and credits. However, cross-worksheet exclusivity applies: an active (non-returned, non-approved) application for a given billing item detail should not exist on a different active worksheet.

Database indexes:

IndexColumnsPurpose
cash_receipt_app_billing_item_detail_idxbilling_item_detail_idFast lookup by receivable
cash_receipt_app_worksheet_idxcash_receipt_worksheet_idAll applications for a worksheet
cash_receipt_app_worksheet_billing_idxcash_receipt_worksheet_id, billing_item_detail_idComposite for worksheet + receivable queries

2.3 cash_receipt_application_deduction

Tracks deductions applied at the individual application level. These are adjustments that reduce or supplement the net application amount -- for example, tax withholding, bank charges, or discounts.

FieldTypeRequiredDefaultDescription
cash_receipt_application_deduction_idserialYesAutoPrimary key.
cash_receipt_application_idintegerYes--FK to cash_receipt_application. Every deduction must be linked to a parent application.
billing_item_deduction_type_cdvarchar(50)NonullCode master type BILLING_ITEM_DEDUCTION_TYPE_CD. Classifies the deduction (Tax, Withholding, Bank Charge, etc.). See Code Master Values section.
deduction_amt_applieddecimal(15,2)NonullThe deduction amount.

NOTE

Application-level deductions are distinct from billing item deductions (billing_item_deduction). Billing item deductions exist on the receivable itself; application-level deductions are recorded when cash is applied and may differ from what was originally estimated on the billing item.

2.4 cash_receipt_client_ledger

Records cash applied on-account to a client ledger entry rather than to a specific billing item receivable. Used when cash arrives but cannot yet be matched to a specific deal or billing item, or when cash is explicitly held on account for future application.

FieldTypeRequiredDefaultDescription
cash_receipt_client_ledger_idserialYesAutoPrimary key.
cash_receipt_worksheet_idintegerNonullFK to cash_receipt_worksheet. Links the ledger application to its parent worksheet.
client_ledger_idintegerNonullFK to client_ledger. The target on-account ledger entry.
deal_idintegerNonullFK to deal. Optional deal context for the on-account entry.
uta_entity_idintegerNonullFK to uta_entity. The UTA billing entity associated with the ledger entry.
department_idintegerNonullFK to department. The UTA department associated with the ledger entry.
client_idintegerNonullFK to party (client). The client whose on-account balance is being credited.
cash_receipt_amt_applieddecimal(15,2)NonullAmount applied to the client ledger. Positive for normal credits, negative for reversals.
reversal_of_ledger_idintegerNonullSelf-FK. Points to the original cash_receipt_client_ledger_id being reversed. Populated on reversal worksheet entries.
reversal_reason_cdvarchar(20)NonullReason code for the reversal. Example: WORKSHEET_RETURN.

IMPORTANT

Client ledger entries are always reversible because the money remains in UTA's accounts. On worksheet return, client ledger entries from the original worksheet are always copied to the replacement draft as editable entries (unlike locked PAY applications which are read-only).

2.5 cash_receipt_payout

Represents an outbound payment line item on the worksheet. Payouts are created during the settlement process and drive the creation of payment_item records at worksheet approval. Each payout represents a specific amount owed to a specific party.

FieldTypeRequiredDefaultDescription
cash_receipt_payout_idserialYesAutoPrimary key.
cash_receipt_worksheet_idintegerNonullFK to cash_receipt_worksheet. Links the payout to its parent worksheet.
payout_party_idintegerNonullFK to party. The party who will receive this payment (client, manager, attorney, etc.).
payment_party_bank_idintegerNonullFK to bank_account. The destination bank account for this payment.
payment_item_idintegerNonullFK to payment_item. Populated after worksheet approval when the business payment record is created.
participant_settlement_item_idintegerNonullFK to participant_settlement_item. Links the payout to a specific settlement line item. Required for settlement-derived payouts (type S).
deal_idintegerNonullFK to deal. Deal context for the payout.
buyer_idintegerNonullFK to party (buyer). The original buyer who paid.
uta_entity_idintegerNonullFK to uta_entity. The UTA entity from which the payment is sent.
department_idintegerNonullFK to department. The department associated with this payout.
payment_item_namevarchar(500)NonullDescriptive label for the payment line item. Displayed on payment advices and bank transmissions.
payment_item_type_cdvarchar(50)NonullCode master type PAYMENT_ITEM_TYPE_CD. Classifies the payout. Values: S (Settlement), P (Passthrough), L (Ledger/Loan), R (Reversal), V (VAT Pass-Through).
payment_item_amtdecimal(15,2)NonullThe payment amount.
payment_item_currency_cdvarchar(10)NonullISO currency code of the payout amount (e.g., USD, GBP, EUR).
payment_datedateNonullTarget date for the payment to be sent.
client_currency_conversion_indbooleanNonullWhen true, indicates the payout requires currency conversion before bank transmission.
target_currency_cdvarchar(10)NonullThe destination currency for conversion. Only relevant when client_currency_conversion_ind = true.
payout_status_cdvarchar(20)NonullPayout lifecycle status. Values: PENDING, PAID, RETURNED, CANCELLED.
returned_dttimestampNonullTimestamp when the payout was returned or cancelled.
returned_by_user_idintegerNonullUser ID who returned the payout.
reversal_of_payout_idintegerNonullSelf-FK. Points to the original payout being reversed. Populated on reversal worksheet entries.
reversal_reason_cdvarchar(50)NonullReason code for the reversal. Example: WORKSHEET_RETURN.
do_not_send_indbooleanNofalseWhen true, the associated payment item will not be transmitted to the bank. Used during reopen to prevent premature bank transmission of re-created payment items. Reset to false on worksheet approval for unlocked items.

NOTE

Settlement-derived payouts (payment_item_type_cd = 'S') must total to the PAY amount applied on the worksheet. The sum of all S-type payouts must equal the sum of all PAY applications for the worksheet to be considered fully settled.

2.6 client_ledger

The on-account ledger entry itself. Represents a standing balance for a client scoped to a deal, entity, and department. Cash receipt client ledger records (cash_receipt_client_ledger) reference these entries when applying cash on-account. Client ledger entries support both on-account (OA) and loan (LOAN) types, with their own lifecycle and GL posting state.

FieldTypeRequiredDefaultDescription
client_ledger_idserialYesAutoPrimary key.
client_idintegerYes--FK to party. The client who owns this ledger entry.
contracted_party_idintegerNonullFK to party. The contracted party (e.g., loan company) associated with this ledger entry.
buyer_idintegerNonullFK to party. The buyer associated with this ledger entry.
deal_idintegerNonullFK to deal. Deal context for the ledger entry.
uta_entity_idintegerNonullFK to uta_entity. The UTA billing entity associated with the ledger entry.
department_idintegerNonullFK to department. The UTA department associated with the ledger entry.
client_ledger_type_cdvarchar(50)NonullCode master type CLIENT_LEDGER_TYPE_CD. Classifies the ledger entry. Values: OA (On-Account), LOAN (Loan).
client_ledger_status_cdvarchar(50)NonullCode master type CLIENT_LEDGER_STATUS_CD. Lifecycle status. Values: D (Draft), V (Void), C (Closed).
client_ledger_namevarchar(255)NonullDescriptive label for the ledger entry.
client_ledger_amtdecimal(20,2)NonullThe ledger entry amount. Precision: 20 digits, 2 decimal places.
client_ledger_currency_cdvarchar(10)NonullISO currency code for the ledger amount (e.g., USD, GBP).
client_ledger_start_dtdateNonullEffective start date of the ledger entry (e.g., loan start date).
client_ledger_end_dtdateNonullEffective end date of the ledger entry (e.g., loan maturity date).
client_ledger_notesvarchar(2000)NonullFree-text notes about the ledger entry.
client_ledger_open_item_indbooleanNonullWhether this ledger entry is still open for cash application. Set to false when fully applied or closed.
client_ledger_payment_item_idintegerNonullFK to payment_item. The payment item associated with a loan-type ledger entry.
posting_status_cdvarchar(50)NonullGL posting pickup status. Values: U (Unposted), P (Posted), X (Skipped).
posting_dtdateNonullThe date the ledger entry was posted to the general ledger.

3. Status Lifecycle

The worksheet follows a strict forward-only lifecycle. No worksheet ever moves backward in status. Corrections are handled through the return/reopen mechanism which produces new documents rather than modifying the original.

3.1 Worksheet Status

StatusCodeDescriptionAllowed Transitions
DraftDInitial editable state. Users add and modify cash applications.P (Applied)
AppliedPCash applications finalized. REV staged for GL posting. Settlements can be created for PAY.T (Settled)
SettledTAll PAY applications have settlements. Awaiting final approval.A (Approved)
ApprovedAFinal approval. Payment items created and ready for bank transmission.R (Returned)
ReturnedRWorksheet sealed as read-only historical record.Terminal
SubmittedSDeprecated. Legacy status between Draft and Approved. Replaced by Applied (P).A (legacy only)
mermaid
stateDiagram-v2
    [*] --> D : Create worksheet
    D --> P : Apply
    P --> T : Settle
    T --> A : Approve
    A --> R : Return
    R --> [*]

    state "Draft (D)" as D
    state "Applied (P)" as P
    state "Settled (T)" as T
    state "Approved (A)" as A
    state "Returned (R)" as R

3.2 Transition Details

Draft (D) to Applied (P)

  • Trigger: User with canApplyWorksheet permission clicks Apply.
  • Preconditions: cash_receipt_worksheet_status_cd = 'D'; at least one application exists across cash_receipt_application, cash_receipt_client_ledger, or cash_receipt_payout. Partial application is allowed (worksheet balance does not need to equal zero).
  • Side-effects: posting_status_cd set to U (Unposted), marking REV applications and client ledger entries as ready for GL posting pickup. applied_dt and applied_by are recorded.

Applied (P) to Settled (T)

  • Trigger: User with canSettleWorksheet permission clicks Settle.
  • Preconditions: cash_receipt_worksheet_status_cd = 'P'; all PAY applications must have a linked participant_settlement_id. Settlement payout totals (type S) must equal total PAY applied.
  • Side-effects: settled_dt and settled_by are recorded. All linked participant_settlement records are updated to Settled status (T).

Settled (T) to Approved (A)

  • Trigger: User with canApproveWorksheet permission clicks Approve.
  • Preconditions: cash_receipt_worksheet_status_cd = 'T' (or 'D'/'S' with elevated privilege for legacy/shortcut flows); at least one application exists.
  • Side-effects: approved_dt and approved_by are recorded. All linked settlements are approved. payment_item records are created from cash_receipt_payout entries. do_not_send_ind is reset to false on unlocked payment items so bank transmission jobs pick them up. Fully paid billing items are closed (open_item_ind = false). Receipt lock is released.

Approved (A) to Returned (R)

  • Trigger: User with canReopenWorksheet permission initiates a Return (also called "Reopen").

  • Preconditions: cash_receipt_worksheet_status_cd = 'A'; receipt type must not be WRITE_OFF (write-off worksheets use a separate recovery process); worksheet must have a cash_receipt_split_id.

  • Side-effects: Returning an approved worksheet always produces three documents:

    1. Original -- sealed as Returned (R), current_item_ind = false, worksheet_type_cd = 'ORIGINAL'
    2. Reversal worksheet -- auto-created with negative entries for ALL items (including locked), worksheet_type_cd = 'REVERSAL', current_item_ind = false, posting_status_cd = 'U'
    3. Replacement draft -- only LOCKED items copied as read-only; unlocked items NOT pre-populated, worksheet_type_cd = 'REPLACEMENT', current_item_ind = true

    returned_dt, returned_by, and return_reason are recorded on the original. replaced_by_worksheet_id on the original points to the replacement draft. previous_worksheet_id on the replacement draft points to the original.

IMPORTANT

The replacement draft contains ONLY locked applications copied as read-only context -- those with payment items that have been sent to the bank and cannot be reversed. Unlocked applications are NOT pre-populated. Users must add fresh applications manually. This prevents duplicate accumulation across successive returns.

3.3 Roles per Transition

FromToActionRoleKey Preconditions
--DCreateCASH_MANAGER, ITSplit exists; receipt not voided/posted; no active worksheet for split
DPApplyCASH_MANAGER, ITAt least one application exists
PTSettleCASH_PROCESSOR, ITAll PAY applications have settlements
TAApproveSETTLEMENT_APPROVER, ITSettlements reviewed
ARReturnSETTLEMENT_APPROVER, ITNot a write-off worksheet; produces 3 documents

3.4 Client Ledger Status

StatusCodeDescriptionAllowed Transitions
DraftDLedger entry created, editable.V (Void), C (Closed)
VoidVLedger entry voided/cancelled.Terminal
ClosedCLedger entry fully applied and closed.Terminal

3.5 Payout Status

StatusCodeDescriptionAllowed Transitions
PendingPENDINGPayout created but payment not yet sent to bank.PAID, RETURNED, CANCELLED
PaidPAIDBank has confirmed payment completion.Terminal
ReturnedRETURNEDPayout returned during a worksheet return process.Terminal
CancelledCANCELLEDPayout cancelled before payment was sent.Terminal

3.6 Payment Item Locking Rules

The locking logic determines what can and cannot be reversed during a return:

Execution StatusLocked?Behavior on Return
null / emptyNoUnlocked -- payment voided, not copied to replacement draft
WAITINGNoUnlocked -- payment voided, not copied to replacement draft
PENDINGNoUnlocked -- payment voided, not copied to replacement draft
FAILEDNoUnlocked -- payment voided, not copied to replacement draft
PROCESSINGYesLocked -- copied as read-only to replacement draft
SENTYesLocked -- copied as read-only to replacement draft
ACKNOWLEDGEDYesLocked -- copied as read-only to replacement draft
PAIDYesLocked -- copied as read-only to replacement draft

IMPORTANT

When ANY payment item in a settlement is locked, the ENTIRE settlement locks -- all settlement items, associated PAY applications, and bilateral REV applications are locked together. This is the "bilateral lock" rule: a locked PAY application also locks its paired REV application within the same settlement.


4. Validation & Database Constraints

4.1 Unique Constraints

TableConstraintColumnsBusiness Rule
cash_receipt_worksheetOne active worksheet per splitcash_receipt_split_id, current_item_indOnly one worksheet with current_item_ind = true per split. Enforced by business logic at creation time, not by a database unique constraint.
cash_receipt_application_deductionNOT NULL on parent FKcash_receipt_application_idEvery deduction must belong to an application. Enforced by database NOT NULL constraint.
client_ledgerNOT NULL on client FKclient_idEvery ledger entry must belong to a client. Enforced by database NOT NULL constraint.

4.2 Business Validation Rules

Worksheet creation:

  • The parent cash_receipt_split must exist.
  • The grandparent cash_receipt must not have posting_status_cd of V (Voided) or P (Posted).
  • No other active worksheet (current_item_ind = true) may exist for the same split.
  • The receipt must not be locked by a different user.

Apply transition (D to P):

  • At least one record must exist across cash_receipt_application, cash_receipt_client_ledger, or cash_receipt_payout.
  • Partial application is allowed -- the worksheet balance does not need to equal zero.

Settle transition (P to T):

  • All PAY-type applications (billing_item_detail_type_cd = 'PAY') must have a non-null participant_settlement_id.
  • The sum of settlement payouts (type S) must match the total PAY amount applied.

Approve transition (T to A):

  • At least one application must exist.
  • For legacy/shortcut flows, elevated privilege (SETTLEMENT_APPROVER or IT) allows approval directly from Draft (D) or Submitted (S).

Return/Reopen:

  • Only worksheets in Approved (A) status can be returned.
  • Write-off worksheets (receipt_type_cd = 'WRITE_OFF') cannot be returned; they use a separate recovery process.
  • Worksheet must have a cash_receipt_split_id (legacy worksheets without a split cannot be reopened).

4.3 Amount Precision

ContextPrecisionScaleMax Value
cash_receipt_amt_applied1529,999,999,999,999.99
deduction_amt_applied1529,999,999,999,999.99
payment_item_amt1529,999,999,999,999.99
client_ledger_amt20299,999,999,999,999,999.99

NOTE

Balance comparison tolerance (epsilon) is 0.005. When checking if a worksheet balance is zero or if a billing item is fully paid, amounts within 0.005 of zero are treated as zero.


5. Code Master Values

All code master values are stored in the code_master table with a composite primary key of (code_master_type, code_master_cd).

5.1 CASH_RECEIPT_WORKSHEET_STATUS_CD

CodeDescriptionBehavior / When Used
DDraftInitial editable state. Users add and modify cash applications.
PAppliedCash applications finalized. REV staged for GL posting. Settlements can be created for PAY. Not present in legacy seed data -- introduced in the current lifecycle.
TSettledAll PAY applications have settlements. Awaiting final approval. Not present in legacy seed data -- introduced in the current lifecycle.
SSubmittedDeprecated. Legacy status between Draft and Approved. Replaced by Applied (P) in the current lifecycle. Retained for backward compatibility.
AApprovedFinal approval. Payment items created and ready for bank transmission.
RReversed / ReturnedWorksheet sealed as read-only historical record. Accompanied by a reversal worksheet and replacement draft.

NOTE

The seed data lists statuses D, S, A, R. Statuses P (Applied) and T (Settled) were added as part of the current multi-step lifecycle and should be added to the code master seed if not already present.

5.2 POSTING_STATUS_CD

CodeDescriptionBehavior / When Used
UUnpostedReady for pickup by the GL posting process. Set when a worksheet transitions to Applied.
PPostedGL posting has been completed for this worksheet.
XSkippedGL posting was skipped (e.g., for reversal worksheets where the original was never posted, or for voided items).

5.3 PAYMENT_ITEM_TYPE_CD

Used on cash_receipt_payout.payment_item_type_cd to classify payout line items.

CodeDescriptionBehavior / When Used
SSettlementDerived from a participant settlement. The primary payout type. Settlement payouts must sum to total PAY applied.
PPassthroughDirect payment to a party, bypassing the settlement process. Used for one-off payments.
LLoan / LedgerPayment against a client ledger loan entry.
RReversal / RefundReversal of a prior payout, created during the return process.
VVAT Pass-ThroughVAT amount passed through to the payee. Used in UK tax scenarios.

5.4 BILLING_ITEM_DEDUCTION_TYPE_CD

Used on cash_receipt_application_deduction.billing_item_deduction_type_cd to classify application-level deductions.

CodeDescriptionBehavior / When Used
TTaxGeneral tax deduction.
WWithholdingGeneral withholding deduction.
BBank ChargeBank fees deducted from the application amount.
DDiscountDiscount applied at the time of cash application.
RReimbursementReimbursement adjustment.
CClient RequestDeduction at client's request.
DPDirect PaymentAmount already paid directly, deducted from application.
WH_US_NRAUS NRA Withholding (30%)US non-resident alien withholding. Applied to payments to non-US persons without a CWA.
WH_UK_FEUUK FEU Withholding (20%)UK Foreign Entertainers Unit withholding. Applied when cumulative UK earnings exceed the personal allowance threshold.
VAT_ARTISTVAT on Artist Fee (20%)UK VAT on the artist's fee portion. Applied for UK Agency + UK Show + UK Client + VAT Registered scenarios.
VAT_COMMVAT on Commission (20%)UK VAT on the commission portion. Applied for UK Agency + UK Client scenarios.

5.5 WORKSHEET_TYPE_CD

Not stored in code_master -- used as enumerated values on cash_receipt_worksheet.worksheet_type_cd.

CodeDescriptionBehavior / When Used
ORIGINALOriginal worksheetSet when a worksheet is sealed during a return. The worksheet that was approved and is now being replaced.
REVERSALReversal worksheetAuto-created during return. Contains negative entries for ALL items (including locked). current_item_ind = false. posting_status_cd = 'U' for GL pickup.
REPLACEMENTReplacement draftNew draft created during return. Contains only locked items as read-only. current_item_ind = true. Users add fresh applications here.

5.6 PAYOUT_STATUS_CD

Not stored in code_master -- used as enumerated values on cash_receipt_payout.payout_status_cd.

CodeDescriptionBehavior / When Used
PENDINGPendingPayout created but payment not yet sent to bank.
PAIDPaidBank has confirmed payment completion.
RETURNEDReturnedPayout was returned during a worksheet return process.
CANCELLEDCancelledPayout was cancelled before payment was sent.

5.7 REVERSAL_REASON_CD

Used on reversal fields across cash_receipt_application, cash_receipt_client_ledger, and cash_receipt_payout.

CodeDescriptionBehavior / When Used
WORKSHEET_RETURNWorksheet ReturnThe reversal was created as part of the three-document worksheet return process.

5.8 CLIENT_LEDGER_TYPE_CD

Used on client_ledger.client_ledger_type_cd to classify ledger entries.

CodeDescriptionBehavior / When Used
OAOn-AccountCash held on account for a client, not yet applied to a specific receivable. Can be applied later via worksheet.
LOANLoanLoan entry for a client. Linked to a payment_item via client_ledger_payment_item_id. Has start and end dates.

5.9 CLIENT_LEDGER_STATUS_CD

Used on client_ledger.client_ledger_status_cd to track ledger entry lifecycle.

CodeDescriptionBehavior / When Used
DDraftLedger entry created and editable. Open for cash application.
VVoidLedger entry has been voided/cancelled. No longer available for cash application.
CClosedLedger entry fully applied and closed. client_ledger_open_item_ind set to false.

6. Cross-References

DocumentRelationship
Cash ReceiptsParent domain. cash_receipt_worksheet is created from a cash_receipt_split, which belongs to a cash_receipt. The receipt's posting status and void status gate worksheet creation.
Billing ItemsTarget of cash application. cash_receipt_application.billing_item_detail_id references billing_item_detail, which is typed as REV or PAY. Billing item balance calculations depend on the sum of applications across all worksheets.
SettlementsDownstream of PAY applications. cash_receipt_application.participant_settlement_id links PAY applications to settlements. Settlement items drive cash_receipt_payout creation. The settle transition requires all PAY applications to have settlements.
SettlementsCreated at approval. cash_receipt_payout.payment_item_id links to payment_item records created during the approve transition. Payment execution status drives the locking logic during returns.

Key cross-domain rules:

  1. Billing item balance = billing_item_detail.total_amt minus the sum of cash_receipt_application.cash_receipt_amt_applied across all active, non-returned worksheets for that detail.

  2. Worksheet unapplied amount = split amount minus the sum of all cash_receipt_amt_applied across cash_receipt_application and cash_receipt_client_ledger for the worksheet. This is a derived (computed) value, not stored.

  3. Settlement completeness = the worksheet can transition from Applied to Settled only when every PAY application has a linked participant_settlement_id, and the sum of settlement payouts (type S) equals the total PAY applied.

  4. Payment item lifecycle = payment_item records are created from cash_receipt_payout at worksheet approval. The payment item's execution status (WAITING through PAID) determines whether the payout is locked during a subsequent return.

  5. GL posting = REV applications and client ledger entries post to GL when the worksheet moves to Applied and the posting process picks up records with posting_status_cd = 'U'. PAY applications post to GL only after the bank confirms payment completion (not at worksheet approval time).

Confidential. For internal use only.