Skip to content

Run night audit

POST
/v1/actions/hospitality.action.run_night_audit/apply
curl --request POST \
--url https://api.aerandil.com/v1/actions/hospitality.action.run_night_audit/apply \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "branch": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "params": { "accrue_commission": true, "balance_packages": true, "business_date": "2026-04-15", "enforce_deposits": true, "expire_waitlist": true, "open_next": true, "post_no_show_fees": true, "post_room_and_tax": true, "release_block_cutoffs": true, "retire_expired_cards": true, "strip_visitor_keys": true, "sweep_no_shows": true }, "return_modified": false, "target": { "id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "object_type": "hospitality.property" } }'

Close the property’s open business date — a real audit, not a bookkeeping stamp, and never a blocking batch: the whole run is one transaction (a failure rolls everything back and the day stays open; a re-run replays idempotently), and nothing else stops while it runs. In order: (1) sweeps the day’s unresolved arrivals to no_show through the mark_reservation_no_show path, releasing their forward room-nights — and on partially-arrived multi-room reservations cancels the individual legs that never showed, releasing theirs (disable with sweep_no_shows = false); (1a) assesses the no-show fee from the reservation’s frozen cancellation policy and posts it as a rooms-bucket no_show_fee charge, recording the amount and an assessed status on the reservation — OPERA’s Post-Revenue-To-No-Shows, and like OPERA’s it is opt-in: enable with post_no_show_fees = true. The fee carries the tax the house’s rules for a no_show_fee produce, and none where it authored none (the UK taxes it, Austria does not); a booking’s tax exemption reaches it. Assessment only; collecting the fee off-session against a stored card is a separate step, because the audit runs inside the ontology and the card rail does not; (1c) releases group-block rooms nobody picked up, per each definite block’s cutoff mode — after the no-show sweep, so a room a no-show hands back to its block is cut off the same night rather than sitting held for a day (disable with release_block_cutoffs = false); (1d) accrues commission on stays that departed today — one row per payee, with the contract that produced it frozen on the row (disable with accrue_commission = false); (1e) expires waitlist entries two business days past their requested departure — OPERA’s End-of-Day auto-delete, as a terminal status rather than a deletion, so the turnaway stays countable (disable with expire_waitlist = false); (1g) strips the booking engine’s visitor key from the offers, turnaways and reservations whose arrival night is the property’s visitor_key_grace_days past (30 unset), keeping the records — the key only joins records of one night (disable with strip_visitor_keys = false); (1h) expires payment requests still pending whose expires_at falls on or before the audited date — the pay link lapses at the close (always on; absent from the summary when none expired); (2) posts the night’s room charge to every in-house stay’s window-1 folio from its reservation_night rate — replay-safe via the charge external_ref business key, complimentary nights skipped, tax_application lines derived from the property’s active rooms tax_rule rows (inclusive rules carve out of the rate, exclusive rules join the folio debit; no rules = zero tax) — disable with post_room_and_tax = false; (2c) balances package allowances: components due on the closing date with no consumption row settle as profit — an append-only consumption row plus the package_discount_adjustment charge, replay-safe (disable with balance_packages = false); (3) counts exceptions instead of halting on them — due-outs still in house, open cashier sessions, unresolvable folios, malformed tax or package config — the OPERA halt conditions turned into a queue (the date roll never waits on a drawer); (4) mints an immutable NightAuditRun carrying posted_room_revenue, posted_room_tax, package_adjustments_posted and exception_count (re-runs create new rows, never edit); (5) closes the BusinessDate and rolls the next day open (disable with open_next = false), moving the property’s open_business_date to it — or clearing it when nothing is opened — so postings from the close on are dated to the new hotel date.

Effects: modify hospitality.property; modify hospitality.block_allocation; modify hospitality.waitlist_entry; modify hospitality.payment_request; modify hospitality.stay_offer; modify hospitality.turnaway; modify hospitality.payment_card; create hospitality.commission_detail; link hospitality.link.commission_detail_for_reservation; link hospitality.link.commission_detail_owed_to_company; link hospitality.link.commission_detail_owed_to_channel; create hospitality.night_audit_run; modify hospitality.business_date; create hospitality.business_date; modify hospitality.reservation; modify hospitality.reservation_room; modify hospitality.availability_day; create hospitality.charge; link hospitality.link.folio_has_charge; link hospitality.link.charge_at_outlet; modify hospitality.folio; create hospitality.folio; link hospitality.link.reservation_has_folio; create hospitality.tax_application; link hospitality.link.charge_has_tax_application; create hospitality.package_component_consumption; link hospitality.link.package_sale_has_consumption; link hospitality.link.consumption_for_charge; link hospitality.link.charge_attributed_to_package_sale; link hospitality.link.charge_attributed_to_package_component; modify hospitality.room_status_block; modify hospitality.room; modify hospitality.share_group; unlink hospitality.link.reservation_in_share_group; link hospitality.link.charge_for_service_item; create hospitality.payment; link hospitality.link.folio_has_payment.

