Appearance
Domain GL Posting
Domain-driven GL posting is not the same as immediate GL posting.
When a domain procedure calls post_domain_transaction_to_gl_v2, the call can end in one of several GL outcomes:
POSTEDPENDING_APPROVALSCHEDULED_FUTURE_POSTREJECTEDFAILED
The domain must treat only POSTED as a final accounting outcome.
Core Rule
Do not apply irreversible domain effects just because post_domain_transaction_to_gl_v2 returned successfully.
Success only means the GL orchestration call itself completed.
The actual GL outcome is exposed through:
@post_domain_transaction_to_gl_v2_draft_status@post_domain_transaction_to_gl_v2_draft_batch_id@post_domain_transaction_to_gl_v2_gl_batch_id@post_domain_transaction_to_gl_v2_should_apply_domain_effects_now
Recommended Pattern
- Create the domain transaction first in a pending domain state.
- Call
post_domain_transaction_to_gl_v2. - Read
@post_domain_transaction_to_gl_v2_draft_status. - Branch by outcome:
POSTED: either apply domain effects immediately, or let a registeredon_postedcallback do itPENDING_APPROVAL: keep the domain transaction pending and waitSCHEDULED_FUTURE_POST: keep the domain transaction pending and wait for the future dateREJECTED: mark the domain transaction rejected or failedFAILED: roll back or keep the domain transaction failed, based on domain policy
Callback Model
The GL engine now supports optional domain callbacks stored with the idempotency record.
Pass them in the submit payload:
json
{
"callbacks": {
"on_posted_callback_id": "my_domain_finalize_after_gl_post_v2",
"on_rejected_callback_id": "my_domain_reject_after_gl_reject_v2",
"payload": {
"domain_transaction_id": 123,
"domain_entity": "MY_DOMAIN_TXN"
}
}
}Both callback procedures must accept a single JSON parameter.
The engine invokes:
on_posted_callback_idwhen the batch finally reachesPOSTEDon_rejected_callback_idwhen an approval-routed batch is rejected
That includes:
- immediate domain posts
- post-after-approval
- scheduled future posting when the due date arrives
Callback Payload
The callback receives the original callbacks.payload merged with GL metadata such as:
source_systemsource_modulesource_txn_iddraft_batch_idgl_batch_idgl_outcomegl_statusactioned_bybusiness_unit_idcomment
Use that payload to finalize the domain safely.
When To Use Callbacks
Use callbacks when the domain has side effects that must happen only after final GL success, for example:
- crediting or debiting a deposit account
- changing account balances or lifecycle state
- releasing or consuming a facility limit
- writing settlement links or downstream artifacts
Do not perform those effects directly after a PENDING_APPROVAL or SCHEDULED_FUTURE_POST outcome.
Domain Approval vs GL Approval
Some domains already have their own approval.
Recommended order:
- Domain approval first
- Domain action becomes ready for accounting
- Call
post_domain_transaction_to_gl_v2 - If GL also requires approval, wait for the GL callback outcome
Do not mix unfinished domain approval and unfinished GL approval in one half-posted transaction.
Loan / Deposit Example
Unsafe pattern:
- loan disbursement calls GL
- GL returns
PENDING_APPROVAL - procedure immediately credits deposit account and marks loan
POSTED
Safe pattern:
- loan transaction stays
PENDING - GL batch goes to
PENDING_APPROVAL - no deposit credit happens yet
- after final GL post,
on_postedcallback credits the deposit account and marks the loan transactionPOSTED - if GL is rejected,
on_rejectedcallback marks the loan transactionFAILED
Procedure Registry
For governance, register reusable callback procedures in the system procedure registry as approved system or utility procedures.
Recommended metadata:
proc_type:SYSTEMorUTILITYdomain: the owning domain, such asLOANSorDEPOSITS- tags including
GL_DOMAIN_CALLBACK
Practical Guidance
- Keep the main domain procedure responsible for validation and domain transaction creation.
- Keep final side effects in callback procedures.
- Make callbacks idempotent.
- Make rejection callbacks safe when no domain side effects were applied yet.
- Prefer one domain transaction ID in the callback payload rather than many loosely related keys.