Media typeapplication/json
object
branch

Apply against an open branch’s overlay view instead of the canonical (main) plane. The action’s writes land in the branch’s copy-on-first-write overlay, its events in the branch’s own stream, and the invocation is journaled for merge-by-replay. Branch writes are action-only, so this is the write-side entry point to a branch (POST /v1/branches forks one).

string format: uuid
params
required
object
accrue_commission
Accrue travel-agent and channel commission on stays that completed today (defaults to true)
boolean
balance_packages
Settle unconsumed package allowances due on the closing date as profit (defaults to true)
boolean
business_date
required
Business date
string format: date
enforce_deposits
Cancel expired courtesy holds and lapsed wholly-unpaid deposits whose frozen policy says auto-cancel; record other lapses for the operator (defaults to true)
boolean
expire_waitlist
Age out waitlist entries two business days past their requested departure (defaults to true)
boolean
open_next
Open the next business date after closing this one (defaults to true)
boolean
post_no_show_fees
Assess and post the cancellation policy's no-show fee for reservations swept to no_show (defaults to FALSE — posting revenue to no-shows is a policy decision, not a default)
boolean
post_room_and_tax
Post the night's room charges to in-house folios (defaults to true)
boolean
release_block_cutoffs
Release group-block rooms nobody picked up, per each block's cutoff mode (defaults to true)
boolean
retire_expired_cards
Mark cards on file whose expiry month has passed as `expired`, so nothing offers a guarantee the issuer will decline (defaults to true)
boolean
strip_visitor_keys
Strip the visitor key from offers, turnaways and reservations whose arrival night is past the property's grace (defaults to true)
boolean
sweep_no_shows
Sweep unresolved arrivals to no_show (defaults to true)
boolean
return_modified

When true, the response carries modified_objects and modified_links projections — the engine reads the event log inside the same transaction so the projection observes the handler’s own writes.

boolean
target
required
object
id
required
string format: uuid
object_type
required
Allowed value: hospitality.property

Action applied. modified_objects and modified_links populated when return_modified: true was supplied.

Media typeapplication/json
ApplyActionResponse

Envelope returned by the Aerandil action engine. correlation_id ties every event emitted by this invocation; modified_objects and modified_links project the events the handler emitted (per the action’s declared effects); warnings carries any non-blocking soft-validator observations.

object
correlation_id
required

Per-invocation correlation id; matches events.correlation_id for every event this action appended.

string format: uuid
modified_links
required

Links established or removed by this invocation. Empty when the caller did not request return_modified.

Array<object>
object
from_id
required
string format: uuid
from_type
required
string
kind
required
Allowed values: linked unlinked end_dated
link_type
required
Allowed values: hospitality.link.commission_detail_for_reservation hospitality.link.commission_detail_owed_to_company hospitality.link.commission_detail_owed_to_channel hospitality.link.folio_has_charge hospitality.link.charge_at_outlet hospitality.link.reservation_has_folio hospitality.link.charge_has_tax_application hospitality.link.package_sale_has_consumption hospitality.link.consumption_for_charge hospitality.link.charge_attributed_to_package_sale hospitality.link.charge_attributed_to_package_component hospitality.link.reservation_in_share_group hospitality.link.charge_for_service_item hospitality.link.folio_has_payment
to_id
required
string format: uuid
to_type
required
string
modified_objects
required

Objects created, modified, or soft-deleted by this invocation. Empty when the caller did not request return_modified.

Array<object>
object
id
required
string format: uuid
kind
required
Allowed values: modified created
object_type
required
Allowed values: hospitality.property hospitality.block_allocation hospitality.waitlist_entry hospitality.payment_request hospitality.stay_offer hospitality.turnaway hospitality.payment_card hospitality.commission_detail hospitality.night_audit_run hospitality.business_date hospitality.reservation hospitality.reservation_room hospitality.availability_day hospitality.charge hospitality.folio hospitality.tax_application hospitality.package_component_consumption hospitality.room_status_block hospitality.room hospitality.share_group hospitality.payment
warnings

Non-blocking soft-validator observations emitted during this invocation (e.g. comp-authority over-limit, recipe pour-cost over sell-price). Absent when no warnings were emitted.

Array<object>
object
message
required

Human-readable summary, suitable for logging or operator-UI surfacing.

string
object_type
required

Object type the warning was raised against.

string
property

Property the warning anchors to, when a single field is the locus. Absent for multi-field rules.

string
rule
required

Stable kebab-case rule identifier (e.g. comp-authority-over-limit).

string
Example
{
"modified_links": [
{
"kind": "linked",
"link_type": "hospitality.link.commission_detail_for_reservation"
}
],
"modified_objects": [
{
"kind": "modified",
"object_type": "hospitality.property"
}
]
}

Conflict — concurrent modification or unique constraint violation.

Validation error — parameter validation or business-rule violation.